|
|
@ -49,21 +49,26 @@ |
|
|
|
#include <inttypes.h> |
|
|
|
#include <inttypes.h> |
|
|
|
#else |
|
|
|
#else |
|
|
|
/* includes when building for NuttX */ |
|
|
|
/* includes when building for NuttX */ |
|
|
|
|
|
|
|
#include <containers/List.hpp> |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
namespace px4 |
|
|
|
namespace px4 |
|
|
|
{ |
|
|
|
{ |
|
|
|
#if defined(__linux) || (defined(__APPLE__) && defined(__MACH__)) |
|
|
|
#if defined(__linux) || (defined(__APPLE__) && defined(__MACH__)) |
|
|
|
class NodeHandle : private ros::NodeHandle |
|
|
|
class NodeHandle : |
|
|
|
|
|
|
|
private ros::NodeHandle |
|
|
|
{ |
|
|
|
{ |
|
|
|
public: |
|
|
|
public: |
|
|
|
NodeHandle () : |
|
|
|
NodeHandle() : |
|
|
|
ros::NodeHandle(), |
|
|
|
ros::NodeHandle(), |
|
|
|
_subs(), |
|
|
|
_subs(), |
|
|
|
_pubs() |
|
|
|
_pubs() |
|
|
|
{} |
|
|
|
{} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
~NodeHandle() { |
|
|
|
|
|
|
|
//XXX empty lists
|
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
template<typename M> |
|
|
|
template<typename M> |
|
|
|
Subscriber subscribe(const char *topic, void(*fp)(M)) { |
|
|
|
Subscriber subscribe(const char *topic, void(*fp)(M)) { |
|
|
|
ros::Subscriber ros_sub = ros::NodeHandle::subscribe(topic, kQueueSizeDefault, fp); |
|
|
|
ros::Subscriber ros_sub = ros::NodeHandle::subscribe(topic, kQueueSizeDefault, fp); |
|
|
@ -87,6 +92,30 @@ private: |
|
|
|
#else |
|
|
|
#else |
|
|
|
class NodeHandle |
|
|
|
class NodeHandle |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
public: |
|
|
|
|
|
|
|
NodeHandle() : |
|
|
|
|
|
|
|
_subs(), |
|
|
|
|
|
|
|
_pubs() |
|
|
|
|
|
|
|
{} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
~NodeHandle() {}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<typename M> |
|
|
|
|
|
|
|
Subscriber subscribe(const char *topic, void(*fp)(M)) { |
|
|
|
|
|
|
|
Subscriber sub(&_subs, , interval); |
|
|
|
|
|
|
|
return sub; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<typename M> |
|
|
|
|
|
|
|
Publisher advertise(const char *topic) { |
|
|
|
|
|
|
|
Publisher pub(ros_pub); |
|
|
|
|
|
|
|
_pubs.push_back(pub); |
|
|
|
|
|
|
|
return pub; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
private: |
|
|
|
|
|
|
|
List<Subscriber> _subs; |
|
|
|
|
|
|
|
List<Publisher> _pubs; |
|
|
|
|
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
} |
|
|
|
} |
|
|
|