12#ifndef LIPMDCMBIASESTIMATOR_HPP
13#define LIPMDCMBIASESTIMATOR_HPP
15#include <state-observation/api.h>
74 constexpr static double defaultDt_ = 0.005;
75 constexpr static double defaultOmega_ =
tools::sqrt(cst::gravityConstant);
83 constexpr static double defaultDcmErrorStd = 0.01;
87 constexpr static double defaultBiasUncertainty = 0.01;
109 double omega_0 = defaultOmega_,
111 double dcmMeasureErrorStd = defaultDcmErrorStd,
114 const Vector2 & initZMP = Vector2::Zero(),
115 const Vector2 & initDcm = Vector2::Zero(),
116 const Vector2 & initBias = Vector2::Zero(),
118 const Vector2 & initBiasUncertainty = Vector2::Constant(defaultBiasUncertainty));
133 const Matrix2 & yaw = Matrix2::Identity(),
134 bool measurementIsWithBias =
true,
135 const Vector2 & initBias = Vector2::Constant(0),
136 const Vector2 & initBiasuncertainty = Vector2::Constant(defaultBiasUncertainty));
152 bool measurementIsWithBias =
true,
153 const Vector2 & initBias = Vector2::Constant(0),
154 const Vector2 & initBiasuncertainty = Vector2::Constant(defaultBiasUncertainty))
157 initBiasuncertainty);
175 bool measurementIsWithBias =
true,
176 const Vector2 & initBias = Vector2::Constant(0),
177 const Vector2 & initBiasuncertainty = Vector2::Constant(defaultBiasUncertainty))
180 measurementIsWithBias, initBias, initBiasuncertainty);
284 const Vector2 & CoMOffset_gamma = Vector2::Zero(),
285 const double ZMPCoef_kappa = 1)
301 const Vector2 & CoMOffset_gamma = Vector2::Zero(),
302 const double ZMPCoef_kappa = 1)
316 const Matrix2 & R = Matrix2::Identity(),
317 const Vector2 & CoMOffset_gamma = Vector2::Zero(),
318 const double ZMPCoef_kappa = 1);
341 return previousOrientation_.transpose() *
getBias();
360 typedef Eigen::Matrix<double, 4, 2> Matrix42;
361 typedef Eigen::Matrix<double, 2, 4> Matrix24;
367 Vector2 gamma_ = Vector2::Zero();
370 double biasDriftStd_;
373 bool needUpdateMatrices_ =
true;
394 return Vector2(v.array().square()).asDiagonal();
400 return Vector2::Constant(d).asDiagonal();
410 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
The class of a Linear Kalman filter.
void setZMPCoef(double kappa)
Set the ZMP oefficient.
void setBias(const Vector2 &bias)
Set the Bias object from a guess.
void setZmpMeasureErrorStd(double)
Set the Zmp Measurement Error Stamdard devbiation.
void setLipmNaturalFrequency(double omega_0)
Set the Lipm Natural Frequency.
static constexpr double defaultZmpErrorStd
default error in the estimation of the sensors
double getZMPCoef() const
get the ZMP Coefficient
static constexpr double defaultBiasLimit
default value for Bias limit (negative means limitless)
~LipmDcmEstimator()
Destroy the Lipm Dcm Bias Estimator object.
static Matrix2 dblToSqDiag_(const double &d)
builds a constant 2x2 diagonal from a square of a double
Matrix24 C_
this needs to be transposed
void setBiasLimit(const Vector2 &biasLimit)
Set the Bias Limit.
double getLipmNaturalFrequency() const
Get the Lipm Natural Frequency.
Vector2 getLocalBias() const
Get the estimated Bias expressed in the local frame of the robot.
LipmDcmEstimator(double dt=defaultDt_, double omega_0=defaultOmega_, double biasDriftPerSecondStd=defaultBiasDriftSecond, double dcmMeasureErrorStd=defaultDcmErrorStd, double zmpMeasureErrorStd=defaultZmpErrorStd, const Vector2 &biasLimit=Vector2::Constant(defaultBiasLimit), const Vector2 &initZMP=Vector2::Zero(), const Vector2 &initDcm=Vector2::Zero(), const Vector2 &initBias=Vector2::Zero(), const Vector2 &initDcmUncertainty=Vector2::Constant(defaultDCMUncertainty), const Vector2 &initBiasUncertainty=Vector2::Constant(defaultBiasUncertainty))
Construct a new Lipm Dcm Estimator object.
static Matrix2 dblToDiag_(const double &d)
builds a constant 2x2 diagonal from a double
Vector2 getUnbiasedDCM() const
Get the Unbiased DCM filtered by the estimator.
void setUnbiasedDCM(const Vector2 &dcm)
set the unbiased DCM position from a guess
void setUnbiasedCoMOffset(const Vector2 &gamma)
Set an offset on the CoM dynamics.
void update()
Runs the estimation. Needs to be called every timestep.
void setInputs(const Vector2 &dcm, const Vector2 &zmp, const Matrix3 &orientation, const Vector2 &CoMOffset_gamma=Vector2::Zero(), const double ZMPCoef_kappa=1)
Set the Inputs of the estimator.
static Matrix2 Vec2ToSqDiag_(const Vector2 &v)
builds a diagonal out of the square valued of the Vec2
static constexpr double defaultDCMUncertainty
default uncertainty in the initial values of DCM and Bias
void setBias(const Vector2 &bias, const Vector2 &uncertainty)
Set the Bias object from a guess.
void setInputs(const Vector2 &dcm, const Vector2 &zmp, const Matrix2 &R=Matrix2::Identity(), const Vector2 &CoMOffset_gamma=Vector2::Zero(), const double ZMPCoef_kappa=1)
Set the Inputs of the estimator.
void updateMatricesABQ_()
set Matrices: A, B, Q
Vector2 getBias() const
Get the estimated Bias.
Matrix2 R_
measurement noise
void resetWithMeasurements(const Vector2 &measuredDcm, const Vector2 &measuredZMP, double yaw, bool measurementIsWithBias=true, const Vector2 &initBias=Vector2::Constant(0), const Vector2 &initBiasuncertainty=Vector2::Constant(defaultBiasUncertainty))
Resets the estimator with first measurements.
Vector2 getUnbiasedCoMOffset() const
Get the ubiased offset on the CoM dynamics.
void setUnbiasedDCM(const Vector2 &dcm, const Vector2 &uncertainty)
void resetWithMeasurements(const Vector2 &measuredDcm, const Vector2 &measuredZMP, const Matrix2 &yaw=Matrix2::Identity(), bool measurementIsWithBias=true, const Vector2 &initBias=Vector2::Constant(0), const Vector2 &initBiasuncertainty=Vector2::Constant(defaultBiasUncertainty))
Resets the estimator with first measurements.
void setInputs(const Vector2 &dcm, const Vector2 &zmp, double yaw, const Vector2 &CoMOffset_gamma=Vector2::Zero(), const double ZMPCoef_kappa=1)
Set the Inputs of the estimator.
const LinearKalmanFilter & getFilter() const
Get the Kalman Filter object This can be used to run specific Advanced Kalman filter related funcions...
void setDcmMeasureErrorStd(double)
Set the Dcm Measurement Error Standard.
LinearKalmanFilter & getFilter()
Get the Kalman Filter object This can be used to run specific Advanced Kalman filter related funcions...
void resetWithMeasurements(const Vector2 &measuredDcm, const Vector2 &measuredZMP, const Matrix3 &rotation, bool measurementIsWithBias=true, const Vector2 &initBias=Vector2::Constant(0), const Vector2 &initBiasuncertainty=Vector2::Constant(defaultBiasUncertainty))
Resets the estimator with first measurements.
static constexpr double defaultBiasDriftSecond
default expected drift of the bias every second
void setSamplingTime(double dt)
Set the Sampling Time.
void setBiasDriftPerSecond(double driftPerSecond)
Set the Bias Drift Per Second.
Defines the class of a Linear Kalman filter.
Gathers many kinds of algorithms.
double constexpr sqrt(double x)
Constexpr version of the square root.
Filtering of divergent component of motion (DCM) and estimation of a bias betweeen the DCM and the co...
Eigen::Matrix4d Matrix4
4x4 Scalar Matrix
Eigen::Rotation2D< double > Rotation2D
2D rotations
Eigen::Matrix2d Matrix2
2D scalar Matrix
Eigen::Matrix3d Matrix3
3x3 Scalar Matrix
Eigen::Matrix< double, 2, 1 > Vector2
2d Vector
Implements integrators for the kinematics, in terms or rotations and translations.
double rotationMatrixToYawAxisAgnostic(const Matrix3 &rotation)
take 3x3 matrix represeting a rotation and gives a corresponding angle around upward vertical axis