12#ifndef KINETICSOBSERVER_HPP
13#define KINETICSOBSERVER_HPP
17#include <boost/utility.hpp>
19#include <state-observation/api.h>
20#include <state-observation/dynamical-system/dynamical-system-functor-base.hpp>
22#include <state-observation/observer/extended-kalman-filter.hpp>
26#include <state-observation/tools/state-vector-arithmetics.hpp>
190 const Kinematics & userImuKinematics,
204 const Kinematics & userImuKinematics,
284 const Matrix12 & initialCovarianceMatrix,
285 const Matrix12 & processCovarianceMatrix,
286 Index contactNumber = -1,
287 const Matrix3 & linearStiffness = Matrix3::Constant(-1),
288 const Matrix3 & linearDamping = Matrix3::Constant(-1),
289 const Matrix3 & angularStiffness = Matrix3::Constant(-1),
290 const Matrix3 & angularDamping = Matrix3::Constant(-1));
308 Index contactNumber = -1,
309 const Matrix3 & linearStiffness = Matrix3::Constant(-1),
310 const Matrix3 & linearDamping = Matrix3::Constant(-1),
311 const Matrix3 & angularStiffness = Matrix3::Constant(-1),
312 const Matrix3 & angularDamping = Matrix3::Constant(-1));
356 const Kinematics & localKine,
357 unsigned contactNumber);
365 const Matrix6 & wrenchCovMatrix,
366 const Kinematics & localKine,
367 unsigned contactNumber);
475 const Vector3 & momentUserFrame,
477 Vector3 & momentCentroidFrame);
557 bool resetContactWrenches =
true,
558 bool resetCovariance =
true);
576 Kinematics worldContactRestPose,
578 bool resetCovariance =
true);
701 void resetStateKinematicsCovMat();
702 void resetStateGyroBiasCovMat(Index i);
703 void resetStateUnmodeledWrenchCovMat();
704 void resetStateContactsCovMat();
705 void resetStateContactCovMat(Index contactNbr);
707 void resetProcessCovarianceMat();
708 void resetProcessKinematicsCovMat();
709 void resetProcessGyroBiasCovMat(Index i);
710 void resetProcessUnmodeledWrenchCovMat();
711 void resetProcessContactsCovMat();
712 void resetProcessContactCovMat(Index contactNbr);
1001 Sensor(Index signalSize) : measIndex(-1), measIndexTangent(-1), size(signalSize), time(0) {}
1004 Index measIndexTangent;
1010 return v.segment(size, measIndex);
1014 struct IMU :
public Sensor
1017 IMU() : Sensor(sizeIMUSignal) {}
1019 Kinematics userImuKinematics;
1020 LocalKinematics centroidImuKinematics;
1026 Index stateIndexTangent;
1028 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
1031 typedef std::vector<IMU, Eigen::aligned_allocator<IMU>> VectorIMU;
1032 typedef VectorIMU::iterator VectorIMUIterator;
1033 typedef VectorIMU::const_iterator VectorIMUConstIterator;
1035 struct Contact :
public Sensor
1037 Contact() : Sensor(sizeWrench),
isSet(
false), withRealSensor(
false), stateIndex(-1), stateIndexTangent(-1)
1062 bool withRealSensor;
1064 Index stateIndexTangent;
1066 static const Kinematics::Flags::Byte contactKineFlags =
1067 Kinematics::Flags::position | Kinematics::Flags::orientation | Kinematics::Flags::linVel
1068 | Kinematics::Flags::angVel;
1070 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
1073 typedef std::vector<Contact, Eigen::aligned_allocator<Contact>> VectorContact;
1074 typedef VectorContact::iterator VectorContactIterator;
1075 typedef VectorContact::const_iterator VectorContactConstIterator;
1077 struct AbsolutePoseSensor :
public Sensor
1079 AbsolutePoseSensor() : Sensor(sizePose) {}
1082 static const Kinematics::Flags::Byte poseFlags = Kinematics::Flags::position | Kinematics::Flags::orientation;
1083 CheckedMatrix6 covMatrix;
1086 struct AbsoluteOriSensor :
public Sensor
1088 AbsoluteOriSensor() : Sensor(sizePose) {}
1091 CheckedMatrix3 covMatrix;
1133 const Vector3 & centroidContactForce,
1134 const Vector3 & centroidContactTorque,
1136 Vector3 & totalCentroidTorque);
1150 const Vector3 & totalForceLocal,
1151 const Vector3 & totalMomentLocal,
1162 LocalKinematics & worldCentroidStateKinematics,
1163 Kinematics & worldRestContactPose,
1225 Index getContactMeasIndexByNum(Index num)
const;
1227 bool getContactIsSetByNum(Index num)
const;
1279 virtual Matrix computeAMatrix();
1281 virtual Matrix computeCMatrix();
1290 double relativeErrorThreshold,
1298 double relativeErrorThreshold,
1303 double relativeErrorThreshold,
1310 double relativeErrorThreshold,
1315 void stateNaNCorrection_();
1325 unsigned maxContacts_;
1326 unsigned maxImuNumber_;
1330 VectorContact contacts_;
1331 VectorIMU imuSensors_;
1334 Index stateTangentSize_;
1335 Index measurementSize_;
1336 Index measurementTangentSize_;
1338 Vector worldCentroidStateVector_;
1339 Vector worldCentroidStateVectorDx_;
1340 Vector oldWorldCentroidStateVector_;
1342 LocalKinematics worldCentroidStateKinematics_;
1343 Kinematics worldCentroidKinematics_;
1348 Vector3 initTotalCentroidForce_;
1349 Vector3 initTotalCentroidTorque_;
1351 Vector measurementVector_;
1352 Matrix measurementCovMatrix_;
1355 bool finiteDifferencesJacobians_;
1357 bool withUnmodeledWrench_;
1358 bool withAccelerationEstimation_;
1360 IndexedVector3 com_, comd_, comdd_;
1361 IndexedVector3 sigma_, sigmad_;
1362 IndexedMatrix3 I_, Id_;
1374 Index numberOfContactRealSensors_;
1375 Index currentIMUSensorNumber_;
1403 inline Index
contactIndex(VectorContactConstIterator i)
const;
1421 inline static constexpr Index sizeAcceleroSignal = 3;
1422 inline static constexpr Index sizeGyroSignal = 3;
1423 inline static constexpr Index sizeIMUSignal = sizeAcceleroSignal + sizeGyroSignal;
1425 inline static constexpr Index sizePos = 3;
1426 inline static constexpr Index sizePosTangent = 3;
1427 inline static constexpr Index sizeOri = 4;
1428 inline static constexpr Index sizeOriTangent = 3;
1429 inline static constexpr Index sizeLinVel = sizePos;
1430 inline static constexpr Index sizeLinVelTangent = sizeLinVel;
1431 inline static constexpr Index sizeLinAccTangent = sizeLinVelTangent;
1432 inline static constexpr Index sizeAngVel = sizeOriTangent;
1433 inline static constexpr Index sizeAngVelTangent = sizeAngVel;
1434 inline static constexpr Index sizeGyroBias = sizeGyroSignal;
1435 inline static constexpr Index sizeGyroBiasTangent = sizeGyroBias;
1437 inline static constexpr Index sizeForce = 3;
1438 inline static constexpr Index sizeForceTangent = sizeForce;
1439 inline static constexpr Index sizeTorque = 3;
1440 inline static constexpr Index sizeTorqueTangent = sizeTorque;
1442 inline static constexpr Index sizeWrench = sizeForce + sizeTorque;
1444 inline static constexpr Index sizeStateKine = sizePos + sizeOri + sizeLinVel + sizeAngVel;
1445 inline static constexpr Index sizeStateBase = sizeStateKine + sizeForce + sizeTorque;
1446 inline static constexpr Index sizeStateKineTangent = sizePos + sizeOriTangent + sizeLinVel + sizeAngVel;
1447 inline static constexpr Index sizeStateTangentBase = sizeStateKineTangent + sizeForce + sizeTorque;
1449 inline static constexpr Index sizePose = sizePos + sizeOri;
1450 inline static constexpr Index sizePoseTangent = sizePos + sizeOriTangent;
1452 inline static constexpr Index sizeContactKine = sizePose;
1453 inline static constexpr Index sizeContactKineTangent = sizePoseTangent;
1455 inline static constexpr Index sizeContact = sizeContactKine + sizeWrench;
1456 inline static constexpr Index sizeContactTangent = sizeContactKineTangent + sizeWrench;
1458 inline static constexpr Kinematics::Flags::Byte flagsStateKine =
1459 Kinematics::Flags::position | Kinematics::Flags::orientation | Kinematics::Flags::linVel
1460 | Kinematics::Flags::angVel;
1462 inline static constexpr Kinematics::Flags::Byte flagsContactKine =
1463 Kinematics::Flags::position | Kinematics::Flags::orientation;
1465 inline static constexpr Kinematics::Flags::Byte flagsPoseKine =
1466 Kinematics::Flags::position | Kinematics::Flags::orientation;
1468 inline static constexpr Kinematics::Flags::Byte flagsPosKine = Kinematics::Flags::position;
1470 inline static constexpr Kinematics::Flags::Byte flagsIMUKine =
1471 Kinematics::Flags::position | Kinematics::Flags::orientation | Kinematics::Flags::linVel
1472 | Kinematics::Flags::angVel | Kinematics::Flags::linAcc | Kinematics::Flags::angAcc;
1475 static const double defaultMass;
1477 static const double statePoseInitVarianceDefault;
1478 static const double stateOriInitVarianceDefault;
1479 static const double stateLinVelInitVarianceDefault;
1480 static const double stateAngVelInitVarianceDefault;
1481 static const double gyroBiasInitVarianceDefault;
1482 static const double unmodeledWrenchInitVarianceDefault;
1483 static const double contactForceInitVarianceDefault;
1484 static const double contactTorqueInitVarianceDefault;
1486 static const double statePoseProcessVarianceDefault;
1487 static const double stateOriProcessVarianceDefault;
1488 static const double stateLinVelProcessVarianceDefault;
1489 static const double stateAngVelProcessVarianceDefault;
1490 static const double gyroBiasProcessVarianceDefault;
1491 static const double unmodeledWrenchProcessVarianceDefault;
1492 static const double contactPositionProcessVarianceDefault;
1493 static const double contactOrientationProcessVarianceDefault;
1494 static const double contactForceProcessVarianceDefault;
1495 static const double contactTorqueProcessVarianceDefault;
1497 static const double acceleroVarianceDefault;
1498 static const double gyroVarianceDefault;
1499 static const double forceSensorVarianceDefault;
1500 static const double torqueSensorVarianceDefault;
1501 static const double positionSensorVarianceDefault;
1502 static const double orientationSensorVarianceDefault;
1504 static const double linearStiffnessDefault;
1505 static const double angularStiffnessDefault;
1506 static const double linearDampingDefault;
1507 static const double angularDampingDefault;
1511 bool nanDetected_ =
false;
1512 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
1517 Matrix3 angularStiffnessMatDefault_;
1518 Matrix3 linearDampingMatDefault_;
1519 Matrix3 angularDampingMatDefault_;
1522 Matrix3 acceleroCovMatDefault_;
1524 Matrix6 contactWrenchSensorCovMatDefault_;
1525 Matrix6 absPoseSensorCovMatDefault_;
1526 Matrix3 absOriSensorCovMatDefault_;
1530 Matrix3 stateLinVelInitCovMat_;
1531 Matrix3 stateAngVelInitCovMat_;
1533 Matrix6 unmodeledWrenchInitCovMat_;
1534 Matrix12 contactInitCovMatDefault_;
1536 Matrix3 statePosProcessCovMat_;
1537 Matrix3 stateOriProcessCovMat_;
1538 Matrix3 stateLinVelProcessCovMat_;
1539 Matrix3 stateAngVelProcessCovMat_;
1540 Matrix3 gyroBiasProcessCovMat_;
1541 Matrix6 unmodeledWrenchProcessCovMat_;
1542 Matrix3 contactPositionProcessCovMat_;
1543 Matrix3 contactOrientationProcessCovMat_;
1544 Matrix3 contactForceProcessCovMat_;
1545 Matrix3 contactTorqueProcessCovMat_;
1546 Matrix12 contactProcessCovMatDefault_;
1548 Matrix12 stateKinematicsInitCovMat_;
1549 Matrix12 stateKinematicsProcessCovMat_;
1557 Opt() : locKine(locKine1), ori(locKine.orientation), ori1(locKine1.orientation), ori2(locKine2.orientation) {}
1559 LocalKinematics locKine1, locKine2;
1560 LocalKinematics & locKine;
1569 const Kinematics & userImuKinematics,
1575#include <state-observation/dynamics-estimators/kinetics-observer.hxx>
Implements the accelerometer-gyrometer inertial measuremen.
virtual void measurementDifference(const Vector &measureVector1, const Vector &measureVector2, Vector &difference)
the difference operator for the measurement statevector1 ⊖ statevector2
Index getIMUMeasIndexByNum(Index num) const
Get the measurement index of the required IMU : allows to access its corresponding measurements in th...
LocalKinematics getLocalCentroidKinematics() const
Get the estimated local Kinematics of the centroid frame in the world frame (local,...
Vector6 getCentroidContactWrench(Index numContact) const
Returns the wrench exerted at the contact, expressed in the frame of the centroid.
Kinematics getContactPosition(Index contactNbr) const
Get the Contact 6D pose n in the global frame.
void setKinematicsProcessCovarianceDefault(const Matrix3 &P_pos, const Matrix3 &P_ori, const Matrix3 &P_linVel, const Matrix3 &P_angVel)
Set the default Kinematics Process Covariance.
friend int testAccelerationsJacobians(KineticsObserver &ko, int errcode, double relativeErrorThreshold, double threshold)
Comparison between the Jacobians of the linear and angular accelerations with respect to the state,...
Index getStateTangentSize() const
Get the State Vector Tangent Size.
Kinematics getGlobalKinematicsOf(const Kinematics &userBodyKin) const
Get the global kinematics of a given frame (in the user frame) in the centroid frame.
Index contactForceIndexTangent(Index contactNbr) const
Get the index of the linear force of a specific contact in the tangent sate vector.
void setStateVector(const Vector &newvalue, bool resetCovariance=true)
Set a value of the state x_k provided from another source.
Vector getMeasurementVector()
Get the Measurement Vector.
Index kineIndexTangent() const
Get the kinematics index of the tangent state vector.
Index linVelIndex() const
Get the linear velocity index of the state vector.
Index posIndex() const
Get the position index of the state vector.
void setUnmodeledWrenchInitCovMatDefault(const Matrix6 &initCovMat)
Set the default value for init Unmodeled Wrench covariance matrix.
void setAbsoluteOriSensorDefaultCovarianceMatrix(const Matrix3 &covMat)
Set the Absolute Orientation Sensor Default Covariance Matrix.
void setStateCovarianceMat(const Matrix &P)
Set the State Covariance Matrix This is useful in case of a setting a guess on a whole state vect9or.
void setCoMAngularMomentum(const Vector3 &sigma, const Vector3 &sigma_dot)
Set the Angular Momentum around the CoM and its derviative expressed in the user frame.
Index gyroBiasIndex(Index IMUNumber) const
Get the gyro bias index of the state vector.
virtual Vector measureDynamics(const Vector &x, const Vector &u, TimeIndex k)
Applies the measurement model to the given state vector using the given input to predict the sensor m...
Kinematics getUserContactInputPose(Index numContact) const
Returns the pose of the contact in the user frame, given as an input when updating the contact.
void computeLocalAccelerations(const Vector &x, Vector &acceleration)
computes the local acceleration from the given state vector
void updateMeasurements()
Updates the measurements.
double getMass() const
Returns the mass of the robot.
void resetSensorsDefaultCovMats()
Reset the default values for the sensors covariance matrices.
void setKinematicsInitCovarianceDefault(const Matrix3 &P_pos, const Matrix3 &P_ori, const Matrix3 &P_linVel, const Matrix3 &P_angVel)
Set the Default value for Kinematics Init Covariance.
Vector6 getContactWrench(Index contactNbr) const
Get the Estimated Contact Wrench This is useful in the case of uncertain wrench sensors or when conta...
void updateContactWithWrenchSensor(const Vector6 &wrenchMeasurement, const Kinematics &localKine, unsigned contactNumber)
Update the contact when it is equipped with wrench sensor.
Index contactIndexTangent(VectorContactConstIterator i) const
Getters for the indexes of the state Vector using private types.
Index contactPosIndexTangent(Index contactNbr) const
Get the index of the position of a specific contact in the tangent sate vector.
Index unmodeledTorqueIndex() const
Get the unmodeled external torque force index of the state vector.
Vector6 getUnmodeledWrench() const
Get the Unmodeled External Wrench (requires setWithUnmodeledWrench() to true before to update()).
void setCenterOfMass(const Vector3 &com)
Set the Center Of Mass kinematics expressed in the user frame.
void setGyroBiasProcessCovariance(const Matrix3 &covMat, unsigned imuNumber)
Set the Gyro Bias Process Covariance.
const IndexedMatrix3 & getInertiaMatrix() const
Returns the global inertia matrix of the robot at the center of mass.
const Vector & update()
Runs the estimation.
void setCenterOfMass(const Vector3 &com, const Vector3 &com_dot)
Set the Center Of Mass kinematics expressed in the user frame.
virtual void resetProcessNoise()
Removes the process noise.
Index contactsIndex() const
Get the index for the contact segment in the state vector.
void updateContactWithWrenchSensor(const Vector6 &wrenchMeasurement, const Matrix6 &wrenchCovMatrix, const Kinematics &localKine, unsigned contactNumber)
Update the contact when it is equipped with wrench sensor.
void setGyroBiasInitCovarianceDefault(const Matrix3 &covMat)
Set the Default value for Gyro Bias Init Covariance.
virtual void setMeasurementNoise(NoiseBase *)
Sets a noise which disturbs the measurements.
virtual void setFiniteDifferenceStep(const Vector &dx)
Set the Finite Difference time step.
virtual void useFiniteDifferencesJacobians(bool b=true)
Define if we use dinite differences Jacobian or analytic.
Kinematics getContactStateRestKinematics(Index numContact) const
Returns the estimated rest pose of the contact in the world frame.
Vector stateDifference(const Vector &stateVector1, const Vector &stateVector2)
the difference operator for the state statevector1 ⊖ statevector2
void setUnmodeledWrenchProcessCovarianceDefault(const Matrix6 &covMat)
Set the default Unmodeled Wrench Process Covariance.
void setContactStateCovMat(Index contactNbr, const Matrix12 &contactCovMat)
Set the Contact State Covariance Matrix.
void setKinematicsProcessCovarianceDefault(const Matrix12 &)
Set the default Kinematics Process Covariance.
void setAbsoluteOriSensor(const Orientation &measurement)
Set an Absolute Orientation Sensor measurement The measurement is the orientation of the observed fra...
Index contactOriIndexTangent(Index contactNbr) const
Get the index of the orientation of a specific contact in the tangent sate vector.
const IndexedMatrix3 & getInertiaMatrixDot() const
Returns the derivative of the global inertia matrix of the robot at the center of mass.
void addUnmodeledAndContactWrench_(const Vector ¢roidStateVector, Vector3 &force, Vector3 &torque)
Adds the unmodeled and contact wrenches from the state to the given wrench.
void setKinematicsProcessCovariance(const Matrix12 &)
Set the Kinematics Process Covariance.
LocalKinematics estimateAccelerations()
gets the Kinematics that include the linear and angular accelerations.
Index angVelIndex() const
Get the angular velocity index of the state vector.
Index posIndexTangent() const
Get the position index of the tangent state vector.
bool getWithAccelerationEstimation() const
Returns if the estimation computes also the accelerations.
Vector stateSum(const Vector &stateVector, const Vector &tangentVector)
the sum operator for the state vector
void setInitWorldCentroidStateVector(const Vector &initStateVector)
Initializes the state vector.
void updateContactWithNoSensor(const Kinematics &localKine, unsigned contactNumber)
Update the contact when it is NOT equipped with wrench sensor.
Index getNumberOfSetContacts() const
Get the Current Number Of Contacts.
Index setIMU(const Vector3 &accelero, const Vector3 &gyrometer, const Matrix3 &acceleroCov, const Matrix3 &gyroCov, const Kinematics &userImuKinematics, Index num=-1)
Provides also the associated covariance matrices
Index oriIndex() const
Get the orientation index of the state vector.
Index angVelIndexTangent() const
Get the angular velocity index of the tangent state vector.
void setContactWrenchSensorDefaultCovarianceMatrix(const Matrix6 &wrenchSensorCovMat)
Set the Contact Wrench Sensor Default Covariance Matrix.
const IndexedVector3 & getCenterOfMassDot() const
Returns the linear velocity of the CoM of the robot in the user frame.
virtual void setProcessNoise(NoiseBase *)
Sets a noise which disturbs the state dynamics.
const ExtendedKalmanFilter & getEKF() const
Gets a const reference on the extended Kalman filter.
const IndexedVector3 & getAngularMomentumDot() const
Returns the derivative of the angular momentum of the robot at the center of mass.
void setKinematicsInitCovarianceDefault(const Matrix &)
Set the Default value for Kinematics Init Covariance.
Kinematics getCentroidContactInputPose(Index numContact) const
Returns the pose of the contact in the centroid frame, given as an input when updating the contact (o...
Index setIMU(const Vector3 &accelero, const Vector3 &gyrometer, const Kinematics &userImuKinematics, Index num=-1)
Set the measurements of an IMU and give the Kinematic of the IMU in the user frame.
void resetInputs()
reset all the sensor inputs and provided contact information but keeps the contacts themselves
Index kineIndex() const
Get the kinematics index of the state vector.
void updateLocalKineAndContacts_()
update of the state kinematics worldCentroidStateKinematics_ and of the contacts pose with the newly ...
void setAbsoluteOriSensor(const Orientation &measurement, const Matrix3 &CovarianceMatrix)
Set an Absolute Orientation Sensor measurement The measurement is the orientation of the observed fra...
void setWithGyroBias(bool b=true)
Set if the gyrometers bias is computed or not. This parameter is global for all the IMUs.
Index contactIndexTangent(Index contactNbr) const
Get the index of a specific contact in the tangent sate vector.
Index unmodeledWrenchIndex() const
Get the unmodeled external wrench index of the state vector.
void setStateUnmodeledWrench(const Vector6 &, bool resetCovariance=true)
Set the State Unmodeled Wrench.
void setWorldCentroidStateKinematics(const LocalKinematics &localKine, bool resetContactWrenches=true, bool resetCovariance=true)
Set the State Kinematics.
void convertWrenchFromUserToCentroid(const Vector3 &forceUserFrame, const Vector3 &momentUserFrame, Vector3 &forceCentroidFrame, Vector3 &momentCentroidFrame)
Returns the predicted Kinematics object of the centroid in the world frame at the time of the measure...
void setStateContact(Index index, Kinematics worldContactRestPose, const Vector6 &wrench, bool resetCovariance=true)
Set the state contact kinematics and wrench.
void setAbsolutePoseSensorDefaultCovarianceMatrix(const Matrix6 &covMat)
Set the Absolute Pose Sensor Default Covariance Matrix.
void setAbsolutePoseSensor(const Kinematics &measurement)
Set an Absolute Pose Sensor measurement The measurement is the kinematics namely position and orienta...
friend int testOrientationsJacobians(KineticsObserver &ko, int errcode, double relativeErrorThreshold, double threshold)
Comparison between the Jacobians of orientation integration with respect to an increment vector delta...
virtual Index getInputSize() const
Gets the input size.
void clearContacts()
remove all the contacts
Index getStateSize() const
Get the State Vector Size.
Matrix3 linearStiffnessMatDefault_
Default Stiffness and damping.
TimeIndex getStateVectorTimeIndex() const
Get the State Vector Internal Time Index This is for advanced use but may be used to check how many s...
Kinematics convertUserToCentroidFrame_(const Kinematics &userKine, TimeIndex k_data)
Converts a Kinematics object from the user's frame to the centroid's frame, which is used for most of...
void addUnmodeledWrench_(const Vector ¢roidStateVector, Vector3 &force, Vector3 &torque)
Adds the unmodeled wrench from the state to the given wrench.
void computeContactForces_(LocalKinematics &worldCentroidStateKinematics, Vector3 &contactForce, Vector3 &contactTorque)
Computes the force exerted at a contact using the visco-elastic model on the given state vector....
void setGyroBiasProcessCovarianceDefault(const Matrix3 &covMat)
Set the default Gyro Bias Process Covariance.
virtual void stateDifference(const Vector &stateVector1, const Vector &stateVector2, Vector &difference)
the difference operator for the state statevector1 ⊖ statevector2 This version prevents a nwe vect...
void setWithAccelerationEstimation(bool b=true)
Sets if the estimation computes also the accelerations.
void computeLocalAccelerations_(LocalKinematics &localStateKine, const Vector3 &totalForceLocal, const Vector3 &totalMomentLocal, Vector3 &linAcc, Vector3 &angAcc)
Computes the local accelerations of the centroid frame in the world frame and adds them to its local ...
Index unmodeledForceIndexTangent() const
Get the unmodeled external linear force index of the tangent state vector.
void resetStateCovarianceMat()
Resets the covariance matrices to their original values.
void setGyroBiasStateCovariance(const Matrix3 &covMat, unsigned imuNumber)
Set the Gyro Bias State Covariance.
Vector6 getAdditionalWrench() const
Returns the input additional wrench, expressed in the centroid frame.
void setMass(double)
Set the total mass of the robot. This can be changed online.
void setCoMInertiaMatrix(const Matrix3 &I)
Set the 3x3 inertia matrix expressed in the user frame.
Kinematics getWorldContactPoseFromCentroid(Index numContact) const
Returns the pose of the contact in the world frame, obtained from the state pose of the centroid in t...
ExtendedKalmanFilter & getEKF()
Index unmodeledWrenchIndexTangent() const
Get the unmodeled external wrench index of the tangent state vector.
void setCoMInertiaMatrix(const Matrix3 &I, const Matrix3 &I_dot)
Set the 3x3 inertia matrix and its derivative expressed in the user frame.
void setProcessNoiseCovarianceMat(const Matrix &Q)
Set the covariance matrices for the process noises.
Index contactPosIndex(Index contactNbr) const
Get the index of the position of a specific contact in the sate vector.
Index getMeasurementSize() const
Get the Measurement vector Size.
Index addContact(const Kinematics &pose, Index contactNumber=-1, const Matrix3 &linearStiffness=Matrix3::Constant(-1), const Matrix3 &linearDamping=Matrix3::Constant(-1), const Matrix3 &angularStiffness=Matrix3::Constant(-1), const Matrix3 &angularDamping=Matrix3::Constant(-1))
Set a new contact with the environment (use default covariance matrices).
virtual void resetMeasurementNoise()
Removes the measurement noise.
void startNewIteration_()
void setGyroBias(const Vector3 &, unsigned numberOfIMU=1, bool resetCovariance=true)
Set the Gyro Bias Allows to initializa the value of the gyro bias of the IMU corresponding to the num...
void removeContact(Index contactnbr)
Remove a contact.
Index unmodeledForceIndex() const
Get the unmodeled external linear force index of the state vector.
void computeContactForce_(VectorContactIterator i, LocalKinematics &worldCentroidStateKinematics, Kinematics &worldRestContactPose, Vector3 &contactForce, Vector3 &contactTorque)
Computes the force exerted at a contact using the visco-elastic model on the given state vector.
void setUnmodeledWrenchStateCovMat(const Matrix6 &newCovMat)
Set the Unmodeled Wrench State Cov Mat.
void setContactProcessCovMat(Index contactNbr, const Matrix12 &contactCovMat)
Set the Contact Process Covariance Matrix.
virtual Vector stateDynamics(const Vector &x, const Vector &u, TimeIndex k)
Applies the state-transition model to the given state vector using the given input to predict the fut...
Matrix getStateCovarianceMat() const
Get the State Covariance matrix.
void setAbsolutePoseSensor(const Kinematics &measurement, const Matrix6 &CovarianceMatrix)
Set an Absolute Pose Sensor measurement The measurement is the kinematics namely position and orienta...
LocalKinematics getLocalKinematicsOf(const Kinematics &userBodyKine)
Get the local kinematics of a given frame (in the user frame) in the centroid frame.
Kinematics getGlobalCentroidKinematics() const
Get the estimated Kinematics of the centroid frame in the world frame.
void setContactProcessCovarianceDefault(const Matrix12 &covMat)
Set the default contact Process Covariance.
Index contactsIndexTangent() const
Get the index for the contact segment in the tangent state vector.
virtual ~KineticsObserver()
Destroy the Kinetics Observer.
Index contactIndex(Index contactNbr) const
Get the index of a specific contact in the sate vector.
Index gyroBiasIndexTangent(Index IMUNumber) const
Get the gyro bias index of the tangent state vector.
const IndexedVector3 & getAngularMomentum() const
Returns the angular momentum of the robot at the center of mass.
Index linVelIndexTangent() const
Get the linear velocity index of the tangent state vector.
void setCoMInertiaMatrix(const Vector6 &I, const Vector6 &I_dot)
Set the inertia matrix and its derivative as a Vector6 expressed in the user frame.
const IndexedVector3 & getCenterOfMassDotDot() const
Returns the linear acceleration of the CoM of the robot in the user frame.
void setCoMAngularMomentum(const Vector3 &sigma)
Set the Angular Momentum around the CoM expressed in the user frame.
void setSamplingTime(double)
Set the Sampling Time.
Index contactForceIndex(Index contactNbr) const
Get the index of the linear force of a specific contact in the sate vector.
virtual void stateSum(const Vector &stateVector, const Vector &tangentVector, Vector &sum)
the sum operator for the state vector This version does not allocate a new vector
void updateGlobalKine_()
updates the global kinematics of the centroid from the local ones, that can be more interpretable
void setWorldCentroidStateKinematics(const Kinematics &kine, bool resetCovariance=true)
Set the State Kinematics.
void convertUserToCentroidFrame_(const Kinematics &userKine, Kinematics ¢roidKine, TimeIndex k_data)
Converts a LocalKinematics object from the user's frame to the centroid's frame, which is used for mo...
Index contactKineIndex(Index contactNbr) const
Get the index of the kinematics of a specific contact in the sate vector.
void setCoMInertiaMatrix(const Vector6 &I)
Set the inertia matrix as a Vector6 expressed in the user frame.
Index contactTorqueIndexTangent(Index contactNbr) const
Get the index of the toraue of a specific contact in the tangent sate vector.
virtual NoiseBase * getMeasurementNoise() const
Gets a pointer on the measurement noise.
void setContactInitCovMatDefault(const Matrix12 &contactCovMat)
Set the default valut for the Initial Covariance Matrix of the contact in the state.
Index contactTorqueIndex(Index contactNbr) const
Get the index of the toraue of a specific contact in the sate vector.
static const double defaultdx
default derivation steps
void setUnmodeledWrenchProcessCovMat(const Matrix6 &processCovMat)
Set the Unmodeled Wrench Process Covariance Mattix.
void setWithUnmodeledWrench(bool b=true)
Set if the unmodeled and unmeasured external wrench should be estimated.
friend int testAnalyticalAJacobianVsFD(KineticsObserver &ko, int errcode, double relativeErrorThreshold, double threshold)
Comparison between the analytical Jacobian matrix A and the one obtained by finite differences....
Index gyroBiasIndex(VectorIMUConstIterator i) const
Getters for the indexes of the state Vector using private types.
const IndexedVector3 & getCenterOfMass() const
Returns the position of the CoM of the robot in the user frame.
std::vector< Index > getListOfContacts() const
Get the List Of Contact ids.
Index unmodeledTorqueIndexTangent() const
Get the unmodeled external torque force index of the tangent state vector.
void setIMUDefaultCovarianceMatrix(const Matrix3 &acceleroCov, const Matrix3 &gyroCov)
set the default covariance matrix for IMU.
void setKinematicsStateCovariance(const Matrix &)
Set the Kinematics State Covariance.
void setAdditionalWrench(const Vector3 &force, const Vector3 &torque)
Set any Additional resultant known wrench (e.g. measured external forces and moments but no contact o...
KineticsObserver(unsigned maxContacts=4, unsigned maxNumberOfIMU=1)
Construct a new Kinetics Observer.
void addContactWrench_(const Kinematics ¢roidContactKine, const Vector3 ¢roidContactForce, const Vector3 ¢roidContactTorque, Vector3 &totalCentroidForce, Vector3 &totalCentroidTorque)
adds the contribution of a contact wrench at the centroid to the total wrench
const Vector & getCurrentStateVector() const
Gets the current value of the state estimation in the form of a state vector .
Index contactWrenchIndex(Index contactNbr) const
Get the index of the wrench of a specific contact in the sate vector.
Index addContact(const Kinematics &pose, const Matrix12 &initialCovarianceMatrix, const Matrix12 &processCovarianceMatrix, Index contactNumber=-1, const Matrix3 &linearStiffness=Matrix3::Constant(-1), const Matrix3 &linearDamping=Matrix3::Constant(-1), const Matrix3 &angularStiffness=Matrix3::Constant(-1), const Matrix3 &angularDamping=Matrix3::Constant(-1))
Set a new contact with the environment.
Index contactKineIndexTangent(Index contactNbr) const
Get the index of the kinematics of a specific contact in the tangent sate vector.
Index contactWrenchIndexTangent(Index contactNbr) const
Get the index of the wrench of a specific contact in the sate tangent vector.
virtual NoiseBase * getProcessNoise() const
Gets the process noise.
void setCenterOfMass(const Vector3 &com, const Vector3 &com_dot, const Vector3 &com_dot_dot)
Set the Center Of Mass kinematics expressed in the user frame.
double getSamplingTime() const
Get the Sampling Time.
Index oriIndexTangent() const
Get the orientation index of the tangent state vector.
Index contactOriIndex(Index contactNbr) const
Get the index of the orientation of a specific contact in the sate vector.
This class is used to customize the way the difference between measurements, the state update functio...
Definitions of types and some structures.
Filtering of divergent component of motion (DCM) and estimation of a bias betweeen the DCM and the co...
Eigen::Vector3d Vector3
3D vector
Eigen::Matrix3d Matrix3
3x3 Scalar Matrix
Eigen::MatrixXd Matrix
Dynamic sized Matrix.
Eigen::Matrix< double, 6, 1 > Vector6
6D vector
Eigen::Matrix< double, 6, 6 > Matrix6
6x6 Scalar Matrix
Eigen::Matrix< double, 12, 12 > Matrix12
12x12 scalar Matrix
Eigen::VectorXd Vector
Dynamic sized scalar vector.
Implements integrators for the kinematics, in terms or rotations and translations.
Class facilitating the manipulation of the kinematics of a frame within another and the associated op...
Class facilitating the manipulation of the local kinematics of a frame within another and the associa...