Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

Are you making all this up as you go along?


comp / comp.lang.python / RE: [Tutor] How to go about a simple object grabbing in python (given coordinates of arms and objects)

Subject: RE: [Tutor] How to go about a simple object grabbing in python (given coordinates of arms and objects)
From: <avi.e.gross@gmail.com>
Newsgroups: comp.lang.python
Date: Mon, 24 Jun 2024 21:57 UTC
References: 1 2 3 4
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: <avi.e.gross@gmail.com>
Newsgroups: comp.lang.python
Subject: RE: [Tutor] How to go about a simple object grabbing in python (given
coordinates of arms and objects)
Date: Mon, 24 Jun 2024 17:57:00 -0400
Lines: 223
Message-ID: <mailman.169.1719266224.2909.python-list@python.org>
References: <CAGJtH9SdZvsrgLHnC+NSmj9P9ykG8qXj2JXk27ai=HAYaam-GQ@mail.gmail.com>
<v58m8o$162k$1@ciao.gmane.io>
<CAGJtH9QgCX1fZ_xN4pfwPATX+s--d1JQJarYsf5dAGYPAQoyJw@mail.gmail.com>
<000601dac681$70bbaf00$52330d00$@gmail.com>
Mime-Version: 1.0
Content-Type: text/plain;
charset="utf-8"
Content-Transfer-Encoding: quoted-printable
X-Trace: news.uni-berlin.de oWtHnrFXdF79iW6KBq5hIwla754GQHBcaq0W6uyjkx0w==
Cancel-Lock: sha1:u++I6Za8jzi5hoV7O4+T9zGh/bk= sha256:11y/97RD7yHohKlDEG/f2bitFVxWFmme02mJE8hLMtI=
Return-Path: <avi.e.gross@gmail.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmail.com header.i=@gmail.com header.b=VdOZhMj6;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.000
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'this:': 0.03; 'absolute':
0.05; 'fairly': 0.05; 'parallel': 0.05; 'usage': 0.05;
'subject:python': 0.06; 'circle': 0.07; 'moderator': 0.07;
'modules': 0.07; 'real-world': 0.07; 'translate': 0.07;
'"python"': 0.09; 'approaches': 0.09; 'code?': 0.09; 'computing':
0.09; 'depend': 0.09; 'example.': 0.09; 'fewer': 0.09; 'modules.':
0.09; 'numpy': 0.09; 'other.': 0.09; 'received:108': 0.09;
'routine': 0.09; 'shortest': 0.09; 'smaller': 0.09; 'supplied':
0.09; 'tons': 0.09; 'traveling': 0.09; 'steps': 0.11;
'url:mailman': 0.15; 'problem.': 0.15; 'that.': 0.15; '(except':
0.16; '2024': 0.16; 'algorithms': 0.16; 'algorithms,': 0.16;
'algorithms.': 0.16; 'approached': 0.16; 'assuming': 0.16;
'backward': 0.16; 'carrying': 0.16; 'destination.': 0.16;
'distance.': 0.16; 'elaborate': 0.16; 'extending': 0.16; 'flickr':
0.16; 'flying': 0.16; 'gauld': 0.16; 'gradually': 0.16; 'in-line':
0.16; 'languages.': 0.16; 'like.': 0.16; 'locate': 0.16; 'lot,':
0.16; 'next,': 0.16; 'object,': 0.16; 'once.': 0.16; 'ones.':
0.16; 'paths': 0.16; 'photo-blog': 0.16; 'programmed': 0.16;
'renaming': 0.16; 'responses,': 0.16; 'robot.': 0.16; 'robotics.':
0.16; 'silence': 0.16; 'slow': 0.16; 'somewhat': 0.16; 'sounds':
0.16; 'structures': 0.16; 'subject:simple': 0.16; 'think.': 0.16;
'url-ip:79.170.44.132/32': 0.16; 'url-ip:79.170.44/24': 0.16;
'url-ip:79.170/16': 0.16; 'url-ip:79/8': 0.16; 'url:alan-g': 0.16;
'url:alan_gauld': 0.16; 'url:alangauldphotos': 0.16; 'url:tutor':
0.16; 'using.': 0.16; 'welcome.': 0.16; 'wikipedia': 0.16;
'wrapper': 0.16; 'wrote:': 0.16; 'problem': 0.16; 'python': 0.16;
'instead': 0.17; 'probably': 0.17; 'message-id:@gmail.com': 0.18;
'round': 0.19; 'url:amazon': 0.19; 'to:addr:python-list': 0.20;
'language': 0.21; 'subject:: [': 0.21; 'subject:] ': 0.21;
'machine': 0.22; 'closed': 0.22; 'first,': 0.22; 'maybe': 0.22;
'purposes': 0.22; 'to:no real name:2**1': 0.22; 'way.': 0.22;
'code': 0.23; 'feedback': 0.23; 'goal': 0.23; 'subject:How': 0.23;
'run': 0.23; 'degree': 0.76; 'detection': 0.76; 'languages,':
0.76; 'supposed': 0.76; 'domain': 0.77; '1st': 0.78; '400': 0.78;
'sent:': 0.78; 'out.': 0.80; '3rd': 0.81; 'monitor': 0.81;
'position': 0.81; 'more.': 0.82; 'known': 0.84; 'add-on': 0.84;
'allowed,': 0.84; 'angle': 0.84; 'arm,': 0.84; 'catching': 0.84;
'choices': 0.84; 'close,': 0.84; 'direction.': 0.84;
'experiments': 0.84; 'luck.': 0.84; 'marathon': 0.84; 'measures':
0.84; 'nao': 0.84; 'newest': 0.84; 'obstacles.': 0.84; 'parts.':
0.84; 'robot': 0.84; 'ultimately': 0.84; 'want.': 0.84; 'wheels':
0.84; '28th': 0.91; 'anticipated': 0.91; 'avoiding': 0.91;
'particular,': 0.91; 'sides.': 0.91; 'stopping': 0.91; 'degrees':
0.93; 'central': 0.95
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20230601; t=1719266222; x=1719871022; darn=python.org;
h=content-language:thread-index:content-transfer-encoding
:mime-version:message-id:date:subject:in-reply-to:references:to:from
:from:to:cc:subject:date:message-id:reply-to;
bh=RJHX99foTV4/0oCrL6Pt5vmNTDrG6Fz2LwNfqPwaVR4=;
b=VdOZhMj6rbYMZySQoRfryVwAuZ/WsLqtZ0if40V15nd6wPvTrEad6ha9wjGzEF9IIO
KczP6Vw6K8pvKy0ex7wBeGxa/ZJS9qJwnOlrGAiTTXOlS+RuHULE3jE2xp0Q9WQJ8RHp
8dsdSK3SuyHvE4oKyRl7ipqfTDGuS6j/7NsJHi/qRKYMjIR7vXA2h0YBx+X+Hj8qziBf
B4BZEg0TS27vh3YmqXqOs0Fp7TcZrfJ5I+6cjQPKbkY1/6U8vk2F8a2lnGqCaQ2vBSkj
ZYv3BWv7EHKjuPhjYkE6bbeAhXLlkZot22JP8wMx5c2sVsW8jLitOlFJdZcPDeRd+lcR
aTAA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20230601; t=1719266222; x=1719871022;
h=content-language:thread-index:content-transfer-encoding
:mime-version:message-id:date:subject:in-reply-to:references:to:from
:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
bh=RJHX99foTV4/0oCrL6Pt5vmNTDrG6Fz2LwNfqPwaVR4=;
b=kVMs3jeaJj13CiQJhQs+KPG12tWo09R3yX5+sZW2fsJk4KLoYbYaXTO7F4cI51OR+M
8zILIkMUInodOyhEfrLqWfXm+kGr+9G/bQPqKMccpIRq/Qxaj927B9++7mfSuUqq+DwR
Thse7zi3+VOS+LvWUszb4CIs5HuBvsNSb6QSuIgetQ0znn1vqPKOH5RwAXWe2n2W9QSB
zTVNCCNy2ZQuvICRRC6Z6C4A1xW60COmxFzlQVG1VLX3Cl+nvdjEIHVZ/Av1h6wHBVhX
AZQacxNw+iUrSF+Hm0J9MwCWJS8Za1AA8qEK/oK3zye2E6ZuHAR95JUguyj2d5XTw4rY
nRlA==
X-Forwarded-Encrypted: i=1;
AJvYcCV6UhCZ5pibuRDgQKetWEJ/lZcGvsjfsiVcZPo6V/NdN0E5VoquKmoTRLTzf9kXuEaucXUnKkbvNEz3QBytg+hqYQl2nDBzQe4M9fhLYKn8WaHj1lSeSjcD
X-Gm-Message-State: AOJu0YzebYuN57rBw3g9McBWRHnR5MjfkrpLEFrjrMDwZpV3iu0GFPYw
+jqfDwfvryzuSAh+70dNvyIkMwv87HQNwoNFA5a9HIBApVX+WRQNYLFUoQ==
X-Google-Smtp-Source: AGHT+IGsJosi9c19haYo+AS72ts9+O2r57fnaT9fZ/5L1sSeO72M+0GJNjEl+3aL4TiERK3f/64n5A==
X-Received: by 2002:a05:690c:710:b0:632:5cae:3912 with SMTP id
00721157ae682-643aa3b138amr52669077b3.6.1719266221417;
Mon, 24 Jun 2024 14:57:01 -0700 (PDT)
In-Reply-To: <CAGJtH9QgCX1fZ_xN4pfwPATX+s--d1JQJarYsf5dAGYPAQoyJw@mail.gmail.com>
X-Mailer: Microsoft Outlook 16.0
Thread-Index: AQIRu0eoxhJKb1M0MjGxX7K/VErFWQCX/NqrAL71Q+GxXs6z4A==
Content-Language: en-us
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <000601dac681$70bbaf00$52330d00$@gmail.com>
X-Mailman-Original-References: <CAGJtH9SdZvsrgLHnC+NSmj9P9ykG8qXj2JXk27ai=HAYaam-GQ@mail.gmail.com>
<v58m8o$162k$1@ciao.gmane.io>
<CAGJtH9QgCX1fZ_xN4pfwPATX+s--d1JQJarYsf5dAGYPAQoyJw@mail.gmail.com>
View all headers

Marc,

Several people have supplied feedback on whether your request is a good fit for here. Ultimately it is up to the owner/moderator. In particular, your request to the Tutor List may not fit the purpose and be a bit complex and to the main Python List also outside some common usage whether it is about a specific module or product you are using, or asking about algorithms in a very general way.

You question has evolved to being about algorithms, more than about Python as a basic language or even commonly used modules.

So, I suggest you simplify your model and then maybe bring it in-line with the module(s) you showed us you were using. Some of what you ask sounds like it would be extremely commonly done in things like robotics, or even just machines with moving parts.

Consider the somewhat related concept often seen of how you get from one place to another in parts of Manhattan where most of the streets run either in one direction or the orthogonal direction. How do you get from say East 14th Street at 1st Avenue to West 28th Street and 11th Avenue? This is a slight imitation of how to move a robotic arm that can mainly either go one way or another but not both at once. And, in the real world, parts of Manhattan are more complex with streets ending or renaming or running more diagonally or huge voids like Central Park.

The number of solutions is huge for walking, and smaller for driving as some streets are one way. But assuming you avoid wasteful paths (except when roads are closed for endless purposes) and you do not take a path through Brooklyn, Queens and The Bronx and back to Manhattan as in the NY Marathon that also touches another borough, the solutions mainly look like this:

