Working with PointCloud2Ptr
Hi!
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); sor.setInputCloud(p); sor.setMeanK(50); sor.setStddevMulThresh(1.0); sor.filter(*pclCloud_filtered); 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?
Asked by rbaleksandar on 2015-08-19 11:33:08 UTC
Answers
Already answered: http://answers.ros.org/question/210533/memory-corruption/
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.
Asked by rbaleksandar on 2015-08-19 15:19:27 UTC
Comments