当前位置: 首页>>代码示例>>C++>>正文


C++ Bottle::get方法代码示例

本文整理汇总了C++中Bottle::get方法的典型用法代码示例。如果您正苦于以下问题:C++ Bottle::get方法的具体用法?C++ Bottle::get怎么用?C++ Bottle::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Bottle的用法示例。


在下文中一共展示了Bottle::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: read

bool NetworkClock::read(ConnectionReader& reader) {
    Bottle bot;
    bool ok = bot.read(reader);

    if(closing)
    {
        _time = -1;
        return false;
    }

    if (!ok && !closing)
    {
        YARP_ERROR(Logger::get(), "Error reading clock port");
        return false;
    }

    timeMutex.lock();
    sec = bot.get(0).asInt32();
    nsec = bot.get(1).asInt32();
    _time = sec + (nsec*1e-9);
    initted = true;
    timeMutex.unlock();

    listMutex.lock();
    Waiters* waiters = static_cast<Waiters*>(pwaiters);
    Waiters::iterator waiter_i;

    waiter_i = waiters->begin();
    while (waiter_i != waiters->end())
    {
        if (waiter_i->first - _time < 1E-12 )
        {
            Semaphore *waiterSemaphore = waiter_i->second;
            waiter_i = waiters->erase(waiter_i);
            if (waiterSemaphore)
                waiterSemaphore->post();
        }
        else
            ++waiter_i;
    }
    listMutex.unlock();
    return true;
}
开发者ID:claudiofantacci,项目名称:yarp,代码行数:43,代码来源:NetworkClock.cpp

示例2: run

void Pointing::run(const Bottle &args) {
    yInfo() << "Pointing::run";
    Bottle *sensation = sensation_port_in.read();

    string obj_name, sentence;
    bool no_objects = true;
    if (args.size()!=0) {
        yDebug()<<args.toString() << args.size();
        obj_name = args.get(0).asList()->get(0).asString();
        yDebug() << "Object selected: " << obj_name;
        sentence = "Okay, this is the ";
        no_objects=false;
    } else {
        if(sensation->size()==0) {
            iCub->lookAtPartner();
            iCub->say("There are no objects I can point at.");
            iCub->home();
            return;
        }
        int id = yarp::os::Random::uniform(0, sensation->size() - 1);
        obj_name = sensation->get(id).asList()->get(1).asString();
        yDebug() << "Randomly selected: " << id << " " << obj_name;
        sentence = "I could point to the ";
    }

    yDebug() << "[pointing]: opc checkout";
    
    iCub->say(sentence + obj_name, false);

    bool succeeded = iCub->point(obj_name);
    if (no_objects){
        bool look_success = iCub->lookAtPartner();
        if (succeeded) {
            iCub->say("Do you know that this is a " + obj_name, false);
        } else {
            iCub->say("I couldn't find the " + obj_name, false);
        }
        if(look_success) {
            yarp::os::Time::delay(1.5);
        }
    }
    iCub->home();
}
开发者ID:robotology,项目名称:wysiwyd,代码行数:43,代码来源:pointing.cpp

示例3: testBlob

    void testBlob() {
        report(0,"testing blob...");
        Bottle bot("{4 42 255} 10 20");
        checkEqual(bot.size(),3,"plausible parse");
        checkTrue(bot.get(0).isBlob(),"blob present");
        checkEqual((int)bot.get(0).asBlobLength(),3,"blob length");
        checkEqual(bot.get(0).asBlob()[1],42, "blob match");

        report(0,"testing blob with internal null...");
        char blob[12]="hello\0world";
        const Value v ((void*)blob, sizeof(blob));
        checkEqual(12,(int)v.asBlobLength(),"value length");
        checkFalse(v.isNull(),"value non-null");
        Bottle b;
        b.add(v);
        checkEqual(b.size(),1,"insertion happened");
        checkTrue(b.get(0).isBlob(),"insertion is right type");
        checkEqual(12,(int)b.get(0).asBlobLength(),"length within bottle");
    }
开发者ID:andreadelprete,项目名称:yarp,代码行数:19,代码来源:BottleTest.cpp

示例4: respond

bool Recognition::respond(const Bottle& command, Bottle& reply) {
   if(command.get(0).asString() == "actionStarted"){
		actionDone = false;
	}
	else if (command.get(0).asString() == "actionStoped"){
		actionDone = true;
	}
	
	if(command.get(0).asString() == "observ"){
		lookAtHand = true;
	}else if(command.get(0).asString() == "stopObserv"){
		lookAtHand = false;
	}
		
	reply.clear();
	reply.addString("Recongition module over");
	
   return true;
}
开发者ID:apostroph,项目名称:helping_behavior,代码行数:19,代码来源:Recognition.cpp

