diff --git a/src/platforms/px4_nodehandle.h b/src/platforms/px4_nodehandle.h index f2d09c15cb..c85b8118b3 100644 --- a/src/platforms/px4_nodehandle.h +++ b/src/platforms/px4_nodehandle.h @@ -116,8 +116,7 @@ public: template Publisher* advertise() { - ros::Publisher ros_pub = ros::NodeHandle::advertisedata())>::type &>(T::handle(), kQueueSizeDefault); - PublisherROS *pub = new PublisherROS(ros_pub); + PublisherROS *pub = new PublisherROS((ros::NodeHandle*)this); _pubs.push_back((PublisherBase*)pub); return (Publisher*)pub; } @@ -134,7 +133,6 @@ public: private: - static const uint32_t kQueueSizeDefault = 1; /**< Size of queue for ROS */ std::list _subs; /**< Subcriptions of node */ std::list _pubs; /**< Publications of node */ }; diff --git a/src/platforms/px4_publisher.h b/src/platforms/px4_publisher.h index afedbbee77..ea675e67be 100644 --- a/src/platforms/px4_publisher.h +++ b/src/platforms/px4_publisher.h @@ -84,9 +84,9 @@ public: * Construct Publisher by providing a ros::Publisher * @param ros_pub the ros publisher which will be used to perform the publications */ - PublisherROS(ros::Publisher ros_pub) : + PublisherROS(ros::NodeHandle *rnh) : Publisher(), - _ros_pub(ros_pub) + _ros_pub(rnh->advertisedata())>::type &>(T::handle(), kQueueSizeDefault)) {} ~PublisherROS() {}; @@ -99,7 +99,8 @@ public: _ros_pub.publish(msg.data()); return 0; } -private: +protected: + static const uint32_t kQueueSizeDefault = 1; /**< Size of queue for ROS */ ros::Publisher _ros_pub; /**< Handle to the ros publisher */ }; #else