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

Relation between Services and Nodes

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

ROSCMBOT gravatar image

Hello,

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:

http://wiki.ros.org/ROS/Tutorials/Und...

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

/clear
/kill
/reset
/rosout/get_loggers
/rosout/set_logger_level
/spawn
/teleop_turtle/get_loggers
/teleop_turtle/set_logger_level
/turtle1/set_pen
/turtle1/teleport_absolute
/turtle1/teleport_relative
/turtlesim/get_loggers
/turtlesim/set_logger_level

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

Thanks

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
2

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

dornhege gravatar image

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

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
1

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

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

Stats

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

Seen: 679 times

Last updated: Sep 22 '14