Class ParametersHandler

Class Documentation

class ParametersHandler

Handles getting parameters and dynamic parmaeter changes.

Public Types

using get_param_func_t = void(const rclcpp::Parameter &param)
using post_callback_t = void()
using pre_callback_t = void()

Public Functions

ParametersHandler() = default

Constructor for mppi::ParametersHandler.

explicit ParametersHandler(const rclcpp_lifecycle::LifecycleNode::WeakPtr &parent)

Constructor for mppi::ParametersHandler.

Parameters:

parent – Weak ptr to node

void start()

Starts processing dynamic parameter changes.

rcl_interfaces::msg::SetParametersResult dynamicParamsCallback(std::vector<rclcpp::Parameter> parameters)

Dynamic parameter callback.

Parameters:

parameterParameter changes to process

Returns:

Set Parameter Result

inline auto getParamGetter(const std::string &ns)

Get an object to retreive parameters.

Parameters:

ns – Namespace to get parameters within

Returns:

Parameter getter object

template<typename T>
void addPostCallback(T &&callback)

Set a callback to process after parameter changes.

Parameters:

callback – Callback function

template<typename T>
void addPreCallback(T &&callback)

Set a callback to process before parameter changes.

Parameters:

callback – Callback function

template<typename T>
void setDynamicParamCallback(T &setting, const std::string &name)

Set a parameter to a dynamic parameter callback.

Parameters:
  • settingParameter

  • name – Name of parameter

inline std::mutex *getLock()

Get mutex lock for changing parameters.

Returns:

Pointer to mutex

template<typename T>
void addDynamicParamCallback(const std::string &name, T &&callback)

Set a parameter to a dynamic parameter callback.

Parameters:
  • name – Name of parameter

  • callbackParameter callback

Protected Functions

template<typename SettingT, typename ParamT>
void getParam(SettingT &setting, const std::string &name, ParamT default_value, ParameterType param_type = ParameterType::Dynamic)

Gets parameter.

Parameters:
  • setting – Return Parameter type

  • nameParameter name

  • default_value – Default parameter value

  • param_type – Type of parameter (dynamic or static)

template<typename ParamT, typename SettingT, typename NodeT>
void setParam(SettingT &setting, const std::string &name, NodeT node) const

Set a parameter.

Parameters:
  • setting – Return Parameter type

  • nameParameter name

  • node – Node to set parameter via

Protected Attributes

std::mutex parameters_change_mutex_
rclcpp::Logger logger_ = {rclcpp::get_logger("MPPIController")}
rclcpp::node_interfaces::OnSetParametersCallbackHandle::SharedPtr on_set_param_handler_
rclcpp_lifecycle::LifecycleNode::WeakPtr node_
std::string node_name_
bool verbose_ = {false}
std::unordered_map<std::string, std::function<get_param_func_t>> get_param_callbacks_
std::vector<std::function<pre_callback_t>> pre_callbacks_
std::vector<std::function<post_callback_t>> post_callbacks_

Protected Static Functions

template<typename T>
static auto as(const rclcpp::Parameter &parameter)

Converts parameter type to real types.

Parameters:

parameterParameter to convert into real type

Returns:

parameter as a functional type