Learning ROS Book: Chapter 2 is missing header file
In "Learning ROS for Robotics Programming," Edition 1, Chapter 2, section "Using the new srv and msg files.":
I copied all the code into my chapter2tutorials/src directory, and I did everything else they mentioned. Then when I run, it tells me that the header file in the include-directives of both example2a.cpp and example2_b.cpp is not found. This is true: it does not exist. Below is what it looks like in the code:
#include "chapter2_tutorials/chapter2_srv1.h"
... and this is what I get when I run "rosmake chapter2_tutorials":
Building CXX object CMakeFiles/example2_b.dir/src/example2_b.cpp.o
/home/viki/dev/rosbook/chapter2_tutorials/src/example2_a.cpp:2:46: fatal error: chapter2_tutorials/chapter2_srv1.h: No such file or directory
#include "chapter2_tutorials/chapter2_srv1.h"
^
compilation terminated.
/home/viki/dev/rosbook/chapter2_tutorials/src/example2_b.cpp:2:46: fatal error: chapter2_tutorials/chapter2_srv1.h: No such file or directory
#include "chapter2_tutorials/chapter2_srv1.h"
^
Is there something I'm forgetting? The book doesn't tell me anywhere how to make the header file or what I should put in it. I feel like I'm missing something obvious. Please help! Thanks in advance!
Asked by bonbonbaron on 2016-06-14 23:52:09 UTC
Answers
There header files are generated automatically from .srv files that you put in your package_folder/srv. (In this case chapter2_srv1.srv) You also need an additional line in your CMakeLists.txt that tells catkin to generate those messages. This should be explained in the book.
add_service_files(
FILES
chapter2_srv1.srv
)
and also add message_generation to catkin components in the CMakeLists.txt. example:
find_package(catkin REQUIRED COMPONENTS
roscpp
rospy
std_msgs
message_generation
)
finally in your package.xml you need the message generation dependency
<build_depend>message_generation</build_depend>
<run_depend>message_runtime</run_depend>
here is the link for the tutorial.
Asked by Mehdi. on 2016-06-15 04:10:06 UTC
Comments