diff options
author | Thomas Gubler <thomasgubler@gmail.com> | 2014-12-11 10:51:19 +0100 |
---|---|---|
committer | Thomas Gubler <thomasgubler@gmail.com> | 2014-12-11 10:51:19 +0100 |
commit | 173b1b2a8bcf2344be92b1f6e5acbc089a43fcab (patch) | |
tree | 63afb74e15312ecf8c60800962895e217c6e634c /src/platforms | |
parent | a1685ed6d093ec01214e6839ea66f9dd565e55ce (diff) | |
download | px4-firmware-173b1b2a8bcf2344be92b1f6e5acbc089a43fcab.tar.gz px4-firmware-173b1b2a8bcf2344be92b1f6e5acbc089a43fcab.tar.bz2 px4-firmware-173b1b2a8bcf2344be92b1f6e5acbc089a43fcab.zip |
WIP, make class based and extended subscriber/publisher example compile for ros
Diffstat (limited to 'src/platforms')
-rw-r--r-- | src/platforms/px4_defines.h | 7 | ||||
-rw-r--r-- | src/platforms/px4_nodehandle.h | 13 |
2 files changed, 18 insertions, 2 deletions
diff --git a/src/platforms/px4_defines.h b/src/platforms/px4_defines.h index 440f1b6fc..819954d0e 100644 --- a/src/platforms/px4_defines.h +++ b/src/platforms/px4_defines.h @@ -66,9 +66,11 @@ #define PX4_TOPIC_T(_name) _name /* Subscribe and providing a class method as callback (do not use directly, use PX4_SUBSCRIBE instead) */ -#define PX4_SUBSCRIBE_CBMETH(_nodehandle, _name, _cbf, _obj, _interval) _nodehandle.subscribe(PX4_TOPIC(_name), &_cbf, &_obj); +#define PX4_SUBSCRIBE_CBMETH(_nodehandle, _name, _cbf, _objptr, _interval) _nodehandle.subscribe(PX4_TOPIC(_name), &_cbf, _objptr); /* Subscribe and providing a function as callback (do not use directly, use PX4_SUBSCRIBE instead) */ #define PX4_SUBSCRIBE_CBFUNC(_nodehandle, _name, _cbf, _interval) _nodehandle.subscribe(PX4_TOPIC(_name), _cbf); +/* Subscribe without a callback (do not use directly, use PX4_SUBSCRIBE instead) */ +#define PX4_SUBSCRIBE_NOCB(_nodehandle, _name, _interval) _nodehandle.subscribe<const PX4_TOPIC_T(_name)&>(PX4_TOPIC(_name)); /* Parameter handle datatype */ typedef const char *px4_param_t; @@ -113,9 +115,10 @@ static inline px4_param_t PX4_ROS_PARAM_SET(const char *name, float value) #define PX4_TOPIC_T(_name) _name##_s /* Subscribe and providing a class method as callback (do not use directly, use PX4_SUBSCRIBE instead) */ -#define PX4_SUBSCRIBE_CBMETH(_nodehandle, _name, _cbf, _obj, _interval) _nodehandle.subscribe<PX4_TOPIC_T(_name)>(PX4_TOPIC(_name), std::bind(&_cbf, _obj, std::placeholders::_1), _interval) +#define PX4_SUBSCRIBE_CBMETH(_nodehandle, _name, _cbf, _objptr, _interval) _nodehandle.subscribe<PX4_TOPIC_T(_name)>(PX4_TOPIC(_name), std::bind(&_cbf, _objptr, std::placeholders::_1), _interval) /* Subscribe and providing a function as callback (do not use directly, use PX4_SUBSCRIBE instead) */ #define PX4_SUBSCRIBE_CBFUNC(_nodehandle, _name, _cbf, _interval) _nodehandle.subscribe<PX4_TOPIC_T(_name)>(PX4_TOPIC(_name), std::bind(&_cbf, std::placeholders::_1), _interval) +/* Subscribe without a callback (do not use directly, use PX4_SUBSCRIBE instead) */ #define PX4_SUBSCRIBE_NOCB(_nodehandle, _name, _interval) _nodehandle.subscribe<PX4_TOPIC_T(_name)>(PX4_TOPIC(_name), nullptr, _interval) /* Parameter handle datatype */ diff --git a/src/platforms/px4_nodehandle.h b/src/platforms/px4_nodehandle.h index 5b7247b20..25b8e037d 100644 --- a/src/platforms/px4_nodehandle.h +++ b/src/platforms/px4_nodehandle.h @@ -100,6 +100,19 @@ public: } /** + * Subscribe with no callback, just the latest value is stored on updates + * @param topic Name of the topic + */ + template<typename M> + Subscriber *subscribe(const char *topic) + { + //XXX missing implementation + // Subscriber *sub = new Subscriber(ros_sub); + // _subs.push_back(sub); + return (Subscriber *)NULL; + } + + /** * Advertise topic * @param topic Name of the topic */ |