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

Represents a simulated DC motor mechanism. More...

#include <wpi/simulation/DCMotorSim.hpp>

Inheritance diagram for wpi::sim::DCMotorSim:
wpi::sim::LinearSystemSim< 2, 1, 2 >

Public Member Functions

 DCMotorSim (const wpi::math::LinearSystem< 2, 1, 2 > &plant, const wpi::math::DCMotor &gearbox, const std::array< double, 2 > &measurementStdDevs={0.0, 0.0})
 Creates a simulated DC motor mechanism.
void SetState (wpi::units::radian_t angularPosition, wpi::units::radians_per_second_t angularVelocity)
 Sets the state of the DC motor.
void SetAngle (wpi::units::radian_t angularPosition)
 Sets the DC motor's angular position.
void SetAngularVelocity (wpi::units::radians_per_second_t angularVelocity)
 Sets the DC motor's angular velocity.
wpi::units::radian_t GetAngularPosition () const
 Returns the DC motor position.
wpi::units::radians_per_second_t GetAngularVelocity () const
 Returns the DC motor velocity.
wpi::units::radians_per_second_squared_t GetAngularAcceleration () const
 Returns the DC motor acceleration.
wpi::units::newton_meter_t GetTorque () const
 Returns the DC motor torque.
wpi::units::ampere_t GetCurrentDraw () const
 Returns the DC motor current draw.
wpi::units::volt_t GetInputVoltage () const
 Gets the input voltage for the DC motor.
void SetInputVoltage (wpi::units::volt_t voltage)
 Sets the input voltage for the DC motor.
const wpi::math::DCMotorGetGearbox () const
 Returns the gearbox.
double GetGearing () const
 Returns the gearing;.
wpi::units::kilogram_square_meter_t GetJ () 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< 2, 1, 2 >
 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< 2, 1, 2 >
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< 2, 1, 2 >
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 DC motor mechanism.

Constructor & Destructor Documentation

◆ DCMotorSim()

wpi::sim::DCMotorSim::DCMotorSim ( const wpi::math::LinearSystem< 2, 1, 2 > & plant,
const wpi::math::DCMotor & gearbox,
const std::array< double, 2 > & measurementStdDevs = {0.0, 0.0} )

Creates a simulated DC motor mechanism.

Parameters
plantThe linear system representing the DC motor. This system can be created with wpi::math::Models::SingleJointedArmFromPhysicalConstants() or wpi::math::Models::SingleJointedArmFromSysId().
gearboxThe type of and number of motors in the DC motor gearbox.
measurementStdDevsThe standard deviation of the measurement noise.

Member Function Documentation

◆ GetAngularAcceleration()

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

Returns the DC motor acceleration.

Returns
The DC motor acceleration

◆ GetAngularPosition()

wpi::units::radian_t wpi::sim::DCMotorSim::GetAngularPosition ( ) const

Returns the DC motor position.

Returns
The DC motor position.

◆ GetAngularVelocity()

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

Returns the DC motor velocity.

Returns
The DC motor velocity.

◆ GetCurrentDraw()

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

Returns the DC motor current draw.

Returns
The DC motor current draw.

◆ GetGearbox()

const wpi::math::DCMotor & wpi::sim::DCMotorSim::GetGearbox ( ) const

Returns the gearbox.

◆ GetGearing()

double wpi::sim::DCMotorSim::GetGearing ( ) const

Returns the gearing;.

◆ GetInputVoltage()

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

Gets the input voltage for the DC motor.

Returns
The DC motor input voltage.

◆ GetJ()

wpi::units::kilogram_square_meter_t wpi::sim::DCMotorSim::GetJ ( ) const

Returns the moment of inertia.

◆ GetTorque()

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

Returns the DC motor torque.

Returns
The DC motor torque

◆ SetAngle()

void wpi::sim::DCMotorSim::SetAngle ( wpi::units::radian_t angularPosition)

Sets the DC motor's angular position.

Parameters
angularPositionThe new position in radians.

◆ SetAngularVelocity()

void wpi::sim::DCMotorSim::SetAngularVelocity ( wpi::units::radians_per_second_t angularVelocity)

Sets the DC motor's angular velocity.

Parameters
angularVelocityThe new velocity in radians per second.

◆ SetInputVoltage()

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

Sets the input voltage for the DC motor.

Parameters
voltageThe input voltage.

◆ SetState() [1/2]

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

Sets the system state.

Parameters
stateThe new state.

◆ SetState() [2/2]

void wpi::sim::DCMotorSim::SetState ( wpi::units::radian_t angularPosition,
wpi::units::radians_per_second_t angularVelocity )

Sets the state of the DC motor.

Parameters
angularPositionThe new position
angularVelocityThe new velocity

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