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

Advertising multiple services from a single node [closed]

asked 2015-06-24 03:44:50 -0500

Reiner gravatar image


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?


edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Reiner
close date 2015-06-24 04:14:40.787606

1 Answer

Sort by ยป oldest newest most voted

answered 2015-06-24 03:58:18 -0500

dornhege gravatar image

updated 2015-06-24 03:58:46 -0500

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

edit flag offensive delete link more


Thanks, this solves my problem completely

Reiner gravatar image Reiner  ( 2015-06-24 04:00:29 -0500 )edit

Do you have any experience regarding performance, when a node advertises many services?

Reiner gravatar image Reiner  ( 2015-06-24 04:01:23 -0500 )edit

It's not a function call obviously, but especially if you use a persistent connection in the client it's OK for speed.

dornhege gravatar image dornhege  ( 2015-06-24 04:04:20 -0500 )edit

Question Tools

1 follower


Asked: 2015-06-24 03:44:50 -0500

Seen: 2,088 times

Last updated: Jun 24 '15