aboutsummaryrefslogtreecommitdiff
path: root/src/platforms/px4_defines.h
diff options
context:
space:
mode:
authorThomas Gubler <thomasgubler@gmail.com>2014-11-28 10:18:28 +0100
committerThomas Gubler <thomasgubler@gmail.com>2014-11-28 10:18:28 +0100
commit59a9648bb60f8c33ca26b5f248d4b28dfc1de139 (patch)
treecf4f399a48cefad7f395952d98aea63949872c41 /src/platforms/px4_defines.h
parentbfc0a52ea23d18c9ef72690aa511e0feeb5a4176 (diff)
downloadpx4-firmware-59a9648bb60f8c33ca26b5f248d4b28dfc1de139.tar.gz
px4-firmware-59a9648bb60f8c33ca26b5f248d4b28dfc1de139.tar.bz2
px4-firmware-59a9648bb60f8c33ca26b5f248d4b28dfc1de139.zip
macro for topic subscription
Diffstat (limited to 'src/platforms/px4_defines.h')
-rw-r--r--src/platforms/px4_defines.h10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/platforms/px4_defines.h b/src/platforms/px4_defines.h
index d4dc71453..79f305140 100644
--- a/src/platforms/px4_defines.h
+++ b/src/platforms/px4_defines.h
@@ -48,8 +48,9 @@
#define PX4_MAIN_FUNCTION(_prefix) int main(int argc, char **argv)
#define PX4_WARN ROS_WARN
#define PX4_INFO ROS_INFO
-#define PX4_TOPIC(name) #name
-#define PX4_TOPIC_T(name) name
+#define PX4_TOPIC(_name) #_name
+#define PX4_TOPIC_T(_name) _name
+#define PX4_SUBSCRIBE(_nodehandle, _name, _cbf) _nodehandle.subscribe(PX4_TOPIC(_name), _cbf);
#else
/*
@@ -62,7 +63,8 @@
#define PX4_WARN warnx
#define PX4_WARN warnx
#define PX4_INFO warnx
-#define PX4_TOPIC(name) ORB_ID(name)
-#define PX4_TOPIC_T(name) name##_s
+#define PX4_TOPIC(_name) ORB_ID(_name)
+#define PX4_TOPIC_T(_name) _name##_s
+#define PX4_SUBSCRIBE(_nodehandle, _name, _cbf) _nodehandle.subscribe<PX4_TOPIC_T(_name)>(PX4_TOPIC(_name), [](const PX4_TOPIC_T(_name)& msg){ return _cbf(msg);})
#endif