Converting different pcl datatypes

asked 2016-11-28 08:42:37 -0500

MaxB gravatar image

updated 2016-11-29 08:57:03 -0500

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/smart_ptr/shared_ptr.hpp:646: typename boost::detail::sp_dereference<t>::type boost::shared_ptr<t>::operator() const [with T = pcl::PointCloud<pcl::pointxyzrgba>; typename boost::detail::sp_dereference<t>::type = pcl::PointCloud<pcl::pointxyzrgba>&]: Assertion `px != 0' failed. [segmentation-3] process has died [pid 6995, exit code -6, cmd /home/osboxes/ROS/catkin_workspace/devel/lib/pf_matching_core/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!

edit retag flag offensive close merge delete

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.

gvdhoorn gravatar image gvdhoorn  ( 2016-11-28 08:55:29 -0500 )edit

OK thank, I also will ask this question on PCL-forum.

MaxB gravatar image MaxB  ( 2016-11-29 07:58:43 -0500 )edit