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 ); } }
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 ); }