WPILibC++ 2023.4.3-108-ge5452e3
frc::sim::FlywheelSim Class Reference

Represents a simulated flywheel mechanism. More...

#include <frc/simulation/FlywheelSim.h>

Inheritance diagram for frc::sim::FlywheelSim:
frc::sim::LinearSystemSim< 1, 1, 1 >

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...
 
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...
 
- 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 > &currentXhat, 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
 
Vectord< States > m_x
 
Vectord< Outputs > m_y
 
Vectord< Inputs > m_u
 
std::array< double, Outputs > m_measurementStdDevs
 

Detailed Description

Represents a simulated flywheel mechanism.

Constructor & Destructor Documentation

◆ FlywheelSim() [1/2]

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.

Parameters
plantThe linear system representing the flywheel.
gearboxThe type of and number of motors in the flywheel gearbox.
gearingThe gearing of the flywheel (numbers greater than 1 represent reductions).
measurementStdDevsThe standard deviation of the measurement noise.

◆ FlywheelSim() [2/2]

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.

Parameters
gearboxThe type of and number of motors in the flywheel gearbox.
gearingThe gearing of the flywheel (numbers greater than 1 represent reductions).
moiThe moment of inertia of the flywheel.
measurementStdDevsThe standard deviation of the measurement noise.

Member Function Documentation

◆ GetAngularVelocity()

units::radians_per_second_t frc::sim::FlywheelSim::GetAngularVelocity ( ) const

Returns the flywheel velocity.

Returns
The flywheel velocity.

◆ GetCurrentDraw()

units::ampere_t frc::sim::FlywheelSim::GetCurrentDraw ( ) const
overridevirtual

Returns the flywheel current draw.

Returns
The flywheel current draw.

Reimplemented from frc::sim::LinearSystemSim< 1, 1, 1 >.

◆ SetInputVoltage()

void frc::sim::FlywheelSim::SetInputVoltage ( units::volt_t  voltage)

Sets the input voltage for the flywheel.

Parameters
voltageThe input voltage.

The documentation for this class was generated from the following file: