Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

[ROS2] Using sim time parameter, nodes time is always zero

I am trying to get the current simulation time, but I always receive zeros..
As soon as I set use_sim_time back to false, I receive current system time.

Sim time should be working, shouldn't it?
I am on Dashing release.

Here is the code:

int main(int argc, char ** argv)
   rclcpp::init(argc, argv);

   rclcpp::Node node("timeTest");

   rclcpp::Parameter simTime( "use_sim_time", rclcpp::ParameterValue( true ) );
   node.set_parameter( simTime );
   auto useSimTime = node.get_parameter( "use_sim_time" ).as_bool();

   auto periodic_timer = node.create_wall_timer(
           [&]() {
               log_info( "time {}.{} useSimTime: {}",,, useSimTime );


  return 0;