22 #include <gazebo/gazebo.hh> 23 #include <gazebo/common/common.hh> 25 #include <ignition/math/Vector2.hh> 26 #include <ignition/math/Vector3.hh> 38 template <
typename T>T
39 SdfParam(sdf::Element& _sdf,
const std::string &_paramName, \
42 if (!_sdf.HasElement(_paramName))
44 gzmsg <<
"Parameter <" << _paramName <<
"> not found: " 45 <<
"Using default value of <" << _defaultVal <<
">." << std::endl;
49 T val = _sdf.Get<T>(_paramName);
50 gzmsg <<
"Parameter found - setting <" << _paramName
51 <<
"> to <" << val <<
">." << std::endl;
58 const std::string& _paramName,
const bool _defaultVal)
60 return SdfParam<bool>(_sdf, _paramName, _defaultVal);
64 const std::string& _paramName,
const size_t _defaultVal)
66 return SdfParam<double>(_sdf, _paramName, _defaultVal);
70 const std::string& _paramName,
const double _defaultVal)
72 return SdfParam<double>(_sdf, _paramName, _defaultVal);
76 const std::string& _paramName,
const std::string &_defaultVal)
78 return SdfParam<std::string>(_sdf, _paramName, _defaultVal);
82 const std::string& _paramName,
const ignition::math::Vector2d _defaultVal)
84 return SdfParam<ignition::math::Vector2d>(_sdf, _paramName, _defaultVal);
88 const std::string& _paramName,
const ignition::math::Vector3d _defaultVal)
90 return SdfParam<ignition::math::Vector3d>(_sdf, _paramName, _defaultVal);
T SdfParam(sdf::Element &_sdf, const std::string &_paramName, const T &_defaultVal)
This file defines utilities for extracting parameters from SDF.
static ignition::math::Vector2d SdfParamVector2(sdf::Element &_sdf, const std::string &_paramName, const ignition::math::Vector2d _defaultVal)
Extract a named Vector2 parameter from an SDF element.
static std::string SdfParamString(sdf::Element &_sdf, const std::string &_paramName, const std::string &_defaultVal)
Extract a named string parameter from an SDF element.
static bool SdfParamBool(sdf::Element &_sdf, const std::string &_paramName, const bool _defaultVal)
Extract a named bool parameter from an SDF element.
static double SdfParamDouble(sdf::Element &_sdf, const std::string &_paramName, const double _defaultVal)
Extract a named double parameter from an SDF element.
static ignition::math::Vector3d SdfParamVector3(sdf::Element &_sdf, const std::string &_paramName, const ignition::math::Vector3d _defaultVal)
Extract a named Vector3 parameter from an SDF element.
static size_t SdfParamSizeT(sdf::Element &_sdf, const std::string &_paramName, const size_t _defaultVal)
Extract a named size_t parameter from an SDF element.