diff options
author | Thomas Gubler <thomasgubler@gmail.com> | 2015-01-23 07:06:02 +0100 |
---|---|---|
committer | Thomas Gubler <thomasgubler@gmail.com> | 2015-01-23 07:06:02 +0100 |
commit | 1e504478a00f08c4d7ab381aa9bec5cdbee5513f (patch) | |
tree | 3522af2c74d67e9a5f3d901826f3cd73da610817 /src/platforms/px4_subscriber.h | |
parent | b2a911b88d6a541218ef6e633be0d6693de31c8e (diff) | |
download | px4-firmware-1e504478a00f08c4d7ab381aa9bec5cdbee5513f.tar.gz px4-firmware-1e504478a00f08c4d7ab381aa9bec5cdbee5513f.tar.bz2 px4-firmware-1e504478a00f08c4d7ab381aa9bec5cdbee5513f.zip |
move ros::subscriber into constructor of subscriber
Diffstat (limited to 'src/platforms/px4_subscriber.h')
-rw-r--r-- | src/platforms/px4_subscriber.h | 29 |
1 files changed, 10 insertions, 19 deletions
diff --git a/src/platforms/px4_subscriber.h b/src/platforms/px4_subscriber.h index c499712a9..a54b8eb08 100644 --- a/src/platforms/px4_subscriber.h +++ b/src/platforms/px4_subscriber.h @@ -102,24 +102,23 @@ class SubscriberROS : public: /** - * Construct Subscriber by providing a callback function + * Construct Subscriber without a callback function */ - SubscriberROS(std::function<void(const T &)> cbf) : - Subscriber<T>(), - _ros_sub(), - _cbf(cbf) + SubscriberROS(ros::NodeHandle *rnh) : + px4::Subscriber<T>(), + _cbf(NULL), + _ros_sub(rnh->subscribe(T::handle(), 1, &SubscriberROS<T>::callback, this)) {} /** - * Construct Subscriber without a callback function + * Construct Subscriber by providing a callback function */ - SubscriberROS() : - Subscriber<T>(), - _ros_sub(), - _cbf(NULL) + //XXX queue default + SubscriberROS(ros::NodeHandle *rnh, std::function<void(const T &)> cbf) : + _cbf(cbf), + _ros_sub(rnh->subscribe(T::handle(), 1, &SubscriberROS<T>::callback, this)) {} - virtual ~SubscriberROS() {}; protected: @@ -139,14 +138,6 @@ protected: } - /** - * Saves the ros subscriber to keep ros subscription alive - */ - void set_ros_sub(ros::Subscriber ros_sub) - { - _ros_sub = ros_sub; - } - ros::Subscriber _ros_sub; /**< Handle to ros subscriber */ std::function<void(const T &)> _cbf; /**< Callback that the user provided on the subscription */ |