diff options
author | Thomas Gubler <thomasgubler@gmail.com> | 2014-11-25 09:56:18 +0100 |
---|---|---|
committer | Thomas Gubler <thomasgubler@gmail.com> | 2014-11-25 09:56:18 +0100 |
commit | 978013bbb8d67e295d92a54e16f7728013722e92 (patch) | |
tree | ac4774fb6b3ea1563408acd7f1d221cfe164cb36 /src/platforms/px4_nodehandle.h | |
parent | 0a3492fc328280422df9472d3d8a586d92242feb (diff) | |
download | px4-firmware-978013bbb8d67e295d92a54e16f7728013722e92.tar.gz px4-firmware-978013bbb8d67e295d92a54e16f7728013722e92.tar.bz2 px4-firmware-978013bbb8d67e295d92a54e16f7728013722e92.zip |
px4 wrapper for ros publisher
Diffstat (limited to 'src/platforms/px4_nodehandle.h')
-rw-r--r-- | src/platforms/px4_nodehandle.h | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/platforms/px4_nodehandle.h b/src/platforms/px4_nodehandle.h index 6880d74f6..bfda636b0 100644 --- a/src/platforms/px4_nodehandle.h +++ b/src/platforms/px4_nodehandle.h @@ -38,6 +38,7 @@ */ #pragma once #include <px4_subscriber.h> +#include <px4_publisher.h> #if defined(__linux) || (defined(__APPLE__) && defined(__MACH__)) #include "ros/ros.h" #include <list> @@ -52,19 +53,28 @@ class NodeHandle : private ros::NodeHandle public: NodeHandle () : ros::NodeHandle(), - _subs() + _subs(), + _pubs() {} - template<class M> + template<typename M> Subscriber subscribe(const char *topic, void(*fp)(M)) { ros::Subscriber ros_sub = ros::NodeHandle::subscribe(topic, QUEUE_SIZE_DEFAULT, fp); - //XXX create list here, for ros and nuttx Subscriber sub(ros_sub); _subs.push_back(sub); return sub; } + + template<typename M> + Publisher advertise(const char *topic) { + ros::Publisher ros_pub = ros::NodeHandle::advertise<M>(topic, QUEUE_SIZE_DEFAULT); + Publisher pub(ros_pub); + _pubs.push_back(pub); + return pub; + } private: std::list<Subscriber> _subs; + std::list<Publisher> _pubs; }; #else class NodeHandle |