aboutsummaryrefslogtreecommitdiff
path: root/src/platforms/px4_subscriber.h
diff options
context:
space:
mode:
authorThomas Gubler <thomasgubler@gmail.com>2014-12-04 13:06:38 +0100
committerThomas Gubler <thomasgubler@gmail.com>2014-12-04 13:06:38 +0100
commite0bb713bb03c0aa79e69496c787c012a8e1b78d1 (patch)
treeb71614bc124479dbe7a57b434872fc7deb39eb20 /src/platforms/px4_subscriber.h
parent0f094d35d5dd183e44148eb1acbd7b7d76fde669 (diff)
downloadpx4-firmware-e0bb713bb03c0aa79e69496c787c012a8e1b78d1.tar.gz
px4-firmware-e0bb713bb03c0aa79e69496c787c012a8e1b78d1.tar.bz2
px4-firmware-e0bb713bb03c0aa79e69496c787c012a8e1b78d1.zip
more documentation comments
Diffstat (limited to 'src/platforms/px4_subscriber.h')
-rw-r--r--src/platforms/px4_subscriber.h32
1 files changed, 29 insertions, 3 deletions
diff --git a/src/platforms/px4_subscriber.h b/src/platforms/px4_subscriber.h
index 6e0ef8aed..fdd0367d5 100644
--- a/src/platforms/px4_subscriber.h
+++ b/src/platforms/px4_subscriber.h
@@ -54,15 +54,24 @@ namespace px4
class Subscriber
{
public:
+ /**
+ * Construct Subscriber by providing a ros::Subscriber
+ * @param ros_sub the ros subscriber which will be used to perform the publications
+ */
Subscriber(ros::Subscriber ros_sub) :
_ros_sub(ros_sub)
{}
+
~Subscriber() {};
private:
- ros::Subscriber _ros_sub;
+ ros::Subscriber _ros_sub; /**< Handle to ros subscriber */
};
+
#else
-// typedef std::function<void(int)> CallbackFunction;
+
+/**
+ * Subscriber class which is used by nodehandle when building for NuttX
+ */
class Subscriber
{
public:
@@ -71,12 +80,22 @@ public:
private:
};
+/**
+ * Subscriber class that is templated with the uorb subscription message type
+ */
template<typename M>
class SubscriberPX4 :
public Subscriber,
public uORB::Subscription<M>
{
public:
+ /**
+ * Construct SubscriberPX4 by providing orb meta data
+ * @param meta orb metadata for the topic which is used
+ * @param callback Callback, executed on receiving a new message
+ * @param interval Minimal interval between calls to callback
+ * @param list subscriber is added to this list
+ */
SubscriberPX4(const struct orb_metadata *meta,
unsigned interval,
std::function<void(const M&)> callback,
@@ -86,8 +105,14 @@ public:
_callback(callback)
//XXX store callback
{}
+
~SubscriberPX4() {};
+ /**
+ * Update Subscription
+ * Invoked by the list traversal in NodeHandle::spinOnce
+ * If new data is available the callback is called
+ */
void update() {
if (!uORB::Subscription<M>::updated()) {
/* Topic not updated, do not call callback */
@@ -102,7 +127,8 @@ public:
};
private:
- std::function<void(const M&)> _callback;
+ std::function<void(const M&)> _callback; /**< Callback handle,
+ called when new data is available */
};
#endif