Service Advertice and Class Usage
Hello,
When we try to advertise a service we normally use as shown in ros tutorials:
ros::ServiceServer service = n.advertiseService("add_two_ints", add);
This is with normal function way.
And if we want to use with class, documentation says use like this:
AddTwo a;
ros::ServiceServer ss = n.advertiseService("add_two_ints", &AddTwo::add, &a);
Which means we need to initialize an object first.
But suppose I want to use everything related with ros in class and suppose my code is like this:
Comm::Comm()
{
ros::ServiceServer ss = n.advertiseService("add_two_ints", &write);
// write() is member of Comm class.
}
In my mind, I should have been use like this, but of course this kind of usage gave me error. Is there any possibility to use service advertise in class as describe. Do I need to initialize the class always?