Ask Your Question

Working with PointCloud2Ptr [closed]

asked 2015-08-19 11:33:08 -0600

rbaleksandar gravatar image


I have a PointCloud2Ptr publishing node. Now I'm trying to figure out how the subscription works:

  • The subscriber:

    ros::Subscriber sub = nh.subscribe<sensor_msgs::PointCloud2>("/camera/points_unrectified", 1, processData);
  • The subscriber's callback (it applies a statistical outlier removal):

    void processData(const sensor_msgs::PointCloud2ConstPtr& msg)
      pcl::PointCloud<pcl::PointXYZ> pclCloud;
      pcl::fromROSMsg(*msg, pclCloud);
      PointCloudPtr pclCloud_filtered(new PointCloud);
      pcl::StatisticalOutlierRemoval<pcl::PointXYZ> sor;
      ROS_INFO("Filtering started");
      pcl::PointCloud<pcl::PointXYZ>::ConstPtr p(&pclCloud);
      ROS_INFO("Filtering completed");

First I'm getting instant segmentation fault. That is until I remove all the pcl::StatisticalOutlierRemoval related stuff and leave only the pcl::PointCloud<pcl::PointXYZ>::ConstPtr p(&pclCloud); line. In that case however I'm getting

double free or corruption (out): 0x00007ffc588890e0 ***
Aborted (core dumped)

The incoming msg is valid and can be displayed in RViz. Can anyone shine some light upon this issue? Syntactically it's all good. The setInputCloud() works only with pcl::PointCloud<pcl::PointXYZ>::ConstPtr hence the need of creating one and assigning my converted cloud to it. The error might also be coming from the pcl::fromROSMsg(). Can this also be due to the fact that the information is shared and when the next message is generated it overwrites the one I'm working on leading to this conflict?

edit retag flag offensive reopen merge delete

Closed for the following reason duplicate question by rbaleksandar
close date 2015-08-19 15:26:35.024415

1 Answer

Sort by ยป oldest newest most voted

answered 2015-08-19 15:19:27 -0600

rbaleksandar gravatar image

updated 2015-08-19 15:24:38 -0600

Already answered: It's the way I define my pointer. The funny thing is that I have already done it the proper way a few lines above at PointCloudPtr pclCloud_filtered(new PointCloud); but pointing at an empty point cloud instance.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2015-08-19 11:33:08 -0600

Seen: 2,116 times

Last updated: Aug 19 '15