RIT VEXU Core API
Toggle main menu visibility
Loading...
Searching...
No Matches
linear_system.h
1
#pragma once
2
3
#include "core/math/eigen_interface.h"
4
#include "core/math/systems/discretization.h"
5
15
template
<
int
STATES,
int
INPUTS,
int
OUTPUTS>
16
class
LinearSystem
{
17
public
:
18
using
MatrixA = EMat<STATES, STATES>;
19
using
MatrixB = EMat<STATES, INPUTS>;
20
using
MatrixC = EMat<OUTPUTS, STATES>;
21
using
MatrixD = EMat<OUTPUTS, INPUTS>;
22
23
using
VectorX = EVec<STATES>;
24
using
VectorU = EVec<INPUTS>;
25
using
VectorY = EVec<OUTPUTS>;
26
35
LinearSystem
(
const
MatrixA &
A
,
const
MatrixB &
B
,
const
MatrixC &
C
,
const
MatrixD &
D
) : m_Ac(
A
), m_Bc(
B
), m_C(
C
), m_D(
D
) {}
36
38
MatrixA
A
() {
return
m_Ac; }
39
41
MatrixB
B
() {
return
m_Bc; }
42
44
const
std::tuple<std::tuple<MatrixA, MatrixB>> &
discAB
(
const
double
&dt) {
return
discretize_AB(m_Ac, m_Bc, dt); }
45
47
MatrixC
C
() {
return
m_C; }
48
50
MatrixD
D
() {
return
m_D; }
51
62
VectorX
compute_X
(
const
VectorX &x,
const
VectorU &u,
double
dt) {
63
// Discretize A and B
64
auto
[Ad, Bd] = discretize_AB(m_Ac, m_Bc, dt);
65
66
return
Ad * x + Bd * u;
67
}
68
77
VectorY
compute_Y
(
const
VectorX &x,
const
VectorU &u) {
78
return
m_C * x + m_D * u;
79
}
80
81
private
:
82
// Continuous system matrix
83
MatrixA m_Ac;
84
// Continuous input matrix
85
MatrixB m_Bc;
86
// Output matrix
87
MatrixC m_C;
88
// Feedthrough matrix
89
MatrixD m_D;
90
};
LinearSystem::compute_X
VectorX compute_X(const VectorX &x, const VectorU &u, double dt)
Definition
linear_system.h:62
LinearSystem::B
MatrixB B()
Returns the continuous input matrix B.
Definition
linear_system.h:41
LinearSystem::discAB
const std::tuple< std::tuple< MatrixA, MatrixB > > & discAB(const double &dt)
Returns a tuple of A and B after being discretized.
Definition
linear_system.h:44
LinearSystem::LinearSystem
LinearSystem(const MatrixA &A, const MatrixB &B, const MatrixC &C, const MatrixD &D)
Definition
linear_system.h:35
LinearSystem::C
MatrixC C()
Returns the output matrix C.
Definition
linear_system.h:47
LinearSystem::D
MatrixD D()
Returns the feedthrough matrix D.
Definition
linear_system.h:50
LinearSystem::A
MatrixA A()
Returns the continuous system matrix A.
Definition
linear_system.h:38
LinearSystem::compute_Y
VectorY compute_Y(const VectorX &x, const VectorU &u)
Definition
linear_system.h:77
include
core
math
systems
linear_system.h
Generated by
1.18.0