示例#1
0
    void requestTopic(NodeArgs& na)
    {
        std::string topic = na.args.get(0).asString();
        topic = fromRosName(topic);
        std::vector<Contact> contacts = query(topic, "+");
        if (contacts.size() < 1) {
            na.fail("Cannot find topic");
            return;
        }
        for (std::vector<Contact>::iterator it = contacts.begin(); it != contacts.end(); ++it) {
            Contact &c = *it;

            if (!c.isValid()) {
                continue;
            }
            Value v;
            Bottle* lst = v.asList();
            lst->addString("TCPROS");
            lst->addString(c.getHost());
            lst->addInt32(c.getPort());
            na.reply = v;
            na.success();
            return;
        }
        na.fail("Cannot find topic");
    }
示例#2
0
 void requestTopic(NodeArgs& na) {
     ConstString topic = na.args.get(0).asString();
     Contact c = lookup(topic);
     if (!c.isValid()) {
         na.fail("Cannot find topic");
         return;
     }
     na.reply.addString("TCPROS");
     na.reply.addString(c.getHost());
     na.reply.addInt(c.getPort());
     na.success();
 }
示例#3
0
 void getPublications(NodeArgs& na) {
     mutex.lock();
     for (std::map<ConstString,NodeItem>::iterator it = by_part_name.begin(); it != by_part_name.end(); it++) {
         NodeItem& item = it->second;
         if (!item.isPublisher()) continue;
         item.update();
         Bottle& lst = na.reply.addList();
         lst.addString(item.nc.getNestedName());
         lst.addString(item.nc.getTypeName());
     }
     mutex.unlock();
     na.success();
 }
示例#4
0
    void getBusInfo(NodeArgs& na)
    {
        unsigned int opaque_id = 1;
        ROSReport report;
        Value v;
        Bottle* connections = v.asList();

        mutex.lock();
        for (std::multimap<std::string, NodeItem>::iterator it = by_part_name.begin(); it != by_part_name.end(); ++it) {
            NodeItem& item = it->second;
            if (!(item.isSubscriber() || item.isPublisher())) {
                continue;
            }
            item.update();
            item.contactable->getReport(report);
        }
        mutex.unlock();

        for (std::multimap<std::string, std::string>::const_iterator it = report.outgoingURIs.begin(); it != report.outgoingURIs.end(); ++it) {
            Bottle& lst = connections->addList();
            lst.addInt32(opaque_id); // connectionId
            lst.addString(it->second);
            lst.addString("o");
            lst.addString("TCPROS");
            NestedContact nc(it->first);
            lst.addString(toRosName(nc.getNestedName()));
            opaque_id++;
        }

        for (std::multimap<std::string, std::string>::const_iterator it = report.incomingURIs.begin(); it != report.incomingURIs.end(); ++it) {
            Bottle& lst = connections->addList();
            lst.addInt32(opaque_id); // connectionId
            lst.addString(it->second);
            lst.addString("i");
            lst.addString("TCPROS");
            NestedContact nc(it->first);
            lst.addString(toRosName(nc.getNestedName()));
            opaque_id++;
        }

        if (connections->size() == 0) {
            connections->addList(); // add empty list
        }

        na.reply = v;
        na.success();
    }
示例#5
0
 void getPublications(NodeArgs& na)
 {
     Value v;
     Bottle* publications = v.asList();
     mutex.lock();
     for (std::multimap<std::string, NodeItem>::iterator it = by_part_name.begin(); it != by_part_name.end(); ++it) {
         NodeItem& item = it->second;
         if (!item.isPublisher()) {
             continue;
         }
         item.update();
         Bottle& lst = publications->addList();
         lst.addString(toRosName(item.nc.getNestedName()));
         lst.addString(item.nc.getTypeName());
     }
     mutex.unlock();
     na.reply = v;
     na.success();
 }
示例#6
0
文件: Node.cpp 项目: ale-git/yarp
 void getPublications(NodeArgs& na)
 {
     Value v;
     Bottle* publications = v.asList();
     mutex.lock();
     for (auto& it : by_part_name) {
         NodeItem& item = it.second;
         if (!item.isPublisher()) {
             continue;
         }
         item.update();
         Bottle& lst = publications->addList();
         lst.addString(toRosName(item.nc.getNestedName()));
         lst.addString(item.nc.getTypeName());
     }
     mutex.unlock();
     na.reply = v;
     na.success();
 }
示例#7
0
 void getPid(NodeArgs& na) {
     na.reply.addInt(ACE_OS::getpid());
     na.success();
 }
示例#8
0
 void getBusInfo(NodeArgs& na) {
     na.reply.addList();
     na.success();
 }
示例#9
0
 void getBusStats(NodeArgs& na) {
     na.reply.addList();
     na.success();
 }
示例#10
0
 void getPid(NodeArgs& na)
 {
     na.reply = Value(static_cast<int>(yarp::os::getpid()));
     na.success();
 }
示例#11
0
 void getMasterUri(NodeArgs& na)
 {
     na.reply = Value(NetworkBase::getEnvironment("ROS_MASTER_URI"));
     na.success();
 }
示例#12
0
 void getBusStats(NodeArgs& na)
 {
     na.reply = Value();
     na.success();
 }