5 #ifndef LODESTAR_DISCRETESYSTEM_HPP
6 #define LODESTAR_DISCRETESYSTEM_HPP
9 #include "StateSpace.hpp"
10 #include "SystemStateful.hpp"
11 #include "Lodestar/aux/CompileTimeQualifiers.hpp"
24 DiscreteSystem(SYS *sys) : system(sys), state(
new Eigen::VectorXd),
25 input(
nullptr), time(0)
45 template <
template <
typename, const
int, const
int, const
int>
class TSystem,
typename TScalar,
const int TStateDim,
const int TInputDim,
const int TOutputDim>
46 class DiscreteSystem<TSystem<TScalar, TStateDim, TInputDim, TOutputDim>>;
48 template <
typename TScalar, const
int TStateDim, const
int TInputDim, const
int TOutputDim>
52 typedef Eigen::Matrix<TScalar, TStateDim, LS_STATIC_UNLESS_DYNAMIC_VAL(TStateDim, 1)> TDStateVector;
53 typedef Eigen::Matrix<TScalar, TInputDim, LS_STATIC_UNLESS_DYNAMIC_VAL(TInputDim, 1)> TDInputVector;
56 input(
nullptr), time(0)
60 input(
nullptr), time(0)
63 IF_DYNAMIC_RETURN(TStateDim, TInputDim, TOutputDim,
void)
65 state->conservativeResize(system->getA().rows());
68 input =
new Eigen::VectorXd;
70 input->conservativeResize(system->getB().cols());
73 IF_STATIC_RETURN(TStateDim, TInputDim, TOutputDim,
void)
81 void advance(TDInputVector *control);
87 void advanceForced(TDInputVector *control);
98 template<
typename TScalar,
int TStateDim,
int TInputDim,
int TOutputDim>
101 if (input !=
nullptr) {
102 *state = (*system->getA()) * (*state) + (*system->getB()) * (*input);
104 *state = (*system->getA()) * (*state);
107 time += system->getSamplingPeriod();
110 template<
typename TScalar,
int TStateDim,
int TInputDim,
int TOutputDim>
112 Eigen::Matrix<TScalar, TInputDim, Kmax2(-1, TInputDim, 1)> *control)
114 *state = (*system->getA()) * (*state) + (*system->getB()) * (*control);
116 time = system->getSamplingPeriod();
119 template<
typename TScalar,
int TStateDim,
int TInputDim,
int TOutputDim>
122 *state = (*system->getA()) * (*state);
124 time += system->getSamplingPeriod();
127 template<
typename TScalar,
int TStateDim,
int TInputDim,
int TOutputDim>
130 *state = (*system->getA()) * (*state) + (*system->getB()) * (*input);
132 time += system->getSamplingPeriod();
135 template<
typename TScalar,
int TStateDim,
int TInputDim,
int TOutputDim>
137 Eigen::Matrix<TScalar, TInputDim, Kmax2(-1, TInputDim, 1)> *control)
139 *state = (*system->getA()) * (*state) + (*system->getB()) * (*control);
141 time += system->getSamplingPeriod();
144 #endif //LODESTAR_DISCRETESYSTEM_HPP