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

What does "add" mean?

asked 2015-05-15 08:44:06 -0500

Carl gravatar image

Hello ROS-Community,

it might be a dumb question for you, but i got a question to one of the Tutorials.

What does the second parameter in the advertise Funktion mean? And what could I write there instead of "add". Is there some kind of library where I can look up how to use that function?

ros::ServiceServer service = n.advertiseService("add_two_ints", add);

Thank you! Carl

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
1

answered 2015-05-15 15:22:30 -0500

gvdhoorn gravatar image

updated 2015-05-15 15:22:53 -0500

What does the second parameter in the advertise Funktion mean?

That is the name of the function (or callback) that will be called whenever a remote node invokes the add_two_ints service. The function is defined in the lines above the service definition (roscpp_tutorials/add_two_ints_server/add_two_ints_server.cpp, lines 31 - 38)):

bool add(roscpp_tutorials::TwoInts::Request &req, roscpp_tutorials::TwoInts::Response &res)
{
  [..]
}

And what could I write there instead of "add".

Essentially any function that has the correct prototype for that service definition. In this case bool (*f)(roscpp_tutorials::TwoInts::Request &req, roscpp_tutorials::TwoInts::Response &res).

Is there some kind of library where I can look up how to use that function?

I'm not sure what you mean by that actually. The function is just a plain C++ function, defined in the same file.

edit flag offensive delete link more

Comments

Oh ok, I didn't see, that "add" was a function in the file, i thought that it would have been some kind of keyword. Thanks a lot!

Carl gravatar image Carl  ( 2015-05-16 06:09:21 -0500 )edit

Question Tools

Stats

Asked: 2015-05-15 08:44:06 -0500

Seen: 130 times

Last updated: May 15 '15