WPILibC++ 2027.0.0-alpha-4
Loading...
Searching...
No Matches
wpi::sim::FlywheelSim Class Reference

Represents a simulated flywheel mechanism. More...

#include <wpi/simulation/FlywheelSim.hpp>

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

Public Member Functions

 FlywheelSim (const wpi::math::LinearSystem< 1, 1, 1 > &plant, const wpi::math::DCMotor &gearbox, const std::array< double, 1 > &measurementStdDevs={0.0})
 Creates a simulated flywheel mechanism.
void SetVelocity (wpi::units::radians_per_second_t velocity)
 Sets the flywheel's angular velocity.
wpi::units::radians_per_second_t GetAngularVelocity () const
 Returns the flywheel's velocity.
wpi::units::radians_per_second_squared_t GetAngularAcceleration () const
 Returns the flywheel's acceleration.
wpi::units::newton_meter_t GetTorque () const
 Returns the flywheel's torque.
wpi::units::ampere_t GetCurrentDraw () const
 Returns the flywheel's current draw.
wpi::units::volt_t GetInputVoltage () const
 Gets the input voltage for the flywheel.
void SetInputVoltage (wpi::units::volt_t voltage)
 Sets the input voltage for the flywheel.
wpi::math::DCMotor Gearbox () const
 Returns the gearbox.
double Gearing () const
 Returns the gearing;.
wpi::units::kilogram_square_meter_t J () const
 Returns the moment of inertia.
void SetState (const wpi::math::Vectord< States > &state)
 Sets the system state.
Public Member Functions inherited from wpi::sim::LinearSystemSim< 1, 1, 1 >
 LinearSystemSim (const wpi::math::LinearSystem< States, Inputs, Outputs > &system, const std::array< double, Outputs > &measurementStdDevs={})
 Creates a simulated generic linear system.
virtual ~LinearSystemSim ()=default
void Update (wpi::units::second_t dt)
 Updates the simulation.
const wpi::math::Vectord< Outputs > & GetOutput () const
 Returns the current output of the plant.
void SetInput (const wpi::math::Vectord< Inputs > &u)
 Sets the system inputs (usually voltages).
const wpi::math::Vectord< Inputs > & GetInput () const
 Returns the current input of the plant.
void SetState (const wpi::math::Vectord< States > &state)
 Sets the system state.

Additional Inherited Members

Protected Member Functions inherited from wpi::sim::LinearSystemSim< 1, 1, 1 >
virtual wpi::math::Vectord< States > UpdateX (const wpi::math::Vectord< States > &currentXhat, const wpi::math::Vectord< Inputs > &u, wpi::units::second_t dt)
 Updates the state estimate of the system.
void ClampInput (double maxInput)
 Clamp the input vector such that no element exceeds the given voltage.
Protected Attributes inherited from wpi::sim::LinearSystemSim< 1, 1, 1 >
wpi::math::LinearSystem< States, Inputs, Outputs > m_plant
 The plant that represents the linear system.
wpi::math::Vectord< States > m_x
 State vector.
wpi::math::Vectord< Inputs > m_u
 Input vector.
wpi::math::Vectord< Outputs > m_y
 Output vector.
std::array< double, Outputs > m_measurementStdDevs
 The standard deviations of measurements, used for adding noise to the measurements.

Detailed Description

Represents a simulated flywheel mechanism.

Constructor & Destructor Documentation

◆ FlywheelSim()

wpi::sim::FlywheelSim::FlywheelSim ( const wpi::math::LinearSystem< 1, 1, 1 > & plant,
const wpi::math::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 wpi::math::Models::FlywheelFromPhysicalConstants() or wpi::math::Models::FlywheelFromSysId().
gearboxThe type of and number of motors in the flywheel gearbox.
measurementStdDevsThe standard deviation of the measurement noise.

Member Function Documentation

◆ Gearbox()

wpi::math::DCMotor wpi::sim::FlywheelSim::Gearbox ( ) const
inline

Returns the gearbox.

◆ Gearing()

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

Returns the gearing;.

◆ GetAngularAcceleration()

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

Returns the flywheel's acceleration.

Returns
The flywheel's acceleration

◆ GetAngularVelocity()

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

Returns the flywheel's velocity.

Returns
The flywheel's velocity.

◆ GetCurrentDraw()

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

Returns the flywheel's current draw.

Returns
The flywheel's current draw.

◆ GetInputVoltage()

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

Gets the input voltage for the flywheel.

Returns
The flywheel input voltage.

◆ GetTorque()

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

Returns the flywheel's torque.

Returns
The flywheel's torque

◆ J()

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

Returns the moment of inertia.

◆ SetInputVoltage()

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

Sets the input voltage for the flywheel.

Parameters
voltageThe input voltage.

◆ SetState()

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

Sets the system state.

Parameters
stateThe new state.

◆ SetVelocity()

void wpi::sim::FlywheelSim::SetVelocity ( wpi::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: