Represents a simulated DC motor mechanism. More...
#include <frc/simulation/DCMotorSim.h>
Public Member Functions | |
DCMotorSim (const LinearSystem< 2, 1, 2 > &plant, const DCMotor &gearbox, const std::array< double, 2 > &measurementStdDevs={0.0, 0.0}) | |
Creates a simulated DC motor mechanism. | |
void | SetState (units::radian_t angularPosition, units::radians_per_second_t angularVelocity) |
Sets the state of the DC motor. | |
void | SetAngle (units::radian_t angularPosition) |
Sets the DC motor's angular position. | |
void | SetAngularVelocity (units::radians_per_second_t angularVelocity) |
Sets the DC motor's angular velocity. | |
units::radian_t | GetAngularPosition () const |
Returns the DC motor position. | |
units::radians_per_second_t | GetAngularVelocity () const |
Returns the DC motor velocity. | |
units::radians_per_second_squared_t | GetAngularAcceleration () const |
Returns the DC motor acceleration. | |
units::newton_meter_t | GetTorque () const |
Returns the DC motor torque. | |
units::ampere_t | GetCurrentDraw () const |
Returns the DC motor current draw. | |
units::volt_t | GetInputVoltage () const |
Gets the input voltage for the DC motor. | |
void | SetInputVoltage (units::volt_t voltage) |
Sets the input voltage for the DC motor. | |
const DCMotor & | GetGearbox () const |
Returns the gearbox. | |
double | GetGearing () const |
Returns the gearing;. | |
units::kilogram_square_meter_t | GetJ () const |
Returns the moment of inertia. | |
void | SetState (const Vectord< States > &state) |
Sets the system state. | |
![]() | |
LinearSystemSim (const LinearSystem< States, Inputs, Outputs > &system, const std::array< double, Outputs > &measurementStdDevs={}) | |
Creates a simulated generic linear system. | |
virtual | ~LinearSystemSim ()=default |
void | Update (units::second_t dt) |
Updates the simulation. | |
const Vectord< Outputs > & | GetOutput () const |
Returns the current output of the plant. | |
double | GetOutput (int row) const |
Returns an element of the current output of the plant. | |
void | SetInput (const Vectord< Inputs > &u) |
Sets the system inputs (usually voltages). | |
void | SetInput (int row, double value) |
Sets the system inputs. | |
const Vectord< Inputs > & | GetInput () const |
Returns the current input of the plant. | |
double | GetInput (int row) const |
Returns an element of the current input of the plant. | |
void | SetState (const Vectord< States > &state) |
Sets the system state. | |
Additional Inherited Members | |
![]() | |
virtual Vectord< States > | UpdateX (const Vectord< States > ¤tXhat, const Vectord< Inputs > &u, 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. | |
![]() | |
LinearSystem< States, Inputs, Outputs > | m_plant |
The plant that represents the linear system. | |
Vectord< States > | m_x |
State vector. | |
Vectord< Inputs > | m_u |
Input vector. | |
Vectord< Outputs > | m_y |
Output vector. | |
std::array< double, Outputs > | m_measurementStdDevs |
The standard deviations of measurements, used for adding noise to the measurements. | |
Represents a simulated DC motor mechanism.
frc::sim::DCMotorSim::DCMotorSim | ( | const LinearSystem< 2, 1, 2 > & | plant, |
const DCMotor & | gearbox, | ||
const std::array< double, 2 > & | measurementStdDevs = {0.0, 0.0} ) |
Creates a simulated DC motor mechanism.
plant | The linear system representing the DC motor. This system can be created with LinearSystemId::DCMotorSystem(). If LinearSystemId::DCMotorSystem(kV, kA) is used, the distance unit must be radians. |
gearbox | The type of and number of motors in the DC motor gearbox. |
measurementStdDevs | The standard deviation of the measurement noise. |
units::radians_per_second_squared_t frc::sim::DCMotorSim::GetAngularAcceleration | ( | ) | const |
Returns the DC motor acceleration.
units::radian_t frc::sim::DCMotorSim::GetAngularPosition | ( | ) | const |
Returns the DC motor position.
units::radians_per_second_t frc::sim::DCMotorSim::GetAngularVelocity | ( | ) | const |
Returns the DC motor velocity.
units::ampere_t frc::sim::DCMotorSim::GetCurrentDraw | ( | ) | const |
Returns the DC motor current draw.
const DCMotor & frc::sim::DCMotorSim::GetGearbox | ( | ) | const |
Returns the gearbox.
double frc::sim::DCMotorSim::GetGearing | ( | ) | const |
Returns the gearing;.
units::volt_t frc::sim::DCMotorSim::GetInputVoltage | ( | ) | const |
Gets the input voltage for the DC motor.
units::kilogram_square_meter_t frc::sim::DCMotorSim::GetJ | ( | ) | const |
Returns the moment of inertia.
units::newton_meter_t frc::sim::DCMotorSim::GetTorque | ( | ) | const |
Returns the DC motor torque.
void frc::sim::DCMotorSim::SetAngle | ( | units::radian_t | angularPosition | ) |
Sets the DC motor's angular position.
angularPosition | The new position in radians. |
void frc::sim::DCMotorSim::SetAngularVelocity | ( | units::radians_per_second_t | angularVelocity | ) |
Sets the DC motor's angular velocity.
angularVelocity | The new velocity in radians per second. |
void frc::sim::DCMotorSim::SetInputVoltage | ( | units::volt_t | voltage | ) |
Sets the input voltage for the DC motor.
voltage | The input voltage. |
|
inline |
Sets the system state.
state | The new state. |
void frc::sim::DCMotorSim::SetState | ( | units::radian_t | angularPosition, |
units::radians_per_second_t | angularVelocity ) |
Sets the state of the DC motor.
angularPosition | The new position |
angularVelocity | The new velocity |