Converting different pcl datatypes
Hello fellow Poinclouduser!
I relativy new to pcl. I have a problem converting some pcl datateypes and publishing them in ROS-Topics. I wrote a node which segments incoming pointclouds and now I like to see the result of course. The incoming pointcloud is from type PointNormal. I like to test my segmentation with pcl::regiongrowing. Here is my code:
void segmentScene(){
pcl::PointCloud<pcl::PointXYZ>::Ptr surface_xyz (new pcl::PointCloud<pcl::PointXYZ>);
pcl::PointCloud<pcl::Normal>::Ptr surface_only_normals (new pcl::PointCloud<pcl::Normal>);
pcl::copyPointCloud(*surface_normals, *surface_xyz);
pcl::copyPointCloud(*surface_normals, *surface_only_normals);
pcl::RegionGrowing<pcl::PointXYZ, pcl::Normal> regionGrowing;
std::vector <pcl::PointIndices> clusters;
//Here comes the whole stuff for preparing the regiongrowing class like minium cluster size and so on
regionGrowing.extract (clusters);
pcl::PointCloud<pcl::PointXYZRGB>::Ptr surface_coloured (new pcl::PointCloud<pcl::PointXYZRGB>);
surface_coloured= regionGrowing.getColoredCloud();
sensor_msgs::PointCloud2 msg_rgb_out;
pcl::toROSMsg(*surface_coloured, msg_rgb_out);
sensor_msgs::PointCloud2::Ptr msg_rgb_out_ptr(new sensor_msgs::PointCloud2(msg_rgb_out));
pubPCRvizOut.publish(msg_rgb_out_ptr);}
After running my code, I get this error message:
segmentation: /usr/include/boost/smartptr/sharedptr.hpp:646: typename boost::detail::spdereference
::type boost::shared ptr::operator() const [with T = pcl::PointCloudpcl::PointXYZRGBA; typename boost::detail::spdereference ::type = pcl::PointCloudpcl::PointXYZRGBA&]: Assertion `px != 0' failed. [segmentation-3] process has died [pid 6995, exit code -6, cmd /home/osboxes/ROS/catkin workspace/devel/lib/pfmatchingcore/segmentation _name:=segmentation _log:=/home/osboxes/.ros/log/621ba038-b55c-11e6-8e7a-0800277b3835/segmentation-3.log]. log file: /home/osboxes/.ros/log/621ba038-b55c-11e6-8e7a-0800277b3835/segmentation-3.log
When commenting out pcl::toROSMsg it works all just fine. I get different clusters and so on. I am hoping someone can help me with this issue.
Thanks so much in advance!
Asked by MaxB on 2016-11-28 09:42:37 UTC
Comments
We can keep this open because of the use of
pcl::toROSMsg(..)
, but I think you'd have a better chance of getting good answers over at the PCL support forums. This forum is for ROS-specific problems only.Asked by gvdhoorn on 2016-11-28 09:55:29 UTC
OK thank, I also will ask this question on PCL-forum.
Asked by MaxB on 2016-11-29 08:58:43 UTC