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


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

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


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

示例1: fromBottle

bool Action::fromBottle(const Bottle &b)
{
    if (!this->Entity::fromBottle(b))
        return false;

    if (!b.check("description")||!b.check("subactions"))
        return false;

    Bottle* bDesc = b.find("description").asList();
    initialDescription.fromBottle(*bDesc);

    this->subActions.clear();
    Bottle* bSub = b.find("subactions").asList();
    for(int i=0; i<bSub->size(); i++)
    {
        Action a;
        a.fromBottle(*bSub->get(i).asList());
        this->subActions.push_back(a);
    }

    this->estimatedDriveEffects.clear();
    bSub = b.find("estimatedDriveEffects").asList();
    for(int i=0; i<bSub->size(); i++)
    {
        string driveName = bSub->get(i).asList()->get(0).asString().c_str();
        double driveEffect = bSub->get(i).asList()->get(1).asDouble();
        this->estimatedDriveEffects[driveName] = driveEffect;
    }
    return true;
}
开发者ID:caomw,项目名称:wysiwyd,代码行数:30,代码来源:action.cpp

示例2: yError

bool MapGrid2D::loadROSParams(string ros_yaml_filename, string& pgm_occ_filename, double& resolution, double& orig_x, double& orig_y, double& orig_t )
{
    std::string file_string;
    std::ifstream file;
    file.open(ros_yaml_filename.c_str());
    if (!file.is_open())
    {
        yError() << "failed to open file" << ros_yaml_filename;
        return false;
    }

    string line;
    while (getline(file, line))
    {
        if (line.find("origin") != std::string::npos)
        {
            std::replace(line.begin(), line.end(), ',', ' ');
            std::replace(line.begin(), line.end(), '[', '(');
            std::replace(line.begin(), line.end(), ']', ')');
            /*
            auto it = line.find('[');
            if (it != string::npos) line.replace(it, 1, "(");
            it = line.find(']');
            if(it != string::npos) line.replace(it, 1, ")");*/
        }
        file_string += (line + '\n');
    }
    file.close();

    bool ret = true;
    Bottle bbb;
    bbb.fromString(file_string);
    string debug_s = bbb.toString();

    if (bbb.check("image:") == false) { yError() << "missing image"; ret = false; }
    pgm_occ_filename = bbb.find("image:").asString();
    //ppm_flg_filename = (pgm_occ_filename.substr(0, pgm_occ_filename.size()-4))+"_yarpflags"+".ppm";

    if (bbb.check("resolution:") == false) { yError() << "missing resolution"; ret = false; }
    resolution = bbb.find("resolution:").asDouble();

    if (bbb.check("origin:") == false) { yError() << "missing origin"; ret = false; }
    Bottle* b = bbb.find("origin:").asList();
    if (b)
    {
        orig_x = b->get(0).asDouble();
        orig_y = b->get(1).asDouble();
        orig_t = b->get(2).asDouble();
    }

    if (bbb.check("occupied_thresh:"))
    {m_occupied_thresh = bbb.find("occupied_thresh:").asDouble();}

    if (bbb.check("free_thresh:"))
    {m_free_thresh = bbb.find("free_thresh:").asDouble();}

    return ret;
}
开发者ID:jgvictores,项目名称:yarp,代码行数:58,代码来源:MapGrid2D.cpp

示例3: testFindPlugins

 void testFindPlugins() {
     report(0,"test get 'home' dirs for writing");
     setUpTestArea(false);
     YarpPluginSelector selector;
     selector.scan();
     Bottle lst = selector.getSelectedPlugins();
     checkTrue(lst.check("fakedev1"),"first device present");
     checkTrue(lst.check("fakedev2"),"second device present");
     checkFalse(lst.check("fakedev3"),"non-existent device absent");
     breakDownTestArea();
 }
开发者ID:apaikan,项目名称:yarp,代码行数:11,代码来源:ResourceFinderTest.cpp

