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

ROS2 Foxy: How to publish byte message from commandline?

asked 2021-04-02 00:02:26 -0600

mitsudome-r gravatar image

How do I publish byte message in ROS2 from ros2 topic command.

When I try to run the following command: ros2 topic pub /byte std_msgs/msg/Byte "{data: 3}"

I get: Failed to populate field: The 'data' field must be of type 'bytes' or 'ByteString' with length 1

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2021-12-01 23:27:14 -0600

ZiTe gravatar image

It's working for me:

ros2 topic pub /byte std_msgs/msg/Byte "data: [0x03]"
edit flag offensive delete link more

answered 2021-04-02 21:24:50 -0600

ryo4432 gravatar image

What about the following command?

$ ros2 topic pub /byte std_msgs/msg/Byte "{data: {3}}"
publisher: beginning loop
publishing #1: std_msgs.msg.Byte(data=b'\x03')

publishing #2: std_msgs.msg.Byte(data=b'\x03')

publishing #3: std_msgs.msg.Byte(data=b'\x03')
edit flag offensive delete link more

Question Tools

1 follower


Asked: 2021-04-02 00:02:26 -0600

Seen: 956 times

Last updated: Dec 01 '21