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

Relation between Services and Nodes

asked 2014-08-11 12:43:41 -0500

ROSCMBOT gravatar image


I have a very simple question. What's the relation between services and nodes? Can we say services are functions/methods defined in a node. For example, according to this tutorial:

when I'm running the turtlesim_node node, here is the list of active services:


The question is where are all these services defined? Where can I find their codes?


edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2014-08-11 13:17:05 -0500

dornhege gravatar image

updated 2014-09-22 19:31:47 -0500

tfoote gravatar image

Yes, services are functions in a node that can be called remotely.

Therefore they are defined in the source code of the respective node.

You can find out which node is running a service by using rosservice info SERVICE_NAME

edit flag offensive delete link more

answered 2014-08-11 13:26:55 -0500

bvbdort gravatar image

services are declared in .srv and functionality defined in .cpp

refrer .srv files for more info.

check srv folder for services declared. turtlesim code

in turtle.cpp

  set_pen_srv_              = nh_.advertiseService("set_pen", &Turtle::setPenCallback, this);
  teleport_relative_srv_ = nh_.advertiseService
                                      ("teleport_relative", &Turtle::teleportRelativeCallback, this);
  teleport_absolute_srv_ = nh_.advertiseService
                                      ("teleport_absolute", &Turtle::teleportAbsoluteCallback, this);
edit flag offensive delete link more

Question Tools

1 follower


Asked: 2014-08-11 12:43:41 -0500

Seen: 643 times

Last updated: Sep 22 '14