improve subsciber api

This commit is contained in:
Thomas Gubler 2014-11-24 17:38:27 +01:00
parent 3f36d30a34
commit 1826fa5d39
3 changed files with 8 additions and 3 deletions

View File

@ -75,6 +75,7 @@ int main(int argc, char **argv)
* away the oldest ones.
*/
px4::Subscriber* sub = n.subscribe("rc_channels", rc_channels_callback);
PX4_INFO("subscribed");
/**
* px4::spin() will enter a loop, pumping callbacks. With this version, all

View File

@ -50,8 +50,9 @@ class NodeHandle : private ros::NodeHandle
public:
template<class M>
Subscriber* subscribe(const char *topic, void(*fp)(M)) {
ros::NodeHandle::subscribe("rc_channels", 1000, fp);
return new Subscriber();
ros::Subscriber ros_sub = ros::NodeHandle::subscribe(topic, 1000, fp);
//XXX create list here, for ros and nuttx
return new Subscriber(ros_sub);
}
};
#else

View File

@ -47,8 +47,11 @@ namespace px4
#if defined(__linux) || (defined(__APPLE__) && defined(__MACH__))
class Subscriber
{
private:
ros::Subscriber _ros_sub;
public:
Subscriber() {};
Subscriber(ros::Subscriber ros_sub) : _ros_sub(ros_sub)
{}
~Subscriber() {};
};
#else