Skip to content

pcl_conversions: Fix compile errors caused by rosidl_buffer introduction#529

Open
wentasah wants to merge 1 commit intoros-perception:ros2from
wentasah:fix_rosidl_buffer
Open

pcl_conversions: Fix compile errors caused by rosidl_buffer introduction#529
wentasah wants to merge 1 commit intoros-perception:ros2from
wentasah:fix_rosidl_buffer

Conversation

@wentasah
Copy link
Copy Markdown

Compiling pcl_ros package in rolling results in errors like this:

In file included from
/build/perception_pcl-release-release-rolling-pcl_ros-2.8.0-1/tools/combined_pointcloud_to_pcd.cpp:47:
/ros-rolling-pcl-conversions-2.8.0-r1/include/pcl_conversions/pcl_conversions/pcl_conversions.h: In
  function 'void pcl_conversions::moveFromPCL(pcl::PCLImage&, sensor_msgs::msg::Image&)':
/ros-rolling-pcl-conversions-2.8.0-r1/include/pcl_conversions/pcl_conversions/pcl_conversions.h:172:16:
  error: 'using sensor_msgs::msg::Image_<std::allocator<void> >::_data_type = class
  rosidl::Buffer<unsigned char, std::allocator<unsigned char> >' {aka 'class rosidl::Buffer<unsigned
  char, std::allocator<unsigned char> >'} has no member named 'swap'
  172 |     image.data.swap(pcl_image.data);
      |                ^~~~

These are caused by ros2/rosidl#941 and followup PRs, which change the type of uint8[] message fields from std::vector<uint8_t> to rosidl::Buffer<uint8_t>. To maintain the previous functionality, explicit typecasting is needed at a few places. This causes invocation of the conversion operator, which returns a reference to the underlying std::vector.

Compiling pcl_ros package in rolling results in errors like this:

    In file included from
    /build/perception_pcl-release-release-rolling-pcl_ros-2.8.0-1/tools/combined_pointcloud_to_pcd.cpp:47:
    /ros-rolling-pcl-conversions-2.8.0-r1/include/pcl_conversions/pcl_conversions/pcl_conversions.h: In
      function 'void pcl_conversions::moveFromPCL(pcl::PCLImage&, sensor_msgs::msg::Image&)':
    /ros-rolling-pcl-conversions-2.8.0-r1/include/pcl_conversions/pcl_conversions/pcl_conversions.h:172:16:
      error: 'using sensor_msgs::msg::Image_<std::allocator<void> >::_data_type = class
      rosidl::Buffer<unsigned char, std::allocator<unsigned char> >' {aka 'class rosidl::Buffer<unsigned
      char, std::allocator<unsigned char> >'} has no member named 'swap'
      172 |     image.data.swap(pcl_image.data);
          |                ^~~~

These are caused by ros2/rosidl#941 and
followup PRs, which change the type of `uint8[]` message fields from
`std::vector<uint8_t>` to `rosidl::Buffer<uint8_t>`. To maintain the
previous functionality, explicit typecasting is needed at a few
places. This causes invocation of the conversion operator [1], which
returns a reference to the underlying std::vector.

[1]: https://github.com/ros2/rosidl/blob/7c4e0f90f2979c16c906d65058fc7966360f52e1/rosidl_buffer/include/rosidl_buffer/buffer.hpp#L420

Signed-off-by: Michal Sojka <michal.sojka@cvut.cz>
@sloretz
Copy link
Copy Markdown
Contributor

sloretz commented Apr 21, 2026

Thank you for the PR!

@nvcyc mind taking a look?

@nvcyc
Copy link
Copy Markdown

nvcyc commented Apr 22, 2026

I think our rosidl::Buffer should be updated to support swap() for the CPU-backed storage.
@wentasah Can you try your original code with this pull request in rosidl ros2/rosidl#959 where I just added swap() to rosidl::Buffer? Thanks!

@wentasah
Copy link
Copy Markdown
Author

@nvcyc Yes, ros2/rosidl#959 allows compiling original pcl_ros.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants