jaxsim icon indicating copy to clipboard operation
jaxsim copied to clipboard

Add possibility to set a base from the `build_from_model_description` method

Open CarlottaSartore opened this issue 1 year ago • 2 comments

I have seen that it is not possible to set the base from the method build_from_model_description although it is the suggested function for loading a model. It would be useful to allow the user to define any base.

CarlottaSartore avatar Nov 29 '24 12:11 CarlottaSartore

I did a first implementation of this in https://github.com/CarlottaSartore/jaxsim/tree/add_base_parameter and I tested it with ergocub, i.e. this model https://github.com/icub-tech-iit/ergocub-software/blob/master/urdf/ergoCub/robots/ergoCubSN001/model.urdf and definite the head as the base link

But it does not work, for instance, if I define head as base, the only links that get parsed are the head and the real sense

the problem seems that the children of the head link contain only the real sense while they should contain other links such as the head imu

the problem seems here

https://github.com/ami-iit/jaxsim/blob/524ad4204e2844bc79c94fd42e22725a349d8a81/src/jaxsim/parsers/kinematic_graph.py#L657-L697

for reference this is the idyntree function that performs the same action :

https://github.com/robotology/idyntree/blob/13cf9e9f0befc6dd08a1b90d21424a043dbf0e48/src/model/src/Model.cpp#L828-L878

CarlottaSartore avatar Nov 29 '24 12:11 CarlottaSartore

Hi @CarlottaSartore, thanks for working on this! The head and the realsense are the only links parsed because realsense is the only child of the head link. This logic should be changed where the link children are set: https://github.com/ami-iit/jaxsim/blob/524ad4204e2844bc79c94fd42e22725a349d8a81/src/jaxsim/parsers/kinematic_graph.py#L278-L298

In brief, the full ordering of the traversal should be changed, as I guess it's done in iDynTree:

https://github.com/robotology/idyntree/blob/13cf9e9f0befc6dd08a1b90d21424a043dbf0e48/src/model/src/Traversal.cpp#L36-L44

flferretti avatar Nov 29 '24 13:11 flferretti