0
$\begingroup$

Rosanswers logo

Hi,

I'm writing a node, that advertises multiple services.

Should I use a diffrent object name for each service, or the same name (see below)? As I understand it, this results in either multiple instances of a ros::ServiceServer Object, or a single one in the latter case..

Ex. 1:

ros::ServiceServer service1 = nodeHandle.advertiseService("serviceOne", serviceOneFunction); ros::ServiceServer service2 = nodeHandle.advertiseService("serviceTwo", serviceTwoFunction);

Ex. 2:

ros::ServiceServer service = nodeHandle.advertiseService("serviceOne", serviceOneFunction); ros::ServiceServer service = nodeHandle.advertiseService("serviceTwo", serviceTwoFunction);

Which Option should I choose? Is there anything else to remember, while writing nodes, that advertise multiple services?

Thanks


Originally posted by Reiner on ROS Answers with karma: 61 on 2015-06-24

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

The first one. The second one doesn't even compile.


Originally posted by dornhege with karma: 31395 on 2015-06-24

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by Reiner on 2015-06-24:
Thanks, this solves my problem completely

Comment by Reiner on 2015-06-24:
Do you have any experience regarding performance, when a node advertises many services?

Comment by dornhege on 2015-06-24:
It's not a function call obviously, but especially if you use a persistent connection in the client it's OK for speed.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.