pcl_conversions fails to convert from sensor_msgs::PointCloud2 to pcl::PointCloud2 on Jetson (arm architecture)

I am trying to use the pcl_conversions library to convert the pointcloud from sensor_msgs::msg::PointCloud2 to pcl::PCLPointCloud2. I am working on a Jetson (ARM architecture) with Jetpack 5.0, in a docker container with Ubuntu 20.04, gcc and g++ version 9.4.0, cmake version 3.22.3 and ROS 2 Foxy. I have installed the library with the usual command apt install libpcl-dev and the version installed is the 1.10.

The part of the code that gives compiling error is the following:

void GlobalPlanner::pointCloudCallback(const sensor_msgs::msg::PointCloud2::SharedPtr msg) {

  pcl::PCLPointCloud2::Ptr pcl_pc2(new pcl::PCLPointCloud2);

  pcl_conversions::toPCL(*msg, *pcl_pc2);
  
}

and the error is

error: no matching function for call to ‘toPCL(const SharedPtr&, pcl::PCLPointCloud2::Ptr&)’
  239 |   pcl_conversions::toPCL(msg, pcl_pc2);
      |                                      ^
In file included from /home/user/D4A/ras/ros2/ras_node_ws/src/navigation/include/global_planner.h:19,
                 from /home/user/D4A/ras/ros2/ras_node_ws/src/navigation/src/global_planner.cpp:1:
/usr/include/pcl_conversions/pcl_conversions.h:86:8: note: candidate: ‘void pcl_conversions::toPCL(const ros::Time&, pcl::uint64_t&)’
   86 |   void toPCL(const ros::Time &stamp, pcl::uint64_t &pcl_stamp)
      |        ^~~~~
/usr/include/pcl_conversions/pcl_conversions.h:86:31: note:   no known conversion for argument 1 from ‘const SharedPtr’ {aka ‘const std::shared_ptr<sensor_msgs::msg::PointCloud2_<std::allocator<void> > >’} to ‘const ros::Time&’
   86 |   void toPCL(const ros::Time &stamp, pcl::uint64_t &pcl_stamp)
      |              ~~~~~~~~~~~~~~~~~^~~~~
/usr/include/pcl_conversions/pcl_conversions.h:100:17: note: candidate: ‘pcl::uint64_t pcl_conversions::toPCL(const ros::Time&)’
  100 |   pcl::uint64_t toPCL(const ros::Time &stamp)
      |                 ^~~~~
/usr/include/pcl_conversions/pcl_conversions.h:100:17: note:   candidate expects 1 argument, 2 provided
/usr/include/pcl_conversions/pcl_conversions.h:118:8: note: candidate: ‘void pcl_conversions::toPCL(const Header&, pcl::PCLHeader&)’
  118 |   void toPCL(const std_msgs::Header &header, pcl::PCLHeader &pcl_header)
      |        ^~~~~
/usr/include/pcl_conversions/pcl_conversions.h:118:38: note:   no known conversion for argument 1 from ‘const SharedPtr’ {aka ‘const std::shared_ptr<sensor_msgs::msg::PointCloud2_<std::allocator<void> > >’} to ‘const Header&’ {aka ‘const std_msgs::Header_<std::allocator<void> >&’}
  118 |   void toPCL(const std_msgs::Header &header, pcl::PCLHeader &pcl_header)
      |              ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
/usr/include/pcl_conversions/pcl_conversions.h:134:18: note: candidate: ‘pcl::PCLHeader pcl_conversions::toPCL(const Header&)’
  134 |   pcl::PCLHeader toPCL(const std_msgs::Header &header)
      |                  ^~~~~
/usr/include/pcl_conversions/pcl_conversions.h:134:18: note:   candidate expects 1 argument, 2 provided
/usr/include/pcl_conversions/pcl_conversions.h:180:8: note: candidate: ‘void pcl_conversions::toPCL(const Image&, pcl::PCLImage&)’
  180 |   void toPCL(const sensor_msgs::Image &image, pcl::PCLImage &pcl_image)
      |        ^~~~~
