Source Files failing to Build (C++ image subscriber tutorial)
Hi,
I'm new to ROS and have recently completed all of the tutorials in the tutorials section. I'm currently trying to get a C++ image subscriber working with our TurtleBot and I'm using the tutorial found here: http://wiki.ros.org/image_transport/T...
but as I follow the tutorial and try to build the node, the source files fail to build. From my experience with the tutorials I think it may be due to me not declaring the proper dependencies while making the package or in the CMakeLists.txt file (I don't know what they should be since it doesn't specify in the tutorial.)
I first create a new catkin package with the roscpp dependency while in ~/catkin_ws by typing the command: catkin_create_pkg image_transport_tutorial roscpp
After that, inside of the new "src" directory at ~/catkin_ws/src/image_transport_tutorial/src I paste the my_subscriber.cpp and my_publisher.cpp files I copied from the tutorial.
Here is probably where I go wrong: Inside of my CMakeLists.txt file in ~/catkin_ws/src/image_transport_tutorial/CMakeLists.txt I don't know exactly what to write to make the file executable since it doesn't specify in the tutorial, so I tried to craft a similar one to the example in the original "Writing a node in C++ for ROS" tutorial and the answer found here http://answers.ros.org/question/50953... . Here is what I added to the bottom of the file:
find_package(OpenCV REQUIRED)
add_executable(my_publisher src/my_publisher.cpp)
target_link_libraries(my_publisher ${catkin_LIBRARIES})
target_link_libraries(my_publisher ${OpenCV_LIBS})
add_dependencies(my_publisher image_transport_tutorial_generate_messages_cpp)
find_package(OpenCV REQUIRED)
add_executable(my_subscriber src/my_subscriber.cpp)
target_link_libraries(my_subscriber ${catkin_LIBRARIES})
target_link_libraries(my_subscriber ${OpenCV_LIBS})
add_dependencies(my_subscriber image_transport_tutorial_cpp)
I then navigate back to ~/catkin_ws and run catkin_make
This is the error message I get:
Scanning dependencies of target my_publisher Scanning dependencies of target my_subscriber
[ 7%] Building CXX object image_transport_tutorial/CMakeFiles/my_publisher.dir/src/my_publisher.cpp.o
[ 11%] Building CXX object image_transport_tutorial/CMakeFiles/my_subscriber.dir/src/my_subroslocate info create_gazebo_plugins --distro hydroscriber.cpp.o
/home/turtlebot/catkin_ws/src/image_transport_tutorial/src/my_publisher.cpp: In function ‘int main(int, char**)’:
/home/turtlebot/catkin_ws/src/image_transport_tutorial/src/my_publisher.cpp:13:16: error: ‘WaitKey’ was not declared in this scope
/home/turtlebot/catkin_ws/src/image_transport_tutorial/src/my_subscriber.cpp: In function ‘void imageCallback(const ImageConstPtr&)’:
/home/turtlebot/catkin_ws/src/image_transport_tutorial/src/my_subscriber.cpp:11:5: error: ‘WaitKey’ is not a member of ‘cv’
make[2]:
* [image_transport_tutorial/CMakeFiles/my_publisher.dir/src/my_publisher.cpp.o] Error 1
make[1]:
* [image_transport_tutorial/CMakeFiles/my_publisher.dir/all] Error 2
make[1]:
* Waiting for unfinished jobs....
make[2]:
* [image_transport_tutorial/CMakeFiles/my_subscriber.dir/src/my_subscriber.cpp.o] Error 1
make[1]:
* [image_transport_tutorial/CMakeFiles/my_subscriber.dir/all] Error 2
make:
* [all] Error 2 Invoking "make" failed
From what I understand, it look like it's not recognizing "cv", so perhaps the opencv dependencies aren't being imported?
Any help would be greatly appreciated.
Keep in mind that my only experience with ROS so far are the main ROS tutorials, so please be gentle and phrase your answers simply.
Thanks!
Please have a look at your question preview before posting, your error had all of the newlines stripped out of it...