Class SimMotorConfigs

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

public final class SimMotorConfigs extends Object

Stores the configurations of the motor.

This class encapsulates the various configuration parameters required to simulate and control a motor in a system. The configurations include:

  • motor: The motor model used in the simulation (e.g., Falcon 500, NEO).
  • gearing: The gear ratio between the motor and the load, affecting the output torque and speed.
  • loadMOI: The moment of inertia (MOI) of the load connected to the motor, which determines the resistance to changes in rotational speed.
  • friction: The torque friction characteristics applied to the motor's simulation, representing real-world losses.
  • positionVoltageController: PID controller for controlling the motor's position via voltage.
  • velocityVoltageController: PID controller for controlling the motor's velocity via voltage.
  • positionCurrentController: PID controller for controlling the motor's position via current.
  • velocityCurrentController: PID controller for controlling the motor's velocity via current.
  • feedforward: A feedforward controller used to compensate for the desired motor behavior based on input speeds.
  • forwardHardwareLimit: The forward limit for motor rotation, specified in angle units.
  • reverseHardwareLimit: The reverse limit for motor rotation, specified in angle units.
  • currentLimit: The current limit applied to the motor to protect it from overcurrent conditions.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected edu.wpi.first.units.measure.Angle
     
    final edu.wpi.first.units.measure.Torque
     
    final double
     
    final edu.wpi.first.units.measure.MomentOfInertia
     
    final DCMotor
     
    protected edu.wpi.first.units.measure.Angle
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    SimMotorConfigs(DCMotor motor, double gearing, edu.wpi.first.units.measure.MomentOfInertia loadMOI, edu.wpi.first.units.measure.Voltage frictionVoltage)
    Constructs a simulated motor configuration.
  • Method Summary

    Modifier and Type
    Method
    Description
    edu.wpi.first.units.measure.Current
    calculateCurrent(edu.wpi.first.units.measure.AngularVelocity mechanismVelocity, edu.wpi.first.units.measure.Voltage voltage)
    Calculates the current of the motor.
    edu.wpi.first.units.measure.Current
    calculateCurrent(edu.wpi.first.units.measure.Torque torque)
    Calculates the current based on the motor's torque.
    edu.wpi.first.units.measure.AngularVelocity
    calculateMechanismVelocity(edu.wpi.first.units.measure.Current current, edu.wpi.first.units.measure.Voltage voltage)
    Calculates the velocity of the motor.
    edu.wpi.first.units.measure.Torque
    calculateTorque(edu.wpi.first.units.measure.Current current)
    Calculates the torque based on the motor's current.
    edu.wpi.first.units.measure.Voltage
    calculateVoltage(edu.wpi.first.units.measure.Current current, edu.wpi.first.units.measure.AngularVelocity mechanismVelocity)
    Calculates the voltage of the motor.
    protected SimMotorConfigs
     
    edu.wpi.first.units.measure.Current
     
    edu.wpi.first.units.measure.AngularVelocity
     
    edu.wpi.first.units.measure.Voltage
     
    edu.wpi.first.units.measure.Current
     
    edu.wpi.first.units.measure.Torque
     
    withHardLimits(edu.wpi.first.units.measure.Angle forwardLimit, edu.wpi.first.units.measure.Angle reverseLimit)
    Configures the hard limits for the motor.

    Methods inherited from class java.lang.Object

    equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • motor

      public final DCMotor motor
    • gearing

      public final double gearing
    • loadMOI

      public final edu.wpi.first.units.measure.MomentOfInertia loadMOI
    • friction

      public final edu.wpi.first.units.measure.Torque friction
    • forwardHardwareLimit

      protected edu.wpi.first.units.measure.Angle forwardHardwareLimit
    • reverseHardwareLimit

      protected edu.wpi.first.units.measure.Angle reverseHardwareLimit
  • Constructor Details

    • SimMotorConfigs

      public SimMotorConfigs(DCMotor motor, double gearing, edu.wpi.first.units.measure.MomentOfInertia loadMOI, edu.wpi.first.units.measure.Voltage frictionVoltage)

      Constructs a simulated motor configuration.

      This constructor initializes a SimMotorConfigs object with the necessary parameters for motor simulation, including the motor model, gearing ratio, load moment of inertia, and friction characteristics.

      Parameters:
      motor - the motor model to be used in the simulation (e.g., Falcon 500, NEO).
      gearing - the gear ratio between the motor and the load, affecting torque and speed output.
      loadMOI - the moment of inertia of the load connected to the motor, representing rotational resistance.
      frictionVoltage - the voltage applied to simulate frictional torque losses in the motor.
  • Method Details

    • calculateVoltage

      public edu.wpi.first.units.measure.Voltage calculateVoltage(edu.wpi.first.units.measure.Current current, edu.wpi.first.units.measure.AngularVelocity mechanismVelocity)

      Calculates the voltage of the motor.

      This method uses the DCMotor model to find the voltage for a given current and angular velocity.

      Parameters:
      current - the current flowing through the motor
      mechanismVelocity - the final angular velocity of the mechanism
      Returns:
      the voltage required for the motor to achieve the specified current and angular velocity
      See Also:
    • calculateMechanismVelocity

      public edu.wpi.first.units.measure.AngularVelocity calculateMechanismVelocity(edu.wpi.first.units.measure.Current current, edu.wpi.first.units.measure.Voltage voltage)

      Calculates the velocity of the motor.

      This method uses the DCMotor model to find the angular velocity for a given current and voltage.

      Parameters:
      current - the current flowing through the motor.
      voltage - the voltage applied to the motor.
      Returns:
      the final angular velocity of the mechanism.
      See Also:
    • calculateCurrent

      public edu.wpi.first.units.measure.Current calculateCurrent(edu.wpi.first.units.measure.AngularVelocity mechanismVelocity, edu.wpi.first.units.measure.Voltage voltage)

      Calculates the current of the motor.

      This method uses the DCMotor model to find the current for a given angular velocity and voltage.

      Parameters:
      mechanismVelocity - the final angular velocity of the mechanism.
      voltage - the voltage applied to the moto.
      Returns:
      the current drawn by the motor.
      See Also:
    • calculateCurrent

      public edu.wpi.first.units.measure.Current calculateCurrent(edu.wpi.first.units.measure.Torque torque)

      Calculates the current based on the motor's torque.

      This method uses the DCMotor model to find the current required for a given torque.

      Parameters:
      torque - the final torque generated by the motor on the mechanism.
      Returns:
      the current required to produce the specified torque.
      See Also:
    • calculateTorque

      public edu.wpi.first.units.measure.Torque calculateTorque(edu.wpi.first.units.measure.Current current)

      Calculates the torque based on the motor's current.

      This method uses the DCMotor model to find the torque generated by a given current.

      Parameters:
      current - the current flowing through the motor.
      Returns:
      the torque generated by the motor.
      See Also:
    • withHardLimits

      public SimMotorConfigs withHardLimits(edu.wpi.first.units.measure.Angle forwardLimit, edu.wpi.first.units.measure.Angle reverseLimit)

      Configures the hard limits for the motor.

      This method sets the hardware limits for the motor's movement. When either the forward or reverse limit is reached, the motor will be physically restricted from moving beyond that point, based on the motor's hardware constraints.

      Parameters:
      forwardLimit - the forward hardware limit angle, beyond which the motor cannot move
      reverseLimit - the reverse hardware limit angle, beyond which the motor cannot move
      Returns:
      this instance for method chaining
    • freeSpinMechanismVelocity

      public edu.wpi.first.units.measure.AngularVelocity freeSpinMechanismVelocity()
    • freeSpinCurrent

      public edu.wpi.first.units.measure.Current freeSpinCurrent()
    • stallCurrent

      public edu.wpi.first.units.measure.Current stallCurrent()
    • stallTorque

      public edu.wpi.first.units.measure.Torque stallTorque()
    • nominalVoltage

      public edu.wpi.first.units.measure.Voltage nominalVoltage()
    • clone

      protected SimMotorConfigs clone()
      Overrides:
      clone in class Object