-
Notifications
You must be signed in to change notification settings - Fork 162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot/don't know how to publish message with byte[]
field
#760
Comments
byte[]
fieldbyte[]
field
root@tomoyafujita:~/ros2_ws/colcon_ws# ros2 topic pub -1 /whatever std_msgs/msg/Float32 "data: 3.0"
root@tomoyafujita:~/ros2_ws/colcon_ws# ros2 topic pub -1 /whatever std_msgs/msg/Float32 "{data: 3.0}"
root@tomoyafujita:~/ros2_ws/colcon_ws# ros2 topic pub -1 /whatever std_msgs/msg/Float32MultiArray "data: [3.0, 4.0]"
root@tomoyafujita:~/ros2_ws/colcon_ws# ros2 topic pub -1 /whatever std_msgs/msg/Float32MultiArray "{data: [3.0, 4.0]}"
root@tomoyafujita:~/ros2_ws/colcon_ws# ros2 topic pub -1 /whatever std_msgs/msg/Float32MultiArray "{data: {3.0, 4.0}}"
root@tomoyafujita:~/ros2_ws/colcon_ws# ros2 topic pub -1 /whatever std_msgs/msg/Byte "data: [3]"
root@tomoyafujita:~/ros2_ws/colcon_ws# ros2 topic pub -1 /whatever std_msgs/msg/Byte "{data: [3]}"
root@tomoyafujita:~/ros2_ws/colcon_ws# ros2 topic pub -1 /whatever std_msgs/msg/Byte "data: [0x03]"
root@tomoyafujita:~/ros2_ws/colcon_ws# ros2 topic pub -1 /whatever std_msgs/msg/Byte "{data: [0x03]}"
root@tomoyafujita:~/ros2_ws/colcon_ws# ros2 topic pub -1 /whatever std_msgs/msg/Byte "data: {3}"
root@tomoyafujita:~/ros2_ws/colcon_ws# ros2 topic pub -1 /whatever std_msgs/msg/Byte "{data: {3}}"
root@tomoyafujita:~/ros2_ws/colcon_ws# ros2 topic pub -1 /whatever std_msgs/msg/Byte "data: {0x03}"
root@tomoyafujita:~/ros2_ws/colcon_ws# ros2 topic pub -1 /whatever std_msgs/msg/Byte "{data: {0x03}}"
root@tomoyafujita:~/ros2_ws/colcon_ws# ros2 topic pub -1 /whatever std_msgs/msg/ByteMultiArray "{data: [3]}"
root@tomoyafujita:~/ros2_ws/colcon_ws# ros2 topic pub -1 /whatever std_msgs/msg/ByteMultiArray "{data: [3,4]}"
root@tomoyafujita:~/ros2_ws/colcon_ws# ros2 topic pub -1 /whatever std_msgs/msg/ByteMultiArray "{data: [0x03]}"
root@tomoyafujita:~/ros2_ws/colcon_ws# ros2 topic pub -1 /whatever std_msgs/msg/ByteMultiArray "{data: [0x03,0x04]}"
root@tomoyafujita:~/ros2_ws/colcon_ws# ros2 topic pub -1 /whatever std_msgs/msg/ByteMultiArray "{data: [0x03],[0x04]}"
root@tomoyafujita:~/ros2_ws/colcon_ws# ros2 topic pub -1 /whatever std_msgs/msg/ByteMultiArray "{data: {0x03}}"
root@tomoyafujita:~/ros2_ws/colcon_ws# ros2 topic pub -1 /whatever std_msgs/msg/ByteMultiArray "{data: {0x03,0x04}}"
root@tomoyafujita:~/ros2_ws/colcon_ws# ros2 topic pub -1 /whatever std_msgs/msg/ByteMultiArray "{data: {0x03},{0x04}}" |
@iuhilnehc-ynos @ivanpauno any thoughts? |
The generated message for python in assert \
((isinstance(value, Sequence) or
isinstance(value, Set) or
isinstance(value, UserList)) and
not isinstance(value, str) and
not isinstance(value, UserString) and
all(isinstance(v, bytes) for v in value) and
True), \
"The 'data' field must be a set or sequence and each value of type 'bytes'"
self._data = value The type could be I am afraid that we should update the above source code with assert \
((isinstance(value, Sequence) or
isinstance(value, Set) or
isinstance(value, UserList)) and
not isinstance(value, str) and
not isinstance(value, UserString) and
all((isinstance(v, bytes) or isinstance(v, int)) for v in value) and
True), \
"The 'data' field must be a set or sequence and each value of type 'bytes'"
if any(isinstance(v, int) for v in value):
self._data = bytearray(value)
else:
self._data = value NOTE: It means that we need to update https://github.com/ros2/rosidl_python/blob/52e099efef21366ff651385da865e305228d24ec/rosidl_generator_py/resource/_msg.py.em |
It's strange that those are valid, they shouldn't IMO.
Those seem fine, does ros2 topic pub -1 /whatever std_msgs/msg/Byte "!!binary 'Aw=='" work?
These should work as well. ros2 topic pub -1 /whatever std_msgs/msg/Byte "!!binary 'AwQ='" work?
I'm not sure about that fix, but if you could propose a PR with it that would be a great start. |
root@tomoyafujita:~/ros2_ws/colcon_ws# ros2 topic pub -1 /whatever std_msgs/msg/Byte "\!\!binary 'Aw=='"
The passed value needs to be a dictionary in YAML format
root@tomoyafujita:~/ros2_ws/colcon_ws# ros2 topic pub -1 /whatever std_msgs/msg/Byte "\!\!binary 'AwQ='"
The passed value needs to be a dictionary in YAML format both do not work. |
any progress?? |
Bug report
Required Info:
Steps to reproduce issue
Trying to
ros2 topic pub
astd_msgs/msg/ByteMultiArray
message. I have tried:bash ros2 topic pub -1 /whatever std_msgs/msg/ByteMultiArray "{data: [{3}, {4}]}"
and
bash ros2 topic pub -1 /whatever std_msgs/msg/ByteMultiArray "{data: [0x03, 0x04]}"
Expected behavior
Successful publishing.
Actual behavior
Error response:
Additional information
The text was updated successfully, but these errors were encountered: