move uorb::publisherbase into constructor of publisher

This commit is contained in:
Thomas Gubler
2015-01-23 08:03:26 +01:00
parent 59f05a7195
commit 16c85c6d18
3 changed files with 7 additions and 11 deletions
+1 -6
View File
@@ -243,13 +243,8 @@ public:
template<typename T> template<typename T>
Publisher<T> *advertise() Publisher<T> *advertise()
{ {
//XXX PublisherUORB<T> *pub = new PublisherUORB<T>();
// uORB::PublicationBase * uorb_pub = new uORB::PublicationBase((new T())->handle());
uORB::PublicationBase * uorb_pub = new uORB::PublicationBase(T::handle());
PublisherUORB<T> *pub = new PublisherUORB<T>(uorb_pub);
_pubs.add(pub); _pubs.add(pub);
return (Publisher<T>*)pub; return (Publisher<T>*)pub;
} }
+2 -2
View File
@@ -130,10 +130,10 @@ public:
/** /**
* Construct Publisher by providing orb meta data * Construct Publisher by providing orb meta data
*/ */
PublisherUORB(uORB::PublicationBase * uorb_pub) : PublisherUORB() :
Publisher<T>(), Publisher<T>(),
PublisherNode(), PublisherNode(),
_uorb_pub(uorb_pub) _uorb_pub(new uORB::PublicationBase(T::handle()))
{} {}
~PublisherUORB() {}; ~PublisherUORB() {};
+4 -3
View File
@@ -107,21 +107,22 @@ public:
SubscriberROS(ros::NodeHandle *rnh) : SubscriberROS(ros::NodeHandle *rnh) :
px4::Subscriber<T>(), px4::Subscriber<T>(),
_cbf(NULL), _cbf(NULL),
_ros_sub(rnh->subscribe(T::handle(), 1, &SubscriberROS<T>::callback, this)) _ros_sub(rnh->subscribe(T::handle(), kQueueSizeDefault, &SubscriberROS<T>::callback, this))
{} {}
/** /**
* Construct Subscriber by providing a callback function * Construct Subscriber by providing a callback function
*/ */
//XXX queue default
SubscriberROS(ros::NodeHandle *rnh, std::function<void(const T &)> cbf) : SubscriberROS(ros::NodeHandle *rnh, std::function<void(const T &)> cbf) :
_cbf(cbf), _cbf(cbf),
_ros_sub(rnh->subscribe(T::handle(), 1, &SubscriberROS<T>::callback, this)) _ros_sub(rnh->subscribe(T::handle(), kQueueSizeDefault, &SubscriberROS<T>::callback, this))
{} {}
virtual ~SubscriberROS() {}; virtual ~SubscriberROS() {};
protected: protected:
static const uint32_t kQueueSizeDefault = 1; /**< Size of queue for ROS */
/** /**
* Called on topic update, saves the current message and then calls the provided callback function * Called on topic update, saves the current message and then calls the provided callback function
* needs to use the native type as it is called by ROS * needs to use the native type as it is called by ROS