WPILibC++ 2025.0.0-alpha-1-10-g1ccd8d1
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, const std::array< double, 1 > &measurementStdDevs={0.0})
 Creates a simulated flywheel mechanism. More...
 
void SetVelocity (units::radians_per_second_t velocity)
 Sets the flywheel's angular velocity. More...
 
units::radians_per_second_t GetAngularVelocity () const
 Returns the flywheel's velocity. More...
 
units::radians_per_second_squared_t GetAngularAcceleration () const
 Returns the flywheel's acceleration. More...
 
units::newton_meter_t GetTorque () const
 Returns the flywheel's torque. More...
 
units::ampere_t GetCurrentDraw () const
 Returns the flywheel's current draw. More...
 
units::volt_t GetInputVoltage () const
 Gets the input voltage for the flywheel. More...
 
void SetInputVoltage (units::volt_t voltage)
 Sets the input voltage for the flywheel. More...
 
DCMotor Gearbox () const
 Returns the gearbox. More...
 
double Gearing () const
 Returns the gearing;. More...
 
units::kilogram_square_meter_t J () const
 Returns the moment of inertia. 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)
 Sets the system inputs. More...
 
const Vectord< Inputs > & GetInput () const
 Returns the current input of the plant. More...
 
double GetInput (int row) const
 Returns an element of the current input of the plant. More...
 
void SetState (const Vectord< States > &state)
 Sets the system state. 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...
 
void ClampInput (double maxInput)
 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...
 

Detailed Description

Represents a simulated flywheel mechanism.

Constructor & Destructor Documentation

◆ FlywheelSim()

frc::sim::FlywheelSim::FlywheelSim ( const LinearSystem< 1, 1, 1 > &  plant,
const DCMotor gearbox,
const std::array< double, 1 > &  measurementStdDevs = {0.0} 
)

Creates a simulated flywheel mechanism.

Parameters
plantThe linear system representing the flywheel. This system can be created with LinearSystemId::FlywheelSystem() or LinearSystemId::IdentifyVelocitySystem().
gearboxThe type of and number of motors in the flywheel gearbox.
measurementStdDevsThe standard deviation of the measurement noise.

Member Function Documentation

◆ Gearbox()

DCMotor frc::sim::FlywheelSim::Gearbox ( ) const
inline

Returns the gearbox.

◆ Gearing()

double frc::sim::FlywheelSim::Gearing ( ) const
inline

Returns the gearing;.

◆ GetAngularAcceleration()

units::radians_per_second_squared_t frc::sim::FlywheelSim::GetAngularAcceleration ( ) const

Returns the flywheel's acceleration.

Returns
The flywheel's acceleration

◆ GetAngularVelocity()

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

Returns the flywheel's velocity.

Returns
The flywheel's velocity.

◆ GetCurrentDraw()

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

Returns the flywheel's current draw.

Returns
The flywheel's current draw.

◆ GetInputVoltage()

units::volt_t frc::sim::FlywheelSim::GetInputVoltage ( ) const

Gets the input voltage for the flywheel.

Returns
The flywheel input voltage.

◆ GetTorque()

units::newton_meter_t frc::sim::FlywheelSim::GetTorque ( ) const

Returns the flywheel's torque.

Returns
The flywheel's torque

◆ J()

units::kilogram_square_meter_t frc::sim::FlywheelSim::J ( ) const
inline

Returns the moment of inertia.

◆ SetInputVoltage()

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

Sets the input voltage for the flywheel.

Parameters
voltageThe input voltage.

◆ SetState()

void frc::sim::LinearSystemSim< States, Inputs, Outputs >::SetState ( const Vectord< States > &  state)
inline

Sets the system state.

Parameters
stateThe new state.

◆ SetVelocity()

void frc::sim::FlywheelSim::SetVelocity ( units::radians_per_second_t  velocity)

Sets the flywheel's angular velocity.

Parameters
velocityThe new velocity

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