ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
I'm assuming you mean the service callback with service function
.
Basically you have to possibilities.
NodeHandle
that is created outside the service callback, make this a member variable (if you are using a class) and just access that, or make it a global variable (if you don't have a class). No need to pass it to the service callback.NodeHandle
in the scope of the service callback. You can have as many NodeHandle
s as you want. And then use this to retrieve the parameter. Again, no need to pass it in.Thus, my suggestion would be to use 1 if you have a class (obviously, the service callback needs to be a member function of the class as well) and 2 if you don't.
(As both ways are trivial, I'll not provide example code for now.)