Robotics StackExchange | Archived questions

how to use ros::AdvertiseServiceOptions with member functions as callback?

Hi,

I want to have a dedicated callback queue for my services. the callback of the service is a member function

how do I use ros::AdvertiseServiceOptions with member functions

i tried:

boost::function<bool(typename pcmatch::getObjPoseRequest&, typename pcmatch::getObjPoseResponse&)> fp;
fp = boost::bind(&MyViewer::getObjPoseCB, this, _1, _2);

and:

boost::function<bool(typename pcmatch::getObjPose::RequestType, typename pcmatch::getObjPose::ResponseType)> fp;
fp = boost::bind(&MyViewer::getObjPoseCB, this, _1, _2);

to get a function pointer I could use with:

ros::AdvertiseServiceOptions serviceOpts =
        ros::AdvertiseServiceOptions::create(
            "getObjPose",
            fp,
            ros::VoidPtr(),
            &serviceCallbackQueue_);

but i get the error "no matching function for call to 'create' -- could not infer template argument 'Service' "

Asked by C.Meyer on 2019-06-15 14:55:44 UTC

Comments

Answers

For the benefit of others, I think the issue is that you were missing the <class Service> part of ros::AdvertiseServiceOptions::create. Try:

ros::AdvertiseServiceOptions serviceOpts = ros::AdvertiseServiceOptions::create<pcmatch::getObjPose>("getObjPose", fp, ros::VoidPtr(), &serviceCallbackQueue_);

Asked by njhetherington on 2021-07-23 19:37:01 UTC

Comments