diff options
author | Thomas Gubler <thomasgubler@gmail.com> | 2014-11-24 17:38:27 +0100 |
---|---|---|
committer | Thomas Gubler <thomasgubler@gmail.com> | 2014-11-24 17:38:27 +0100 |
commit | 1826fa5d39a5feb2a7c044102c899c23c1f12453 (patch) | |
tree | fac6bd06ecaa4884c6b7477c2700f87743a6ea76 | |
parent | 3f36d30a3413cd70096e953a2c9ea0ded65bf24e (diff) | |
download | px4-firmware-1826fa5d39a5feb2a7c044102c899c23c1f12453.tar.gz px4-firmware-1826fa5d39a5feb2a7c044102c899c23c1f12453.tar.bz2 px4-firmware-1826fa5d39a5feb2a7c044102c899c23c1f12453.zip |
improve subsciber api
-rw-r--r-- | src/examples/subscriber/subscriber.cpp | 1 | ||||
-rw-r--r-- | src/platforms/px4_nodehandle.h | 5 | ||||
-rw-r--r-- | src/platforms/px4_subscriber.h | 5 |
3 files changed, 8 insertions, 3 deletions
diff --git a/src/examples/subscriber/subscriber.cpp b/src/examples/subscriber/subscriber.cpp index 39059daa3..5d1d14d7f 100644 --- a/src/examples/subscriber/subscriber.cpp +++ b/src/examples/subscriber/subscriber.cpp @@ -75,6 +75,7 @@ int main(int argc, char **argv) * away the oldest ones. */ px4::Subscriber* sub = n.subscribe("rc_channels", rc_channels_callback); + PX4_INFO("subscribed"); /** * px4::spin() will enter a loop, pumping callbacks. With this version, all diff --git a/src/platforms/px4_nodehandle.h b/src/platforms/px4_nodehandle.h index df198615c..809d0eb15 100644 --- a/src/platforms/px4_nodehandle.h +++ b/src/platforms/px4_nodehandle.h @@ -50,8 +50,9 @@ class NodeHandle : private ros::NodeHandle public: template<class M> Subscriber* subscribe(const char *topic, void(*fp)(M)) { - ros::NodeHandle::subscribe("rc_channels", 1000, fp); - return new Subscriber(); + ros::Subscriber ros_sub = ros::NodeHandle::subscribe(topic, 1000, fp); + //XXX create list here, for ros and nuttx + return new Subscriber(ros_sub); } }; #else diff --git a/src/platforms/px4_subscriber.h b/src/platforms/px4_subscriber.h index 8f883154e..8933b2ab2 100644 --- a/src/platforms/px4_subscriber.h +++ b/src/platforms/px4_subscriber.h @@ -47,8 +47,11 @@ namespace px4 #if defined(__linux) || (defined(__APPLE__) && defined(__MACH__)) class Subscriber { +private: + ros::Subscriber _ros_sub; public: - Subscriber() {}; + Subscriber(ros::Subscriber ros_sub) : _ros_sub(ros_sub) + {} ~Subscriber() {}; }; #else |