8#ifndef DYNAMICAL_SYSTEM_HPP_
9#define DYNAMICAL_SYSTEM_HPP_
13#include <state-observation/api.h>
14#include <state-observation/dynamical-system/dynamical-system-functor-base.hpp>
20#include <Eigen/Cholesky>
25namespace flexibilityEstimation
40 static constexpr unsigned posCom = 0;
41 static constexpr unsigned velCom = 3;
42 static constexpr unsigned accCom = 6;
43 static constexpr unsigned inertia = 9;
44 static constexpr unsigned angMoment = 15;
45 static constexpr unsigned dotInertia = 18;
46 static constexpr unsigned dotAngMoment = 24;
47 static constexpr unsigned posIMU = 27;
48 static constexpr unsigned oriIMU = 30;
49 static constexpr unsigned linVelIMU = 33;
50 static constexpr unsigned angVelIMU = 36;
51 static constexpr unsigned linAccIMU = 39;
52 static constexpr unsigned additionalForces = 42;
53 static constexpr unsigned contacts = 48;
55 static constexpr unsigned sizeBase = 48;
60 static constexpr unsigned pos = 0;
61 static constexpr unsigned ori = 3;
62 static constexpr unsigned linVel = 6;
63 static constexpr unsigned angVel = 9;
64 static constexpr unsigned fc = 12;
65 static constexpr unsigned unmodeledForces = 24;
66 static constexpr unsigned comBias = 30;
67 static constexpr unsigned drift = 32;
69 static constexpr unsigned size = 35;
76 static constexpr unsigned pendulum = 2;
77 static constexpr unsigned none = 0;
80 typedef Eigen::LLT<Matrix3> LLTMatrix3;
91 void computeContactWrench(
const Matrix3 & orientation,
93 const IndexedVectorArray & contactPosV,
94 const IndexedVectorArray & contactOriV,
105 virtual void computeAccelerations(
const Vector3 & positionCom,
107 const Vector3 & accelerationCom,
109 const Vector3 & dotAngMomentum,
112 const IndexedVectorArray & contactPos,
113 const IndexedVectorArray & contactOri,
209 virtual void setContactModel(
unsigned nb);
211 virtual void setPrinted(
bool b)
216 virtual void computeElastContactForcesAndMoments(
const IndexedVectorArray & contactPosArray,
217 const IndexedVectorArray & contactOriArray,
218 const IndexedVectorArray & contactVelArray,
219 const IndexedVectorArray & contactAngVelArray,
228 virtual void computeElastPendulumForcesAndMoments(
const IndexedVectorArray & PrArray,
237 void computeForcesAndMoments(
const IndexedVectorArray & position1,
238 const IndexedVectorArray & position2,
239 const IndexedVectorArray & velocity1,
240 const IndexedVectorArray & velocity2,
249 virtual void computeForcesAndMoments(
const Vector & x,
const Vector & u);
251 virtual Vector getForcesAndMoments();
258 virtual void iterateDynamicsEuler(
const Vector3 & positionCom,
260 const Vector3 & accelerationCom,
262 const Vector3 & dotAngMomentum,
265 const IndexedVectorArray & contactPos,
266 const IndexedVectorArray & contactOri,
279 virtual void iterateDynamicsRK4(
const Vector3 & positionCom,
281 const Vector3 & accelerationCom,
283 const Vector3 & dotAngMomentum,
286 const IndexedVectorArray & contactPos,
287 const IndexedVectorArray & contactOri,
300 virtual void setWithForceMeasurements(
bool b);
301 virtual bool getWithForceMeasurements()
const;
302 virtual void setWithComBias(
bool b);
303 virtual bool getWithComBias()
const;
304 virtual void setWithAbsolutePosition(
bool b);
305 virtual bool getWithAbsolutePosition()
const;
306 void setWithUnmodeledForces(
bool b);
308 virtual void setKfe(
const Matrix3 & m);
309 virtual void setKfv(
const Matrix3 & m);
310 virtual void setKte(
const Matrix3 & m);
311 virtual void setKtv(
const Matrix3 & m);
313 virtual void setKfeRopes(
const Matrix3 & m);
314 virtual void setKfvRopes(
const Matrix3 & m);
315 virtual void setKteRopes(
const Matrix3 & m);
316 virtual void setKtvRopes(
const Matrix3 & m);
318 virtual Matrix getKfe()
const;
319 virtual Matrix getKfv()
const;
320 virtual Matrix getKte()
const;
321 virtual Matrix getKtv()
const;
323 virtual void setRobotMass(
double d);
325 virtual double getRobotMass()
const;
334 void updateMeasurementSize_();
339 double robotMassInv_;
343 static constexpr Index stateSize_ = state::size;
345 static constexpr Index measurementSizeBase_ = 6;
346 unsigned nbContacts_;
347 unsigned contactModel_;
362 Index measurementSize_;
364 std::vector<Vector3, Eigen::aligned_allocator<Vector3>> contactPositions_;
366 Matrix3 Kfe_, Kte_, Kfv_, Ktv_;
367 Matrix3 KfeRopes_, KteRopes_, KfvRopes_, KtvRopes_;
371 bool withForceMeasurements_;
373 bool withAbsolutePos_;
374 bool withUnmodeledForces_;
378 double marginalStabilityFactor_;
389 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
396 Vector3 angularAccelerationFlex;
424 LLTMatrix3 invinertia;
449 Vector3 angularVelocityControl;
453 IndexedVectorArray contactPosV;
454 IndexedVectorArray contactOriV;
455 IndexedVectorArray contactVelArray;
456 IndexedVectorArray contactAngVelArray;
461 IndexedVectorArray efforts;
518 : curRotation0(Matrix3::Identity()), orientationVector0(Vector3::Zero()), curRotation1(Matrix3::Identity()),
519 orientationVector1(Vector3::Zero()), curRotation2(Matrix3::Identity()), orientationVector2(Vector3::Zero()),
520 curRotation3(Matrix3::Identity()), orientationVector3(Vector3::Zero())
524 inline Vector3 & orientationVector(
int i)
526 if(i == 0)
return orientationVector0;
527 if(i == 1)
return orientationVector1;
528 if(i == 2)
return orientationVector2;
530 return orientationVector3;
533 inline Matrix3 & curRotation(
int i)
535 if(i == 0)
return curRotation0;
536 if(i == 1)
return curRotation1;
537 if(i == 2)
return curRotation2;
545 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
Implements the accelerometer-gyrometer inertial measuremen.
Implements the accelerometer-gyrometer measurements.
This is the base class of any functor that describes the dynamics of the state and the measurement....
virtual void resetMeasurementNoise()
Removes the measurement noise.
stateObservation::Matrix measureDynamicsJacobian()
compute the Jacobien of the measurements dynamics at the last computed value
stateObservation::Matrix stateDynamicsJacobian()
compute the jacobien of the state dynamics at the last computed value
virtual Index getStateSize() const
Gets the state size.
virtual void setContactsNumber(unsigned)
Sets the number of contacts.
virtual stateObservation::Vector stateDynamics(const stateObservation::Vector &x, const stateObservation::Vector &u, TimeIndex k)
Description of the state dynamics.
IMUElasticLocalFrameDynamicalSystem(double dt)
constructor
stateObservation::Matrix stateDynamicsJacobian(const stateObservation::Vector &x, const stateObservation::Vector &u, TimeIndex k)
compute the jacobien of the state dynamics at a given state
virtual Index getInputSize() const
Gets the input size.
virtual void setInputSize(Index i)
Sets the input size.
virtual void setProcessNoise(stateObservation::NoiseBase *)
Sets a noise which disturbs the state dynamics.
virtual stateObservation::NoiseBase * getProcessNoise() const
Gets the process noise.
virtual void setSamplingPeriod(double dt)
Set the period of the time discretization.
virtual void resetProcessNoise()
Removes the process noise.
virtual stateObservation::Vector measureDynamics(const stateObservation::Vector &x, const stateObservation::Vector &u, TimeIndex k)
Description of the sensor's dynamics.
unsigned getContactsNumber(void) const
Gets the nimber of contacts.
virtual ~IMUElasticLocalFrameDynamicalSystem()
virtual destructor
virtual stateObservation::NoiseBase * getMeasurementNoise() const
Gets a pointer on the measurement noise.
virtual Index getMeasurementSize() const
Gets the contacts position.
stateObservation::Matrix measureDynamicsJacobian(const stateObservation::Vector &x, const stateObservation::Vector &u, TimeIndex k)
compute the Jacobien of the measurements dynamics at a given state value
void setFDstep(const stateObservation::Vector &dx)
sets the finite differences derivation step vector
virtual void setMeasurementNoise(stateObservation::NoiseBase *)
Sets a noise which disturbs the measurements.
Definitions of Hrp2 constants.
Filtering of divergent component of motion (DCM) and estimation of a bias betweeen the DCM and the co...
Eigen::AngleAxis< double > AngleAxis
Euler Axis/Angle representation of orientation.
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::VectorXd Vector
Dynamic sized scalar vector.
Implements integrators for the kinematics, in terms or rotations and translations.