Segmentation fault (core dumped) : PCL tutorial
Hey, I am new to ROS (Version Jade-1.11.20) and want to work with pointclouds. I followed the first ROS PCL tutorial as written in http://wiki.ros.org/pcl/Tutorials . However, rosrun
leads to the following error output:
rosrun my_pcl_tutorial example input:=/narrow_stereo_textured/points2
Segmentation fault (core dumped)
Normally, that would mean that pointers are screwed up, but as I simply copy-pasted the code from the tutorial, the following example.cpp
file should be correct:
#include <ros/ros.h>
// PCL specific includes
#include <sensor_msgs/PointCloud2.h>
#include <pcl_conversions/pcl_conversions.h>
#include <pcl/point_cloud.h>
#include <pcl/point_types.h>
#include <pcl/filters/voxel_grid.h>
ros::Publisher pub;
void
cloud_cb (const sensor_msgs::PointCloud2ConstPtr& cloud_msg)
{
// Container for original & filtered data
pcl::PCLPointCloud2* cloud = new pcl::PCLPointCloud2;
pcl::PCLPointCloud2ConstPtr cloudPtr(cloud);
pcl::PCLPointCloud2 cloud_filtered;
// Convert to PCL data type
pcl_conversions::toPCL(*cloud_msg, *cloud);
// Perform the actual filtering
pcl::VoxelGrid<pcl::PCLPointCloud2> sor;
sor.setInputCloud (cloudPtr);
sor.setLeafSize (0.1, 0.1, 0.1);
sor.filter (cloud_filtered);
// Convert to ROS data type
sensor_msgs::PointCloud2 output;
pcl_conversions::fromPCL(cloud_filtered, output);
// Publish the data
pub.publish (output);
}
int
main (int argc, char** argv)
{
// Initialize ROS
ros::init (argc, argv, "my_pcl_tutorial");
ros::NodeHandle nh;
// Create a ROS subscriber for the input point cloud
ros::Subscriber sub = nh.subscribe ("input", 1, cloud_cb);
// Create a ROS publisher for the output point cloud
pub = nh.advertise<sensor_msgs::PointCloud2> ("output", 1);
// Spin
ros::spin ();
}
Could it be that I need to manually download and put /narrow_stereo_textured/points2
in the same folder as example.cpp
? I assumed that it gets taken from the library, but maybe this assumption is wrong. If you need any further code or info, just tell me (you would have to give all instructions though).
I also had a problem incorporating the package before as can be read in http://answers.ros.org/question/24426... .
GDB bt output:
(gdb) bt
#0 0x00007ffff402ea70 in boost::math::lanczos::lanczos_initializer<boost::math::lanczos::lanczos17m64, long double>::init::init() ()
from /usr/lib/libpcl_sample_consensus.so.1.7
#1 0x00007ffff40066be in ?? () from /usr/lib/libpcl_sample_consensus.so.1.7
#2 0x00007ffff7dea10a in call_init (l=<optimized out>, argc=argc@entry=1,
argv=argv@entry=0x7fffffffd9c8, env=env@entry=0x7fffffffd9d8)
at dl-init.c:78
#3 0x00007ffff7dea1f3 in call_init (env=<optimized out>,
argv=<optimized out>, argc=<optimized out>, l=<optimized out>)
at dl-init.c:36
#4 _dl_init (main_map=0x7ffff7ffe1c8, argc=1, argv=0x7fffffffd9c8,
env=0x7fffffffd9d8) at dl-init.c:126
#5 0x00007ffff7ddb30a in _dl_start_user () from /lib64/ld-linux-x86-64.so.2
#6 0x0000000000000001 in ?? ()
#7 0x00007fffffffddd1 in ?? ()
#8 0x0000000000000000 in ?? ()
(gdb)
Probably easiest to run your node in GDB and debug it. You can do this either directly (starting the node binary from
lib
in yourdevel
space), or by using a launch prefix: wiki/roslaunch/nodes in gdb.Well, this is difficult for me to grasp. I built a launch file in
my_pcl_tutorial/launch
and tried to run it with the prefixes, but it did not work. Could you give step by step instructions for simply doing what I am supposed to do?The first would be to actually tell us what "did not work".
I never used GDB :>. Would
gdb example
invoked in thelib/my_pcl_tutorial
workspace be sufficient? The output is attached to the question. Additionally, I have not written launch files until yet and find it hard to transfer the launch files written in tutorials to my specific example.The launch file (probably something wrong there):
I am listening to gdb tutorials on youtube now. I am wondering if it is easier to debug with qtcreator.
gdb example
would work, yes. Start the rest of your application (ie: other nodes, and a roscore). After that, return togdb
, enterr
(short for run) and press enter. That should start your node. Wait for the crash, enterbt
(backtrace), enter. Copy/paste the backtrace in your question.Make sure to compile your node with debug symbols though.
And this may all seem overly complicated to solve your problem, but if you're going to be working in C/C++, knowing how to use
gdb
for tracking down a simpleSEGFAULT
is a really valuable skill.re: qt creator: also possible. But that is basically
gdb
with a UI.