29template <
int States,
int Inputs,
int Outputs>
40 const std::array<double, Outputs>& measurementStdDevs = {})
130 units::second_t dt) {
131 return m_plant.CalculateX(currentXhat, u, dt);
A plant defined using state-space notation.
Definition LinearSystem.h:35
This class helps simulate linear systems.
Definition LinearSystemSim.h:30
double GetInput(int row) const
Returns an element of the current input of the plant.
Definition LinearSystemSim.h:111
double GetOutput(int row) const
Returns an element of the current output of the plant.
Definition LinearSystemSim.h:81
const Vectord< Outputs > & GetOutput() const
Returns the current output of the plant.
Definition LinearSystemSim.h:73
std::array< double, Outputs > m_measurementStdDevs
The standard deviations of measurements, used for adding noise to the measurements.
Definition LinearSystemSim.h:158
LinearSystemSim(const LinearSystem< States, Inputs, Outputs > &system, const std::array< double, Outputs > &measurementStdDevs={})
Creates a simulated generic linear system.
Definition LinearSystemSim.h:38
Vectord< Inputs > m_u
Input vector.
Definition LinearSystemSim.h:151
void ClampInput(double maxInput)
Clamp the input vector such that no element exceeds the given voltage.
Definition LinearSystemSim.h:140
void Update(units::second_t dt)
Updates the simulation.
Definition LinearSystemSim.h:54
void SetInput(const Vectord< Inputs > &u)
Sets the system inputs (usually voltages).
Definition LinearSystemSim.h:88
Vectord< States > m_x
State vector.
Definition LinearSystemSim.h:148
LinearSystem< States, Inputs, Outputs > m_plant
The plant that represents the linear system.
Definition LinearSystemSim.h:145
void SetState(const Vectord< States > &state)
Sets the system state.
Definition LinearSystemSim.h:118
const Vectord< Inputs > & GetInput() const
Returns the current input of the plant.
Definition LinearSystemSim.h:103
virtual Vectord< States > UpdateX(const Vectord< States > ¤tXhat, const Vectord< Inputs > &u, units::second_t dt)
Updates the state estimate of the system.
Definition LinearSystemSim.h:128
Vectord< Outputs > m_y
Output vector.
Definition LinearSystemSim.h:154
virtual ~LinearSystemSim()=default
void SetInput(int row, double value)
Sets the system inputs.
Definition LinearSystemSim.h:96
Eigen::Vector< double, Size > Vectord
Definition EigenCore.h:12
Vectord< sizeof...(Ts)> MakeWhiteNoiseVector(Ts... stdDevs)
Definition StateSpaceUtil.h:156
Vectord< Inputs > DesaturateInputVector(const Vectord< Inputs > &u, double maxMagnitude)
Renormalize all inputs if any exceeds the maximum magnitude.
Definition StateSpaceUtil.h:360