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

How are service.h files are generated from service.srv files ?

asked 2018-05-03 04:57:00 -0500

aks gravatar image

Using Sevices in ROS, we create a service definition file in the srv folder and name it as service.srv and when we include this as service.h in the cpp file. How is the .h file generated from .srv ? In my case, while compiling using catkin_make it says no service.h file found in the .cpp file whereas it is present. Any leads ?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2018-05-03 05:12:12 -0500

gvdhoorn gravatar image

In my case, while compiling using catkin_make it says no service.h file found in the .cpp file whereas it is present. Any leads ?

you're running into a dependency declaration problem. We can explain to you how headers are generated from the IDL, but for this particular problem, see C++ message or service dependencies in the Catkin documentation.

edit flag offensive delete link more

Comments

I took this example from github and i guess it already has all the dependencies. @gvdhoorn

aks gravatar image aks  ( 2018-05-03 16:15:34 -0500 )edit

@gvdhoorn : yes, you were correct : fixed it by adding dependencies.

aks gravatar image aks  ( 2018-05-03 16:24:52 -0500 )edit

I took this example from github and i guess it already has all the dependencies. @gvdhoorn

well, I just checked it, and it doesn't (as you probably also found out).

gvdhoorn gravatar image gvdhoorn  ( 2018-05-04 03:19:48 -0500 )edit

yes : dependencies added !

aks gravatar image aks  ( 2018-05-04 03:20:49 -0500 )edit

@gvdhoorn again coming back to my previous question, how are headers generated from IDL ? For example, if i need to create a new service file, then how can I add the header file in the cpp. Normally it says no such file found.

aks gravatar image aks  ( 2018-05-15 10:59:19 -0500 )edit

Normally it says no such file found.

it should only give that error if you've not followed procedure.

provided the msg / srv file exists, you've added the dependencies to your target and followed the docs on generating msgs / srvs things should work.

gvdhoorn gravatar image gvdhoorn  ( 2018-05-15 11:01:24 -0500 )edit

It's all documented in the Catkin documentation I linked earlier and on the ROS wiki.

gvdhoorn gravatar image gvdhoorn  ( 2018-05-15 11:01:49 -0500 )edit

I created an overlay space and copied the demo_nodes_cpp example in ROS2 into the overlay ws and renamed it(heatflow_cpp). Created a new service file(heatFlow.srv) and changed the name of the service file in the CMAKELISTS and then included heatFlow.hpp in the cpp.Am i forgetting something ?

aks gravatar image aks  ( 2018-05-15 11:06:46 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2018-05-03 04:57:00 -0500

Seen: 1,553 times

Last updated: May 03 '18