Class ParamHandler
Defined in File param_handler.h
Class Documentation
-
class ParamHandler
The param handler is a convenience class for managing static and dynamic ROS parameters. It will handle receiving and sending parameter updates.
When registering a new parameter the param handler will return a parameter object which can be used to access the parameter value in a thread safe way if the application is using multiple threads.
All parameters require a name, default value, and description.
Optionally, a pointer to an existing variable can be passed in when registering a parameter. In this case that variable is used to store the parameter value, but access to it is not protected, so should only be used in single threaded applications.
When registering a parameter it is possible to chain additional configuration items to the parameter, such as:
.dynamic() - allow the parameter to by modified with dynamic reconfig
.callback(func) - provide a callback function when the parameter changes, implies .dynamic()
.min(val) - specify a minimun value for numeric parameters
.max(val) - specify a maximum value for numeric parameters
.step(val) - specify step size for numeric parameters
.enum(list) - specify an enumeration for integer parameters
Once the parameter has been configured, it’s necessary to call the
.declare()
method.The parameter objects values can be accessed in a thread safe way with the .value() method and updated with the .update(val) method.
Assigning parameter objects results in a shallow copy.
Public Functions
-
~ParamHandler() = default
-
inline void register_verbose_logging_param()
Register a boolean ‘verbose’ dynamic parameter to enable or disable debug level logging.
-
inline BoolParameter ¶m(const std::string &name, const bool &default_val, const std::string &description)
Register a bool parameter and return it’s value.
-
inline BoolParameter ¶m(bool *param, const std::string &name, const bool &default_val, const std::string &description)
Register a bool parameter and return it’s value.
NOTE: This version is only recommended for single threaded applications since the user provided parameter pointer won’t be fully guarded from concurrent usage.
The point should also remain valid for the life of the handler.
-
inline IntParameter ¶m(const std::string &name, const int &default_val, const std::string &description)
Register an integer parameter and return it’s value.
-
inline IntParameter ¶m(int *param, const std::string &name, const int &default_val, const std::string &description)
Register an integer parameter and return it’s value.
NOTE: This version is only recommended for single threaded applications since the user provided parameter pointer won’t be fully guarded from concurrent usage.
The point should also remain valid for the life of the handler.
-
inline DoubleParameter ¶m(const std::string &name, const double &default_val, const std::string &description)
Register a double parameter and return it’s value.
-
inline DoubleParameter ¶m(double *param, const std::string &name, const double &default_val, const std::string &description)
Register a double parameter and return it’s value.
NOTE: This version is only recommended for single threaded applications since the user provided parameter pointer won’t be fully guarded from concurrent usage.
The point should also remain valid for the life of the handler.
-
inline StringParameter ¶m(const std::string &name, const std::string &default_val, const std::string &description)
Register a string parameter and return it’s value.
-
inline StringParameter ¶m(std::string *param, const std::string &name, const std::string &default_val, const std::string &description)
Register a string parameter and return it’s value.
NOTE: This version is only recommended for single threaded applications since the user provided parameter pointer won’t be fully guarded from concurrent usage.
The point should also remain valid for the life of the handler.