Modulo 5.0.0
Loading...
Searching...
No Matches
RobotControllerInterface.hpp
1#pragma once
2
3#include <realtime_tools/realtime_buffer.h>
4
5#include <robot_model/Model.hpp>
6#include <state_representation/space/cartesian/CartesianState.hpp>
7#include <state_representation/space/cartesian/CartesianWrench.hpp>
8#include <state_representation/space/joint/JointState.hpp>
9
10#include "modulo_controllers/ControllerInterface.hpp"
11
12namespace modulo_controllers {
13
24public:
29
37 bool robot_model_required, const std::string& control_type = "", bool load_geometries = false);
38
43 CallbackReturn add_interfaces() override;
44
50 CallbackReturn on_configure() override;
51
56 CallbackReturn on_activate() override;
57
62 CallbackReturn on_deactivate() override;
63
64protected:
69 const state_representation::JointState& get_joint_state();
70
76 const state_representation::CartesianState& get_cartesian_state();
77
82 const state_representation::CartesianWrench& get_ft_sensor();
83
90
95 void set_joint_command(const state_representation::JointState& joint_command);
96
100 bool
101 on_validate_parameter_callback(const std::shared_ptr<state_representation::ParameterInterface>& parameter) override;
102
103 std::shared_ptr<robot_model::Model> robot_;
104 std::string task_space_frame_;
105
106 std::string ft_sensor_name_;
108
109private:
114 controller_interface::return_type read_state_interfaces() final;
115
120 controller_interface::return_type write_command_interfaces(const rclcpp::Duration& period) final;
121
122 std::vector<std::string> joints_;
123 std::string control_type_;
124
125 bool robot_model_required_;
126 bool load_geometries_;
127 bool
128 new_joint_command_ready_;
129 double
130 command_decay_factor_;
131 double
132 command_rate_limit_;
133
134 realtime_tools::RealtimeBuffer<std::vector<double>> joint_command_values_;
135 std::vector<double> previous_joint_command_values_;
136
137 state_representation::JointState joint_state_;
138 state_representation::CartesianState cartesian_state_;
139 state_representation::CartesianWrench ft_sensor_;
140};
141
142}// namespace modulo_controllers
Base controller class that automatically associates joints with a JointState object.
std::string ft_sensor_name_
The name of a force torque sensor in the hardware description.
const state_representation::CartesianState & get_cartesian_state()
Access the Cartesian state object.
CallbackReturn on_activate() override
Activate the controller.
bool on_validate_parameter_callback(const std::shared_ptr< state_representation::ParameterInterface > &parameter) override
Parameter validation function to be redefined by derived controller classes.
const state_representation::JointState & get_joint_state()
Access the joint state object.
std::string ft_sensor_reference_frame_
The sensing reference frame.
CallbackReturn on_deactivate() override
Deactivate the controller.
const state_representation::CartesianWrench & get_ft_sensor()
Access the Cartesian wrench object.
std::shared_ptr< robot_model::Model > robot_
Robot model object generated from URDF.
void compute_cartesian_state()
Compute the Cartesian state from forward kinematics of the current joint state.
void set_joint_command(const state_representation::JointState &joint_command)
Set the joint command object.
CallbackReturn add_interfaces() override
Add interfaces like parameters, signals, services, and predicates to the controller.
std::string task_space_frame_
The frame in task space for forward kinematics calculations, if applicable.
CallbackReturn on_configure() override
Configure the controller.