3

I included well image_transport in both my CMake file and packake.xml. Am using ROS Kineltic on ubuntu 16, though I got the same issue on ubuntu 14 with ros indigo and jade.

My CMake file is as follows:

find_package(catkin REQUIRED COMPONENTS
  cv_bridge
  image_transport
  roscpp
  rospy
  std_msgs
  message_generation
  genmsg
  )

generate_messages(
  DEPENDENCIES
  std_msgs
  )

catkin_package(
  CATKIN_DEPENDS  cv_bridge image_transport roscpp rospy std_msgs message_generation
  )
    include_directories(
   ${catkin_INCLUDE_DIRS}
   ) 
....

While my package.xml is

<buildtool_depend>catkin</buildtool_depend>
 <build_depend>cv_bridge</build_depend>
  <build_depend>image_transport</build_depend>
  <build_depend>roscpp</build_depend>
 <build_depend>rospy</build_depend>
  <build_depend>std_msgs</build_depend>
  <build_depend>message_generation</build_depend>
   <run_depend>cv_bridge</run_depend>
  <run_depend>image_transport</run_depend>
  <run_depend>roscpp</run_depend>
  <run_depend>rospy</run_depend>
 <run_depend>std_msgs</run_depend>
  <run_depend>message_runtime</run_depend>
 <run_depend>message_generation</run_depend>
    <run_depend>image_transport</run_depend>

and in my .cpp file

#include <ros/ros.h>
#include <image_transport/image_transport.h>
.....
int main(int argc, char **argv)
{

  ros::init(argc, argv, "imagegraber");
  ros::NodeHandle nodea;

 image_transport::ImageTransport it(nodea);

image_transport::Subscriber sub = it.subscribe("/pg_15508342/image_raw", 1, imageCallback);


 ros::spin();
return 0;
}

Yet, I receive Segmentation fault (core dumped) when I run my code.... What could be the problem? The code crashes at image_transport::ImageTransport it(nodea);

Note that am able to run image_transport with command line: rosrun image_transport republish raw in:=/pg_15508342/image_raw raw out:=/newim. Also able to run image_view

Courier
  • 920
  • 2
  • 11
  • 36

1 Answers1

0

I think I can see now the origin of the problem. It is related to Boost included from outside ros. In fact I should have reported my full CMakeLists.txt in the question, but I was initially far from thinking the issue was in any how related...

In my CMakeLists.txt I included my own boost (latest version downloaded from source) like

SET (BOOST_DIR "/home/polar/soft/lib/boost/boost_1_61_0")
SET (BOOST_INCLUDEDIR "/home/polar/soft/lib/boost/boost_1_61_0/build/include")
SET (BOOST_LIBRARYDIR "/home/polar/soft/lib/boost/boost_1_61_0/build/lib")

FIND_PACKAGE(Boost 1.61.0 REQUIRED thread)
if (NOT Boost_FOUND)
  message(FATAL_ERROR " Fatal error: Boost (version >= 1.55) required.")
else()
  message(STATUS "Setting up BOOST")
  message(STATUS " Includes - ${Boost_INCLUDE_DIRS}")
  message(STATUS " Library  - ${Boost_LIBRARY_DIRS}")
  include_directories(${Boost_INCLUDE_DIRS})
  link_directories(${Boost_LIBRARY_DIRS})
endif (NOT Boost_FOUND)

As such I got segmentation fault at image_transport::ImageTransport it(nh);. However, after replacing the above CMake code with only

FIND_PACKAGE(Boost)

I no longer have that segmentation fault. I should have put more attention to the warning message given by ros regarding eventual conflict between ROS's Boost and my standalone Boost....

Thus another question, how to use the standalone Boost with ROS catkin??

Courier
  • 920
  • 2
  • 11
  • 36