ros-controls/ros2_controllers

rqt_joint_trajectory_controller crashes if former selected controller_manager is not available

Opened this issue · 0 comments

Describe the bug
rqt_joint_trajectory_controller crashes if former selected controller_manager is not available

To Reproduce
Steps to reproduce the behavior:

  1. Launch a robot, e.g., ros2 launch ros2_control_demo_example_1 rrbot.launch.py and activate JTC
  2. ros2 run rqt_joint_trajectory_controller rqt_joint_trajectory_controller, select the JTC.
  3. Close all.
  4. Run ros2 run rqt_joint_trajectory_controller rqt_joint_trajectory_controller, it crashes:
IndexError: list index out of range

Traceback (most recent call last):
  File "/workspaces/ros2_rolling_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 "/workspaces/ros2_rolling_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 "/workspaces/ros2_rolling_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 "/workspaces/ros2_rolling_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 "/workspaces/ros2_rolling_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]
                        ~~~~~~~~^^^
IndexError: list index out of range

Expected behavior
no crash

Environment:

  • OS: noble
  • Version: Rolling from source