Go as far horizontally as you need and then as far vertically.
Or, do vertical, then horizontal.
Or lots of combined versions such as climbing stairs by doing a block or three one way then some in the other and repeat.

The above is referred to as Manhattan Distance, as compared to other measures like Euclidean distance.

So back to your robot arm, you can see a set of simple solutions where you make a sort of triangle with the direct Euclidean arm being a hypoteneuse and the X and Y movements are the other two sides. You can then break up your problem as heading one way and pausing and turning the other way and stopping just short of the object you want. If there are no obstacles, you can do that in either order. Or, you could alternate in smaller amounts and get to the same destination.

Grabbing it would be something else I will not address except to say that depending on what is grabbing and how it is shaped, you may need to aim not for the object, but the appropriate distance and direction so that when you stop moving, the "grasper" can close on it, again, avoiding existing obstacles. And note, speed is a consideration as many things need to be approached slowly and gently.

Next, consider what it would mean if you could have a combined motion based on both operations allowed at the same time. Consider a robot that is on wheels that can move horizontally while also having a "lift" component that lifts the part with the graspers vertically. Both could be programmed to run in tandem at appropriate speeds so the graspers are traveling along the hypotenuse I mention and are going the shortest path. This might be faster and more economical in other ways but can be more complex. And, it may be the robot does not have power or computing ability to do both at the same time. Your design is beyond vague.

Both of the approaches above make a plan and carry it out. But in the real world, many algorithms must adjust and work somewhat probabilistically. One algorithm for say catching a moving object, especially one that can change speed and direction a bit, like a running dog or a kite flying in the wind, is to locate where the object seems to be now, perhaps just a direction and a guess at distance, and maybe with some observation make a guess at where it might be at some time in the future that is approximately when you might move the robot near there. Then, use a technique like above (or completely different) that perhaps aims to get you something like halfway there. Monitor along the way to update your position and the newest destination position (if it is moving) and re-evaluate and adjust for the next round and maybe evaluate again as you approach halfway or so, again. Eventually, if you are close, slow down and gradually try to come to a stop where you can grab. If the object reacts to your attempting to go after it, it can be complex. And, you may overshoot and sort of circle back.

Now, expand the problem more if needed. What does the robot look like. How many places can it bend? For example, can it have something like two or more elbows, perhaps one allowing twisting of up to 30 degrees and one moving forward and backward and another allowing movement side to side, up to some number of degrees. Are all these degrees of freedom absolute or are there constraints? For example, to turn beyond some number of combined degrees may not be allowed, and instead of turning 400 degrees clockwise, you simply move forward or back to a 40 degree angle from some baseline. Perhaps bending certain ways while carrying some kind of weight, can cause it to topple. There can be an amazing number of considerations that cannot be anticipated and depend on specific choices in making a robot. A longer arm, for example, requires fewer degrees of turn to move some known amount.