示例4: configureSalutation

void ReactiveLayer::configureSalutation(yarp::os::ResourceFinder &rf)
{
    ;
    //Initialise the gestures response
    Bottle grpSocial = rf.findGroup("SOCIAL");
    salutationLifetime = grpSocial.check("salutationLifetime", Value(15.0)).asDouble();
    Bottle *socialStimulus = grpSocial.find("stimuli").asList();

    if (socialStimulus)
    {
        for (int d = 0; d<socialStimulus->size(); d++)
        {
            string socialStimulusName = socialStimulus->get(d).asString().c_str();
            StimulusEmotionalResponse response;
            Bottle * bSentences = grpSocial.find((socialStimulusName + "-sentence").c_str()).asList();
            for (int s = 0; s<bSentences->size(); s++)
            {
                response.m_sentences.push_back(bSentences->get(s).asString().c_str());
            }
            std::string sGroupTemp = socialStimulusName;
            sGroupTemp += "-effect";
            Bottle *bEffects = grpSocial.find(sGroupTemp.c_str()).asList();
            for (int i = 0; bEffects && i<bEffects->size(); i += 2)
            {
                response.m_emotionalEffect[bEffects->get(i).asString().c_str()] = bEffects->get(i + 1).asDouble();
            }
            salutationEffects[socialStimulusName] = response;
        }
    }

    //Add the relevant Entities for handling salutation
    iCub->opc->addOrRetrieveAction("is");
    iCub->opc->addOrRetrieveAdjective("saluted");
}
开发者ID:GunnyPong,项目名称:wysiwyd,代码行数:34,代码来源:reactiveLayer.cpp

示例5: connectTopic

bool RosNameSpace::connectTopic(Bottle& cmd,
                                bool srcIsTopic,
                                const Contact& src,
                                const Contact& dest,
                                ContactStyle style,
                                bool activeRegistration) {
    Bottle reply;
    Contact dynamicSrc = src;
    Contact dynamicDest = dest;
    if (style.carrier!="") {
        if (srcIsTopic) {
            dynamicDest.setCarrier(style.carrier);
        } else {
            dynamicSrc.setCarrier(style.carrier);
        }
    }
    Contact base = getNameServerContact();
    bool ok = NetworkBase::write(base,
                                    cmd,
                                    reply);
    bool fail = (reply.check("faultCode", Value(0)).asInt()!=0)||!ok;
    if (fail) {
        if (!style.quiet) {
            fprintf(stderr, "Failure: name server did not accept connection to topic.\n");
            if (reply.check("faultString")) {
                fprintf(stderr, "Cause: %s\n", reply.check("faultString", Value("")).asString().c_str());
            }
        }
    }
    if (!fail) {
        if (activeRegistration) {
            Bottle *lst = reply.get(2).asList();
            Bottle cmd2;
            if (lst!=nullptr) {
                cmd2.addString("publisherUpdate");
                cmd2.addString("/yarp");
                cmd2.addString(dynamicSrc.getName());
                cmd2.addList() = *lst;
                NetworkBase::write(dynamicDest,
                                    cmd2,
                                    reply,
                                    true);
            }
        }
    }
    return !fail;
}
开发者ID:jgvictores,项目名称:yarp,代码行数:47,代码来源:RosNameSpace.cpp

示例6: fromBottle

