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

Including entire services directory

asked 2019-08-01 09:54:21 -0500

mikepark93 gravatar image

I have a srv directory that has all the services I have created. In my main node I am including each individual .hpp manually. Is there a way to include all the .hpp files in one include statement, or do I need to do it for each individual service I created?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2019-08-01 10:15:04 -0500

alsora gravatar image

updated 2019-08-01 10:23:06 -0500

No, C++ does not allow that.

However, you may create a file named my_services.hpp with all the includes.

#pragma once

#include "srv_pkg/srv/service_1"
#include "srv_pkg/srv/service_2"
#include "srv_pkg/srv/service_3"
#include "srv_pkg/srv/service_4"

Then in all the places where you need to use the services you can just use #include "my_services.hpp".

An alternative would be to use a script to automatically add all the include directives to your files, but I really think that's a bad and error-prone solution.

edit flag offensive delete link more

Question Tools



Asked: 2019-08-01 09:54:21 -0500

Seen: 96 times

Last updated: Aug 01 '19