ros2_control - kilted
Loading...
Searching...
No Matches
fts_grav_comp_plugin.hpp
1
20#ifndef MUJOCO_ROS2_CONTROL_PLUGINS__FTS_GRAV_COMP_PLUGIN_HPP_
21#define MUJOCO_ROS2_CONTROL_PLUGINS__FTS_GRAV_COMP_PLUGIN_HPP_
22
23#include <geometry_msgs/msg/wrench.hpp>
24#include <rclcpp/rclcpp.hpp>
25#include "mujoco_ros2_control_plugins/mujoco_ros2_control_plugins_base.hpp"
26
28{
29
35struct FtsData
36{
37 // sensor name of FTS. Mujoco should have sensors <sensor_name>_force and <sensor_name>_torque
38 std::string sensor_name;
39 // mujoco sensor address for the force and torque sensors
40 int sensor_adr_force{ -1 };
41 int sensor_adr_torque{ -1 };
42 // site id of the site used for center of gravity reference
43 int cog_site_id{ -1 };
44 // array of doubles of the center of gravity w.r.t. cog_site_it in meters for [x, y, z]
45 mjtNum cog_pos[3];
46 // mass that is being compensated in kg
47 mjtNum cog_mass;
48 // site id of the site used for the mujoco force and torque sensors
49 int fts_site_id{ -1 };
50};
51
56{
57public:
58 FtsGravCompPlugin() = default;
59 ~FtsGravCompPlugin() override = default;
60
65 std::vector<std::string> get_sensor_names_from_parameters();
66
71 bool register_fts(const mjModel* model);
72
76 bool init(rclcpp::Node::SharedPtr node, const mjModel* model, mjData* data) override;
77
81 void update_read(const mjModel* model, mjData* data) override;
82
86 void cleanup() override;
87
91 std::vector<FtsData> get_fts_data() const
92 {
93 return fts_;
94 }
95
96private:
97 rclcpp::Node::SharedPtr node_;
98 rclcpp::Logger logger_ = rclcpp::get_logger("FtsGravCompPlugin");
99
100 std::vector<FtsData> fts_;
101};
102
103} // namespace mujoco_ros2_control_plugins
104
105#endif // MUJOCO_ROS2_CONTROL_PLUGINS__FTS_GRAV_COMP_PLUGIN_HPP_
Plugin that runs gravity compensation on a force torque sensor.
Definition fts_grav_comp_plugin.hpp:56
std::vector< FtsData > get_fts_data() const
getter for fts data used for testing
Definition fts_grav_comp_plugin.hpp:91
void cleanup() override
Cleanup the plugin.
Definition fts_grav_comp_plugin.cpp:220
std::vector< std::string > get_sensor_names_from_parameters()
Parses the params file and returns a vector of unique sensor names.
Definition fts_grav_comp_plugin.cpp:26
bool init(rclcpp::Node::SharedPtr node, const mjModel *model, mjData *data) override
Initialize the plugin.
Definition fts_grav_comp_plugin.cpp:150
bool register_fts(const mjModel *model)
Register force torque sensors from the model that match the params.
Definition fts_grav_comp_plugin.cpp:68
void update_read(const mjModel *model, mjData *data) override
Compensate the force/torque sensors in the state read by ros2_control.
Definition fts_grav_comp_plugin.cpp:168
Base class for MuJoCo ROS 2 control plugins.
Definition mujoco_ros2_control_plugins_base.hpp:52
Definition mujoco_ros2_control_plugins_base.hpp:22
Per-FTS bookkeeping -.
Definition fts_grav_comp_plugin.hpp:36