bool Agent::fromBottle(Bottle b)
{
    if (!this->Object::fromBottle(b))
        return false;

    if (!b.check("belief")||!b.check("emotions"))
        return false;

    m_belief.clear();
    Bottle* beliefs = b.find("belief").asList();
    for(int i=0; i<beliefs->size() ; i++)
    {
        Bottle* bRelation = beliefs->get(i).asList();
        Relation r(*bRelation);
        m_belief.push_back(r);
    }

    m_emotions_intrinsic.clear();
    Bottle* emotions = b.find("emotions").asList();
    for(int i=0; i<emotions->size() ; i++)
    {
        Bottle* bEmo = emotions->get(i).asList();
        string emotionName = bEmo->get(0).asString().c_str();
        double emotionValue = bEmo->get(1).asDouble();
        m_emotions_intrinsic[emotionName.c_str()] = emotionValue;
    }

    m_drives.clear();
    Bottle* drivesProperty = b.find("drives").asList();
    string drivesDebug = drivesProperty->toString().c_str();
    for(int i=0; i<drivesProperty->size() ; i++)
    {
            Bottle* bD = drivesProperty->get(i).asList();
            string drivesDebug1 = bD->toString().c_str();
            Drive currentDrive;
            currentDrive.fromBottle(*bD);
            m_drives[currentDrive.name] = currentDrive;

    }
               
    Bottle* bodyProperty = b.find("body").asList();
    m_body.fromBottle(*bodyProperty);

    return true;
}
开发者ID:GunnyPong,项目名称:wysiwyd,代码行数:45,代码来源:agent.cpp

示例7: Value

/**
Add an interaction in the adjKnowledge
bInput format:
(action sAction_name)
(timing timing)
(coordinate X Y dX dY)
*/
void    adjKnowledge::addInteraction(Bottle bInput)
{

	string sAction = bInput.check("action", Value("none")).asString();
	vdGnlTiming.push_back(bInput.check("timing", Value(0.)).asDouble());

	Bottle bTemp = *bInput.get(2).asList();
	pair<double, double>    pXY(bTemp.get(1).asDouble(), bTemp.get(2).asDouble());
	pair<double, double>    pDXY(bTemp.get(3).asDouble(), bTemp.get(4).asDouble());

	//    mActionTiming[sAction].first.push_back(bInput.check("timing", Value(0.)).asDouble());

	vdGnlXY.push_back(pXY);
	vdGnlDelta.push_back(pDXY);

	mActionAbsolut[sAction].push_back(pXY);
	mActionDelta[sAction].push_back(pDXY);
}
开发者ID:johan--,项目名称:wysiwyd,代码行数:25,代码来源:adjKnowledge.cpp

示例8: fromBottle

bool Adjective::fromBottle(Bottle b)
{
    if (!this->Entity::fromBottle(b))
        return false;

    if (!b.check("qualityType"))
        return false;

    m_quality = b.find("qualityType").asString().c_str();
    return true;
}
开发者ID:GunnyPong,项目名称:wysiwyd,代码行数:11,代码来源:adjective.cpp

示例9: getProjectionMatrix

bool getProjectionMatrix(Bottle b, Matrix &P)
{
  double fx,fy,cx,cy;

  if(b.check("fx"))
    fx = b.find("fx").asDouble();
  else 
    return 0;
  if(b.check("fy"))
    fy = b.find("fy").asDouble();
  else 
    return 0;  

  // we suppose that the center distorsion is already compensated
  if(b.check("w"))
    cx = b.find("w").asDouble()/2.0;
  else 
    return 0;
  if(b.check("h"))
    cy = b.find("h").asDouble()/2.0;
  else 
    return 0;
  
  double sth= 0.0; double sx = fx; double sy = fy;
  double ox = cx;  double oy = cy;
  double f  = 1.0;

  Matrix K = eye(3,3);
  K(0,0)=sx*f;   K(1,1)=sy*f;   K(0,1)=sth*f;  K(0,2)=ox;   K(1,2)=oy; 

  Matrix Pi = zeros(3,4); 
  Pi(0,0)=1.0;  Pi(1,1)=1.0;  Pi(2,2)=1.0; 

  P = K*Pi;

  //fprintf(stderr, "Working with Projection %s\n", P.toString().c_str());

  return 1;
}
开发者ID:xufango,项目名称:contrib_bk,代码行数:39,代码来源:main.cpp

示例10: readInt

