WPILibC++ 2024.3.2
|
Represents a simulated flywheel mechanism. More...
#include <frc/simulation/FlywheelSim.h>
Public Member Functions | |
FlywheelSim (const LinearSystem< 1, 1, 1 > &plant, const DCMotor &gearbox, double gearing, const std::array< double, 1 > &measurementStdDevs={0.0}) | |
Creates a simulated flywheel mechanism. More... | |
FlywheelSim (const DCMotor &gearbox, double gearing, units::kilogram_square_meter_t moi, const std::array< double, 1 > &measurementStdDevs={0.0}) | |
Creates a simulated flywheel mechanism. More... | |
void | SetState (units::radians_per_second_t velocity) |
Sets the flywheel's state. More... | |
units::radians_per_second_t | GetAngularVelocity () const |
Returns the flywheel velocity. More... | |
units::ampere_t | GetCurrentDraw () const override |
Returns the flywheel current draw. More... | |
void | SetInputVoltage (units::volt_t voltage) |
Sets the input voltage for the flywheel. More... | |
void | SetState (const Vectord< States > &state) |
Sets the system state. More... | |
Public Member Functions inherited from frc::sim::LinearSystemSim< 1, 1, 1 > | |
LinearSystemSim (const LinearSystem< States, Inputs, Outputs > &system, const std::array< double, Outputs > &measurementStdDevs={}) | |
Creates a simulated generic linear system. More... | |
virtual | ~LinearSystemSim ()=default |
void | Update (units::second_t dt) |
Updates the simulation. More... | |
const Vectord< Outputs > & | GetOutput () const |
Returns the current output of the plant. More... | |
double | GetOutput (int row) const |
Returns an element of the current output of the plant. More... | |
void | SetInput (const Vectord< Inputs > &u) |
Sets the system inputs (usually voltages). More... | |
void | SetInput (int row, double value) |
void | SetState (const Vectord< States > &state) |
Sets the system state. More... | |
virtual units::ampere_t | GetCurrentDraw () const |
Returns the current drawn by this simulated system. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from frc::sim::LinearSystemSim< 1, 1, 1 > | |
virtual Vectord< States > | UpdateX (const Vectord< States > ¤tXhat, const Vectord< Inputs > &u, units::second_t dt) |
Updates the state estimate of the system. More... | |
Vectord< Inputs > | ClampInput (Vectord< Inputs > u) |
Clamp the input vector such that no element exceeds the given voltage. More... | |
Protected Attributes inherited from frc::sim::LinearSystemSim< 1, 1, 1 > | |
LinearSystem< States, Inputs, Outputs > | m_plant |
The plant that represents the linear system. More... | |
Vectord< States > | m_x |
State vector. More... | |
Vectord< Inputs > | m_u |
Input vector. More... | |
Vectord< Outputs > | m_y |
Output vector. More... | |
std::array< double, Outputs > | m_measurementStdDevs |
The standard deviations of measurements, used for adding noise to the measurements. More... | |
Represents a simulated flywheel mechanism.
frc::sim::FlywheelSim::FlywheelSim | ( | const LinearSystem< 1, 1, 1 > & | plant, |
const DCMotor & | gearbox, | ||
double | gearing, | ||
const std::array< double, 1 > & | measurementStdDevs = {0.0} |
||
) |
Creates a simulated flywheel mechanism.
plant | The linear system representing the flywheel. This system can be created with LinearSystemId::FlywheelSystem(). |
gearbox | The type of and number of motors in the flywheel gearbox. |
gearing | The gearing of the flywheel (numbers greater than 1 represent reductions). |
measurementStdDevs | The standard deviation of the measurement noise. |
frc::sim::FlywheelSim::FlywheelSim | ( | const DCMotor & | gearbox, |
double | gearing, | ||
units::kilogram_square_meter_t | moi, | ||
const std::array< double, 1 > & | measurementStdDevs = {0.0} |
||
) |
Creates a simulated flywheel mechanism.
gearbox | The type of and number of motors in the flywheel gearbox. |
gearing | The gearing of the flywheel (numbers greater than 1 represent reductions). |
moi | The moment of inertia of the flywheel. |
measurementStdDevs | The standard deviation of the measurement noise. |
units::radians_per_second_t frc::sim::FlywheelSim::GetAngularVelocity | ( | ) | const |
Returns the flywheel velocity.
|
overridevirtual |
Returns the flywheel current draw.
Reimplemented from frc::sim::LinearSystemSim< 1, 1, 1 >.
void frc::sim::FlywheelSim::SetInputVoltage | ( | units::volt_t | voltage | ) |
Sets the input voltage for the flywheel.
voltage | The input voltage. |
|
inline |
Sets the system state.
state | The new state. |
void frc::sim::FlywheelSim::SetState | ( | units::radians_per_second_t | velocity | ) |
Sets the flywheel's state.
velocity | The new velocity |