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

Advertising multiple services from a single node [closed]

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

Reiner gravatar image

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

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
1

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

dornhege gravatar image

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

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

edit flag offensive delete link more

Comments

Thanks, this solves my problem completely

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

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

Reiner gravatar image Reiner  ( 2015-06-24 04:01:23 -0600 )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 -0600 )edit

Question Tools

1 follower

Stats

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

Seen: 2,127 times

Last updated: Jun 24 '15