Ask Your Question
0

Not able to run image_transport from cpp code: ` Segmentation fault (core dumped)`

asked 2016-07-17 22:43:26 -0600

polar gravatar image

updated 2016-07-18 06:49:42 -0600

I included well image_transport in both my CMake file and packake.xml 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
  )

....

and

<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);

Am also able to run image_transport with command line: rosrun image_transport republish..... Able also to use image_view, etc...

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2016-07-18 22:55:25 -0600

polar gravatar image

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.

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

edit flag offensive delete link more

Comments

1

Your 'stand-alone Boost' question should really be a new question (but please use the search first, as it has been asked many times already), but in short: you can't. Or at least, not without building all of ROS from source using your version of Boost.

gvdhoorn gravatar imagegvdhoorn ( 2016-07-19 03:20:30 -0600 )edit

@gvdhoorn please what has already been answered: the ability to use a standalone boost with ros or the fact that the segmentation fault is due to the standalone boost?

polar gravatar imagepolar ( 2016-07-19 04:20:23 -0600 )edit

Both questions have been answered previously, actually.

But again: to use a different version of Boost than the one that is used to build the binary ROS packages, you'll need to build all packages you use from source, making sure the build scripts finds and uses your Boost version.

gvdhoorn gravatar imagegvdhoorn ( 2016-07-19 05:04:37 -0600 )edit

I would be grateful if you can provide me the link. I found only quite few answers related to segmentation fault with image_transport....

polar gravatar imagepolar ( 2016-07-19 20:40:46 -0600 )edit

Be aware of potential compatibility problems though. There is no guarantee that all packages will be compatible with newer Boost versions, as they haven't been tested with them.

gvdhoorn gravatar imagegvdhoorn ( 2016-07-20 06:27:15 -0600 )edit

@gvdhoorn Thanks for the info. But still, NONE of these report the issue related to image_transport (segmentation fault).

polar gravatar imagepolar ( 2016-07-20 21:18:52 -0600 )edit

I had understood that you wanted info about incompatibility between binary ROS distributions and from-source built pkgs with a different version of Boost.

And the issue is universal, it's not limited to image_transport, or even ROS: mixing different Boost versions can always lead to problems.

gvdhoorn gravatar imagegvdhoorn ( 2016-07-21 01:15:03 -0600 )edit

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

Stats

Asked: 2016-07-17 22:43:26 -0600

Seen: 249 times

Last updated: Jul 18 '16