fix issue of not listing new JTCs #1891
Open
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.
The Problem
If you launched
rqt_joint_trajectory_controller
with one JTC running, then started a new JTC with different joints, it would not show up.How to reproduce the problem
left_arm_jtc
) running for some jointsros2 run rqt_joint_trajectory_controller rqt_joint_trajectory_controller
and see you controller listed thereright_arm_jtc
) which controls some different jointsWhy does this happen?
Because the timer callback code actually only load of the joints limits from the URDF once, and only checks for joints "used" by the JTC, ignoring all other joints. Then when we check for new JTCs, they get filtered out as "invalid" because the code checks if we know the limits of the joints, which we do not if the new JTC has different joints than the initial set.
Proposed solution
Load all joint limits in the robot description into
JointTrajectoryController._robot_joint_limits
.This still assumes the URDF never changes.
But now you can start new JTCs and they are automatically listed!
To be honest the diff display makes this look more confusing than it is. All I did was move the
if name in joints_names:
check inside theexcept IndexError
clause. That way, we still throw an error if somehow the urdf does not contain a limit for a joint which is needed by a JTC.Also, I snuck in one other small fix.
The change to
utils.py
fixes this error message. You can get this error (randomly) when starting JTC just becausenode.get_service_names_and_types()
sometimes takes a second to return everything.Please let me know if I should also make PRs for humble/jazzy!