-
Notifications
You must be signed in to change notification settings - Fork 52
Open
Labels
Description
Bug report
Required Info:
- Operating System:
- focal
- Installation type:
- source
- Version or commit hash:
- master
- DDS implementation:
- n/a
- Client library (if applicable):
- rclpy
Steps to reproduce issue
from test_msgs.msg import UnboundedSequences
msg = UnboundedSequences()
msg.byte_values = b'ffff'
Expected behavior
A bytes
instance should be accepted, as it is the type documented in the design doc.
http://design.ros2.org/articles/idl_interface_definition.html
Actual behavior
>>> from test_msgs.msg import UnboundedSequences
>>> msg = UnboundedSequences()
>>> msg.byte_values = msg.byte_values = b'ffff'
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/sloretz/ws/ros2/install/test_msgs/lib/python3.8/site-packages/test_msgs/msg/_unbounded_sequences.py", line 466, in byte_values
assert \
AssertionError: The 'byte_values' field must be a set or sequence and each value of type 'bytes'
It only accepts a sequence of bytes instances
msg.byte_values = (b'ff', b'ff')
Additional information
I noticed while reviewing #129
russkel and hacker1024
Activity
byte
array ros2/ros2#1151russkel commentedon Jul 5, 2021
I ran into this issue as well. Thought I'd make a note about also supporting
bytearray
objects (https://docs.python.org/3/library/stdtypes.html#bytearray)And for anyone wanting a quick work around:
And for returning a list of byte objects into a single byte object:
It's a bit awkward. Can the python IDL be changed so maybe a byte[] message field would yield bytearray instead of List[bytes]?
byte[]
AKA IDL typesequence<octet>
to Python typebytes
#142dav-ell commentedon Feb 29, 2024
This issue is still present in ROS2 Humble (using
ros:humble
docker image) and a script like the following:CornerOfSkyline commentedon Oct 16, 2024
this line is EXTREMELY slow , agree