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

Learning ROS Book: Chapter 2 is missing header file

asked 2016-06-14 23:52:09 -0500

bonbonbaron gravatar image

updated 2016-06-15 04:05:08 -0500

Mehdi. gravatar image

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 chapter2_tutorials/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 example2_a.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!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2016-06-15 04:10:06 -0500

Mehdi. gravatar image

updated 2016-06-15 04:11:11 -0500

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.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2016-06-14 23:52:09 -0500

Seen: 233 times

Last updated: Jun 15 '16