I would like to debug joint_trajectory_controller in ros_controllers package while running Gazebo and RViz through a launch file generated by MoveIt Setup Assistant:

roslaunch myrobot_moveit_config demo_gazebo.launch

If ros_controllers is installed as a binary, both RViz and Gazebo launch successfully and load controllers: executing a trajectory in RViz after moving the robot arm will cause Gazebo to reflect the arm moving.

Next I follow these instructions to clone and build ros_controllers from source, so that I can debug them:

(instructions from http://wiki.ros.org/ros_control)

cd ~/catkin_ws/src
wstool init
wstool merge https://raw.github.com/ros-controls/ros_control/$ROS_DISTRO-devel/ros_control.rosinstall
wstool update
rosdep install --from-paths . --ignore-src --rosdistro $ROS_DISTRO -y
catkin_make -DCMAKE_BUILD_TYPE=Debug -C ~/catkin_ws

If I launch Gazebo & RViz again, Gazebo Server crashes with this error just after "unpausing physics":

terminate called after throwing an instance of 'std::runtime_error'
what():  Time is out of dual 32-bit range

The controller spawner then exits because it fails to find an instance of controller manager that was supposed to be maintained by Gazebo Server.

If I uninstall ROS, delete Catkin workspace, and then re-install every package it works again, but then I can't debug ros controllers, since it installs as a binary.

This sounds to me like a version mismatch, where the ros_controllers built from source are using a different version of some binary data structure, but I have no idea what it is or how to look for it. I do see that the default branch for ros_controllers is Noetic, which is the correct distribution I am using.

Did anyone get ros controllers built from source? I tried this same thing a few months ago and it appeared to work.

  • $\begingroup$ I'm skeptical that the error message is accurate. It's more likely that some required shared library .so file could not be loaded. Please show us the output from echo $LD_LIBRARY_PATH at the point you are ready to do the roslaunch. $\endgroup$
    – Mike973
    Dec 17, 2023 at 14:51
  • $\begingroup$ I am getting the following for $LD_LIBRARY_PATH: ~/catkin_ws/devel/lib:/opt/ros/noetic/lib:/opt/ros/noetic/lib/x86_64-linux-gnu $\endgroup$
    – 01 Binary
    Dec 17, 2023 at 21:05
  • $\begingroup$ I adjusted the launch files to start Gazebo paused, since I had the clue that it crashed just after unpausing. Attached a debugger and clicked Play in Gazebo. Visual Studio broke into joint_state_controller.cpp in function void JointStateController::starting(const ros::Time& time), this line: last_publish_time_ = time - ros::Duration(1.001/publish_rate_); Apparently it crashed because the "time" passed into the function had 0 seconds and 1000000 nano-seconds. It's trying to subtract 1.001 / 50 from this value which would make it negative. $\endgroup$
    – 01 Binary
    Dec 17, 2023 at 22:05
  • $\begingroup$ All right, so I modified the code that was throwing the exception and the joint state controller successfully initializes now. I guess the work-around for this issue has been found, and we'll never know why the code was buggy. auto interval = ros::Duration(1.001 / publish_rate_); if (!pub_time_initialized_ && time.toSec() >= interval.toSec()) /* then initialize publish time */ $\endgroup$
    – 01 Binary
    Dec 17, 2023 at 22:19
  • 1
    $\begingroup$ Nice work. It's amazing to me that a bug like this could be in there for so long! You should combine your 2 comments into an answer, and ideally show the code change you made. If you have the time, please open a bug report in the github repo & put a link to it in your answer.) $\endgroup$
    – Mike973
    Dec 18, 2023 at 13:29

1 Answer 1


This was a bug introduced in a recent pull request, which has not yet made it into the apt binary packages so it only reproduces when ros_controllers is build from source.

Created issue #628 in ros_controllers repo.

This bug has now been fixed in https://github.com/ros-controls/ros_controllers/pull/630


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.