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

Timestamp message ros2 - python

asked 2020-06-05 14:43:38 -0500

mirella melo gravatar image

Hi. I`m trying to form the timestamp message in ROS2 (dashing) in python.

When I use

msg.header.stamp = node.get_clock().now()

I have the error:

The 'stamp' field must be a sub message of type 'Time'

Thanks in advance! :)


edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2020-06-05 17:42:37 -0500

sloretz gravatar image

Use to_msg() to convert from rclpy.time.Time to builtin_interfaces.msg.Time

  msg.header.stamp = node.get_clock().now().to_msg()

Link to Time.to_msg() in rclpy/

edit flag offensive delete link more


Tks!! It totally works! :D

mirella melo gravatar image mirella melo  ( 2020-06-07 23:03:56 -0500 )edit

Question Tools

1 follower


Asked: 2020-06-05 14:43:38 -0500

Seen: 21,915 times

Last updated: Jun 05 '20