Robotics Asked by Anthares on October 3, 2021
I have defined a custom message: uint8[] data
The custom message is imported in my Node class with no problems:
from my_shared.msg import MyMessage
In the same Node, I create the publisher with:
self.my_publisher = self.create_publisher(MyMessage, 'topic_in', 200)
and I publish the message with:
self.my_publisher.publish(my_msg)
my_msg is built in the following way:
payload_bitstream = np.fromstring(my_data, np.uint8) my_msg = payload_bitstream.tolist()
Sadly, I get a TypeError:
File "/opt/ros/eloquent/lib/python3.6/site-packages/rclpy/publisher.py", line 68, in publish raise TypeError() TypeError
Could you help out with this if you know what I am doing wrong pls?
Thanks in advance, G.
The problem was caused by how I was creating and assigning value to the message.
The right way in ROS2 is:
my_msg = MyMessage()
...
my_msg.data = my_value
that did the trick and solved my problem
Answered by Anthares on October 3, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP