RIT VEXU Core API
Toggle main menu visibility
Loading...
Searching...
No Matches
discretization.h
1
#pragma once
2
3
#include "core/utils/math/eigen_interface.h"
4
#include "../vendor/eigen/unsupported/Eigen/MatrixFunctions"
5
6
#include <cmath>
7
#include <tuple>
8
20
template
<
int
STATES,
int
INPUTS>
21
std::tuple<EMat<STATES, STATES>, EMat<STATES, INPUTS>> discretize_AB(EMat<STATES, STATES> Ac, EMat<STATES, INPUTS> Bc,
const
double
&dt) {
22
// Form the intermediate matrix M
23
//
24
// [A B]
25
// M = [0 0]
26
//
27
EMat<STATES + INPUTS, STATES + INPUTS> M;
28
M.template block<STATES, STATES>(0, 0) = Ac;
29
M.template block<STATES, INPUTS>(0, STATES) = Bc;
30
M.template block<INPUTS, STATES + INPUTS>(STATES, 0).setZero();
31
32
//
33
// M * T [Ad Bd]
34
// e = [0 I]
35
//
36
EMat<STATES + INPUTS, STATES + INPUTS> phi = (M * dt).exp();
37
38
// Extract Ad and Bd from phi and put them in a tuple
39
return
std::make_tuple(phi.template block<STATES, STATES>(0, 0), phi.template block<STATES, INPUTS>(0, STATES));
40
}
include
core
utils
math
systems
discretization.h
Generated by
1.17.0