Class DCMotor

java.lang.Object
edu.wpi.first.math.system.plant.DCMotor
All Implemented Interfaces:
ProtobufSerializable, StructSerializable, WPISerializable

public class DCMotor extends Object implements ProtobufSerializable, StructSerializable
Holds the constants for a DC motor.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final double
    Current draw under no load in amps.
    final double
    Angular velocity under no load in radians per second.
    final double
    Motor torque constant in Newton-meters per amp.
    final double
    Motor velocity constant in (rad/s)/V.
    final double
    Voltage at which the motor constants were measured.
    static final DCMotorProto
    DCMotor protobuf for serialization.
    final double
    Motor internal resistance in Ohms.
    final double
    Current draw when stalled in amps.
    final double
    Torque when stalled in Newton-meters.
    static final DCMotorStruct
    DCMotor struct for serialization.
  • Constructor Summary

    Constructors
    Constructor
    Description
    DCMotor(double nominalVoltage, double stallTorque, double stallCurrent, double freeCurrent, double freeSpeed, int numMotors)
    Constructs a DC motor.
  • Method Summary

    Modifier and Type
    Method
    Description
    static DCMotor
    getAndymark9015(int numMotors)
    Return a gearbox of Andymark 9015 motors.
    static DCMotor
    getAndymarkRs775_125(int numMotors)
    Return a gearbox of Andymark RS775-125 motors.
    static DCMotor
    getBag(int numMotors)
    Return a gearbox of Bag motors.
    static DCMotor
    getBanebotsRs550(int numMotors)
    Return a gearbox of Banebots RS 550 motors.
    static DCMotor
    getBanebotsRs775(int numMotors)
    Return a gearbox of Banebots RS775 motors.
    static DCMotor
    getCIM(int numMotors)
    Return a gearbox of CIM motors.
    double
    getCurrent(double torque)
    Calculate current drawn by motor for a given torque.
    double
    getCurrent(double speed, double voltageInput)
    Calculate current drawn by motor with given speed and input voltage.
    static DCMotor
    getFalcon500(int numMotors)
    Return a gearbox of Falcon 500 motors.
    static DCMotor
    getFalcon500Foc(int numMotors)
    Return a gearbox of Falcon 500 motors with FOC (Field-Oriented Control) enabled.
    static DCMotor
    getKrakenX60(int numMotors)
    Return a gearbox of Kraken X60 brushless motors.
    static DCMotor
    getKrakenX60Foc(int numMotors)
    Return a gearbox of Kraken X60 brushless motors with FOC (Field-Oriented Control) enabled.
    static DCMotor
    getMiniCIM(int numMotors)
    Return a gearbox of MiniCIM motors.
    static DCMotor
    getNEO(int numMotors)
    Return a gearbox of NEO motors.
    static DCMotor
    getNeo550(int numMotors)
    Return a gearbox of NEO 550 motors.
    static DCMotor
    getNeoVortex(int numMotors)
    Return a gearbox of Neo Vortex brushless motors.
    static DCMotor
    getRomiBuiltIn(int numMotors)
    Return a gearbox of Romi/TI_RSLK MAX motors.
    double
    getSpeed(double torque, double voltageInput)
    Calculates the angular speed produced by the motor at a given torque and input voltage.
    double
    getTorque(double current)
    Calculate torque produced by the motor with a given current.
    static DCMotor
    getVex775Pro(int numMotors)
    Return a gearbox of 775Pro motors.
    double
    getVoltage(double torque, double speed)
    Calculate the voltage provided to the motor for a given torque and angular velocity.
    withReduction(double gearboxReduction)
    Returns a copy of this motor with the given gearbox reduction applied.

    Methods inherited from class java.lang.Object

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

    • nominalVoltage

      public final double nominalVoltage
      Voltage at which the motor constants were measured.
    • stallTorque

      public final double stallTorque
      Torque when stalled in Newton-meters.
    • stallCurrent

      public final double stallCurrent
      Current draw when stalled in amps.
    • freeCurrent

      public final double freeCurrent
      Current draw under no load in amps.
    • freeSpeed

      public final double freeSpeed
      Angular velocity under no load in radians per second.
    • R

      public final double R
      Motor internal resistance in Ohms.
    • Kv

      public final double Kv
      Motor velocity constant in (rad/s)/V.
    • Kt

      public final double Kt
      Motor torque constant in Newton-meters per amp.
    • proto

      public static final DCMotorProto proto
      DCMotor protobuf for serialization.
    • struct

      public static final DCMotorStruct struct
      DCMotor struct for serialization.
  • Constructor Details

    • DCMotor

      public DCMotor(double nominalVoltage, double stallTorque, double stallCurrent, double freeCurrent, double freeSpeed, int numMotors)
      Constructs a DC motor.
      Parameters:
      nominalVoltage - Voltage at which the motor constants were measured.
      stallTorque - Torque when stalled.
      stallCurrent - Current draw when stalled.
      freeCurrent - Current draw under no load.
      freeSpeed - Angular velocity under no load.
      numMotors - Number of motors in a gearbox.
  • Method Details

    • getCurrent

      public double getCurrent(double speed, double voltageInput)
      Calculate current drawn by motor with given speed and input voltage.
      Parameters:
      speed - The current angular velocity of the motor.
      voltageInput - The voltage being applied to the motor.
      Returns:
      The estimated current.
    • getCurrent

      public double getCurrent(double torque)
      Calculate current drawn by motor for a given torque.
      Parameters:
      torque - The torque produced by the motor in Newton-meters.
      Returns:
      The current drawn by the motor.
    • getTorque

      public double getTorque(double current)
      Calculate torque produced by the motor with a given current.
      Parameters:
      current - The current drawn by the motor in amps.
      Returns:
      The torque output in Newton-meters.
    • getVoltage

      public double getVoltage(double torque, double speed)
      Calculate the voltage provided to the motor for a given torque and angular velocity.
      Parameters:
      torque - The torque produced by the motor in Newton-meters.
      speed - The current angular velocity of the motor in radians per second.
      Returns:
      The voltage of the motor.
    • getSpeed

      public double getSpeed(double torque, double voltageInput)
      Calculates the angular speed produced by the motor at a given torque and input voltage.
      Parameters:
      torque - The torque produced by the motor in Newton-meters.
      voltageInput - The voltage applied to the motor.
      Returns:
      The angular speed of the motor.
    • withReduction

      public DCMotor withReduction(double gearboxReduction)
      Returns a copy of this motor with the given gearbox reduction applied.
      Parameters:
      gearboxReduction - The gearbox reduction.
      Returns:
      A motor with the gearbox reduction applied.
    • getCIM

      public static DCMotor getCIM(int numMotors)
      Return a gearbox of CIM motors.
      Parameters:
      numMotors - Number of motors in the gearbox.
      Returns:
      A gearbox of CIM motors.
    • getVex775Pro

      public static DCMotor getVex775Pro(int numMotors)
      Return a gearbox of 775Pro motors.
      Parameters:
      numMotors - Number of motors in the gearbox.
      Returns:
      A gearbox of 775Pro motors.
    • getNEO

      public static DCMotor getNEO(int numMotors)
      Return a gearbox of NEO motors.
      Parameters:
      numMotors - Number of motors in the gearbox.
      Returns:
      A gearbox of NEO motors.
    • getMiniCIM

      public static DCMotor getMiniCIM(int numMotors)
      Return a gearbox of MiniCIM motors.
      Parameters:
      numMotors - Number of motors in the gearbox.
      Returns:
      A gearbox of MiniCIM motors.
    • getBag

      public static DCMotor getBag(int numMotors)
      Return a gearbox of Bag motors.
      Parameters:
      numMotors - Number of motors in the gearbox.
      Returns:
      A gearbox of Bag motors.
    • getAndymarkRs775_125

      public static DCMotor getAndymarkRs775_125(int numMotors)
      Return a gearbox of Andymark RS775-125 motors.
      Parameters:
      numMotors - Number of motors in the gearbox.
      Returns:
      A gearbox of Andymark RS775-125 motors.
    • getBanebotsRs775

      public static DCMotor getBanebotsRs775(int numMotors)
      Return a gearbox of Banebots RS775 motors.
      Parameters:
      numMotors - Number of motors in the gearbox.
      Returns:
      A gearbox of Banebots RS775 motors.
    • getAndymark9015

      public static DCMotor getAndymark9015(int numMotors)
      Return a gearbox of Andymark 9015 motors.
      Parameters:
      numMotors - Number of motors in the gearbox.
      Returns:
      A gearbox of Andymark 9015 motors.
    • getBanebotsRs550

      public static DCMotor getBanebotsRs550(int numMotors)
      Return a gearbox of Banebots RS 550 motors.
      Parameters:
      numMotors - Number of motors in the gearbox.
      Returns:
      A gearbox of Banebots RS 550 motors.
    • getNeo550

      public static DCMotor getNeo550(int numMotors)
      Return a gearbox of NEO 550 motors.
      Parameters:
      numMotors - Number of motors in the gearbox.
      Returns:
      A gearbox of NEO 550 motors.
    • getFalcon500

      public static DCMotor getFalcon500(int numMotors)
      Return a gearbox of Falcon 500 motors.
      Parameters:
      numMotors - Number of motors in the gearbox.
      Returns:
      A gearbox of Falcon 500 motors.
    • getFalcon500Foc

      public static DCMotor getFalcon500Foc(int numMotors)
      Return a gearbox of Falcon 500 motors with FOC (Field-Oriented Control) enabled.
      Parameters:
      numMotors - Number of motors in the gearbox.
      Returns:
      A gearbox of Falcon 500 FOC enabled motors.
    • getRomiBuiltIn

      public static DCMotor getRomiBuiltIn(int numMotors)
      Return a gearbox of Romi/TI_RSLK MAX motors.
      Parameters:
      numMotors - Number of motors in the gearbox.
      Returns:
      A gearbox of Romi/TI_RSLK MAX motors.
    • getKrakenX60

      public static DCMotor getKrakenX60(int numMotors)
      Return a gearbox of Kraken X60 brushless motors.
      Parameters:
      numMotors - Number of motors in the gearbox.
      Returns:
      a gearbox of Kraken X60 motors.
    • getKrakenX60Foc

      public static DCMotor getKrakenX60Foc(int numMotors)
      Return a gearbox of Kraken X60 brushless motors with FOC (Field-Oriented Control) enabled.
      Parameters:
      numMotors - Number of motors in the gearbox.
      Returns:
      A gearbox of Kraken X60 FOC enabled motors.
    • getNeoVortex

      public static DCMotor getNeoVortex(int numMotors)
      Return a gearbox of Neo Vortex brushless motors.
      Parameters:
      numMotors - Number of motors in the gearbox.
      Returns:
      a gearbox of Neo Vortex motors.