/usr/include/pcl_conversions/pcl_conversions.h:180:40: note:   no known conversion for argument 1 from ‘const SharedPtr’ {aka ‘const std::shared_ptr<sensor_msgs::msg::PointCloud2_<std::allocator<void> > >’} to ‘const Image&’ {aka ‘const sensor_msgs::Image_<std::allocator<void> >&’}
  180 |   void toPCL(const sensor_msgs::Image &image, pcl::PCLImage &pcl_image)
      |              ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
/usr/include/pcl_conversions/pcl_conversions.h:216:8: note: candidate: ‘void pcl_conversions::toPCL(const PointField&, pcl::PCLPointField&)’
  216 |   void toPCL(const sensor_msgs::PointField &pf, pcl::PCLPointField &pcl_pf)
      |        ^~~~~
/usr/include/pcl_conversions/pcl_conversions.h:216:45: note:   no known conversion for argument 1 from ‘const SharedPtr’ {aka ‘const std::shared_ptr<sensor_msgs::msg::PointCloud2_<std::allocator<void> > >’} to ‘const PointField&’ {aka ‘const sensor_msgs::PointField_<std::allocator<void> >&’}
  216 |   void toPCL(const sensor_msgs::PointField &pf, pcl::PCLPointField &pcl_pf)
      |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
/usr/include/pcl_conversions/pcl_conversions.h:225:8: note: candidate: ‘void pcl_conversions::toPCL(const std::vector<sensor_msgs::PointField_<std::allocator<void> > >&, std::vector<pcl::PCLPointField>&)’
  225 |   void toPCL(const std::vector<sensor_msgs::PointField> &pfs, std::vector<pcl::PCLPointField> &pcl_pfs)
      |        ^~~~~
/usr/include/pcl_conversions/pcl_conversions.h:225:58: note:   no known conversion for argument 1 from ‘const SharedPtr’ {aka ‘const std::shared_ptr<sensor_msgs::msg::PointCloud2_<std::allocator<void> > >’} to ‘const std::vector<sensor_msgs::PointField_<std::allocator<void> > >&’
  225 |   void toPCL(const std::vector<sensor_msgs::PointField> &pfs, std::vector<pcl::PCLPointField> &pcl_pfs)
      |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/pcl_conversions/pcl_conversions.h:278:8: note: candidate: ‘void pcl_conversions::toPCL(const PointCloud2&, pcl::PCLPointCloud2&)’
  278 |   void toPCL(const sensor_msgs::PointCloud2 &pc2, pcl::PCLPointCloud2 &pcl_pc2)
      |        ^~~~~
/usr/include/pcl_conversions/pcl_conversions.h:278:46: note:   no known conversion for argument 1 from ‘const SharedPtr’ {aka ‘const std::shared_ptr<sensor_msgs::msg::PointCloud2_<std::allocator<void> > >’} to ‘const PointCloud2&’ {aka ‘const sensor_msgs::PointCloud2_<std::allocator<void> >&’}
  278 |   void toPCL(const sensor_msgs::PointCloud2 &pc2, pcl::PCLPointCloud2 &pcl_pc2)
      |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/pcl_conversions/pcl_conversions.h:308:8: note: candidate: ‘void pcl_conversions::toPCL(const PointIndices&, pcl::PointIndices&)’
  308 |   void toPCL(const pcl_msgs::PointIndices &pi, pcl::PointIndices &pcl_pi)
      |        ^~~~~
/usr/include/pcl_conversions/pcl_conversions.h:308:44: note:   no known conversion for argument 1 from ‘const SharedPtr’ {aka ‘const std::shared_ptr<sensor_msgs::msg::PointCloud2_<std::allocator<void> > >’} to ‘const PointIndices&’ {aka ‘const pcl_msgs::PointIndices_<std::allocator<void> >&’}
  308 |   void toPCL(const pcl_msgs::PointIndices &pi, pcl::PointIndices &pcl_pi)
      |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
/usr/include/pcl_conversions/pcl_conversions.h:338:8: note: candidate: ‘void pcl_conversions::toPCL(const ModelCoefficients&, pcl::ModelCoefficients&)’
  338 |   void toPCL(const pcl_msgs::ModelCoefficients &mc, pcl::ModelCoefficients &pcl_mc)
      |        ^~~~~
