ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

How to transfer second to rostime in ROS2

asked 2022-06-10 20:42:29 -0600

lilyGinger gravatar image

In ROS2, which function can replace ros1 'ros::Time().fromSec'? Thanks a lot for your time!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2022-06-10 21:01:56 -0600

fergs gravatar image

rclcpp::Duration has a from_seconds() constructor - but rclcpp::Time does not, the best approximation that I've found is:

rclcpp::Time t(static_cast<uin64_t>(seconds * 1e9));

I have a bit more detailed write up in the ros2_cookbook

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2022-06-10 20:42:29 -0600

Seen: 523 times

Last updated: Jun 10 '22