Header and timestamp for Float32MultiArray in ROS2 [closed]
Hi,
I am working with ROS 2 foxy distribution. I have a publisher which sends an array (for every second) to the ROS queue. I am able to successfully subscribe it and save it. I want to add a timestamp every time the array is getting sent over ROS queue. I tried the following code.
Without timeStamp: // Working
data_to_send = Float32MultiArray()
data_to_send.data = my_array
sample_publisher_.publish(data_to_send)
With added timestamp code: // Not Working
pp = PublishingNode() // creating an instance of the class
data_to_send = std_msgs.msg.Header()
data_to_send.stamp = pp.get_clock().now().to_msg()
data_to_send.data = my_array
AttributeError: 'Header' object has no attribute 'data'
The aim is send an array along with the timestamp every second using python in ROS2.
Any guidance would be helpful?
Regards Niranjan