Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Joint order does not follow the joint name list when reducing the model #393

Open
CarlottaSartore opened this issue Mar 27, 2025 · 6 comments

Comments

@CarlottaSartore
Copy link
Contributor

In Jaxsim, eventhough we pass a joint name list when we reduce the model, the joint order does not follow the passed list but the order in which the kinematic chain is created in the associated urdf/sdf file. To inspect the correct joint name list one should use the model method joint_names().

It happens few times that this thing create confusion, we should find a way either to correctly allert the user about this or use the joint order passed by the user

C.C. @ami-iit/darwin

@traversaro
Copy link
Contributor

Is this behavior clear in the model reduction documentation? Just to provide a bit of context for external users, the reason why most users in AMI expect that model reducer API both specify which joints are part of the reduced model and their order is that iDynTree API provides that, while most other dynamics libraries use what Featherstone call "normal joint ordering", where the order of the joints depends on the chosen base.

@CarlottaSartore
Copy link
Contributor Author

CarlottaSartore commented Mar 27, 2025

Is this behavior clear in the model reduction documentation? Just to provide a bit of context for external users, the reason why most users in AMI expect that model reducer API both specify which joints are part of the reduced model and their order is that iDynTree API provides that, while most other dynamics libraries use what Featherstone call "normal joint ordering", where the order of the joints depends on the chosen base.

I think in the documentation gives for granted that the order will not change, this with the AMI bias had lead (and most likely will) to errors, as a first step I think we can improve the documentation, but I am tempted to add also a warning. The problem I see is that currently there are a lot of prints when the model is loaded, thus an additional print most likely will get lost

def reduce(self, considered_joints: Sequence[str]) -> ModelDescription:
"""
Reduce the model by removing specified joints.
Args:
considered_joints: Sequence of joint names to consider.
Returns:
A `ModelDescription` instance that only includes the considered joints.
"""
if len(set(considered_joints) - set(self.joint_names())) != 0:
extra_joints = set(considered_joints) - set(self.joint_names())
msg = f"Found joints not part of the model: {extra_joints}"
raise ValueError(msg)
reduced_model_description = ModelDescription.build_model_from(
name=self.name,
links=list(self.links_dict.values()),
joints=self.joints,
frames=self.frames,
collisions=tuple(self.collision_shapes),
fixed_base=self.fixed_base,
base_link_name=next(iter(self)).name,
model_pose=self.root_pose,
considered_joints=considered_joints,
)
# Include the unconnected/removed joints from the original model.
for joint in self.joints_removed:
reduced_model_description.joints_removed.append(joint)
return reduced_model_description

@flferretti
Copy link
Collaborator

flferretti commented Mar 27, 2025

I agree with adding a logging in the js.model.reduce and to add that to the docstrings

there are a lot of prints when the model is loaded

This is due to the fact that the logging level is set to DEBUG when JaxSim is installed in editable mode

@CarlottaSartore
Copy link
Contributor Author

This is due to the fact that the logging level is set to DEBUG when JaxSim is installed in editable mode

Since internally in A,MI most user use Jaxsim in editable mode, we could decrease the things printed, so that more critical things, as the joint order, do not get lost.

@flferretti
Copy link
Collaborator

This is due to the fact that the logging level is set to DEBUG when JaxSim is installed in editable mode

Since internally in A,MI most user use Jaxsim in editable mode, we could decrease the things printed, so that more critical things, as the joint order, do not get lost.

I agree with that. We could move some logs from DEBUG to TRACE level, especially when the links are lumped

@flferretti
Copy link
Collaborator

This is due to the fact that the logging level is set to DEBUG when JaxSim is installed in editable mode

Since internally in A,MI most user use Jaxsim in editable mode, we could decrease the things printed, so that more critical things, as the joint order, do not get lost.

Done in https://github.com/ami-iit/jaxsim/tree/fix/logging_level

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants