Skip to content

Conversation

peter-mitrano-ar
Copy link
Contributor

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

  • Start a robot (I used fake hardware) with one JTC (e.g. left_arm_jtc) running for some joints
  • ros2 run rqt_joint_trajectory_controller rqt_joint_trajectory_controller and see you controller listed there
  • Then enable a second controller (e.g. right_arm_jtc) which controls some different joints
  • Notice that the drop-down of available JTCs in the RQT app does not include the new JTC. If you restart the GUI, you can then see both controllers. But you should not need to restart!

Why 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 the except 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 because node.get_service_names_and_types() sometimes takes a second to return everything.

Traceback (most recent call last):
  File "/home/peter.mitrano/code/p2_4_jazzy_ws/build/rqt_joint_trajectory_controller/rqt_joint_trajectory_controller/joint_trajectory_controller.py", line 229, in _update_cm_list
    update_combo(self._widget.cm_combo, self._list_cm())
                                        ^^^^^^^^^^^^^^^
  File "/home/peter.mitrano/code/p2_4_jazzy_ws/build/rqt_joint_trajectory_controller/rqt_joint_trajectory_controller/utils.py", line 185, in __call__
    self._cm_list = get_controller_managers(self._ns, self._cm_list)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/peter.mitrano/code/p2_4_jazzy_ws/build/rqt_joint_trajectory_controller/rqt_joint_trajectory_controller/utils.py", line 80, in get_controller_managers
    ns_list += [ns for ns in ns_list_curr if ns not in ns_list and is_controller_manager(node, ns)]
                                                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/peter.mitrano/code/p2_4_jazzy_ws/build/rqt_joint_trajectory_controller/rqt_joint_trajectory_controller/utils.py", line 101, in is_controller_manager
    if not _srv_exists(node, cm_ns + srv_name, cm_services[srv_name]):
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/peter.mitrano/code/p2_4_jazzy_ws/build/rqt_joint_trajectory_controller/rqt_joint_trajectory_controller/utils.py", line 155, in _srv_exists
    srv_obtained_type = srv_info[0][1][0]
                        ~~~~~~~~^^^

Please let me know if I should also make PRs for humble/jazzy!

the problem was that we initially load only the joints limits for the joints used in active JTCs.
Then in the future when we check for JTCs, we ignore any JTCs if a joint is missing.

my fix is to load all joint limits in the robot description.
@peter-mitrano-ar
Copy link
Contributor Author

@destogl @moriarty Hey all! I hope someone can find some time, I did my best to make it easy to review!

@codecov
Copy link

codecov bot commented Oct 17, 2025

Codecov Report

❌ Patch coverage is 0% with 39 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.12%. Comparing base (9d06851) to head (977d1c2).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...t_joint_trajectory_controller/joint_limits_urdf.py 0.00% 37 Missing ⚠️
...ontroller/rqt_joint_trajectory_controller/utils.py 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1891      +/-   ##
==========================================
- Coverage   85.13%   85.12%   -0.02%     
==========================================
  Files         143      143              
  Lines       13742    13744       +2     
  Branches     1200     1201       +1     
==========================================
  Hits        11699    11699              
- Misses       1636     1638       +2     
  Partials      407      407              
Flag Coverage Δ
unittests 85.12% <0.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...ontroller/rqt_joint_trajectory_controller/utils.py 0.00% <0.00%> (ø)
...t_joint_trajectory_controller/joint_limits_urdf.py 0.00% <0.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@christophfroehlich christophfroehlich left a comment

Choose a reason for hiding this comment

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

Thanks for the fix. I was able to reproduce the issue, and that this PR fixes it!

@christophfroehlich christophfroehlich added backport-jazzy Triggers PR backport to ROS 2 jazzy. backport-humble Triggers PR backport to ROS 2 humble. labels Oct 17, 2025
@christophfroehlich christophfroehlich merged commit 56c6fa0 into ros-controls:master Oct 17, 2025
18 checks passed
mergify bot pushed a commit that referenced this pull request Oct 17, 2025
mergify bot pushed a commit that referenced this pull request Oct 17, 2025
@peter-mitrano-ar peter-mitrano-ar deleted the feature/rqt_jtc_reconnect branch October 21, 2025 11:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-humble Triggers PR backport to ROS 2 humble. backport-jazzy Triggers PR backport to ROS 2 jazzy.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants