Template Function cras::getParam(const ::ros::NodeHandle&, const ::std::string&, const ::cras::optional<ResultType>&, const ::std::string&, const ::cras::GetParamOptions<ResultType, ParamServerType>&)
Defined in File node_utils.hpp
Function Documentation
-
template<typename ResultType, typename ParamServerType = typename ::cras::DefaultParamServerType<ResultType>::type, ::cras::check_get_param_types<ResultType, ParamServerType>* = nullptr>
inline ResultType cras::getParam(const ::ros::NodeHandle &node, const ::std::string &name, const ::cras::optional<ResultType> &defaultValue = ResultType(), const ::std::string &unit = "", const ::cras::GetParamOptions<ResultType, ParamServerType> &options = {}) Get the value of the given ROS parameter, falling back to the specified default value (if not nullopt), and print out a ROS log message with the loaded values (if specified).
- Template Parameters:
ResultType – Param type (the C++ type). It is converted from the intermediate ParamServerType using options.toResult function (which defaults to static_cast).
ParamServerType – Intermediate type to which the XmlRpcValue read from parameter server is converted. The conversion is done using options.toParam function (which defaults to cras::convert). Most overloads of cras::convert are in xmlrpc_value_utils.hpp, but you can add your own.
- Parameters:
node – [in] The node handle from which parameters are read.
name – [in] Name of the parameter.
defaultValue – [in] The default value to use. If std::nullopt, then the parameter is required. If a required param is not found, a GetParamException is thrown.
unit – [in] Optional string serving as a [physical/SI] unit of the parameter, just to make the messages more informative.
options – [in] Options specifying detailed behavior of this function. Use the braced initializer syntax for comfortable writing, e.g.
{.throwIfConvertFails = true, .allowNestedParams = false}.
- Returns:
The loaded parameter value.