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


C++ Context::properties方法代码示例

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


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

示例1: elementType

    void
    loadElementsFromConfigFile( orcaqgemv::GuiElementModel &guiElementModel,
                                const orcaice::Context     &context )
    {
        // create a map of types
        const string typePrefix = context.tag() + ".Config.Element.Type";
        std::map<string,string> typeMap = context.properties()->getPropertiesForPrefix(typePrefix);
        
        // create a map of descriptions
        const string descriptionPrefix = context.tag() + ".Config.Element.Description";
        std::map<string,string> descriptionMap = context.properties()->getPropertiesForPrefix(descriptionPrefix);
        
        // debug output
        for ( map<string,string>::iterator it=typeMap.begin(); it!=typeMap.end(); ++it )
        {
            stringstream ss;
            ss << "it->first: " << it->first << endl;
            ss << "it->second: " << it->second << endl;  
            context.tracer().debug( ss.str(), 5 );
        }
        
        // create elements based on Type entries
        for ( map<string,string>::iterator it = typeMap.begin(); it != typeMap.end(); ++it )
        {
            // extract the key: e.g. for Config.Element.TypeXX the key is XX
            QString elementType( it->second.c_str() );
            string key = it->first.substr( typePrefix.size() );
            stringstream ss; ss << "Extracted key is: " << key;
            context.tracer().debug( ss.str(), 5 );
            
            // find the corresponding entry in the descriptionMap
            map<string,string>::iterator descriptionMapIt = descriptionMap.find( context.tag() + ".Config.Element.Description" + key );
            if ( descriptionMapIt==descriptionMap.end() ) 
            {
                ss.str(""); ss << "'Description' entry with key " << key << " expected. Check your config file!";
                context.tracer().warning( ss.str() );
                continue;
            }
            
            // found an entry
            ss.str(""); ss << "Found Description entry: " << descriptionMapIt->second;
            context.tracer().debug( ss.str(), 5 );
            
            //
            // assemble all pieces to create the GUI element
            //
            QString elementDescription( descriptionMapIt->second.c_str() );
            QString uniqueId = extractUniqueId( elementDescription );
            QString platformName = extractPlatformName( elementDescription );
            
            guiElementModel.createGuiElement( elementType, elementDescription, platformName, uniqueId );
        }

    }
开发者ID:mjs513,项目名称:orca-robotics,代码行数:54,代码来源:configfileelements.cpp

示例2: readFromProperties

void readFromProperties( orcaice::Context context, VfhAlgorithmConfig &c )
{
    Ice::PropertiesPtr prop = context.properties();
    std::string prefix = context.tag();
    prefix += ".Config.Vfh.";

    c.cellSize                  = orcaice::getPropertyAsDoubleWithDefault( prop, prefix+"CellSize", 0.1 );
    c.gridWidthInCells          = orcaice::getPropertyAsIntWithDefault(    prop, prefix+"GridWidthInCells", 61 );
    c.sectorAngle               = orcaice::getPropertyAsDoubleWithDefault( prop, prefix+"SectorAngle", 5.0 )*M_PI/180.0;
    // c.robotRadius               = orcaice::getPropertyAsDoubleWithDefault( prop, prefix+"RobotRadius", 0.3 );
    c.safetyDist0ms             = orcaice::getPropertyAsDoubleWithDefault( prop, prefix+"SafetyDist0ms", 0.1 );
    c.safetyDist1ms             = orcaice::getPropertyAsDoubleWithDefault( prop, prefix+"SafetyDist1ms", 0.1 );
    c.maxSpeed                  = orcaice::getPropertyAsDoubleWithDefault( prop, prefix+"MaxSpeed", 0.2 );
    c.maxSpeedNarrowOpening     = orcaice::getPropertyAsDoubleWithDefault( prop, prefix+"MaxSpeedNarrowOpening", 0.2 );
    c.maxSpeedWideOpening       = orcaice::getPropertyAsDoubleWithDefault( prop, prefix+"MaxSpeedWideOpening", 0.2 );
    c.maxAcceleration           = orcaice::getPropertyAsDoubleWithDefault( prop, prefix+"MaxAcceleration", 0.2 );
    c.maxTurnrate0ms            = orcaice::getPropertyAsDoubleWithDefault( prop, prefix+"MaxTurnrate0ms", 40.0 )*M_PI/180.0;
    c.maxTurnrate1ms            = orcaice::getPropertyAsDoubleWithDefault( prop, prefix+"MaxTurnrate1ms", 40.0 )*M_PI/180.0;
    c.absoluteMaxTurnrate       = orcaice::getPropertyAsDoubleWithDefault( prop, prefix+"AbsoluteMaxTurnrate", 60.0 )*M_PI/180.0;
    c.minTurnRadiusSafetyFactor = orcaice::getPropertyAsDoubleWithDefault( prop, prefix+"MinTurnRadiusSafetyFactor", 1.10 );
    c.freeSpaceCutoff0ms        = orcaice::getPropertyAsDoubleWithDefault( prop, prefix+"FreeSpaceCutoff0ms", 2e6 );
    c.freeSpaceCutoff1ms        = orcaice::getPropertyAsDoubleWithDefault( prop, prefix+"FreeSpaceCutoff1ms", 2e6 );
    c.obsCutoff0ms              = orcaice::getPropertyAsDoubleWithDefault( prop, prefix+"ObsCutoff0ms", 2e6 );
    c.obsCutoff1ms              = orcaice::getPropertyAsDoubleWithDefault( prop, prefix+"ObsCutoff1ms", 2e6 );
    c.weightDesiredDir          = orcaice::getPropertyAsDoubleWithDefault( prop, prefix+"WeightDesiredDir", 5.0 );
    c.weightCurrentDir          = orcaice::getPropertyAsDoubleWithDefault( prop, prefix+"WeightCurrentDir", 3.0 );
}
开发者ID:mjs513,项目名称:orca-robotics,代码行数:27,代码来源:vfh_algorithmconfig.cpp


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