示例5: pauseTracker

bool TRACKERManager::pauseTracker(int id)
{
    mutex.wait();
    bool reply = true;
    
    Bottle ids = getIDs();
    bool gotid = false;
    
    for (int i = 0; i <ids.size(); i++)
    {
        if (id == ids.get(i).asInt())
        {
            gotid = true;
            yDebug()<< "got the ID " << id <<" == "<< ids.get(i).asInt();
        }
    }
    
    if (gotid)
    {
        yDebug() << "[TRACKERManager::pauseTracker] attempting to pause tracker id " << id ;
        if (workerThreads[id]->isRunning())
        {
            workerThreads[id]->suspend();
            pausedThreads.push_back(id);
            yDebug() << "[TRACKERManager::pauseTracker] done pausing tracker id " << id ;
            reply = true;
        }
        else
        {
            yError() << "[TRACKERManager::pauseTracker] failed to pause tracker id %d " << id << " - Not running.. ";
            reply=false;
        }
    
    }
    else
    {
        yError() << "[TRACKERManager::pauseTracker] failed to pause tracker id %d " << id << " - Not running.. ";
        reply = false;
    }
    
    mutex.post();
    return reply;
}
开发者ID:robotology,项目名称:poeticon,代码行数:43,代码来源:activeParticle.cpp

示例6: testSerialCopy

 void testSerialCopy() {
     report(0,"test serialization by copy");
     Value v(3.14);
     Bottle b;
     b.read(v);
     checkEqualish(b.get(0).asDouble(),3.14,"copy to bottle succeeded");
     Bottle b2;
     b.write(b2);
     checkEqualish(b2.get(0).asDouble(),3.14,"copy from bottle succeeded");
 }
开发者ID:andreadelprete,项目名称:yarp,代码行数:10,代码来源:BottleTest.cpp

示例7: v

Vector PMPthread::Bottle2Vector(Bottle Bot)
{
	Vector v(Bot.size());
	for (int i = 0; i < Bot.size(); i++)
	{
		v(i) = Bot.get(i).asDouble();
	}

	return v;
}
开发者ID:xufango,项目名称:contrib_bk,代码行数:10,代码来源:PMPthread.cpp

示例8: onRead

void PointedLocation::onRead(Bottle &b)
{
    fprintf(stdout, "got read from points size %d \n",b.size());
    if (b.size()>1)
    {
        loc.x=(int)b.get(0).asDouble();
        loc.y=(int)b.get(1).asDouble();
        rxTime=Time::now();
    }
}
开发者ID:atabakd,项目名称:karma,代码行数:10,代码来源:utils.cpp

示例9: addKnowledge

/**
* Add a new entity to the timeKnowledge
* input format :
* <string name> <string timeArg1> <string timeArg2>
*/
void timeKnowledge::addKnowledge(Bottle bInput)
{
    if (bInput.size() != 3)
    {
        yInfo() << "\t" << "Error in addKnowledge : fromBottle. Wrong number of inputs (need 3 inputs : <string name> <string timeArg1> <string timeArg2>)"  ;
        return;
    }
    if (!(bInput.get(0).isString() && bInput.get(1).isString() && bInput.get(2).isString()))
    {
        yInfo() << "\t" << "Error in addKnowledge : fromBottle. Wrong format of inputs (need 3 inputs : <string name> <string timeArg1> <string timeArg2>)"  ;
        return;
    }

    struct tm   tmTimeArg1 = abmReasoningFunction::string2Time(bInput.get(1).asString().c_str()),
                tmTimeArg2 = abmReasoningFunction::string2Time(bInput.get(2).asString().c_str());

    timeArg1.push_back(tmTimeArg1);
    timeArg2.push_back(tmTimeArg2);
}
开发者ID:towardthesea,项目名称:wysiwyd,代码行数:24,代码来源:timeKnowledge.cpp

示例10: execute

//execute action, stop to go out
Bottle learnPrimitive::execute(){
    Bottle bOutput ;
    Bottle bRecognized, //received FROM speech recog with transfer information (1/0 (bAnswer))
    bAnswer, //response from speech recog without transfer information, including raw sentence
    bSemantic; // semantic information of the content of the recognition

    string sSay = " What do you want me to do?";
    yInfo() << sSay;
    iCub->say(sSay);

    Bottle bCurrentOrder = nodeNameAction("any");

    string orderType = bCurrentOrder.get(0).asString();
    if(orderType == "stop"){
        string sSay = " Allright, thank you for the exercice";
        yInfo() << sSay;
        iCub->say(sSay);

        return bCurrentOrder ;
    }

    string orderVerb = bCurrentOrder.get(1).asString();
    string orderArg  = bCurrentOrder.get(2).asString();

    sSay = orderVerb + "ing my " + orderArg;
    if(orderArg == "one" || orderArg == "two" || orderArg == "three" || orderArg == "four" || orderArg == "five"){
        sSay = orderVerb + "ing " + orderArg;
    }
    sSay = sSay ;
    yInfo() << sSay;
    iCub->say(sSay);

    if(orderType == "proto-action") {
        protoCommand(orderVerb, orderArg);
    } else if (orderType == "primitive") {
        primitiveCommand(orderVerb, orderArg);
    } else {
        actionCommand(orderVerb, orderArg);
    }

    yarp::os::Time::delay(6);
    return execute();
}
开发者ID:MagnusJohnsson,项目名称:wysiwyd,代码行数:44,代码来源:learnPrimitive.cpp

