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 Details

    • motor

      public final DCMotor motor
    • gearing

      public final double gearing
    • loadMOI

      public final MomentOfInertia loadMOI
    • friction

      public final Torque friction
    • forwardHardwareLimit

      protected Angle forwardHardwareLimit
    • reverseHardwareLimit

      protected Angle reverseHardwareLimit
  • Constructor Details

    • SimMotorConfigs

      public SimMotorConfigs(DCMotor motor, double gearing, MomentOfInertia loadMOI, 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 Voltage calculateVoltage(Current current, 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 AngularVelocity calculateMechanismVelocity(Current current, 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 Current calculateCurrent(AngularVelocity mechanismVelocity, 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 Current calculateCurrent(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 Torque calculateTorque(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(Angle forwardLimit, 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 AngularVelocity freeSpinMechanismVelocity()
    • freeSpinCurrent

      public Current freeSpinCurrent()
    • stallCurrent

      public Current stallCurrent()
    • stallTorque

      public Torque stallTorque()
    • nominalVoltage

      public Voltage nominalVoltage()
    • clone

      protected SimMotorConfigs clone()
      Overrides:
      clone in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object