Template Function nav2_util::declare_or_get_parameter(const rclcpp::Logger&, NodeParamInterfacePtr, const std::string&, const ParamType&, bool, bool, const ParameterDescriptor&)

Function Documentation

template<typename ParamType>
ParamType nav2_util::declare_or_get_parameter(const rclcpp::Logger &logger, NodeParamInterfacePtr param_interface, const std::string &parameter_name, const ParamType &default_value, bool warn_if_no_override = false, bool strict_param_loading = false, const ParameterDescriptor &parameter_descriptor = ParameterDescriptor())

If the parameter is already declared, returns its value, otherwise declares it and returns the default value If the parameter is already declared, returns its value, otherwise declares it and returns the default value. The method can optionally print a warning or throw when the override is missing.

Parameters:
  • logger[in] Node logging interface

  • param_interface[in] Node parameter interface

  • parameter_name[in] Name of the parameter

  • default_value[in] Default value of the parameter

  • warn_if_no_override[in] If true, prints a warning whenever the parameter override is missing

  • strict_param_loading[in] If true, throws an InvalidParameterValueException if the parameter override is missing

  • parameter_descriptor[in] Optional parameter descriptor

Returns:

The value of the param from the override if existent, otherwise the default value