Modulo 5.0.0
|
Public Member Functions | |
ControllerInterface (bool claim_all_state_interfaces=false) | |
Default constructor. | |
CallbackReturn | on_init () override |
Declare parameters. | |
CallbackReturn | on_configure (const rclcpp_lifecycle::State &previous_state) final |
Set class properties from parameters. | |
CallbackReturn | on_activate (const rclcpp_lifecycle::State &previous_state) final |
Initialize internal data attributes from configured interfaces and wait for valid states from hardware. | |
CallbackReturn | on_deactivate (const rclcpp_lifecycle::State &previous_state) final |
Deactivate the controller. | |
controller_interface::return_type | update (const rclcpp::Time &time, const rclcpp::Duration &period) final |
Read the state interfaces, perform control evaluation and write the command interfaces. | |
controller_interface::InterfaceConfiguration | state_interface_configuration () const final |
Configure the state interfaces. | |
controller_interface::InterfaceConfiguration | command_interface_configuration () const final |
Configure the command interfaces. | |
![]() | |
BaseControllerInterface () | |
Default constructor. | |
CallbackReturn | on_init () override |
Declare parameters and register the on_set_parameters callback. | |
CallbackReturn | on_configure (const rclcpp_lifecycle::State &previous_state) override |
Add signals. | |
template<> | |
void | write_output (const std::string &name, const bool &data) |
template<> | |
void | write_output (const std::string &name, const double &data) |
template<> | |
void | write_output (const std::string &name, const std::vector< double > &data) |
template<> | |
void | write_output (const std::string &name, const int &data) |
template<> | |
void | write_output (const std::string &name, const std::string &data) |
Protected Member Functions | |
virtual CallbackReturn | add_interfaces () |
Add interfaces like parameters, signals, services, and predicates to the controller. | |
virtual CallbackReturn | on_configure () |
Configure the controller. | |
virtual CallbackReturn | on_activate () |
Activate the controller. | |
virtual CallbackReturn | on_deactivate () |
Deactivate the controller. | |
virtual controller_interface::return_type | read_state_interfaces () |
Read the state interfaces. | |
virtual controller_interface::return_type | write_command_interfaces (const rclcpp::Duration &period) |
Write the command interfaces. | |
virtual controller_interface::return_type | evaluate (const rclcpp::Time &time, const std::chrono::nanoseconds &period)=0 |
The control logic callback. | |
void | add_state_interface (const std::string &name, const std::string &interface) |
Add a state interface to the controller by name. | |
void | add_command_interface (const std::string &name, const std::string &interface) |
Add a command interface to the controller by name. | |
std::unordered_map< std::string, double > | get_state_interfaces (const std::string &name) const |
Get a map containing the state interfaces by name of the parent tag. | |
double | get_state_interface (const std::string &name, const std::string &interface) const |
Get the value of a state interface by name. | |
double | get_command_interface (const std::string &name, const std::string &interface) const |
Get the value of a command interface by name. | |
void | set_command_interface (const std::string &name, const std::string &interface, double value) |
Set the value of a command interface by name. | |
![]() | |
void | add_parameter (const std::shared_ptr< state_representation::ParameterInterface > ¶meter, const std::string &description, bool read_only=false) |
Add a parameter. | |
template<typename T > | |
void | add_parameter (const std::string &name, const T &value, const std::string &description, bool read_only=false) |
Add a parameter. | |
virtual bool | on_validate_parameter_callback (const std::shared_ptr< state_representation::ParameterInterface > ¶meter) |
Parameter validation function to be redefined by derived controller classes. | |
std::shared_ptr< state_representation::ParameterInterface > | get_parameter (const std::string &name) const |
Get a parameter by name. | |
template<typename T > | |
T | get_parameter_value (const std::string &name) const |
Get a parameter value by name. | |
template<typename T > | |
void | set_parameter_value (const std::string &name, const T &value) |
Set the value of a parameter. | |
void | add_predicate (const std::string &predicate_name, bool predicate_value) |
Add a predicate to the map of predicates. | |
void | add_predicate (const std::string &predicate_name, const std::function< bool(void)> &predicate_function) |
Add a predicate to the map of predicates based on a function to periodically call. | |
bool | get_predicate (const std::string &predicate_name) const |
Get the logical value of a predicate. | |
void | set_predicate (const std::string &predicate_name, bool predicate_value) |
Set the value of the predicate given as parameter, if the predicate is not found does not do anything. | |
void | set_predicate (const std::string &predicate_name, const std::function< bool(void)> &predicate_function) |
Set the value of the predicate given as parameter, if the predicate is not found does not do anything. | |
void | add_trigger (const std::string &trigger_name) |
Add a trigger to the controller. | |
void | trigger (const std::string &trigger_name) |
Latch the trigger with the provided name. | |
template<typename T > | |
void | add_input (const std::string &name, const std::string &topic_name="") |
Add an input to the controller. | |
template<typename T > | |
void | add_output (const std::string &name, const std::string &topic_name="") |
Add an output to the controller. | |
void | set_input_validity_period (double input_validity_period) |
Set the input validity period of input signals. | |
template<typename T > | |
std::optional< T > | read_input (const std::string &name) |
Read the most recent message of an input. | |
template<typename T > | |
void | write_output (const std::string &name, const T &data) |
Write an object to an output. | |
void | add_service (const std::string &service_name, const std::function< ControllerServiceResponse(void)> &callback) |
Add a service to trigger a callback function with no input arguments. | |
void | add_service (const std::string &service_name, const std::function< ControllerServiceResponse(const std::string &string)> &callback) |
Add a service to trigger a callback function with a string payload. | |
rclcpp::QoS | get_qos () const |
Getter of the Quality of Service attribute. | |
void | set_qos (const rclcpp::QoS &qos) |
Set the Quality of Service for ROS publishers and subscribers. | |
bool | is_active () const |
Check if the controller is currently in state active or not. | |
std::timed_mutex & | get_command_mutex () |
Get the reference to the command mutex. | |
template<> | |
void | add_input (const std::string &name, const std::string &topic_name) |
template<> | |
void | add_input (const std::string &name, const std::string &topic_name) |
template<> | |
void | add_input (const std::string &name, const std::string &topic_name) |
template<> | |
void | add_output (const std::string &name, const std::string &topic_name) |
template<> | |
void | add_output (const std::string &name, const std::string &topic_name) |
template<> | |
void | add_output (const std::string &name, const std::string &topic_name) |
template<> | |
std::optional< bool > | read_input (const std::string &name) |
template<> | |
std::optional< double > | read_input (const std::string &name) |
template<> | |
std::optional< int > | read_input (const std::string &name) |
Protected Attributes | |
std::string | hardware_name_ |
The hardware name provided by a parameter. | |
Definition at line 10 of file ControllerInterface.hpp.
modulo_controllers::ControllerInterface::ControllerInterface | ( | bool | claim_all_state_interfaces = false | ) |
Default constructor.
claim_all_state_interfaces | Flag to indicate if all state interfaces should be claimed |
Definition at line 9 of file ControllerInterface.cpp.
|
protected |
Add a command interface to the controller by name.
name | The name of the parent tag, e.g. the name of the joint, sensor or gpio |
interface | The desired command interface |
Definition at line 84 of file ControllerInterface.cpp.
|
protectedvirtual |
Add interfaces like parameters, signals, services, and predicates to the controller.
This function is called during the on_init
callback of the base class to perform post-construction steps.
Reimplemented in modulo_controllers::RobotControllerInterface.
Definition at line 39 of file ControllerInterface.cpp.
|
protected |
Add a state interface to the controller by name.
name | The name of the parent tag, e.g. the name of the joint, sensor or gpio |
interface | The desired state interface |
Definition at line 80 of file ControllerInterface.cpp.
|
final |
Configure the command interfaces.
Definition at line 106 of file ControllerInterface.cpp.
|
protectedpure virtual |
The control logic callback.
This method should be overridden by derived classes. It is called in the update() method between reading the state interfaces and writing the command interfaces.
time | The controller clock time |
period | Time elapsed since the last control evaluation |
|
protected |
Get the value of a command interface by name.
name | The name of the parent tag, e.g. the name of the joint, sensor or gpio |
interface | The desired command interface |
out_of_range | if the desired command interface is not available |
Definition at line 278 of file ControllerInterface.cpp.
|
protected |
Get the value of a state interface by name.
name | The name of the parent tag, e.g. the name of the joint, sensor or gpio |
interface | The desired state interface |
out_of_range | if the desired state interface is not available |
Definition at line 274 of file ControllerInterface.cpp.
|
protected |
Get a map containing the state interfaces by name of the parent tag.
name | The name of the parent tag, e.g. the name of the joint, sensor or gpio |
out_of_range | if the desired state interface is not available |
Definition at line 270 of file ControllerInterface.cpp.
|
protectedvirtual |
Activate the controller.
This method should be overridden by derived classes.
Reimplemented in modulo_controllers::RobotControllerInterface.
Definition at line 194 of file ControllerInterface.cpp.
|
final |
Initialize internal data attributes from configured interfaces and wait for valid states from hardware.
This functions calls the internal on_activate() method
previous_state | The previous lifecycle state |
Definition at line 141 of file ControllerInterface.cpp.
|
protectedvirtual |
Configure the controller.
This method should be overridden by derived classes.
Reimplemented in modulo_controllers::RobotControllerInterface.
Definition at line 76 of file ControllerInterface.cpp.
|
final |
Set class properties from parameters.
This functions calls the internal on_configure() method
previous_state | The previous lifecycle state |
Definition at line 44 of file ControllerInterface.cpp.
|
protectedvirtual |
Deactivate the controller.
This method should be overridden by derived classes.
Definition at line 208 of file ControllerInterface.cpp.
|
final |
Deactivate the controller.
previous_state | The previous lifecycle state |
Definition at line 199 of file ControllerInterface.cpp.
|
override |
Declare parameters.
Definition at line 12 of file ControllerInterface.cpp.
|
protectedvirtual |
Read the state interfaces.
Definition at line 253 of file ControllerInterface.cpp.
|
protected |
Set the value of a command interface by name.
name | The name of the parent tag, e.g. the name of the sensor or gpio |
interface | The name of the command interface |
value | The new value of the interface |
Definition at line 282 of file ControllerInterface.cpp.
|
final |
Configure the state interfaces.
Definition at line 123 of file ControllerInterface.cpp.
|
final |
Read the state interfaces, perform control evaluation and write the command interfaces.
time | The controller clock time |
period | Time elapsed since the last control evaluation |
Definition at line 213 of file ControllerInterface.cpp.
|
protectedvirtual |
Write the command interfaces.
period | Time elapsed since the last control evaluation |
Definition at line 262 of file ControllerInterface.cpp.
|
protected |
The hardware name provided by a parameter.
Definition at line 169 of file ControllerInterface.hpp.