17 #ifndef ADMITTANCE_CONTROLLER__ADMITTANCE_RULE_HPP_
18 #define ADMITTANCE_CONTROLLER__ADMITTANCE_RULE_HPP_
26 #include "admittance_controller_parameters.hpp"
27 #include "control_msgs/msg/admittance_controller_state.hpp"
28 #include "controller_interface/controller_interface_base.hpp"
29 #include "kinematics_interface/kinematics_interface.hpp"
30 #include "pluginlib/class_loader.hpp"
31 #include "trajectory_msgs/msg/joint_trajectory_point.hpp"
38 Eigen::Isometry3d ref_base_ft_;
41 Eigen::Isometry3d base_ft_;
44 Eigen::Isometry3d base_control_;
47 Eigen::Isometry3d base_tip_;
50 Eigen::Isometry3d base_cog_;
52 Eigen::Isometry3d world_base_;
59 admittance_velocity.setZero();
60 admittance_acceleration.setZero();
65 selected_axes.setZero();
66 auto idx =
static_cast<Eigen::Index
>(num_joints);
67 current_joint_pos = Eigen::VectorXd::Zero(idx);
68 joint_pos = Eigen::VectorXd::Zero(idx);
69 joint_vel = Eigen::VectorXd::Zero(idx);
70 joint_acc = Eigen::VectorXd::Zero(idx);
73 Eigen::VectorXd current_joint_pos;
74 Eigen::VectorXd joint_pos;
75 Eigen::VectorXd joint_vel;
76 Eigen::VectorXd joint_acc;
77 Eigen::Matrix<double, 6, 1> damping;
78 Eigen::Matrix<double, 6, 1> mass;
79 Eigen::Matrix<double, 6, 1> mass_inv;
80 Eigen::Matrix<double, 6, 1> selected_axes;
81 Eigen::Matrix<double, 6, 1> stiffness;
82 Eigen::Matrix<double, 6, 1> wrench_base;
83 Eigen::Matrix<double, 6, 1> admittance_acceleration;
84 Eigen::Matrix<double, 6, 1> admittance_velocity;
85 Eigen::Isometry3d admittance_position;
86 Eigen::Matrix<double, 3, 3> rot_base_control;
87 Eigen::Isometry3d ref_trans_base_ft;
88 std::string ft_sensor_frame;
95 const std::shared_ptr<admittance_controller::ParamListener> & parameter_handler)
97 parameter_handler_ = parameter_handler;
98 parameters_ = parameter_handler_->get_params();
99 num_joints_ = parameters_.joints.size();
105 controller_interface::return_type
configure(
106 const std::shared_ptr<rclcpp_lifecycle::LifecycleNode> & node,
const size_t num_joint,
107 const std::string & robot_description);
110 controller_interface::return_type
reset(
const size_t num_joints);
120 const trajectory_msgs::msg::JointTrajectoryPoint & current_joint_state,
121 const trajectory_msgs::msg::JointTrajectoryPoint & reference_joint_state);
141 controller_interface::return_type
update(
142 const trajectory_msgs::msg::JointTrajectoryPoint & current_joint_state,
143 const geometry_msgs::msg::Wrench & measured_wrench,
144 const trajectory_msgs::msg::JointTrajectoryPoint & reference_joint_state,
145 const rclcpp::Duration & period,
146 trajectory_msgs::msg::JointTrajectoryPoint & desired_joint_states);
158 std::shared_ptr<admittance_controller::ParamListener> parameter_handler_;
159 admittance_controller::Params parameters_;
180 const geometry_msgs::msg::Wrench & measured_wrench,
181 const Eigen::Matrix<double, 3, 3> & sensor_world_rot,
182 const Eigen::Matrix<double, 3, 3> & cog_world_rot);
184 template <
typename T1,
typename T2>
185 void vec_to_eigen(
const std::vector<T1> & data, T2 & matrix);
191 std::shared_ptr<pluginlib::ClassLoader<kinematics_interface::KinematicsInterface>>
193 std::unique_ptr<kinematics_interface::KinematicsInterface> kinematics_;
196 Eigen::Matrix<double, 6, 1> wrench_world_;
205 Eigen::Vector3d cog_pos_;
208 Eigen::Vector3d end_effector_weight_;
211 control_msgs::msg::AdmittanceControllerState state_message_;
Definition: admittance_rule.hpp:92
bool calculate_admittance_rule(AdmittanceState &admittance_state, double dt)
Definition: admittance_rule_impl.hpp:233
bool get_all_transforms(const trajectory_msgs::msg::JointTrajectoryPoint ¤t_joint_state, const trajectory_msgs::msg::JointTrajectoryPoint &reference_joint_state)
Definition: admittance_rule_impl.hpp:147
controller_interface::return_type reset(const size_t num_joints)
Reset all values back to default.
Definition: admittance_rule_impl.hpp:87
controller_interface::return_type configure(const std::shared_ptr< rclcpp_lifecycle::LifecycleNode > &node, const size_t num_joint, const std::string &robot_description)
Configure admittance rule memory using number of joints.
Definition: admittance_rule_impl.hpp:37
void apply_parameters_update()
Definition: admittance_rule_impl.hpp:124
const control_msgs::msg::AdmittanceControllerState & get_controller_state()
Definition: admittance_rule_impl.hpp:347
controller_interface::return_type update(const trajectory_msgs::msg::JointTrajectoryPoint ¤t_joint_state, const geometry_msgs::msg::Wrench &measured_wrench, const trajectory_msgs::msg::JointTrajectoryPoint &reference_joint_state, const rclcpp::Duration &period, trajectory_msgs::msg::JointTrajectoryPoint &desired_joint_states)
Definition: admittance_rule_impl.hpp:175
void process_wrench_measurements(const geometry_msgs::msg::Wrench &measured_wrench, const Eigen::Matrix< double, 3, 3 > &sensor_world_rot, const Eigen::Matrix< double, 3, 3 > &cog_world_rot)
Definition: admittance_rule_impl.hpp:319
Definition: admittance_controller.hpp:40
Definition: admittance_rule.hpp:56