DCMotorSim
- class wpilib.simulation.DCMotorSim(*args, **kwargs)
Bases:
LinearSystemSim_2_1_2
Represents a simulated DC motor mechanism.
Overloaded function.
__init__(self: wpilib.simulation._simulation.DCMotorSim, plant: wpimath._controls._controls.system.LinearSystem_2_1_2, gearbox: wpimath._controls._controls.plant.DCMotor, gearing: float, measurementStdDevs: Annotated[list[float], FixedSize(2)] = [0.0, 0.0]) -> None
Creates a simulated DC motor mechanism.
- Parameters:
plant – The linear system representing the DC motor. This system can be created with LinearSystemId::DCMotorSystem().
gearbox – The type of and number of motors in the DC motor gearbox.
gearing – The gearing of the DC motor (numbers greater than 1 represent reductions).
measurementStdDevs – The standard deviation of the measurement noise.
__init__(self: wpilib.simulation._simulation.DCMotorSim, gearbox: wpimath._controls._controls.plant.DCMotor, gearing: float, moi: wpimath.units.kilogram_square_meters, measurementStdDevs: Annotated[list[float], FixedSize(2)] = [0.0, 0.0]) -> None
Creates a simulated DC motor mechanism.
- Parameters:
gearbox – The type of and number of motors in the DC motor gearbox.
gearing – The gearing of the DC motor (numbers greater than 1 represent reductions).
moi – The moment of inertia of the DC motor.
measurementStdDevs – The standard deviation of the measurement noise.
- getAngularPosition() wpimath.units.radians
Returns the DC motor position.
- Returns:
The DC motor position.
- getAngularVelocity() wpimath.units.radians_per_second
Returns the DC motor velocity.
- Returns:
The DC motor velocity.
- getCurrentDraw() wpimath.units.amperes
Returns the DC motor current draw.
- Returns:
The DC motor current draw.
- 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