00001 #include <rtt/RTT.hpp>
00002 #include <rtt/plugin/ServicePlugin.hpp>
00003 #include <RosLib.hpp>
00004
00005 using namespace RTT;
00006 using namespace std;
00007
00011 class ROSService : public RTT::Service {
00012 public:
00013 int protocol_id;
00018 ROSService(TaskContext* owner)
00019 : Service("ros", owner),
00020 protocol_id(ORO_ROS_PROTOCOL_ID)
00021 {
00022
00023 this->addOperation("topic", &ROSService::topic, this).doc("Creates a ConnPolicy for subscribing to or publishing a topic. No buffering is done, only the last sample is kept.").arg("name", "The ros topic name");
00024 this->addOperation("topicBuffer", &ROSService::topicBuffer, this).doc("Creates a ConnPolicy for subscribing to or publishing a topic.").arg("name", "The ros topic name").arg("size","The size of the buffer.");
00025 this->addConstant("protocol_id", protocol_id );
00026 }
00027
00032 ConnPolicy topic(const std::string& name) {
00033 ConnPolicy cp = ConnPolicy::data();
00034 cp.transport = ORO_ROS_PROTOCOL_ID;
00035 cp.name_id = name;
00036 return cp;
00037 }
00038
00044 ConnPolicy topicBuffer(const std::string& name, int size) {
00045 ConnPolicy cp = ConnPolicy::buffer(size);
00046 cp.transport = ORO_ROS_PROTOCOL_ID;
00047 cp.name_id = name;
00048 return cp;
00049 }
00050 };
00051
00052
00053
00054
00055 ORO_SERVICE_NAMED_PLUGIN(ROSService, "ros")