![]() |
Bioscara
DALSA's DIY SCARA Robot Arm.
|
A general purpose controller which can be used to trigger command interfaces. More...
#include <single_trigger_controller.hpp>
Public Member Functions | |
| SingleTriggerController () | |
| controller_interface::InterfaceConfiguration | command_interface_configuration () const override |
| Sets the command interface configuration to INDIVIDUAL. | |
| controller_interface::InterfaceConfiguration | state_interface_configuration () const override |
| Sets the state interface configuration to INDIVIDUAL. | |
| CallbackReturn | on_init () override |
Called on initialization to the unconfigured state. | |
| CallbackReturn | on_configure (const rclcpp_lifecycle::State &previous_state) override |
Called on the transistion from the unconfigured to the inactive state. | |
| CallbackReturn | on_activate (const rclcpp_lifecycle::State &previous_state) override |
Called on the transistion from the inactive to the active state. | |
| CallbackReturn | on_deactivate (const rclcpp_lifecycle::State &previous_state) override |
Called on the transistion from the active to the inactive state. | |
| controller_interface::return_type | update (const rclcpp::Time &time, const rclcpp::Duration &period) override |
Realtime update method called when in active state. | |
Protected Attributes | |
| InterfacesNames | command_interface_types_ |
| vector of string holding all command interface names as configured from the parameters. | |
| InterfacesNames | state_interface_types_ |
| vector of string holding all state interface names as configured from the parameters. | |
| MapOfReferencesToCommandInterfaces | command_interfaces_map_ |
| map containing a reference to the actual hardwares command interfaces | |
| MapOfReferencesToStateInterfaces | state_interfaces_map_ |
| map containing a reference to the actual hardwares state interfaces | |
| rclcpp::Subscription< CmdType >::SharedPtr | command_subscriber_ {} |
| Subscriber object for the '~/commands' topic. | |
| std::shared_ptr< rclcpp::Publisher< StateType > > | state_publisher_ {} |
| Publisher object to the '~/states' topic. | |
| std::shared_ptr< realtime_tools::RealtimePublisher< StateType > > | realtime_state_publisher_ {} |
| Realtime publisher wrapper of the state_publisher_. | |
| StateType | state_msg_ |
| Message object holding the states to be published. | |
| std::shared_ptr< single_trigger_controller_parameters::ParamListener > | param_listener_ {} |
| parameter listerner object. | |
| single_trigger_controller_parameters::Params | params_ |
| Parameter structure holding controller configuration parameters. | |
Private Member Functions | |
| void | store_command_interface_types () |
| Stores all configured command interfaces in command_interface_types_. | |
| void | store_state_interface_types () |
| Stores all configured state interfaces in state_interface_types_. | |
| void | initialize_state_msg () |
| Initializes the state message state_msg_ with NaN values for each configured state interface. | |
| void | update_states () |
| Publishes current state values. | |
| controller_interface::return_type | update_commands (const CmdType &commands) |
| Callback method for received command msg. Calls apply_command() for each command interface. | |
| template<typename T > | |
| std::unordered_map< std::string, std::reference_wrapper< T > > | create_map_of_references_to_interfaces (const InterfacesNames &interfaces_from_params, std::vector< T > &configured_interfaces) |
| Create a map of references to the hardware components interfaces. | |
| template<typename T > | |
| bool | check_if_configured_interfaces_matches_received (const InterfacesNames &interfaces_from_params, const T &configured_interfaces) |
| performs checks on the configured interfaces vs received interfaces. | |
| void | apply_state_value (StateType &state_msg, std::size_t index, std::size_t interface_index) const |
| retrieves the state values from the hardware and populates the state_msg with the result. | |
| void | apply_command (const CmdType &commands, std::size_t index, std::size_t command_interface_index) const |
| calls the set_value() method for the hardwares command interface references from the command_interfaces_map_ | |
| InterfacesNames | get_state_interfaces_names (const std::string &name) const |
Gets the all qualified state interface names from the state_interface_types_ for the joint matching name. | |
| bool | update_dynamic_map_parameters () |
| Update the controller parameters. | |
A general purpose controller which can be used to trigger command interfaces.
This controller is a derivative of the ros2_control GpioCommandController. The key differences between this controller and the GpioCommandController is two-fold:
The controller subscribes and publishes to the same topics as the GpioCommandController.
| single_trigger_controller::SingleTriggerController::SingleTriggerController | ( | ) |
|
private |
calls the set_value() method for the hardwares command interface references from the command_interfaces_map_
| commands | |
| index | |
| command_interface_index |
|
private |
retrieves the state values from the hardware and populates the state_msg with the result.
calls the get_optional() method of each state interface from the state_interfaces_map_ for the state referenced by the index and interface_index.
| state_msg | |
| index | |
| interface_index |
|
private |
performs checks on the configured interfaces vs received interfaces.
| T |
| interfaces_from_params | |
| configured_interfaces |
|
override |
Sets the command interface configuration to INDIVIDUAL.
See ControllerInterfaceBase::command_interface_configuration()
|
private |
Create a map of references to the hardware components interfaces.
| T |
| interfaces_from_params | |
| configured_interfaces |
|
private |
Gets the all qualified state interface names from the state_interface_types_ for the joint matching name.
| name |
|
private |
Initializes the state message state_msg_ with NaN values for each configured state interface.
For example the state message could look like this:
|
override |
Called on the transistion from the inactive to the active state.
Populates command_interfaces_map_ and state_interfaces_map_ by invoking create_map_of_references_to_interfaces() for both command and state interfaces.
Initializes an empty state message by calling initialize_state_msg().
| previous_state |
|
override |
Called on the transistion from the unconfigured to the inactive state.
Stores all configured command and state interfaces using the store_command_interface_types() and store_state_interface_types() methods.
Creates a subscription to the '~/commands' topic if command interfaces are configured. Creates a realtime publisher to the '~/states' topic is state interfaces are configured.
|
override |
Called on the transistion from the active to the inactive state.
| previous_state |
|
override |
Called on initialization to the unconfigured state.
Retrieves and stores the parameters supplied to the controller in params_
|
override |
Sets the state interface configuration to INDIVIDUAL.
See ControllerInterfaceBase::state_interface_configuration()
|
private |
Stores all configured command interfaces in command_interface_types_.
|
private |
Stores all configured state interfaces in state_interface_types_.
|
override |
Realtime update method called when in active state.
Only publishes the states by invoking update_states().
| time | |
| period |
|
private |
Callback method for received command msg. Calls apply_command() for each command interface.
Sets all command interaces to 0.0 if an empty command message is received.
| commands |
|
private |
Update the controller parameters.
Only called in on_configure() to update the parameters in case they have been changed.
|
private |
Publishes current state values.
Loops over all interface groups and command interfaces and calls the apply_state_value(). Then publishes the result using the realtime_state_publisher_.
|
protected |
vector of string holding all command interface names as configured from the parameters.
Looks like this for example:
|
protected |
map containing a reference to the actual hardwares command interfaces
|
protected |
Subscriber object for the '~/commands' topic.
|
protected |
parameter listerner object.
|
protected |
Parameter structure holding controller configuration parameters.
|
protected |
Realtime publisher wrapper of the state_publisher_.
|
protected |
vector of string holding all state interface names as configured from the parameters.
Looks like this for example:
|
protected |
map containing a reference to the actual hardwares state interfaces
|
protected |
Message object holding the states to be published.
|
protected |
Publisher object to the '~/states' topic.