fix(examples): use link-tree traversal in create_conn_tree to fix IndexError#86
Open
amirhosein-vedadi wants to merge 1 commit intochungmin99:mainfrom
Conversation
…exError create_conn_tree() was given link indices from get_mapping_from_mano_to_shadow but treated them as joint indices and indexed robot.joints.parent_indices, which is joint-indexed. With more links than joints (e.g. Shadow Hand) this caused IndexError when running 09_hand_retargeting.py. - Derive parent link from links.parent_joint_indices and joints.parent_indices via a joint_to_child_link map. - Walk the link tree in is_direct_chain_connection instead of the joint tree. - Use a set of link indices for membership checks. Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Running
examples/09_hand_retargeting.pyraised:Cause
create_conn_tree()receives link indices fromget_mapping_from_mano_to_shadow()(which enumeratesrobot.links.names) but used them as joint indices when indexingrobot.joints.parent_indices. For robots like the Shadow Hand,num_linkscan be larger thannum_joints, so some link indices were out of range for the joint tuple.Solution
joint_to_child_linkmap and aget_parent_link(link_idx)helper from existingrobot.links.parent_joint_indicesandrobot.joints.parent_indices.is_direct_chain_connectionand use a set of the given link indices for membership checks.Testing
python examples/09_hand_retargeting.pysuccessfully; the script proceeds pastcreate_conn_treeand runs the optimization and viser server.