17 #ifndef __sot_torque_control_base_estimator_H__
18 #define __sot_torque_control_base_estimator_H__
25 #if defined(base_estimator_EXPORTS)
26 #define TALOS_BASE_ESTIMATOR_EXPORT __declspec(dllexport)
28 #define TALOS_BASE_ESTIMATOR_EXPORT __declspec(dllimport)
31 #define TALOS_BASE_ESTIMATOR_EXPORT
37 #include <pinocchio/fwd.hpp>
39 #include <dynamic-graph/signal-helper.h>
42 #include <sot/core/matrix-geometry.hh>
43 #include <sot/core/robot-utils.hh>
45 #include "boost/assign.hpp"
47 #include <boost/math/distributions/normal.hpp>
50 #include <pinocchio/algorithm/kinematics.hpp>
51 #include <pinocchio/multibody/model.hpp>
52 #include <pinocchio/parsers/urdf.hpp>
56 namespace talos_balance {
63 void se3Interp(
const pinocchio::SE3& s1,
const pinocchio::SE3& s2,
64 const double alpha, pinocchio::SE3& s12);
67 void rpyToMatrix(
double r,
double p,
double y, Eigen::Matrix3d& R);
70 void rpyToMatrix(
const Eigen::Vector3d& rpy, Eigen::Matrix3d& R);
73 void matrixToRpy(
const Eigen::Matrix3d& M, Eigen::Vector3d& rpy);
87 double wEulerMean(
double a1,
double a2,
double w1,
double w2);
90 :
public ::dynamicgraph::Entity {
92 typedef pinocchio::SE3 SE3;
93 typedef Eigen::Vector2d Vector2;
94 typedef Eigen::Vector3d
Vector3;
95 typedef Eigen::Vector4d Vector4;
97 typedef Vector7d Vector7;
98 typedef Eigen::Matrix3d Matrix3;
99 typedef boost::math::normal normal;
101 DYNAMIC_GRAPH_ENTITY_DECL();
104 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
109 void init(
const double&
dt,
const std::string& urdfFile);
111 void set_fz_stable_windows_size(
const int& ws);
112 void set_alpha_w_filter(
const double& a);
113 void set_alpha_DC_acc(
const double& a);
114 void set_alpha_DC_vel(
const double& a);
115 void reset_foot_positions();
116 void set_imu_weight(
const double& w);
117 void set_zmp_std_dev_right_foot(
const double& std_dev);
118 void set_zmp_std_dev_left_foot(
const double& std_dev);
119 void set_normal_force_std_dev_right_foot(
const double& std_dev);
120 void set_normal_force_std_dev_left_foot(
const double& std_dev);
125 void set_zmp_margin_right_foot(
const double& margin);
126 void set_zmp_margin_left_foot(
const double& margin);
127 void set_normal_force_margin_right_foot(
const double& margin);
128 void set_normal_force_margin_left_foot(
const double& margin);
130 void reset_foot_positions_impl(
const Vector6& ftlf,
const Vector6& ftrf);
131 void compute_zmp(
const Vector6& w, Vector2& zmp);
132 double compute_zmp_weight(
const Vector2& zmp,
const Vector4& foot_sizes,
133 double std_dev,
double margin);
134 double compute_force_weight(
double fz,
double std_dev,
double margin);
135 void kinematics_estimation(
const Vector6& ft,
const Vector6&
K,
137 const pinocchio::FrameIndex foot_id, SE3& oMff,
138 SE3& oMfa, SE3& fsMff);
216 virtual void display(std::ostream& os)
const;
double m_fz_margin_lf
margin used for computing zmp weight
SE3 m_oMlfs
world-to-base transformation obtained through right foot
DECLARE_SIGNAL_IN(dforceRLEG, dynamicgraph::Vector)
derivative of left force torque sensor
DECLARE_SIGNAL_OUT(q_rf, dynamicgraph::Vector)
n+6 robot configuration with base6d in RPY
DECLARE_SIGNAL_OUT(v_gyr, dynamicgraph::Vector)
DECLARE_SIGNAL_OUT(rf_xyzquat, dynamicgraph::Vector)
left foot pose
Eigen::VectorXd m_v_pin
robot configuration according to SoT convention
Vector3 m_a_ac
velocity of the base in the world with DC component removed
pinocchio::FrameIndex m_left_foot_id
bool m_isFirstIterFlag
Normal distribution.
Vector4 m_right_foot_sizes
DECLARE_SIGNAL_IN(imu_quaternion, dynamicgraph::Vector)
Eigen::VectorXd m_v_kin
6d stiffness of left foot spring
DECLARE_SIGNAL_IN(lf_ref_xyzquat, dynamicgraph::Vector)
RobotUtilShrPtr m_robot_util
sampling time step
DECLARE_SIGNAL_OUT(v_flex, dynamicgraph::Vector)
DECLARE_SIGNAL_IN(w_rf_in, double)
weight of the estimation coming from the left foot
Vector3 m_last_vel
base orientation in the world
pinocchio::Data * m_data
Pinocchio robot model.
pinocchio::FrameIndex m_torso_id
DECLARE_SIGNAL_IN(forceRLEG, dynamicgraph::Vector)
DECLARE_SIGNAL_IN(forceLLEG, dynamicgraph::Vector)
double m_zmp_margin_rf
margin used for computing zmp weight
DECLARE_SIGNAL_IN(rf_ref_xyzquat, dynamicgraph::Vector)
DECLARE_SIGNAL_IN(accelerometer, dynamicgraph::Vector)
DECLARE_SIGNAL_OUT(w_lf_filtered, double)
weight of the estimation coming from the right foot
DECLARE_SIGNAL_IN(w_lf_in, double)
derivative of right force torque sensor
double m_zmp_std_dev_rf
weight of IMU for sensor fusion
bool m_left_foot_is_stable
DECLARE_SIGNAL_OUT(w_rf_filtered, double)
filtered weight of the estimation coming from the left foot
double m_dt
true after the command resetFootPositions is called
DECLARE_SIGNAL_OUT(v, dynamicgraph::Vector)
n+6 robot configuration with base6d in RPY
DECLARE_SIGNAL_OUT(a_ac, dynamicgraph::Vector)
right foot pose
double m_fz_margin_rf
margin used for computing normal force weight
DECLARE_SIGNAL_OUT(v_kin, dynamicgraph::Vector)
n+6 robot velocities
Matrix3 m_oRff
chest orientation in the world from angular fusion
DECLARE_SIGNAL_OUT(v_ac, dynamicgraph::Vector)
pinocchio::FrameIndex m_IMU_frame_id
DECLARE_SIGNAL_IN(joint_velocities, dynamicgraph::Vector)
DECLARE_SIGNAL_OUT(q, dynamicgraph::Vector)
DECLARE_SIGNAL_OUT(w_lf, double)
n+6 robot configuration with base6d in RPY
DECLARE_SIGNAL_OUT(q_lf, dynamicgraph::Vector)
pinocchio::SE3 m_torsoMimu
Pinocchio robot data.
DECLARE_SIGNAL_OUT(q_imu, dynamicgraph::Vector)
n+6 robot configuration with base6d in RPY
Vector4 m_left_foot_sizes
Matrix3 m_oRtorso
robot velocities according to SoT convention
DECLARE_SIGNAL_INNER(kinematics_computations, dynamicgraph::Vector)
DECLARE_SIGNAL_OUT(lf_xyzquat, dynamicgraph::Vector)
Eigen::VectorXd m_v_sot
robot velocities according to pinocchio convention
int m_fz_stable_windows_size
Eigen::VectorXd m_q_sot
robot configuration according to pinocchio convention
pinocchio::SE3 m_oMff_rf
world-to-base transformation obtained through left foot
Vector6 m_K_rf
margin used for computing normal force weight
DECLARE_SIGNAL_OUT(v_imu, dynamicgraph::Vector)
bool m_reset_foot_pos
true if the entity has been successfully initialized
DECLARE_SIGNAL_IN(K_fb_feet_poses, double)
weight of the estimation coming from the right foot
Vector7 m_oMlfs_xyzquat
transformation from world to right foot sole
DECLARE_SIGNAL_IN(joint_positions, dynamicgraph::Vector)
DECLARE_SIGNAL_IN(gyroscope, dynamicgraph::Vector)
bool m_right_foot_is_stable
SE3 m_oMrfs
transformation from world to left foot sole
pinocchio::FrameIndex m_right_foot_id
foot sole to F/T sensor transformation
DECLARE_SIGNAL_IN(dforceLLEG, dynamicgraph::Vector)
DECLARE_SIGNAL_OUT(w_rf, double)
weight of the estimation coming from the left foot
pinocchio::SE3 m_oMff_lf
chest to imu transformation
Vector6 m_K_lf
6d stiffness of right foot spring
Eigen::Matrix< Scalar, 6, 1 > Vector6
Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > Vector
Eigen::Matrix< Scalar, 3, 1 > Vector3
AdmittanceControllerEndEffector EntityClassName
double wEulerMean(double a1, double a2, double w1, double w2)
double eulerMean(double a1, double a2)
void se3Interp(const pinocchio::SE3 &s1, const pinocchio::SE3 &s2, const double alpha, pinocchio::SE3 &s12)
void rpyToMatrix(double r, double p, double y, Eigen::Matrix3d &R)
void matrixToRpy(const Eigen::Matrix3d &M, Eigen::Vector3d &rpy)
#define TALOS_BASE_ESTIMATOR_EXPORT