clemense / yourdfpy

Python parser for URDFs
MIT License
122 stars 13 forks source link

Getting a chain between 2 links is not available #31

Open nashmit opened 2 years ago

nashmit commented 2 years ago

The current implementation is nice and all but it misses an important feature if you are interested in building the corresponding dynamical model.

The workaround is to do it manually using the list of the joints that contains all the necessary information ( the adjoint links for each joint ) for building a tree but I imagine, this functionality should be available out of the bat like it is available in urdf_parser_py ( ) : "get_chain(root, tip)" In that sense, I think it will be also easier if each link will also have a list of the joints which are to be found in the local coordinates...

clemense commented 2 years ago

To understand this better: The feature request would be to provide a function named get_chain(root, tip) that returns a list of joint and link names in the order they appear when traversing the kinematic graph from root to tip?

Or is it about getting all transforms via something like get_transforms?

nashmit commented 2 years ago

get_chain( root, tip, joints=True, links=True, fixed=True )

Returns a list of links and joints ( as strings / or the corresponding objects ) in the order they appear when traversing from "root" to "tip" with the possibility to switch on/off the type of the elements you want in that list ( e.g. to contain or not the "links", to contain or not the "joints"... to contain or not the "fixed" joints ). In the end, the corresponding functionality of "get_transforms", mentioned above, can be achieved by using this list.

These pieces of information are useful when you want to build, let's say, the multibody dynamics of the corresponding chain. When you build a multibody chain, you are also interested in the transformations that happen inside each link ( change of reference of inertia/ etc relative to the, closest, first non-fixed joint, part of the chain..) hence, a chain like this can make life easier :)

Also, something like child_map / parent_map for links would be nice... and a "parent" list as well as a "child" list as part of joints ( I haven't used this library in the past few days so, I don't remember which one of these is missing )