37 #include "ompl/base/GenericParam.h"
38 #include "ompl/util/Exception.h"
42 std::map<std::string, GenericParamPtr>::const_iterator it = params_.find(key);
43 if (it != params_.end())
44 return it->second->setValue(value);
47 OMPL_ERROR(
"Parameter '%s' was not found", key.c_str());
55 for (std::map<std::string, std::string>::const_iterator it = kv.begin() ; it != kv.end() ; ++it)
58 if (!hasParam(it->first))
60 bool r = setParam(it->first, it->second);
68 std::map<std::string, GenericParamPtr>::const_iterator it = params_.find(key);
69 if (it != params_.end())
71 value = it->second->getValue();
80 params.reserve(params_.size());
81 for (std::map<std::string, GenericParamPtr>::const_iterator it = params_.begin() ; it != params_.end() ; ++it)
82 params.push_back(it->first);
87 std::vector<std::string> names;
89 vals.resize(names.size());
90 for (std::size_t i = 0 ; i < names.size() ; ++i)
91 vals[i] = params_.find(names[i])->second->getValue();
101 static GenericParamPtr empty;
102 std::map<std::string, GenericParamPtr>::const_iterator it = params_.find(key);
103 if (it != params_.end())
111 for (std::map<std::string, GenericParamPtr>::const_iterator it = params_.begin() ; it != params_.end() ; ++it)
112 params[it->first] = it->second->getValue();
117 return params_.find(key) != params_.end();
123 throw Exception(
"Parameter '%s' is not defined", key.c_str());
124 return *getParam(key);
129 const std::map<std::string, GenericParamPtr> &p = other.
getParams();
131 for (std::map<std::string, GenericParamPtr>::const_iterator it = p.begin() ; it != p.end() ; ++it)
132 params_[it->first] = it->second;
134 for (std::map<std::string, GenericParamPtr>::const_iterator it = p.begin() ; it != p.end() ; ++it)
135 params_[prefix +
"." + it->first] = it->second;
140 params_[param->getName()] = param;
155 for (std::map<std::string, GenericParamPtr>::const_iterator it = params_.begin() ; it != params_.end() ; ++it)
156 out << it->first <<
" = " << it->second->getValue() << std::endl;
void print(std::ostream &out) const
Print the parameters to a stream.
bool hasParam(const std::string &key) const
Check whether this set of parameters includes the parameter named key.
void include(const ParamSet &other, const std::string &prefix="")
Include the params of a different ParamSet into this one. Optionally include a prefix for each of the...
Motion planning algorithms often employ parameters to guide their exploration process. (e.g., goal biasing). Motion planners (and some of their components) use this class to declare what the parameters are, in a generic way, so that they can be set externally.
void getParamNames(std::vector< std::string > ¶ms) const
List the names of the known parameters.
bool setParams(const std::map< std::string, std::string > &kv, bool ignoreUnknown=false)
Set the values for a set of parameters. The parameter names are the keys in the map kv...
bool getParam(const std::string &key, std::string &value) const
Get the value of the parameter named key. Store the value as string in value and return true if the p...
Maintain a set of parameters.
void getParams(std::map< std::string, std::string > ¶ms) const
Get the known parameter as a map from names to their values cast as string.
bool setParam(const std::string &key, const std::string &value)
Algorithms in OMPL often have parameters that can be set externally. While each algorithm will have t...
void remove(const std::string &name)
Remove a parameter from the set.
#define OMPL_ERROR(fmt,...)
Log a formatted error string.
void getParamValues(std::vector< std::string > &vals) const
List the values of the known parameters, in the same order as getParamNames()
GenericParam & operator[](const std::string &key)
Access operator for parameters, by name. If the parameter is not defined, an exception is thrown...
The exception type for ompl.
const std::map< std::string, GenericParamPtr > & getParams(void) const
Get the map from parameter names to parameter descriptions.
void add(const GenericParamPtr ¶m)
Add a parameter to the set.
void clear(void)
Clear all the set parameters.