mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-05-01 13:44:07 +08:00
move uorb::publisherbase into constructor of publisher
This commit is contained in:
parent
59f05a7195
commit
16c85c6d18
@ -243,13 +243,8 @@ public:
|
||||
template<typename T>
|
||||
Publisher<T> *advertise()
|
||||
{
|
||||
//XXX
|
||||
// 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);
|
||||
|
||||
PublisherUORB<T> *pub = new PublisherUORB<T>();
|
||||
_pubs.add(pub);
|
||||
|
||||
return (Publisher<T>*)pub;
|
||||
}
|
||||
|
||||
|
||||
@ -130,10 +130,10 @@ public:
|
||||
/**
|
||||
* Construct Publisher by providing orb meta data
|
||||
*/
|
||||
PublisherUORB(uORB::PublicationBase * uorb_pub) :
|
||||
PublisherUORB() :
|
||||
Publisher<T>(),
|
||||
PublisherNode(),
|
||||
_uorb_pub(uorb_pub)
|
||||
_uorb_pub(new uORB::PublicationBase(T::handle()))
|
||||
{}
|
||||
|
||||
~PublisherUORB() {};
|
||||
|
||||
@ -107,21 +107,22 @@ public:
|
||||
SubscriberROS(ros::NodeHandle *rnh) :
|
||||
px4::Subscriber<T>(),
|
||||
_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
|
||||
*/
|
||||
//XXX queue default
|
||||
SubscriberROS(ros::NodeHandle *rnh, std::function<void(const T &)> 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() {};
|
||||
|
||||
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
|
||||
* needs to use the native type as it is called by ROS
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user