What does "add" mean?
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
Asked by Carl on 2015-05-15 08:44:06 UTC
Answers
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.
Asked by gvdhoorn on 2015-05-15 15:22:30 UTC
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!
Asked by Carl on 2015-05-16 06:09:21 UTC
Comments