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

Enhance MeshcatVisualizer to support base frame in load_model method #1229

Merged
merged 6 commits into from
Feb 11, 2025

Conversation

GiulioRomualdi
Copy link
Member

@GiulioRomualdi GiulioRomualdi commented Feb 7, 2025

This pull request includes modifications to the bindings/python/visualize/meshcat_visualizer.py file to enhance the load_model method by adding support for an optional base_frame parameter. This change allows for more flexible model loading by specifying a base frame for the model's traversal computation.

@GiulioRomualdi
Copy link
Member Author

This PR is required for: ami-iit/robot-log-visualizer#93

@traversaro
Copy link
Member

I have just a double on the name. At the moment we only support base_link for base, not base frames (not that it is impossible, simply no one ever worked on #422). Given this, could it make sense to change the name of the argument to base_link instead of base_frame ?

Comment on lines 639 to 640
base_frame_index = self.model[model_name].getFrameIndex(base_frame)
self.model[model_name].computeFullTreeTraversal(self.traversal[model_name], base_frame_index)
Copy link
Member

@traversaro traversaro Feb 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we handle somehow the case in which base_frame (or base_link, see the other comment) is not a valid name?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GiulioRomualdi I may be missing something, but it does not seem that 08b75f2 handles the case in which base_link is not a valid name?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My fault : d1d688d

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I got

 if base_link_index == idyn.LINK_INVALID_INDEX:
AttributeError: module 'idyntree.bindings' has no attribute 'LINK_INVALID_INDEX'

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wondering if LINK_INVALID_INDEX is exported in python given: https://github.com/search?q=repo%3Arobotology%2Fidyntree%20LINK_INVALID_INDEX&type=code

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strange, it seems exposed at least on MATLAB:

. Anyhow, you can hardcode -1, see
LinkIndex LINK_INVALID_INDEX = -1;
.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or check if it is smaller than 0.

@GiulioRomualdi GiulioRomualdi self-assigned this Feb 10, 2025
@traversaro
Copy link
Member

See #1229 (comment) .

@traversaro
Copy link
Member

Thanks!

@traversaro
Copy link
Member

Can i squash?

@GiulioRomualdi
Copy link
Member Author

Sure!

@traversaro traversaro merged commit 0e13378 into master Feb 11, 2025
37 checks passed
@traversaro traversaro deleted the visualizer_base_frame branch February 11, 2025 08:47
@traversaro
Copy link
Member

I released this change in iDynTree 13.3.0 : https://github.com/robotology/idyntree/releases/tag/v13.3.0 .

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

Successfully merging this pull request may close these issues.

2 participants