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

Timestamp message ros2 - python

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

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
16

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

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/time.py

edit flag offensive delete link more

Comments

Tks!! It totally works! :D

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

Question Tools

1 follower

Stats

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

Seen: 25,350 times

Last updated: Jun 05 '20