Clock (sim time) from Ign-Gazebo to ROS2

asked 2021-04-29 17:52:54 -0500

dimai gravatar image

updated 2021-04-29 17:56:37 -0500

I am trying to use sim time in ROS2 with ignition gazebo in order to control joints of a humanoid robot.

To do that, I launch the ignition bridge for /clock topic and set use_sim_time true for both of ign-bridge and a node that publishes desire joint angles based on sim time.

The node display the sim time as follows

double SimTime=node().now().nanoseconds();
RCLCPP_INFO(this->get_logger(), "NANOsec: '%f'", SimTime);

However, it is always zero.

Details:

  1. In both ignition gazebo and ros2, /clocktopic echos the same sim time -> ignition bridge works properly.
  2. The frequency of desire joint angles became same as the frequency of publisher after setting use_sim_time true.
  3. In the case where use_sim_time is false, it shows the system time properly.

I know some answers for classic gazebo and ROS2 (this) But, I cannot use them because "ros_init" is not available for ignition-gazebo.

Please let me where I went wrong and solutions. If you also show the code that using sim time in ROS2 from ignition-gazebo, I would appreciate you.

Thanks,

edit retag flag offensive close merge delete