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

Creating a ROS msg and srv tutorial problems

asked 2016-06-23 15:26:11 -0500

Starmit gravatar image

updated 2016-06-28 15:02:49 -0500

Hey guys,

I've been stuck on this problem for the last two days and would really appreciate some help.

I'm following the ROS tutorial on msgs ans srv and every time I get to the catkin_make install part I get the following error.

CMake Error at /opt/ros/indigo/share/genmsg/cmake/genmsg-extras.cmake:151 (message): add_service_files() directory not found: /home/user_name/catkin_ws/src/beginner_tutorials/src/srv Call Stack (most recent call first): beginner_tutorials/src/CMakeLists.txt:9 (add_service_files)

One forum I looked into stated that I can just comment out add_service_files() from the CMakeLists.txt. However, when I do that I get the following error

 /home/user_name/catkin_ws/src/beginner_tutorials/src/add_two_ints_server.cpp:2:83: fatal error: beginner_tutorials/AddTwoInts.h: No such file or directory
 #include "beginner_tutorials/AddTwoInts.h" //header file generated in the SRV file
                                                                                   ^
compilation terminated.
/home/user_name/catkin_ws/src/beginner_tutorials/src/add_two_ints_client.cpp:2:43: fatal error: beginner_tutorials/AddTwoInts.h: No such file or directory
 #include "beginner_tutorials/AddTwoInts.h"

Again I appreciate any help I can receive. ROS is giving me a lot of trouble and the tutorials are not always so helpful. Thank you for any feedback!

EDIT: CMakeLists.txt

cmake_minimum_required(VERSION 2.8.3)
project(beginner_tutorials)

## Find catkin and any catkin packages
find_package(catkin REQUIRED COMPONENTS roscpp rospy std_msgs genmsg message_generation)

## Declare ROS messages and services
##add_message_files(FILES Num.msg)
##add_service_files(FILES AddTwoInts.srv)

## Generate added messages and services
##generate_messages(DEPENDENCIES std_msgs)

## Declare a catkin package
catkin_package( CATKIN_DEPENDS message_runtime)

## Build talker and listener
include_directories(include ${catkin_INCLUDE_DIRS})

add_executable(talker talker.cpp)
target_link_libraries(talker ${catkin_LIBRARIES})
add_dependencies(talker beginner_tutorials_generate_messages_cpp)

add_executable(listener listener.cpp)
target_link_libraries(listener ${catkin_LIBRARIES})
add_dependencies(listener beginner_tutorials_generate_messages_cpp)

add_executable(add_two_ints_server add_two_ints_server.cpp)
target_link_libraries(add_two_ints_server ${catkin_LIBRARIES})
add_dependencies(add_two_ints_server beginner_tutorials_gencpp)

add_executable(add_two_ints_client add_two_ints_client.cpp)
target_link_libraries(add_two_ints_client ${catkin_LIBRARIES})
add_dependencies(add_two_ints_client beginner_tutorials_gencpp)
edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2016-06-24 06:05:36 -0500

gvdhoorn gravatar image

updated 2016-06-24 06:06:25 -0500

With these kind of questions, you should indeed include your CMakeLists.txt so we can see whether you made any mistakes, as @ROSkinect suggests.

But in this case I think there is enough information in the error message you posted (I've left out some bits):

[..] directory not found: /home/user_name/catkin_ws/src/beginner_tutorials/src/srv
Call Stack (most recent call first): beginner_tutorials/src/CMakeLists.txt:9 (add_service_files)

I believe the directory argument you give to add_service_files(..) is relative to the CMakeLists.txt it is being called in (but only if you don't specify an absolute path). From the error message it would seem you have your CMakeLists.txt in beginner_tutorials/src, and not in the more customary beginner_tutorials top-level directory.

As you can see in the error message, the build system is looking for a directory beginner_tutorials/src/srv, while the tutorial instructs you to create the directory srv directly under the beginner_tutorials directory.

src/srv != srv, so I'm guessing that's why CMake is complaining.

edit flag offensive delete link more

Comments

I added CMakeLists.txt to the original question. I'm looking through the files and a lot of what you said isn't present. srv is not in my src folder. I tried moving CMakeLists.txt to the beginner tutorials top-level directory and that didn't fix anything either.

Starmit gravatar image Starmit  ( 2016-06-28 15:04:31 -0500 )edit

Your beginner tutorials directory should have a CMakeLists.txt in the top level, and there should be a subdirectory called srv/ that contains AddTwoInts.srv. I.e., the fullpath would be something like /home/user/catkin_ws/src/beginner_tutorials/srv/AddTwoInts.srv.

jarvisschultz gravatar image jarvisschultz  ( 2016-06-28 15:10:38 -0500 )edit

You can see the correct structure of your package here (if your version doesn't match, it's not correct): https://github.com/ros/catkin_tutoria...

jarvisschultz gravatar image jarvisschultz  ( 2016-06-28 15:12:13 -0500 )edit

a lot of what you said isn't present. srv is not in my src folder

@Starmit: that could very well be the case. As I said: I took an educated guess.

Could you include the output of tree /home/user/catkin_ws/src/beginner_tutorials in your original post? Use the edit link/button.

gvdhoorn gravatar image gvdhoorn  ( 2016-06-29 03:10:26 -0500 )edit
0

answered 2016-06-23 17:48:03 -0500

ROSkinect gravatar image

updated 2016-06-23 17:48:36 -0500

You have to generate the header from the server you created, here

You should share your CMakeLists to help us spot the problem easily and quickly!

Did you add add_dependencies to your CMakeLists:

add_dependencies(add_two_ints_server ${beginner_tutorials_EXPORTED_TARGETS})
add_dependencies(add_two_ints_client ${beginner_tutorials_EXPORTED_TARGETS})
edit flag offensive delete link more

Question Tools

Stats

Asked: 2016-06-23 15:26:11 -0500

Seen: 1,518 times

Last updated: Jun 28 '16