Ask Your Question
0

PCL complains no member functions

asked 2021-01-20 14:04:21 -0500

anonymous user

Anonymous

updated 2021-01-20 23:35:58 -0500

Hello, My system details: Arch Linux, ROS melodic. I have installed the ROS system using yay.

I am building a library that is dependent on PCL library.

Part of the code that I am using is;

  pointcloud_pub_ =
      nh_.advertise<pcl::PointCloud<pcl::PointXYZRGB>>("time_horizon_pointcloud", 1, true);
  pcl::PointCloud<pcl::PointXYZRGB>::Ptr msg(new PointCloudXYZRGB);
  msg->header.frame_id = world_frame_id_;
  msg->is_dense = true;
  msg->height = 1;
  msg->width = points_with_id.size();
  msg->points.resize(points_with_id.size());
  ros::Time ros_timestamp;
  ros_timestamp.fromNSec(timestamp);
  pcl_conversions::toPCL(ros_timestamp, msg->header.stamp);
  // pointcloud_pub_.publish(msg);

The commented line is the one which is causing the following error (i.e, if not commented out, it causes the following error and if commented out no error is reported.).

/opt/ros/melodic/include/ros/message_traits.h:125:14: error: ‘const class std::shared_ptr<pcl::PointCloud<pcl::PointXYZRGB> >’ has no member named ‘__getMD5Sum’
  125 |     return m.__getMD5Sum().c_str();

/opt/ros/melodic/include/ros/serialization.h:144:14: error: ‘const class std::shared_ptr<pcl::PointCloud<pcl::PointXYZRGB> >’ has no member named ‘serializationLength’
  144 |     return t.serializationLength();
      |            ~~^~~~~~~~~~~~~~~~~~~

/opt/ros/melodic/include/ros/serialization.h:127:7: error: ‘const class std::shared_ptr<pcl::PointCloud<pcl::PointXYZRGB> >’ has no member named ‘serialize’
  127 |     t.serialize(stream.getData(), 0);

I am not quite sure how to circumvent this error.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
2

answered 2021-01-21 01:59:48 -0500

gvdhoorn gravatar image

updated 2021-01-21 02:22:54 -0500

A pcl::PointCloud<pcl::PointXYZRGB>::Ptr is not a sensor_msgs::PointCloud2. You cannot directly publish a pcl::PointCloud<pcl::PointXYZRGB>::Ptr. You need to convert it to a sensor_msgs::PointCloud2 first.

See Publishing point clouds on wiki/pcl_ros.


Edit:

But based on this tutorial I am allowed to publish. Although I am able to get rid of the error if the msg is of the type pcl::PointCloud<pcl::PointXYZRGB> rather than pcl::PointCloud<pcl::PointXYZRGB>::Ptr.

Apparently there are overloads for pcl::PointCloud<pcl::PointXYZRGB> which perform the conversion for you.

In that case you should pass the pointed-to, instead of the smart pointer itself.

edit flag offensive delete link more

Comments

But based on this tutorial I am allowed to publish. Although I am able to get rid of the error if the msg is of the type pcl::PointCloud<pcl::PointXYZRGB> rather than pcl::PointCloud<pcl::PointXYZRGB>::Ptr.

anonymous userAnonymous ( 2021-01-21 02:18:49 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2021-01-20 14:04:21 -0500

Seen: 1,159 times

Last updated: Jan 21 '21