30template <
int States,
int Inputs,
int Outputs>
41 const std::array<double, Outputs>& measurementStdDevs = {})
127 units::second_t dt) {
128 return m_plant.CalculateX(currentXhat, u, dt);
139 return frc::DesaturateInputVector<Inputs>(
A plant defined using state-space notation.
Definition: LinearSystem.h:31
static double GetInputVoltage()
Get the input voltage to the robot controller.
This class helps simulate linear systems.
Definition: LinearSystemSim.h:31
double GetOutput(int row) const
Returns an element of the current output of the plant.
Definition: LinearSystemSim.h:82
const Vectord< Outputs > & GetOutput() const
Returns the current output of the plant.
Definition: LinearSystemSim.h:74
std::array< double, Outputs > m_measurementStdDevs
The standard deviations of measurements, used for adding noise to the measurements.
Definition: LinearSystemSim.h:157
LinearSystemSim(const LinearSystem< States, Inputs, Outputs > &system, const std::array< double, Outputs > &measurementStdDevs={})
Creates a simulated generic linear system.
Definition: LinearSystemSim.h:39
Vectord< Inputs > m_u
Input vector.
Definition: LinearSystemSim.h:150
void Update(units::second_t dt)
Updates the simulation.
Definition: LinearSystemSim.h:55
void SetInput(const Vectord< Inputs > &u)
Sets the system inputs (usually voltages).
Definition: LinearSystemSim.h:89
Vectord< States > m_x
State vector.
Definition: LinearSystemSim.h:147
LinearSystem< States, Inputs, Outputs > m_plant
The plant that represents the linear system.
Definition: LinearSystemSim.h:144
void SetState(const Vectord< States > &state)
Sets the system state.
Definition: LinearSystemSim.h:107
Vectord< Inputs > ClampInput(Vectord< Inputs > u)
Clamp the input vector such that no element exceeds the given voltage.
Definition: LinearSystemSim.h:138
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:125
Vectord< Outputs > m_y
Output vector.
Definition: LinearSystemSim.h:153
virtual ~LinearSystemSim()=default
void SetInput(int row, double value)
Definition: LinearSystemSim.h:97
virtual units::ampere_t GetCurrentDraw() const
Returns the current drawn by this simulated system.
Definition: LinearSystemSim.h:115
state
Definition: core.h:2271
Definition: XboxControllerSim.h:13
Eigen::Vector< double, Size > Vectord
Definition: EigenCore.h:12