1
$\begingroup$

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

$\endgroup$

1 Answer 1

1
$\begingroup$

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

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.