3#include "modulo_controllers/BaseControllerInterface.hpp"
5namespace modulo_controllers {
22 CallbackReturn
on_init()
override;
30 CallbackReturn
on_configure(
const rclcpp_lifecycle::State& previous_state)
final;
38 CallbackReturn
on_activate(
const rclcpp_lifecycle::State& previous_state)
final;
45 CallbackReturn
on_deactivate(
const rclcpp_lifecycle::State& previous_state)
final;
53 controller_interface::return_type
update(
const rclcpp::Time& time,
const rclcpp::Duration& period)
final;
118 virtual controller_interface::return_type
119 evaluate(
const rclcpp::Time& time,
const std::chrono::nanoseconds& period) = 0;
180 const std::string& name,
const std::string& interface, std::vector<std::string>& list,
const std::string& type);
182 using controller_interface::ControllerInterfaceBase::command_interfaces_;
183 using controller_interface::ControllerInterfaceBase::state_interfaces_;
185 std::unordered_map<std::string, std::unordered_map<std::string, double>>
186 state_interface_data_;
187 std::vector<double> command_interface_data_;
188 std::unordered_map<std::string, std::unordered_map<std::string, unsigned int>>
189 command_interface_indices_;
190 std::vector<std::string> state_interface_names_;
191 std::vector<std::string> command_interface_names_;
192 bool claim_all_state_interfaces_;
195 unsigned int missed_locks_;
196 bool on_init_called_;
Base controller class to combine ros2_control, control libraries and modulo.
virtual CallbackReturn add_interfaces()
Add interfaces like parameters, signals, services, and predicates to the controller.
controller_interface::InterfaceConfiguration command_interface_configuration() const final
Configure the command interfaces.
virtual controller_interface::return_type write_command_interfaces(const rclcpp::Duration &period)
Write the command interfaces.
virtual CallbackReturn on_configure()
Configure the controller.
virtual controller_interface::return_type evaluate(const rclcpp::Time &time, const std::chrono::nanoseconds &period)=0
The control logic callback.
virtual controller_interface::return_type read_state_interfaces()
Read the state interfaces.
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.
CallbackReturn on_init() override
Declare parameters.
ControllerInterface(bool claim_all_state_interfaces=false)
Default constructor.
void add_state_interface(const std::string &name, const std::string &interface)
Add a state interface to the controller by name.
double get_command_interface(const std::string &name, const std::string &interface) const
Get the value of a command interface by name.
virtual CallbackReturn on_activate()
Activate the controller.
double get_state_interface(const std::string &name, const std::string &interface) const
Get the value of a state interface by name.
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.
void set_command_interface(const std::string &name, const std::string &interface, double value)
Set the value of a command interface by name.
std::string hardware_name_
The hardware name provided by a parameter.
virtual CallbackReturn on_deactivate()
Deactivate the controller.
void add_command_interface(const std::string &name, const std::string &interface)
Add a command interface to the controller by name.
controller_interface::InterfaceConfiguration state_interface_configuration() const final
Configure the state interfaces.