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

Client Service in different folder than Server Service

asked 2021-11-01 11:54:21 -0600

CroCo gravatar image

updated 2021-11-01 12:25:50 -0600

I've created node that has service in package (i.e. pk1). The associated headers files reside in devel/include/<pk1> folder. Now I need to create client service in another package (i.e. pk2) which needs to use the header files of service created in pk1. How can configure the project so that it can detect the location of service's headers automatically. I've added the full path of the header, I'm surprised this not working at all, which it should be from C++ perspective. Any suggestions? I'm using C++, kinetic, and Ubuntu 16.04.

edit retag flag offensive close merge delete

Comments

Which headers are in the devel/include/<pk1> folder? Where is your service definition?

Geoff gravatar image Geoff  ( 2021-11-01 18:02:20 -0600 )edit

@Geoff headers generated automatically for .srv file. I do believe there are three header files (i.e. the request and response classes).

CroCo gravatar image CroCo  ( 2021-11-02 09:48:40 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted
1

answered 2021-11-02 17:43:50 -0600

Geoff gravatar image

In the package for your client, follow the steps in 3. Dependencies of this tutorial. This explains how to add a dependency from pk2 to pk1 so that your client can access the header and library files for the service.

edit flag offensive delete link more
1

answered 2021-11-03 10:05:41 -0600

CroCo gravatar image

The credit goes to @Geoff. I will add my attempt to solve this problem so people should save their time if they encounter this problem. In my case, I've defined a custom message ExampleServiceMsg.srv in srv folder in package example_service. This package is a server that receives request. In this package, three header files are generated ExampleServiceMsg.h, ExampleServiceMsgResponse.h and ExampleServiceMsgRequest.h. These files reside in devel/include/example_service.

Now I've created a new package service_client. This package needs to use ExampleServiceMsg.h, a customized message generated in example_service package. To allow the new package to detect the header file, we need to the following: in package.xml

<build_depend>example_service</build_depend>
<exec_depend>example_service</exec_depend>

in CMakelists.txt for the new package

find_package(catkin REQUIRED COMPONENTS example_service)
edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2021-11-01 11:54:21 -0600

Seen: 81 times

Last updated: Nov 03 '21