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