g2o
Loading...
Searching...
No Matches
Functions
continuous_to_discrete.h File Reference
#include <iostream>
#include <unsupported/Eigen/MatrixFunctions>
Include dependency graph for continuous_to_discrete.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

template<typename MatrixType >
void continuousToDiscrete (MatrixType &Fd, MatrixType &Qd, const MatrixType &Fc, const MatrixType &Qc, double dt)
 

Function Documentation

◆ continuousToDiscrete()

template<typename MatrixType >
void continuousToDiscrete ( MatrixType &  Fd,
MatrixType &  Qd,
const MatrixType &  Fc,
const MatrixType &  Qc,
double  dt 
)

Definition at line 9 of file continuous_to_discrete.h.

10 {
11 enum {
12 NX = MatrixType::ColsAtCompileTime,
13 NY = MatrixType::RowsAtCompileTime,
14 NX2 = 2 * MatrixType::RowsAtCompileTime
15 };
16
17 typedef Eigen::Matrix<typename MatrixType::Scalar, NX2, NX2>
18 DoubleSizedMatrixType;
19 DoubleSizedMatrixType bigA(NX2, NX2), bigB(NX2, NX2);
20
21 // Construct the "big A matrix"
22 bigA.template topLeftCorner<NX, NX>() = -Fc * dt;
23 bigA.template topRightCorner<NX, NX>() = Qc * dt;
24 bigA.template bottomLeftCorner<NX, NX>().setZero();
25 bigA.template bottomRightCorner<NX, NX>() = Fc.transpose() * dt;
26
27 // bigB = expm(bigA)
28 // Eigen::MatrixExponential<DoubleSizedMatrixType> me(bigA);
29 // me.compute(bigB);
30 bigB = bigA.exp();
31
32 // Extract the discrete time components
33 Fd = bigB.template bottomRightCorner<NX, NX>().transpose();
34 Qd = Fd * bigB.template topRightCorner<NX, NX>();
35}