diff options
Diffstat (limited to 'src/platforms/px4_nodehandle.h')
-rw-r--r-- | src/platforms/px4_nodehandle.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/platforms/px4_nodehandle.h b/src/platforms/px4_nodehandle.h index 45ef225fa..415351756 100644 --- a/src/platforms/px4_nodehandle.h +++ b/src/platforms/px4_nodehandle.h @@ -71,6 +71,7 @@ public: //XXX empty lists }; + /* Constructor with callback to function */ template<typename M> Subscriber * subscribe(const char *topic, void(*fp)(M)) { ros::Subscriber ros_sub = ros::NodeHandle::subscribe(topic, kQueueSizeDefault, fp); @@ -78,6 +79,14 @@ public: _subs.push_back(sub); return sub; } + /* Constructor with callback to class method */ + template<typename M, typename T> + Subscriber * subscribe(const char *topic, void(T::*fp)(M), T *obj) { + ros::Subscriber ros_sub = ros::NodeHandle::subscribe(topic, kQueueSizeDefault, fp, obj); + Subscriber * sub = new Subscriber(ros_sub); + _subs.push_back(sub); + return sub; + } template<typename M> Publisher * advertise(const char *topic) { |