Calling Can I call my defined ROS services through a vector of function pointers? [closed]

asked 2014-08-29 02:00:04 -0600

Sahil Malhotra gravatar image

My code is something like this.


class Foo { public: typedef bool (Foo::*fnPtr) (int, int);

struct serv_desc{
    std::string service_name;
    std::string callback_name;
    fnPtr call_backFunction;
    ros::ServiceServer server;
};

std::vector <serv_desc> serv_list;





bool start_services ()

{

    for (std::vector<fnPtr>::iterator iter = serv_list.begin(); iter != serv_list.end(); iter++ )
    {
        iter->server = n->advertise(iter->service_name,iter->fnPtr,this);

    }

}

};

I need to know hot to define my fnPtr (?????,????); so that i can call setup callbacks and advertisement for various services. through a vector and kill them etc using the vector andlook them up by name etc within the program. Is there a parent type for all package_name::service_type::Request and Response types that i can use and type cast later.

Any help might end up saving me and my team 1000s of lines of code. so thanks in advance

edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by tfoote
close date 2016-07-08 14:06:43.320458