g2o
continuous_to_discrete.h
Go to the documentation of this file.
1 #ifndef G2O_CONTINUOUS_TO_DISCRETE_H_
2 #define G2O_CONTINUOUS_TO_DISCRETE_H_
3 
4 #include <unsupported/Eigen/MatrixFunctions>
5 #include <iostream>
6 
7 // Form for fixed-size matrices
8 template<typename MatrixType>
9 void continuousToDiscrete(MatrixType& Fd, MatrixType& Qd,
10  const MatrixType& Fc, const MatrixType& Qc, double dt)
11 {
12  enum
13  {
14  NX = MatrixType::ColsAtCompileTime,
15  NY = MatrixType::RowsAtCompileTime,
16  NX2 = 2 * MatrixType::RowsAtCompileTime
17  };
18 
19  typedef Eigen::Matrix<typename MatrixType::Scalar,NX2,NX2> DoubleSizedMatrixType;
20  DoubleSizedMatrixType bigA(NX2,NX2), bigB(NX2,NX2);
21 
22  // Construct the "big A matrix"
23  bigA.template topLeftCorner<NX,NX>()=-Fc*dt;
24  bigA.template topRightCorner<NX,NX>()= Qc * dt;
25  bigA.template bottomLeftCorner<NX,NX>().setZero();
26  bigA.template bottomRightCorner<NX,NX>()=Fc.transpose() * dt;
27 
28  // bigB = expm(bigA)
29  //Eigen::MatrixExponential<DoubleSizedMatrixType> me(bigA);
30  //me.compute(bigB);
31  bigB = bigA.exp();
32 
33  // Extract the discrete time components
34  Fd = bigB.template bottomRightCorner<NX,NX>().transpose();
35  Qd = Fd * bigB.template topRightCorner<NX,NX>();
36 }
37 
38 #endif // __CONTINUOUS_TO_DISCRETE_H__
void continuousToDiscrete(MatrixType &Fd, MatrixType &Qd, const MatrixType &Fc, const MatrixType &Qc, double dt)