Skip to main content
Version: 1.5.0

ROS Time in ROS2

The clock object

Comparing times

rclcpp::Rate

rclcpp::Duration

Duration object storing an interal of 1 second:

rclcpp::Duration(std::chrono::duration<double>(1.0))

rclcpp::Time

  • creating the Time object out of a floating point time:
rclcpp::Duration(std::chrono::duration<double>(1.0))

Sleeping

What was in ROS1 done as:

ros::Duration(duration).sleep();

is in ROS2 done as:

clock_->sleep_for(std::chrono::duration<double>(duration));

Simulation time