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 close merge delete

Sort by » oldest newest most voted

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)
{
[..]
}


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.

more

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!

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