Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Replacement for rospy.time.now() in ROS2?

In ROS1 if I wanted to publish an Odometry msg I would use rospy.Time.now() to get the current time and publish the odom msg using that time. However, I haven't been able to find anything similar in ROS2? Does anyone know what functionality I can use to get the time for a msg I am publishing in ROS2?

now = rospy.Time.now()
odom = Odometry()
odom.header.frame_id = self._odom_frame
odom.header.stamp = now