Example #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");
    }
Example #2
0
    void publisherUpdate(NodeArgs& na)
    {
        std::string topic = fromRosName(na.args.get(0).asString());
        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;
            }
            c.setName("");
            // just pass the message along, YARP ports know what to do with it
            ContactStyle style;
            style.admin = true;
            style.carrier = "tcp";
            Bottle reply;
            if (!NetworkBase::write(c, na.request, reply, style)) {
                continue;
            }
            na.fromExternal(reply);
        }
    }
Example #3
0
 void publisherUpdate(NodeArgs& na) {
     ConstString topic = na.args.get(0).asString();
     Contact c = lookup(topic);
     if (!c.isValid()) {
         na.fail("Cannot find topic");
         return;
     }
     c = c.addName("");
     // just pass the message along, YARP ports know what to do with it
     ContactStyle style;
     style.admin = true;
     style.carrier = "tcp";
     Bottle reply;
     if (!NetworkBase::write(c,na.request,reply,style)) {
         na.fail("Cannot communicate with local port");
         return;
     }
     na.fromExternal(reply);
     //printf("DONE with passing on publisherUpdate\n");
 }
Example #4
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();
 }