DCMotorSim
- class wpilib.simulation.DCMotorSim(plant: wpimath._wpimath.LinearSystem_2_1_2, gearbox: wpimath._wpimath.DCMotor, measurementStdDevs: Annotated[collections.abc.Sequence[SupportsFloat | SupportsIndex], 'FixedSize(2)'] = [0.0, 0.0])
Bases:
LinearSystemSim_2_1_2Represents a simulated DC motor mechanism.
Creates a simulated DC motor mechanism.
- Parameters:
plant – The linear system representing the DC motor. This system can be created with wpi::math::Models::SingleJointedArmFromPhysicalConstants() or wpi::math::Models::SingleJointedArmFromSysId().
gearbox – The type of and number of motors in the DC motor gearbox.
measurementStdDevs – The standard deviation of the measurement noise.
- getAngularAcceleration() wpimath.units.radians_per_second_squared
Returns the DC motor acceleration.
- Returns:
The DC motor acceleration
- getAngularPosition() wpimath.units.radians
Returns the DC motor position.
- Returns:
The DC motor position.
- getAngularPositionRotations() wpimath.units.turns
Returns the DC motor position in rotations
- getAngularVelocity() wpimath.units.radians_per_second
Returns the DC motor velocity.
- Returns:
The DC motor velocity.
- getAngularVelocityRPM() wpimath.units.revolutions_per_minute
Returns the DC motor velocity in revolutions per minute
- getCurrentDraw() wpimath.units.amperes
Returns the DC motor current draw.
- Returns:
The DC motor current draw.
- getGearbox() wpimath._wpimath.DCMotor
Returns the gearbox.
- getGearing() float
Returns the gearing;
- getInputVoltage() wpimath.units.volts
Gets the input voltage for the DC motor.
- Returns:
The DC motor input voltage.
- getJ() wpimath.units.kilogram_square_meters
Returns the moment of inertia
- getTorque() wpimath.units.newton_meters
Returns the DC motor torque.
- Returns:
The DC motor torque
- setAngle(angularPosition: wpimath.units.radians) None
Sets the DC motor’s angular position.
- Parameters:
angularPosition – The new position in radians.
- setAngularVelocity(angularVelocity: wpimath.units.radians_per_second) None
Sets the DC motor’s angular velocity.
- Parameters:
angularVelocity – The new velocity in radians per second.
- setInputVoltage(voltage: wpimath.units.volts) None
Sets the input voltage for the DC motor.
- Parameters:
voltage – The input voltage.
- setState(angularPosition: wpimath.units.radians, angularVelocity: wpimath.units.radians_per_second) None
Sets the state of the DC motor.
- Parameters:
angularPosition – The new position
angularVelocity – The new velocity