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

ROS2 Foxy: How to publish byte message from commandline?

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

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
0

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

ZiTe gravatar image

It's working for me:

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

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

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

Stats

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

Seen: 1,198 times

Last updated: Dec 01 '21