I'm using robot localization nodes and I noticed that if my system fails to update fast enough the node propagates the state using the last predicted values. This results in a massive time step.

Tracking down the issue it's because the This->Now() used in the filter node doesn't return ros2 bag time and instead returns the current system time.

All my running nodes are launched using use_sim_time, I'm not sure what else to do.


1 Answer 1


In ROS1 there was a parameter server, but in ROS2 it's ever person for themselves, basically. The use_sim_time parameter is something that's set (or not) on a per-node basis. It could be that all the other nodes have it set, but if your filter node doesn't have it set then it's not going to use it.

You can try force-setting it. Assuming you have an rclcpp::Node::SharedPtr node; then

node->set_parameter(rclcpp::Parameter("use_sim_time", true));

Any subsequent calls to node->now() should use sim time. You can also double-check this two ways: By fetching the parameter:

bool is_sim_time_set = node->get_parameter("use_sim_time").as_bool();

or by polling the ros_time status in the node's clock:

bool is_sim_time_set = node->get_clock()->ros_time_is_active();
  • $\begingroup$ I set all the nodes to use_sim_time in their launch files/launch parameter, have any other ideas? $\endgroup$ Commented May 23 at 4:19
  • $\begingroup$ @FourierFlux - What happens you you query the parameter after the node has started? Is it actually set? Are you playing your bagfile with the --clock option? $\endgroup$
    – Chuck
    Commented May 23 at 16:33

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.