Quantcast
Channel: ROS Answers: Open Source Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 69

How to use a service defined in another package ?

$
0
0
Hi all, I am facing a compilation problem when I try to include a service.h file in a node located in another package. Here is the architecture : rosfond/ src/ my_nodes.cpp include/ ... srv/ my_service.srv hmi/ src/ my_other_nodes.cpp include/ ... I want to use `my_service` in the `hmi` package, and especially include `my_service.h` in `my_other_nodes.cpp`. For that, I wrote at the beginning of `my_other_nodes.cpp` `#include "rosfond/my_service.h"`. I also use `my_service` in `my_nodes`. When I try to compile my whole workspace, it fails. However, if I compile only `rosfond`, it works. So the problem seems to be related to how I include/link `my_service` in `my_other_nodes` and in the hmi's `CMakeLists.txt`. Here are the `CMakeLists.txt` and the `package.xml` file of each package : cmake_minimum_required(VERSION 2.8.3) project(rosfond) find_package(catkin REQUIRED COMPONENTS roscpp rospy std_msgs message_generation ) add_service_files(DIRECTORY srv FILES my_service.srv) generate_messages(DEPENDENCIES std_msgs) catkin_package( INCLUDE_DIRS include # LIBRARIES rosfond CATKIN_DEPENDS roscpp rospy std_msgs # DEPENDS system_lib ) include_directories( ${catkin_INCLUDE_DIRS} include ) add_executable(my_nodes src/my_nodes.cpp) target_link_libraries(my_nodes ${catkin_LIBRARIES} ) +++++++++++++++++++++++++++++++++++++++++++++++ rosfond0.0.0The rosfond packageghostTODOcatkinroscpprospystd_msgsroscpprospystd_msgs +++++++++++++++++++++++++++++++++++++++++++++++ cmake_minimum_required(VERSION 2.8.3) project(hmi) find_package(catkin REQUIRED COMPONENTS roscpp rospy std_msgs message_generation ) generate_messages(DEPENDENCIES std_msgs) catkin_package( INCLUDE_DIRS include # LIBRARIES hmi CATKIN_DEPENDS roscpp rospy std_msgs # DEPENDS system_lib ) include_directories( ${catkin_INCLUDE_DIRS} include ) add_executable(my_other_nodes src/my_other_nodes.cpp) target_link_libraries(my_other_nodes ${catkin_LIBRARIES} ) +++++++++++++++++++++++++++++++++++++++++++++++ hmi0.0.0The hmi packageghostTODOcatkinroscpprospystd_msgsrosfondrosfondroscpprospystd_msgs ++++++++++++++++++++++++++++++++++++++++++++++++ The error message is : `my_other_nodes.cpp : rosfond/my_service.h: No such file or directory`. Thanking you in advance for your answers, roach

Viewing all articles
Browse latest Browse all 69

Trending Articles