ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

build errors when trying to use CVbridge with ROS Hydro

asked 2014-09-16 12:53:00 -0600

voladoddi gravatar image

updated 2014-09-16 13:49:21 -0600

I'm trying to follow this tutorial - http://wiki.ros.org/cv_bridge/Tutoria...

to stream images to a node.

After I added the node see_image.cpp, I'm adding an executable by name image_viewer.

To be clearer, my CMakeLists.txt looks like this -

cmake_minimum_required(VERSION 2.8.3)
project(visual_odometry)

find_package(catkin REQUIRED COMPONENTS
  ardrone_autonomy
  roscpp
  rospy
  sensor_msgs
  cv_bridge
  std_msgs
  image_transport
)
include_directories(
  ${catkin_INCLUDE_DIRS}
)
add_executable(subscriber_test src/subscriber.cpp)
target_link_libraries(subscriber_test
${catkin_LIBRARIES}
)
   find_package(OpenCV REQUIRED)
   include_directories(${OpenCV_INCLUDE_DIRS})
   add_executable(image_viewer src/see_image.cpp)
   target_link_libraries(image_viewer ${OpenCV_LIBRARIES})

And my package.xml looks like this:

<package>
  <name>visual_odometry</name>
  <version>0.0.0</version>
  <description>The visual_odometry package</description>
 <maintainer email="voladoddi@todo.todo">voladoddi</maintainer>
 <buildtool_depend>catkin</buildtool_depend>
  <build_depend>ardrone_autonomy</build_depend>
  <build_depend>roscpp</build_depend>
  <build_depend>rospy</build_depend>
<!--adding build_depend and run_depend according to page http://wiki.ros.org/cv_bridge/Tutorials/UsingCvBridgeToConvertBetweenROSImagesAndOpenCVImages Example 1.4 - ROS node-->
  <build_depend>sensor_msgs</build_depend>
  <build_depend>cv_bridge</build_depend>
  <build_depend>std_msgs</build_depend>
  <build_depend>image_transport</build_depend>


  <run_depend>ardrone_autonomy</run_depend>
  <run_depend>roscpp</run_depend>
  <run_depend>rospy</run_depend>
<!--run dependencies for the 4 build dependencies added above-->
  <run_depend>sensor_msgs</run_depend>
  <run_depend>cv_bridge</run_depend>
  <run_depend>std_msgs</run_depend>
  <run_depend>image_transport</run_depend>



  <!-- The export tag contains other, unspecified, tags -->
  <export>
    <!-- You can specify that this package is a metapackage here: -->
    <!-- <metapackage/> -->

    <!-- Other tools can request additional information be placed here -->

  </export>
</package>

After all this, I try to build using catkin_make and I'm getting the following errors:

  Linking CXX executable /home/voladoddi/catkin_ws/devel/lib/visual_odometry/image_viewer
[  5%] Performing install step for 'ardronelib'
make[3]: warning: jobserver unavailable: using -j1.  Add `+' to parent make rule.
[  6%] Completed 'ardronelib'
[  8%] Built target ardronelib
[  9%] Built target subscriber_test
CMakeFiles/image_viewer.dir/src/see_image.cpp.o: In function `main':
see_image.cpp:(.text+0x55): undefined reference to `ros::init(int&, char**, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned int)'
see_image.cpp:(.text+0x81): undefined reference to `ros::spin()'
CMakeFiles/image_viewer.dir/src/see_image.cpp.o: In function `image_transport::TransportHints::TransportHints(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, ros::TransportHints const&, ros::NodeHandle const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
see_image.cpp:(.text._ZN15image_transport14TransportHintsC2ERKSsRKN3ros14TransportHintsERKNS3_10NodeHandleES2_[_ZN15image_transport14TransportHintsC5ERKSsRKN3ros14TransportHintsERKNS3_10NodeHandleES2_]+0x53): undefined reference to `ros::NodeHandle::NodeHandle(ros::NodeHandle const&)'
see_image.cpp:(.text._ZN15image_transport14TransportHintsC2ERKSsRKN3ros14TransportHintsERKNS3_10NodeHandleES2_[_ZN15image_transport14TransportHintsC5ERKSsRKN3ros14TransportHintsERKNS3_10NodeHandleES2_]+0x84): undefined reference to `ros::NodeHandle::~NodeHandle()'
CMakeFiles/image_viewer.dir/src/see_image.cpp.o: In function `image_transport::TransportHints::~TransportHints()':
see_image.cpp:(.text._ZN15image_transport14TransportHintsD2Ev[_ZN15image_transport14TransportHintsD5Ev]+0x19): undefined reference to `ros::NodeHandle::~NodeHandle()'
CMakeFiles/image_viewer.dir/src/see_image.cpp.o: In function `ImageConverter::ImageConverter()':
see_image.cpp:(.text._ZN14ImageConverterC2Ev[_ZN14ImageConverterC5Ev]+0x47): undefined reference to `ros::NodeHandle::NodeHandle(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::map<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > const&)'
see_image.cpp:(.text._ZN14ImageConverterC2Ev[_ZN14ImageConverterC5Ev]+0x82): undefined reference to `image_transport::ImageTransport ...
(more)
edit retag flag offensive close merge delete

Comments

can you post your .cpp file

bvbdort gravatar image bvbdort  ( 2014-09-16 13:01:05 -0600 )edit

I needed to add a target library for the new executable on catkin_libraries. worked. Thank you. However, still not able to see the images.

Do have a look at the .cpp file.

voladoddi gravatar image voladoddi  ( 2014-09-16 13:48:10 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2014-09-16 13:18:57 -0600

William gravatar image

It appears that your image_viewer program uses ros::spin, therefore you will need to link against at least roscpp, this diff should work:

--- cmake_minimum_required(VERSION 2.8.3)
+++ (clipboard)
@@ -20,4 +20,4 @@
    find_package(OpenCV REQUIRED)
    include_directories(${OpenCV_INCLUDE_DIRS})
    add_executable(image_viewer src/see_image.cpp)
-   target_link_libraries(image_viewer ${OpenCV_LIBRARIES})
+   target_link_libraries(image_viewer ${OpenCV_LIBRARIES} ${catkin_LIBRARIES})
edit flag offensive delete link more

Comments

find_package(OpenCV) include_directories(${OpenCV_INCLUDE_DIRS}) add_executable(image_viewer src/see_image.cpp) target_link_libraries(image_viewer ${OpenCV_LIBRARIES}) target_link_libraries(image_viewer ${catkin_LIBRARIES})

is what I did. works. Thank you.

voladoddi gravatar image voladoddi  ( 2014-09-16 13:43:41 -0600 )edit

However when I run the executable, I am now not able to see any image windows. I'm trying to visualize the images from a .bag file.

I can see that the topics are published when i run the bag file and say rostopic list

voladoddi gravatar image voladoddi  ( 2014-09-16 13:46:47 -0600 )edit

Run rqt_graph and make sure your topics are connected correctly.

William gravatar image William  ( 2014-09-16 13:47:56 -0600 )edit

Awesome this solved my issue as well. For some reason I had to do it on two lines like voladoddi, for it to work.

graouve gravatar image graouve  ( 2014-09-18 05:13:27 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2014-09-16 12:53:00 -0600

Seen: 1,670 times

Last updated: Sep 16 '14