示例11: activate

 bool activate(bool force = false) {
     if (force) {
         // wipe if forced
         clear();
     }
     // return if namespaces already present
     if (spaces.size()!=0) return true;
     // read namespace list from config file
     NameConfig conf;
     if (!conf.fromFile()) {
         double now = Time::now();
         static double last_shown = now-10;
         if (now-last_shown>3) {
             last_shown = now;
             fprintf(stderr,"warning: YARP name server(s) not configured, ports will be anonymous\n");
             fprintf(stderr,"warning: check your namespace and settings with 'yarp detect'\n");
         }
         return false;
     }
     Bottle ns = conf.getNamespaces();
     // loop through namespaces
     for (int i=0; i<ns.size(); i++) {
         ConstString n = ns.get(i).asString();
         NameConfig conf2;
         // read configuration of individual namespace
         if (!conf2.fromFile(n.c_str())) {
             fprintf(stderr, "Could not find namespace %s\n",
                     n.c_str());
             continue;
         }
         String mode = conf2.getMode();
         Contact address = conf2.getAddress().addName(n);
         if (mode=="yarp"||mode=="//") {
             // add a yarp namespace
             NameSpace *ns = new YarpNameSpace(address);
             spaces.push_back(ns);
         } else if (mode=="ros") {
             // add a ros namespace
             NameSpace *ns = new RosNameSpace(address);
             spaces.push_back(ns);
         } else if (mode=="local") {
             NameSpace *ns = new YarpDummyNameSpace;
             spaces.push_back(ns);
         } else {
             // shrug
             YARP_SPRINTF1(Logger::get(),error,
                           "cannot deal with namespace of type %s",
                           mode.c_str());
             return false;
         }
     }
     // cache flags
     scan();
     return true;
 }
开发者ID:BRKMYR,项目名称:yarp,代码行数:55,代码来源:MultiNameSpace.cpp

示例12: storeImageOIDs

bool autobiographicalMemory::storeImageOIDs(int instance) {
    Bottle bRequest;
    ostringstream osStoreOIDReq;

    osStoreOIDReq << "SELECT \"time\", img_provider_port, relative_path FROM visualdata WHERE img_oid IS NULL";
    if (instance >= 0) {
        osStoreOIDReq << " AND instance = " << instance;
    }
    bRequest = requestFromString(osStoreOIDReq.str());

    if (bRequest.size() > 0 && bRequest.get(0).toString() != "NULL") {
        yInfo() << "[storeImageOIDs] This may take a while!";
    }
    else {
        return true;
    }

    ostringstream osStoreOID;

    for (int i = 0; i < bRequest.size(); i++) {
        string imgTime = bRequest.get(i).asList()->get(0).toString().c_str();
        string imgProviderPort = bRequest.get(i).asList()->get(1).toString().c_str();
        string imgRelativePath = bRequest.get(i).asList()->get(2).toString().c_str();

        string fullPath = storingPath + "/" + imgRelativePath;
        database_mutex.lock();
        unsigned int new_img_oid = ABMDataBase->lo_import(fullPath.c_str());
        database_mutex.unlock();

        osStoreOID << "UPDATE visualdata SET img_oid=" << new_img_oid;
        osStoreOID << " WHERE time='" << imgTime << "' and img_provider_port = '" << imgProviderPort << "';";

        if (((i+1) % 100 == 0 && i != 0) || i == bRequest.size() - 1) {
            requestFromString(osStoreOID.str());
            yInfo() << "[storeImageOIDs] Saved " << i+1 << " images out of " << bRequest.size();
            osStoreOID.str("");
        }
    }
    yInfo() << "[storeImageOIDs] All images saved.";

    return true;
}
开发者ID:robotology,项目名称:wysiwyd,代码行数:42,代码来源:storing.cpp

