1

Rosanswers logo

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! :)

'


Originally posted by mirella melo on ROS Answers with karma: 194 on 2020-06-05

Post score: 10

1 Answers1

1

Rosanswers logo

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


Originally posted by sloretz with karma: 3061 on 2020-06-05

This answer was ACCEPTED on the original site

Post score: 16


Original comments

Comment by mirella melo on 2020-06-07:
Tks!! It totally works! :D

Shane Loretz
  • 1,273
  • 1
  • 2
  • 3