Add support for rosidl::Buffer in rosidl Python path for rclpy#250
Add support for rosidl::Buffer in rosidl Python path for rclpy#250
Conversation
Signed-off-by: CY Chen <cyc@nvidia.com>
hidmic
left a comment
There was a problem hiding this comment.
First pass. Ownership is bit fuzzy.
Signed-off-by: CY Chen <cyc@nvidia.com>
Signed-off-by: CY Chen <cyc@nvidia.com>
|
Pulls: #250 |
|
Pulls: ros2/rosidl#943, ros2/rosidl_typesupport_fastrtps#144, ros2/rosidl_runtime_py#39, #250 |
|
Pulls: ros2/rosidl#943, ros2/rosidl_typesupport_fastrtps#144, ros2/rosidl_runtime_py#39, #250 |
|
Pulls: ros2/rosidl#943, ros2/rosidl_typesupport_fastrtps#144, ros2/rosidl_runtime_py#39, #250, ros2/rosidl_core#14, ros2/rmw_cyclonedds#575 |
|
Pulls: ros2/rosidl#943, ros2/rosidl_typesupport_fastrtps#144, ros2/rosidl_runtime_py#39, #250, ros2/rosidl_core#14, ros2/rmw_cyclonedds#575 |
|
Triggered with custom ros2.repos that contain all PRs: https://raw.githubusercontent.com/nvcyc/ros2/refs/heads/rolling-native-buffer-prs/ros2.repos Started by user CY Chen |
|
Pulls: ros2/rosidl#943, ros2/rosidl_typesupport_fastrtps#144, ros2/rosidl_runtime_py#39, #250, ros2/rosidl_core#14, ros2/rmw_fastrtps#867 |
Description
This pull request adds
rosidl::Buffersupport for uint8[] fields in the Python code generation path.This pull request consists of the following key changes:
_msg.py.em): Foruint8[]fields, the generated setters now allow assigning fromrosidl_buffer.Bufferor plainarray.array. Existing code that setsmsg.data = array.array('B', ...)continues to work unchanged._msg_support.c.em): Messages withuint8[]fields use the sequence'sis_rosidl_bufferflag to determine the conversion path:rosidl_buffer.Bufferobjects, calls_get_buffer_ptr()and sets the C++ Buffer pointer plusis_rosidl_buffer = trueso the RMW path uses the existing buffer without copying. Forarray.arrayobjects, uses the normal byte-copy path.is_rosidl_buffer == true), calls_take_buffer_from_ptr()to wrap the pointer in a PythonBuffer(taking ownership) and set it on the message. CPU-based data is converted toarray.arrayas before.Is this user-facing behavior change?
This pull request does not change existing rclpy behavior. Existing code using
array.arrayforuint8[]fields continues to work. Therosidl_buffer.Buffertype is only encountered when a subscriber receives data from a non-CPU buffer backend (and has opted in viaacceptable_buffer_backends).Did you use Generative AI?
Yes. Claude (claude-4.6-opus) via Cursor was used to assist with creating an initial prototype version of the changes contained in this PR.
Additional Information
This PR is part of the broader ROS 2 native buffer feature introduced in this post.