示例13: respond

    bool respond(const Bottle& command, Bottle& reply) 
    {
        reply.clear(); 
        
        if (command.get(0).isInt())
        {
            if (command.get(0).asInt()==0)
            {
                fprintf(stderr,"Asking recalibration...\n");
                if (inv_dyn)
                {
                    inv_dyn->suspend();
                    inv_dyn->calibrateOffset(); 
                    inv_dyn->resume();
                }
                fprintf(stderr,"Recalibration complete.\n");
                reply.addString("Recalibrated");
                return true;
            }
        }

        if (command.get(0).isString())
        {
            if (command.get(0).asString()=="help")
            {
                reply.addVocab(Vocab::encode("many"));
                reply.addString("Available commands:");
                reply.addString("calib all");
                reply.addString("calib arms");
                reply.addString("calib legs");
                reply.addString("calib feet");
                return true;
            }
            else if (command.get(0).asString()=="calib")
            {
                fprintf(stderr,"Asking recalibration...\n");
                if (inv_dyn)
                {
                    calib_enum calib_code=CALIB_ALL;
                          if (command.get(1).asString()=="all")  calib_code=CALIB_ALL;
                    else  if (command.get(1).asString()=="arms") calib_code=CALIB_ARMS;
                    else  if (command.get(1).asString()=="legs") calib_code=CALIB_LEGS;
                    else  if (command.get(1).asString()=="feet") calib_code=CALIB_FEET;

                    inv_dyn->suspend();
                    inv_dyn->calibrateOffset(calib_code);
                    inv_dyn->resume();
                }
                fprintf(stderr,"Recalibration complete.\n");
                reply.addString("Recalibrated");
                return true;
            }
        }

        reply.addString("Unknown command");
        return true;
    }
开发者ID:apaikan,项目名称:icub-main,代码行数:57,代码来源:main.cpp

示例14: getTarget

    void CubCartThread::getTarget()
    {   
        Bottle command;

        printf("current command: left %f %f %f, right %f %f %f\n", Lxd[0], Lxd[1], Lxd[2], Rxd[0], Rxd[1], Rxd[2]);

        if(inputPort.read(command))
        {
            if(command.get(0).asString()=="left")
            {
                icartR->stopControl();  //stop the right arm
                printf("recieved command: left %f %f %f\n", command.get(1).asDouble(), command.get(2).asDouble(), command.get(3).asDouble());

                Lxd[0] = command.get(1).asDouble() - 0.065;    //left arm negative in front
                Lxd[1] = command.get(2).asDouble() - 0.065;    //left arm negative on correct side of body (x)
                Lxd[2] = command.get(3).asDouble();    //positive from waist up

				// sanity check the position before moving there
                if(Lxd[0] < -0.5) Lxd[0] = -0.5;
				if(Lxd[0] > -0.1) Lxd[0] = -0.1;
				if(Lxd[1] < -0.4) Lxd[1] = -0.4;
                if(Lxd[1] > 0.1) Lxd[1] = 0.1;
				if(Lxd[2] < -0.2) Lxd[2] = -0.2;
				if(Lxd[2] > 0.4) Lxd[2] = 0.4;

                icartL->goToPose(Lxd,Lod);
                Time::delay(3);              
                icartL->stopControl();  //stop the left arm
            }
            else if(command.get(0).asString()=="right")
            {
                icartL->stopControl();  //stop the left arm
                printf("recieved command: right %f %f %f\n", command.get(1).asDouble(), command.get(2).asDouble(), command.get(3).asDouble());

                Rxd[0] = command.get(1).asDouble() - 0.04;    //right arm negative in front
                Rxd[1] = command.get(2).asDouble() + 0.05;    //right arm positive on correct side of body
                Rxd[2] = command.get(3).asDouble();    //positive from waist up

				// sanity check the position before moving there
                if(Rxd[0] < -0.5) Rxd[0] = -0.5;
				if(Rxd[0] > -0.1) Rxd[0] = -0.1;
				if(Rxd[1] > 0.4) Rxd[1] = 0.4;
				if(Rxd[1] < 0.0) Rxd[1] = 0.0;
				if(Rxd[2] < -0.2) Rxd[2] = -0.2;
				if(Rxd[2] > 0.4) Rxd[2] = 0.4;

                icartR->goToPose(Rxd,Rod);
                Time::delay(3);
                icartR->stopControl();  //stop the right arm
            }
        }
    }
开发者ID:himstien,项目名称:iCubFiles,代码行数:52,代码来源:cartesian.cpp

示例15: recogMSR

Bottle VisuoThread::recogMSR(string &obj_name)
{
    Bottle bDetect;
    Bottle *bMSR=recMSRPort.read(false);
    if(bMSR!=NULL)
    {
        bDetect=*bMSR;
        obj_name=bDetect.get(0).asString().c_str();
    }
    return bDetect;
}
开发者ID:bhigy,项目名称:tactile_objrec,代码行数:11,代码来源:VisuoThread.cpp


注:本文中的Bottle::get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。