Skip to content

fix(examples): use link-tree traversal in create_conn_tree to fix IndexError#86

Open
amirhosein-vedadi wants to merge 1 commit intochungmin99:mainfrom
amirhosein-vedadi:fix-hand-retargeting-conn-tree-index-error
Open

fix(examples): use link-tree traversal in create_conn_tree to fix IndexError#86
amirhosein-vedadi wants to merge 1 commit intochungmin99:mainfrom
amirhosein-vedadi:fix-hand-retargeting-conn-tree-index-error

Conversation

@amirhosein-vedadi
Copy link
Copy Markdown

Problem

Running examples/09_hand_retargeting.py raised:

IndexError: tuple index out of range
  File ".../retarget_helpers/_utils.py", line 22, in is_direct_chain_connection
    parent = robot.joints.parent_indices[current]

Cause

create_conn_tree() receives link indices from get_mapping_from_mano_to_shadow() (which enumerates robot.links.names) but used them as joint indices when indexing robot.joints.parent_indices. For robots like the Shadow Hand, num_links can be larger than num_joints, so some link indices were out of range for the joint tuple.

Solution

  • Treat the input as link indices and implement link-tree traversal.
  • Build a joint_to_child_link map and a get_parent_link(link_idx) helper from existing robot.links.parent_joint_indices and robot.joints.parent_indices.
  • Use this to walk the link tree in is_direct_chain_connection and use a set of the given link indices for membership checks.

Testing

  • Ran python examples/09_hand_retargeting.py successfully; the script proceeds past create_conn_tree and runs the optimization and viser server.

…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>
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.

1 participant