Image_proc fails with segmentation fault on ros::spin()

asked 2015-07-04 08:35:28 -0500

chilypepper gravatar image


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",
  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("~");
  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;

  // 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);
  // 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");
  std::string rectify_color_name = ros::this_node::getName() + "_rectify_color";
  if (shared_params.valid())
    ros::param::set(rectify_color_name, shared_params);
  manager.load(rectify_color_name, "image_proc/rectify", remappings, my_argv);
  // Check for only the original camera topics
  ros::V_string topics;
  image_proc::AdvertisementChecker check_inputs(ros::NodeHandle(), ros::this_node::getName());
  check_inputs.start(topics, 60.0);

  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!

edit retag flag offensive close merge delete


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 your CMakeLists.txt file. set(CMAKE_BUILD_TYPE DEBUG)

allenh1 gravatar image allenh1  ( 2015-07-04 13:25:18 -0500 )edit

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 >.<

chilypepper gravatar image chilypepper  ( 2015-07-04 13:53:47 -0500 )edit