ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

Segmentation fault in PCL segmentation project

asked 2013-10-09 11:59:49 -0500

RosBiscuit gravatar image

updated 2013-10-09 22:02:02 -0500

I am working on a segmentation project with PCL, but i am receiving a Segmentation fault (core dumped) error. Unfortunately i dont get much more error than that, but i have determined that the segmentation function is causing the problem. I hope someone can spot my typo/mistake, as i am becoming more and more blind in the code.

void cloud_cb (const sensor_msgs::PointCloud2& pc2_raw)
    pcl::PointCloud<pcl::PointXYZ>::Ptr pcl_cloud(new pcl::PointCloud<pcl::PointXYZ>);
    pcl::PointCloud<pcl::PointXYZ>::Ptr temp_cloud(new pcl::PointCloud<pcl::PointXYZ>);

    // Convert PC2 to PCL

    // Create variables for segmentation
    pcl::ModelCoefficients::Ptr coefficient (new pcl::ModelCoefficients);
    pcl::PointIndices::Ptr inliers (new pcl::PointIndices);
    pcl::search::KdTree<pcl::PointXYZ>::Ptr search(new pcl::search::KdTree<pcl::PointXYZ>);
    pcl::SACSegmentation<pcl::PointXYZ> segmentation;

    // Set segmentation variables
    segmentation.setSamplesMaxDist(1.0, search);

    // Start segmentation
    segmentation.segment(*inliers, *coefficient);

gdb backtrace:

#0  0xb785cecd in pcl::SACSegmentation<pcl::PointXYZ>::segment(pcl::PointIndices&, pcl::ModelCoefficients&) () from /usr/lib/
#1  0x08074bfc in cloud_cb (pc2_raw=...) at /home/mirex/catkin_ws/src/isa_cuda/src/cuda.cpp:48
#2  0x080816e0 in boost::detail::function::void_function_invoker1<void (*)(sensor_msgs::PointCloud2_<std::allocator<void> > const&), void, sensor_msgs::PointCloud2_<std::allocator<void> > const&>::invoke (
    function_ptr=..., a0=...) at /usr/include/boost/function/function_template.hpp:112
#3  0x080872ab in boost::function1<void, sensor_msgs::PointCloud2_<std::allocator<void> > const&>::operator() (this=0x80c47c4, a0=...) at /usr/include/boost/function/function_template.hpp:1013
#4  0x08086b95 in ros::SubscriptionCallbackHelperT<sensor_msgs::PointCloud2_<std::allocator<void> > const&, void>::call (this=0x80c47c0, params=...)
    at /opt/ros/hydro/include/ros/subscription_callback_helper.h:180
#5  0xb7f89497 in ros::SubscriptionQueue::call() () from /opt/ros/hydro/lib/
#6  0xb7f38117 in ros::CallbackQueue::callOneCB(ros::CallbackQueue::TLS*) () from /opt/ros/hydro/lib/
#7  0xb7f39c24 in ros::CallbackQueue::callAvailable(ros::WallDuration) () from /opt/ros/hydro/lib/
#8  0xb7f8cad8 in ros::SingleThreadedSpinner::spin(ros::CallbackQueue*) () from /opt/ros/hydro/lib/
#9  0xb7f70b87 in ros::spin(ros::Spinner&) () from /opt/ros/hydro/lib/
#10 0xb7f70bb8 in ros::spin() () from /opt/ros/hydro/lib/
#11 0x08074f15 in main (argc=1, argv=0xbffff054) at /home/mirex/catkin_ws/src/isa_cuda/src/cuda.cpp:77
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2013-10-10 03:15:38 -0500

makokal gravatar image

Change this line



pcl::fromROSMsg(pc2_raw, pcl_cloud);

See the API of pcl::fromROSMsg, for details. It needs a pointer and you already have that.

edit flag offensive delete link more

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


Asked: 2013-10-09 11:59:49 -0500

Seen: 2,482 times

Last updated: Oct 10 '13