DCMotorSim
- class wpilib.simulation.DCMotorSim(plant: wpimath._wpimath.LinearSystem_2_1_2, gearbox: wpimath._wpimath.DCMotor, measurement_std_devs: 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.
measurement_std_devs – The standard deviation of the measurement noise.
- get_angular_acceleration() wpimath.units.radians_per_second_squared
Returns the DC motor acceleration.
- Returns:
The DC motor acceleration
- get_angular_position() wpimath.units.radians
Returns the DC motor position.
- Returns:
The DC motor position.
- get_angular_position_rotations() wpimath.units.turns
Returns the DC motor position in rotations
- get_angular_velocity() wpimath.units.radians_per_second
Returns the DC motor velocity.
- Returns:
The DC motor velocity.
- get_angular_velocity_rpm() wpimath.units.revolutions_per_minute
Returns the DC motor velocity in revolutions per minute
- get_current_draw() wpimath.units.amperes
Returns the DC motor current draw.
- Returns:
The DC motor current draw.
- get_gearbox() wpimath._wpimath.DCMotor
Returns the gearbox.
- get_gearing() float
Returns the gearing;
- get_input_voltage() wpimath.units.volts
Gets the input voltage for the DC motor.
- Returns:
The DC motor input voltage.
- get_j() wpimath.units.kilogram_square_meters
Returns the moment of inertia
- get_torque() wpimath.units.newton_meters
Returns the DC motor torque.
- Returns:
The DC motor torque
- set_angle(angular_position: wpimath.units.radians) None
Sets the DC motor’s angular position.
- Parameters:
angular_position – The new position in radians.
- set_angular_velocity(angular_velocity: wpimath.units.radians_per_second) None
Sets the DC motor’s angular velocity.
- Parameters:
angular_velocity – The new velocity in radians per second.
- set_input_voltage(voltage: wpimath.units.volts) None
Sets the input voltage for the DC motor.
- Parameters:
voltage – The input voltage.
- set_state(angular_position: wpimath.units.radians, angular_velocity: wpimath.units.radians_per_second) None
Sets the state of the DC motor.
- Parameters:
angular_position – The new position
angular_velocity – The new velocity