Class MapleMotorSim

java.lang.Object
org.ironmaple.simulation.motorsims.MapleMotorSim

public class MapleMotorSim extends Object

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 Details

    • MapleMotorSim

      public MapleMotorSim(SimMotorConfigs configs)

      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 toLinearSystemSim.update(double).

    • useMotorController

      public <T extends SimulatedMotorController> T useMotorController(T motorController)
    • useSimpleDCMotorController

      public SimulatedMotorController.GenericMotorController 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

      public SimMotorConfigs 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