Skip to content

Fix get_link_names exception for single-link groups (#160) - #465

Open
Swastik-Verma wants to merge 1 commit into
compas-dev:mainfrom
Swastik-Verma:fix/160-robot-get-link-names
Open

Fix get_link_names exception for single-link groups (#160)#465
Swastik-Verma wants to merge 1 commit into
compas-dev:mainfrom
Swastik-Verma:fix/160-robot-get-link-names

Conversation

@Swastik-Verma

Copy link
Copy Markdown

Fixes #160

Problem

RobotCell.get_link_names() raised an exception when called on a group
consisting of a single link (e.g. an end-effector group with no
configurable joints), instead of returning that link's name.

Root cause

When a group's base link and end-effector link are the same (i.e. the
group has only one link), get_link_names() would still call
iter_link_chain(), which internally tries to compute a shortest path
between two identical nodes. This returns an empty path, which was
incorrectly treated as "no chain found," raising an exception even
though the group is valid.

Fix

Added a check in get_link_names(): if the base link and end-effector
link are the same, the function returns that single link's name
directly, without going through the chain-finding logic.

Testing

Added a test case in test_get_link_names using the endeffector
group on the ur10e_gripper_one_beam fixture, which has a single link
and zero configurable joints — reproducing the original bug scenario.
Verified the fix with:

  • invoke test --doctest
  • invoke testcodeblocks

Both show the same pre-existing, unrelated baseline failures as before
this change (documented in issue discussion/PR comments if needed),
with no new failures introduced.

@gonzalocasas gonzalocasas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the contribution! Please add a line to the changelog and check the feedback regarding the test!

Comment on lines +181 to +183
robot_cell, robot_cell_state = ur10e_gripper_one_beam
link_names = robot_cell.get_link_names("endeffector")
assert link_names == ["tool0"]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This doesn't really test that the fix works. You'd need to add a test that has a robot with a single link group.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks for the feedback! I'm a bit busy right now but will address both points soon.

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.

Robot's get_link_names throws exception for group with one link

2 participants