micro_ros_arduino icon indicating copy to clipboard operation
micro_ros_arduino copied to clipboard

Support class member function for callbak of subscriber

Open asukiaaa opened this issue 2 years ago • 3 comments

Is there any way to use class member function for callback of subscriber? If there is not now, do you plan to support it?

I'm going to replace ros1 rosserial to ros2 microros. The ros1 rosserial supports registering class member function as callback of subscriber so I use classes to manage rosserial. https://answers.ros.org/question/258249/publisher-or-subscriber-inside-a-class-rosserial/ https://github.com/ros-drivers/rosserial/blob/c169ae2173dcfda7cee567d64beae45198459400/rosserial_client/src/ros_lib/ros/subscriber.h#L66 If microros does not support it, complicated change is needed for my project.

Could you give me some advice or future plan?

asukiaaa avatar Sep 02 '23 13:09 asukiaaa

@JanStaschulat do you know any way of adding an object method as callback for RCLC sub?

pablogs9 avatar Sep 04 '23 06:09 pablogs9

Is there any news or plan?

asukiaaa avatar Nov 06 '23 06:11 asukiaaa

You just need to make the functions public members of your class and declare them static.

Then you can pass them to the add subscription function as &MyClass::callback.

Zherokt avatar Apr 22 '24 14:04 Zherokt