//---------------------------------------------------------
void readInt(Bottle &rf, string name, int &v, int vdefault)
{
    if(rf.check(name.c_str()))
    {
        v = rf.find(name.c_str()).asInt();
    }
    else
    {
        v = vdefault;
        cout<<"Could not find value for "<<name<<". "
            <<"Setting default "<<vdefault<<endl;
    }
    displayNameValue(name,v);
}
开发者ID:ghamon88,项目名称:jtsCalibration,代码行数:15,代码来源:modHelp.cpp

示例11: getArmHomeOptions

void cartControlReachAvoidThread::getArmHomeOptions(Bottle &b, Vector &poss, Vector &vels)
{
        if (b.check("poss","Getting arm home poss"))
        {
            Bottle &grp=b.findGroup("poss");
            int sz=grp.size()-1;
            int len=sz>7?7:sz;

            for (int i=0; i<len; i++){
                poss[i]=grp.get(1+i).asDouble();
            }
        }

        if (b.check("vels","Getting arm home vels"))
        {
            Bottle &grp=b.findGroup("vels");
            int sz=grp.size()-1;
            int len=sz>7?7:sz;

            for (int i=0; i<len; i++)
                vels[i]=grp.get(1+i).asDouble();
        }
}
开发者ID:jgqysu,项目名称:wysiwyd,代码行数:23,代码来源:cartControlReachAvoidThread.cpp

示例12: setPidOptions

void Localizer::setPidOptions(const Bottle &options)
{
    mutex.lock();

    pid->setOptions(options);
    if (options.check("dominantEye"))
    {
        string domEye=options.find("dominantEye").asString().c_str();
        if ((domEye=="left") || (domEye=="right"))
            dominantEye=domEye;
    }

    mutex.unlock();
}
开发者ID:Karma-Revolutions,项目名称:icub-main,代码行数:14,代码来源:localizer.cpp

示例13: readVector

//---------------------------------------------------------
void readVector(Bottle &rf, string name, Vector &v, int len)
{
    v.resize(len,0.0);
    if(rf.check(name.c_str()))
    {
        Bottle &grp = rf.findGroup(name.c_str());
        for (int i=0; i<len; i++)
            v[i]=grp.get(1+i).asDouble();
    }
    else
    {
        cout<<"Could not find parameters for "<<name<<". "
            <<"Setting everything to zero by default"<<endl;
    }
    displayNameVector(name,v);
}
开发者ID:ghamon88,项目名称:jtsCalibration,代码行数:17,代码来源:modHelp.cpp

示例14: readBool

//---------------------------------------------------------
void readBool(Bottle &rf, string name, bool &v, bool vdefault)
{
    if(rf.check(name.c_str()))
    {
        if((rf.find(name.c_str()).asString()=="true")||(rf.find(name.c_str()).asString()=="on"))
            v = true;
        else
            v = false;
    }
    else
    {
        v = vdefault;
        cout<<"Could not find value true/false for "<<name<<". "
            <<"Setting default "<<((vdefault==true)?"true":"false")<<endl;
    }
    displayNameValue(name,((v==true)?"true":"false"));
}
开发者ID:ghamon88,项目名称:jtsCalibration,代码行数:18,代码来源:modHelp.cpp

示例15: readBridgeHeaderVector

void readBridgeHeaderVector(Bottle &rf, string name, field &groups, int size)
{
    groups.clear();
    if ( rf.check( name.c_str() ) )
    {
        Bottle &grp = rf.findGroup(name.c_str());
        for ( int i = 0; i < size; i++)
        {
            groups.push_back({grp.get(1+i).asString().c_str(),""});
        }
    }
    else
    {
        cout << "Could not find parameters for " << name << ". "
            << "Setting everything to null by default" << endl;
    }
}
开发者ID:wrousseau,项目名称:yarp-to-ros-bridge,代码行数:17,代码来源:bridgeHeader.cpp


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