/usr/include/pcl_conversions/pcl_conversions.h:338:49: note:   no known conversion for argument 1 from ‘const SharedPtr’ {aka ‘const std::shared_ptr<sensor_msgs::msg::PointCloud2_<std::allocator<void> > >’} to ‘const ModelCoefficients&’ {aka ‘const pcl_msgs::ModelCoefficients_<std::allocator<void> >&’}
  338 |   void toPCL(const pcl_msgs::ModelCoefficients &mc, pcl::ModelCoefficients &pcl_mc)
      |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
/usr/include/pcl_conversions/pcl_conversions.h:388:8: note: candidate: ‘void pcl_conversions::toPCL(const Vertices&, pcl::Vertices&)’
  388 |   void toPCL(const pcl_msgs::Vertices &vert, pcl::Vertices &pcl_vert)
      |        ^~~~~
/usr/include/pcl_conversions/pcl_conversions.h:388:40: note:   no known conversion for argument 1 from ‘const SharedPtr’ {aka ‘const std::shared_ptr<sensor_msgs::msg::PointCloud2_<std::allocator<void> > >’} to ‘const Vertices&’ {aka ‘const pcl_msgs::Vertices_<std::allocator<void> >&’}
  388 |   void toPCL(const pcl_msgs::Vertices &vert, pcl::Vertices &pcl_vert)
      |              ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
/usr/include/pcl_conversions/pcl_conversions.h:394:8: note: candidate: ‘void pcl_conversions::toPCL(const std::vector<pcl_msgs::Vertices_<std::allocator<void> > >&, std::vector<pcl::Vertices>&)’
  394 |   void toPCL(const std::vector<pcl_msgs::Vertices> &verts, std::vector<pcl::Vertices> &pcl_verts)
      |        ^~~~~
/usr/include/pcl_conversions/pcl_conversions.h:394:53: note:   no known conversion for argument 1 from ‘const SharedPtr’ {aka ‘const std::shared_ptr<sensor_msgs::msg::PointCloud2_<std::allocator<void> > >’} to ‘const std::vector<pcl_msgs::Vertices_<std::allocator<void> > >&’
  394 |   void toPCL(const std::vector<pcl_msgs::Vertices> &verts, std::vector<pcl::Vertices> &pcl_verts)
      |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
/usr/include/pcl_conversions/pcl_conversions.h:440:8: note: candidate: ‘void pcl_conversions::toPCL(const PolygonMesh&, pcl::PolygonMesh&)’
  440 |   void toPCL(const pcl_msgs::PolygonMesh &mesh, pcl::PolygonMesh &pcl_mesh)
      |        ^~~~~
/usr/include/pcl_conversions/pcl_conversions.h:440:43: note:   no known conversion for argument 1 from ‘const SharedPtr’ {aka ‘const std::shared_ptr<sensor_msgs::msg::PointCloud2_<std::allocator<void> > >’} to ‘const PolygonMesh&’ {aka ‘const pcl_msgs::PolygonMesh_<std::allocator<void> >&’}
  440 |   void toPCL(const pcl_msgs::PolygonMesh &mesh, pcl::PolygonMesh &pcl_mesh)
      |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~

This is strange to me because one of the templates listed in the error is exactly the one that I am using

void pcl_conversions::toPCL( const sensor_msgs::PointCloud2& pc2, pcl::PCLPointCloud2& pcl_pc2)

I have used the same code, with the same Dockerfile (with different architecture) on my laptop and everything worked.
Another strange thing is that, on the Jetson, I had also to manually install the pcl_conversions library with apt install libpcl-conversions-dev (version 1.10).

I tried to use different functions but I need this specific one. I also tried to write a custom function to transform the two types but is not the best solution.

How can I try to solve this problem?

Thanks

Upvotes: -1

Views: 192

Answers (1)

IBitMyBytes
IBitMyBytes

Reputation: 706

I think libpcl-conversions-dev is the wrong package. It seems like a ROS 1 version. I believe what you need is ros-foxy-pcl-conversions

Upvotes: 0

Related Questions