Class MapleMotorSim
DCMotorSim
with a bit of extra spice.
This class extends the functionality of the original DCMotorSim
and
models the following aspects in addition:
- Motor Controller Closed Loops.
- Smart current limiting.
- Friction force on the rotor.
-
Constructor Summary
ConstructorDescriptionMapleMotorSim
(SimMotorConfigs configs) Constructs a Brushless Motor Simulation Instance. -
Method Summary
Modifier and TypeMethodDescriptionedu.wpi.first.units.measure.Angle
Obtains the final position of the mechanism.edu.wpi.first.units.measure.Voltage
Obtains the applied voltage by the motor controller.Obtains the configuration of the motor.edu.wpi.first.units.measure.Angle
Obtains the angular position measured by the relative encoder of the motor.edu.wpi.first.units.measure.AngularVelocity
Obtains the angular velocity measured by the relative encoder of the motor.edu.wpi.first.units.measure.Current
Obtains the stator current.edu.wpi.first.units.measure.Current
Obtains the supply current.edu.wpi.first.units.measure.AngularVelocity
Obtains the final velocity of the mechanism.void
update
(edu.wpi.first.units.measure.Time dt) Updates the simulation.<T extends SimulatedMotorController>
TuseMotorController
(T motorController)
-
Constructor Details
-
MapleMotorSim
Constructs a Brushless Motor Simulation Instance.
- Parameters:
configs
- the configuration for this motor
-
-
Method Details
-
update
public void update(edu.wpi.first.units.measure.Time dt) Updates the simulation.
This is equivalent to
LinearSystemSim.update(double)
. -
useMotorController
-
useSimpleDCMotorController
-
getAngularPosition
public edu.wpi.first.units.measure.Angle getAngularPosition()Obtains the final position of the mechanism.
This is equivalent to
DCMotorSim.getAngularPosition()
.- Returns:
- the angular position of the motor, continuous
-
getEncoderPosition
public edu.wpi.first.units.measure.Angle getEncoderPosition()Obtains the angular position measured by the relative encoder of the motor.
- Returns:
- the angular position measured by the encoder, continuous
-
getVelocity
public edu.wpi.first.units.measure.AngularVelocity getVelocity()Obtains the final velocity of the mechanism.
This is equivalent to
DCMotorSim.getAngularVelocity()
.- Returns:
- the final angular velocity of the rotter
-
getEncoderVelocity
public edu.wpi.first.units.measure.AngularVelocity getEncoderVelocity()Obtains the angular velocity measured by the relative encoder of the motor.
- Returns:
- the angular velocity measured by the encoder
-
getAppliedVoltage
public edu.wpi.first.units.measure.Voltage getAppliedVoltage()Obtains the applied voltage by the motor controller.
The applied voltage is calculated by the motor controller in the previous call to
update(Time)
The motor controller specified by
useMotorController(SimulatedMotorController)
is used to calculate the applied voltage.The applied voltage is also restricted for current limit and battery voltage.
- Returns:
- the applied voltage
-
getStatorCurrent
public edu.wpi.first.units.measure.Current getStatorCurrent()Obtains the stator current.
This is equivalent to
DCMotorSim.getCurrentDrawAmps()
- Returns:
- the stator current of the motor
-
getSupplyCurrent
public edu.wpi.first.units.measure.Current getSupplyCurrent()Obtains the supply current.
The supply current is different from the stator current, as described here.
- Returns:
- the supply current of the motor
-
getConfigs
Obtains the configuration of the motor.
You can modify the configuration of this motor by:
mapleMotorSim.getConfigs() .with...(...) .with...(...);
- Returns:
- the configuration of the motor
-