ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Async spinner with callback that is class member

asked 2020-03-25 13:54:39 -0500

Marcel Usai gravatar image

Hi guys, I want to use an ros::AsyncSpinner with a callback that is a class member. Can somebody provide me an example? The problems I run into is that either, the subscriber does not take a ros::CallbackQueue or that ros::SubscriberOptions that I initialize do not take my tracked object when using

ros::SubscriberOptions s;
s.create<std_msgs::Float64>("topic_name", 1, &MyClass::callbackFunction, this, callbackQueue);

The error I get with this is

cannot convert '(MyClass*)this' (type 'MyClass*') to type 'const VoidConstPtr& {aka const boost::shared_ptr<const void>&}'

It seems to me that the create function of ros::SubscriberOptions is not made for use of class members as Callbacks. But how does it work? It is easy to use a class member as callback function but how do I add my CallbackQueue to use an AsyncSpinner? Any of both questions would lead to solving this issue, I suppose. Thank you for your support!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-03-27 11:34:21 -0500

Marcel Usai gravatar image

I think I found my answer:

ros::SubscriberOptions s;
s.create<std_msgs::Float64>("topic_name", 1, boost::bind(&MyClass::callbackFunction, this, _1), callbackQueue);
edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2020-03-25 13:54:39 -0500

Seen: 309 times

Last updated: Mar 27 '20