As before, there are an amazing number of ways to do such things in any language as we are discussing "algorithms." If the goal is finding A WAY, any simpler ones will do. If it is to find an optimum way, we have tons you need to learn and consider. If this was a contest and a contestant on the other side of the object was supposed to start at the same time as you, and the first to grab the object wins, ...

And, if this has machine learning components, which python is in some ways well suited to, you may design a robot that moves clumsily and almost randomly, at first, and then "learns" from such experiments and gradually figures out better and maybe even better ways until it just does well at reaching and grasping for any similar enough problems and maybe even somewhat different ones. I suspect that is more than you need but in real-world robotics, may be part of how to make more sophisticated and even general-purpose robots.

But if you want to talk more about python in doing parts of this, there are several things to consider. Base python has data structures you can use to store and manipulate many things you may need to keep track of, or if planning a whole routine in advance, things like lists to hold the steps you can then hand over to function. Add-on modules like numpy can be very helpful in extending python for some purposes, as an example. There are probably many functions that already do things like given two points, calculate the slope and distance of a direct line between them, or compare two or more approaches and return what is best in some way and so on. There ways of running things in parallel while sharing some data while making sure to avoid them interfering with each other. You can set timers to wake up and recalculate and much more. Then there are all kinds of modules that help you with parts. There is a good chance that whatever you showed us is just one of many such modules people have shared or sold for purposes similar enough to your robot problem.

But if your main goal is to do this mainly with the kind of functionality you pointed at, since likely none of us have read the documentation, nor care to without getting paid a lot, it means you should be reading a lot and looking carefully at examples that may apply AND finding resources more about that than asking people about "python" and especially asking python people how one does things in robotics. Mose specific questions such as how to calculate a distance using python, will likely get helpful responses, and brief but complete examples of code that you want debugged, may also be responded to. But asking for complex algorithms in the abstract probably will result in silence or ever more elaborate debates till a moderator suggest a halt! LOL!

Python, like many languages, is a fairly general purpose language that can do many things well, and some less well, and some mainly by standing on it's head while including software built in other languages. Your project may happen to be in python, but more likely most of it should be using functions built-in to whatever add-ons you are using if it is designed to do what you want. Your goal is not to create it all from scratch, I would think. You may end up using just a little base python to glue things together.

Good Luck.

-----Original Message-----
From: Python-list <python-list-bounces+avi.e.gross=gmail.com@python.org> On Behalf Of marc nicole via Python-list
Sent: Monday, June 24, 2024 5:24 AM
To: Alan Gauld <alan.gauld@yahoo.co.uk>; python-list@python.org; Tutor@python.org
Subject: Re: [Tutor] How to go about a simple object grabbing in python (given coordinates of arms and objects)

What are the parameters to account for in this type of algorithm? are there
some checks to perform the arm moves ? for example angle moves or cartesian
moves based on some distance thresholds? Any idea about the
pseudo-algorithm is welcome.

Thanks.

Le dim. 23 juin 2024 à 10:33, Alan Gauld via Tutor <tutor@python.org> a
écrit :

> On 22/06/2024 13:41, marc nicole wrote:
>
> > So, given the x,y,z coordinates of a target object and the offset x,y,z
> of
> > arms of a robot, what is a good algorithm to perform to grab the object
> > between the hands (either from both sides or from below all using both
> > hands).
> >
> > Specifically, my problem is applied to a NAO robot environment where I
> > retrieve a target object coordinates using the following code:
>
> This is almost entirely outside the Python domain and all within
> your 3rd party environment. Do they have a user forum or mailing
> list? You will probably get better results asking there?
>
> Another possibility is that you are using a Python wrapper around
> a C (or other language) library and there might be FAQs, fora or
> lists supporting that. If so you should be able to translate
> their examples to your Python code?
>
> In terms of generic solutions the only thing I can suggest that
> might help is to research collision detection algorithms.
> Wikipedia is likely a good starting point.
>
> --
> Alan G
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
> http://www.amazon.com/author/alan_gauld
> Follow my photo-blog on Flickr at:
> http://www.flickr.com/photos/alangauldphotos
>
>
>
> _______________________________________________
> Tutor maillist - Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
--
https://mail.python.org/mailman/listinfo/python-list

SubjectRepliesAuthor
o RE: [Tutor] How to go about a simple object grabbing in python (given coordinate

By: avi.e.gross on Mon, 24 Jun 2024

0<avi.e.gross

rocksolid light 0.9.8
clearnet tor