13#include "wpi/units/time.hpp"
28template <
int States,
int Inputs,
int Outputs>
39 const std::array<double, Outputs>& measurementStdDevs = {})
53 void Update(wpi::units::second_t dt) {
137 return m_plant.CalculateX(currentXhat, u, dt);
A plant defined using state-space notation.
Definition LinearSystem.hpp:35
const wpi::math::Vectord< Inputs > & GetInput() const
Returns the current input of the plant.
Definition LinearSystemSim.hpp:102
void ClampInput(double maxInput)
Clamp the input vector such that no element exceeds the given voltage.
Definition LinearSystemSim.hpp:146
virtual wpi::math::Vectord< States > UpdateX(const wpi::math::Vectord< States > ¤tXhat, const wpi::math::Vectord< Inputs > &u, wpi::units::second_t dt)
Updates the state estimate of the system.
Definition LinearSystemSim.hpp:134
wpi::math::Vectord< Outputs > m_y
Output vector.
Definition LinearSystemSim.hpp:160
void Update(wpi::units::second_t dt)
Updates the simulation.
Definition LinearSystemSim.hpp:53
const wpi::math::Vectord< Outputs > & GetOutput() const
Returns the current output of the plant.
Definition LinearSystemSim.hpp:72
wpi::math::LinearSystem< States, Inputs, Outputs > m_plant
The plant that represents the linear system.
Definition LinearSystemSim.hpp:151
void SetInput(const wpi::math::Vectord< Inputs > &u)
Sets the system inputs (usually voltages).
Definition LinearSystemSim.hpp:87
LinearSystemSim(const wpi::math::LinearSystem< States, Inputs, Outputs > &system, const std::array< double, Outputs > &measurementStdDevs={})
Creates a simulated generic linear system.
Definition LinearSystemSim.hpp:37
double GetInput(int row) const
Returns an element of the current input of the plant.
Definition LinearSystemSim.hpp:110
wpi::math::Vectord< Inputs > m_u
Input vector.
Definition LinearSystemSim.hpp:157
std::array< double, Outputs > m_measurementStdDevs
The standard deviations of measurements, used for adding noise to the measurements.
Definition LinearSystemSim.hpp:164
wpi::math::Vectord< States > m_x
State vector.
Definition LinearSystemSim.hpp:154
void SetState(const wpi::math::Vectord< States > &state)
Sets the system state.
Definition LinearSystemSim.hpp:117
double GetOutput(int row) const
Returns an element of the current output of the plant.
Definition LinearSystemSim.hpp:80
void SetInput(int row, double value)
Sets the system inputs.
Definition LinearSystemSim.hpp:95
virtual ~LinearSystemSim()=default
Eigen::Vector< double, Inputs > DesaturateInputVector(const Eigen::Vector< double, Inputs > &u, double maxMagnitude)
Renormalize all inputs if any exceeds the maximum magnitude.
Definition StateSpaceUtil.hpp:195
Eigen::Vector< double, sizeof...(Ts)> Normal(Ts... stdDevs)
Creates a vector of normally distributed random values with the given standard deviations for each el...
Definition Normal.hpp:28
Eigen::Vector< double, Size > Vectord
Definition EigenCore.hpp:12
Definition CTREPCMSim.hpp:13