mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-07-22 00:30:35 +08:00
move uorb::publisherbase into constructor of publisher
This commit is contained in:
@@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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() {};
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user