Image_proc fails with segmentation fault on ros::spin()
Hi,
I'm trying to run this node:
#include <ros/ros.h>
#include <nodelet/loader.h>
#include <image_proc/advertisement_checker.h>
int main(int argc, char **argv)
{
ros::init(argc, argv, "image_proc");
// Check for common user errors
if (ros::names::remap("camera") != "camera")
{
ROS_WARN("Remapping 'camera' has no effect! Start image_proc in the "
"camera namespace instead.\nExample command-line usage:\n"
"\t$ ROS_NAMESPACE=%s rosrun image_proc image_proc",
ros::names::remap("camera").c_str());
}
if (ros::this_node::getNamespace() == "/")
{
ROS_WARN("Started in the global namespace! This is probably wrong. Start image_proc "
"in the camera namespace.\nExample command-line usage:\n"
"\t$ ROS_NAMESPACE=my_camera rosrun image_proc image_proc");
}
// Shared parameters to be propagated to nodelet private namespaces
ros::NodeHandle private_nh("~");
ROS_INFO("Step1");
XmlRpc::XmlRpcValue shared_params;
int queue_size;
if (private_nh.getParam("queue_size", queue_size))
shared_params["queue_size"] = queue_size;
nodelet::Loader manager(false); // Don't bring up the manager ROS API
nodelet::M_string remappings;
nodelet::V_string my_argv;
ROS_INFO("Step2");
// Debayer nodelet, image_raw -> image_mono, image_color
std::string debayer_name = ros::this_node::getName() + "_debayer";
manager.load(debayer_name, "image_proc/debayer", remappings, my_argv);
// Rectify nodelet, image_mono -> image_rect
std::string rectify_mono_name = ros::this_node::getName() + "_rectify_mono";
if (shared_params.valid())
ros::param::set(rectify_mono_name, shared_params);
manager.load(rectify_mono_name, "image_proc/rectify", remappings, my_argv);
ROS_INFO("Step3");
// Rectify nodelet, image_color -> image_rect_color
// NOTE: Explicitly resolve any global remappings here, so they don't get hidden.
remappings["image_mono"] = ros::names::resolve("image_color");
remappings["image_rect"] = ros::names::resolve("image_rect_color");
ROS_INFO("Step4");
std::string rectify_color_name = ros::this_node::getName() + "_rectify_color";
if (shared_params.valid())
ros::param::set(rectify_color_name, shared_params);
ROS_INFO("Step5");
manager.load(rectify_color_name, "image_proc/rectify", remappings, my_argv);
ROS_INFO("Step6");
// Check for only the original camera topics
ros::V_string topics;
ROS_INFO("Step7");
topics.push_back(ros::names::resolve("image_raw"));
topics.push_back(ros::names::resolve("camera_info"));
ROS_INFO("Step8");
image_proc::AdvertisementChecker check_inputs(ros::NodeHandle(), ros::this_node::getName());
ROS_INFO("Step9");
check_inputs.start(topics, 60.0);
ros::spin();
ROS_INFO("Step10");
return 0;
}
However, every time I run it, it goes through it's lines (look at the ROS_INFO(StepX)) and then when it reaches the end, it just fails.
peter@peter:~/brokenGlasses$ ROS_NAMESPACE=camera rosrun image_proc image_proc
[ INFO] [1436016564.924762943]: Step1
[ INFO] [1436016564.940809151]: Step2
[ INFO] [1436016565.444694821]: Step3
[ INFO] [1436016565.444757917]: Step4
[ INFO] [1436016565.444783119]: Step5
[ INFO] [1436016565.671524024]: Step6
[ INFO] [1436016565.671576133]: Step7
[ INFO] [1436016565.671605069]: Step8
[ INFO] [1436016565.671639400]: Step9
Segmentation fault (core dumped)
I'm assuming the namespace is correct since I didn't get the yellow warnings, however there is really nothing to work on here and I'm at an impasse on what to do.
If anyone ahs some good ideas, I would really appreciate it!
Asked by chilypepper on 2015-07-04 08:35:28 UTC
Comments
I would be very suspicious of the
check_inputs.start(topics, 60.0);
line. It's probably just some sort of initialization issue. Try using gdb with it. You can enable debug info by putting this line in yourCMakeLists.txt
file.set(CMAKE_BUILD_TYPE DEBUG)
Asked by allenh1 on 2015-07-04 13:25:18 UTC
I ran it as a super user and as it turns out, it refuses to run unless the camera is "calibrated" which presents another hundred problems related to openCV >.<
Asked by chilypepper on 2015-07-04 13:53:47 UTC