Class MockDcMotorEx

java.lang.Object
org.firstinspires.ftc.teamcode.fy23.fakestuff.MockDcMotorEx
All Implemented Interfaces:
com.qualcomm.robotcore.hardware.DcMotor, com.qualcomm.robotcore.hardware.DcMotorEx, com.qualcomm.robotcore.hardware.DcMotorSimple, com.qualcomm.robotcore.hardware.HardwareDevice

public class MockDcMotorEx extends Object implements com.qualcomm.robotcore.hardware.DcMotorEx
This appears as a normal DcMotorEx to your program, and it even updates the position for you over time based on the set velocity and can determine the velocity the motor is running at based on the set power (approximated as a percentage of the maximum velocity). It also handles DcMotor.RunMode.RUN_TO_POSITION mode, running at the set power until the position is reached. Remember that this simulated class is perfect, without the natural variance of a real motor. Have your test put this "device" into the HardwareMap with the correct name so that the test subject can get it.
  • Nested Class Summary

    Nested classes/interfaces inherited from interface com.qualcomm.robotcore.hardware.DcMotor

    com.qualcomm.robotcore.hardware.DcMotor.RunMode, com.qualcomm.robotcore.hardware.DcMotor.ZeroPowerBehavior

    Nested classes/interfaces inherited from interface com.qualcomm.robotcore.hardware.DcMotorSimple

    com.qualcomm.robotcore.hardware.DcMotorSimple.Direction

    Nested classes/interfaces inherited from interface com.qualcomm.robotcore.hardware.HardwareDevice

    com.qualcomm.robotcore.hardware.HardwareDevice.Manufacturer
  • Constructor Summary

    Constructors
    Constructor
    Description
    MockDcMotorEx(com.qualcomm.robotcore.hardware.DcMotorSimple.Direction direction, com.qualcomm.robotcore.hardware.configuration.typecontainers.MotorConfigurationType motorType, com.qualcomm.robotcore.util.ElapsedTime elapsedTime)
     
    MockDcMotorEx(com.qualcomm.robotcore.hardware.DcMotorSimple.Direction direction, com.qualcomm.robotcore.util.ElapsedTime elapsedTime)
     
    MockDcMotorEx(com.qualcomm.robotcore.util.ElapsedTime elapsedTime)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
     
    com.qualcomm.robotcore.hardware.DcMotorController
     
    double
    getCurrent(org.firstinspires.ftc.robotcore.external.navigation.CurrentUnit unit)
     
    double
    getCurrentAlert(org.firstinspires.ftc.robotcore.external.navigation.CurrentUnit unit)
     
    int
     
     
    com.qualcomm.robotcore.hardware.DcMotorSimple.Direction
     
    com.qualcomm.robotcore.hardware.HardwareDevice.Manufacturer
     
    com.qualcomm.robotcore.hardware.DcMotor.RunMode
     
    com.qualcomm.robotcore.hardware.configuration.typecontainers.MotorConfigurationType
     
    com.qualcomm.robotcore.hardware.PIDCoefficients
    getPIDCoefficients(com.qualcomm.robotcore.hardware.DcMotor.RunMode mode)
     
    com.qualcomm.robotcore.hardware.PIDFCoefficients
    getPIDFCoefficients(com.qualcomm.robotcore.hardware.DcMotor.RunMode mode)
     
    int
     
    double
     
    boolean
     
    int
     
    int
     
    double
     
    double
    getVelocity(org.firstinspires.ftc.robotcore.external.navigation.AngleUnit unit)
     
    int
     
    com.qualcomm.robotcore.hardware.DcMotor.ZeroPowerBehavior
     
    boolean
     
    boolean
     
    boolean
     
    void
     
    void
    setCurrentAlert(double current, org.firstinspires.ftc.robotcore.external.navigation.CurrentUnit unit)
     
    void
    setDirection(com.qualcomm.robotcore.hardware.DcMotorSimple.Direction direction)
     
    void
    setMaxVelocityTicks(double maxVelocityTicks)
    For use by your test - sets the maximum velocity of the motor in ticks per second
    void
    setMode(com.qualcomm.robotcore.hardware.DcMotor.RunMode mode)
     
    void
     
    void
     
    void
    setMotorType(com.qualcomm.robotcore.hardware.configuration.typecontainers.MotorConfigurationType motorType)
     
    void
    setPIDCoefficients(com.qualcomm.robotcore.hardware.DcMotor.RunMode mode, com.qualcomm.robotcore.hardware.PIDCoefficients pidCoefficients)
     
    void
    setPIDFCoefficients(com.qualcomm.robotcore.hardware.DcMotor.RunMode mode, com.qualcomm.robotcore.hardware.PIDFCoefficients pidfCoefficients)
     
    void
    setPosition(int position)
     
    void
     
    void
    setPower(double power)
     
    void
     
    void
    setTargetPosition(int position)
     
    void
     
    void
    setTicksPerRotation(double ticksPerRotation)
    For use by your test - sets the ticks counted by the encoder on each rotation of the motor
    void
    setVelocity(double angularRate)
     
    void
    setVelocity(double angularRate, org.firstinspires.ftc.robotcore.external.navigation.AngleUnit unit)
     
    void
    setVelocityPIDFCoefficients(double p, double i, double d, double f)
     
    void
    setZeroPowerBehavior(com.qualcomm.robotcore.hardware.DcMotor.ZeroPowerBehavior zeroPowerBehavior)
     

    Methods inherited from class java.lang.Object

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

    • MockDcMotorEx

      public MockDcMotorEx(com.qualcomm.robotcore.util.ElapsedTime elapsedTime)
    • MockDcMotorEx

      public MockDcMotorEx(com.qualcomm.robotcore.hardware.DcMotorSimple.Direction direction, com.qualcomm.robotcore.util.ElapsedTime elapsedTime)
    • MockDcMotorEx

      public MockDcMotorEx(com.qualcomm.robotcore.hardware.DcMotorSimple.Direction direction, @NonNull com.qualcomm.robotcore.hardware.configuration.typecontainers.MotorConfigurationType motorType, com.qualcomm.robotcore.util.ElapsedTime elapsedTime)
  • Method Details

    • setMotorEnable

      public void setMotorEnable()
      Specified by:
      setMotorEnable in interface com.qualcomm.robotcore.hardware.DcMotorEx
    • setMotorDisable

      public void setMotorDisable()
      Specified by:
      setMotorDisable in interface com.qualcomm.robotcore.hardware.DcMotorEx
    • isMotorEnabled

      public boolean isMotorEnabled()
      Specified by:
      isMotorEnabled in interface com.qualcomm.robotcore.hardware.DcMotorEx
    • setVelocity

      public void setVelocity(double angularRate)
      Specified by:
      setVelocity in interface com.qualcomm.robotcore.hardware.DcMotorEx
    • setVelocity

      public void setVelocity(double angularRate, org.firstinspires.ftc.robotcore.external.navigation.AngleUnit unit)
      Specified by:
      setVelocity in interface com.qualcomm.robotcore.hardware.DcMotorEx
    • getVelocity

      public double getVelocity()
      Specified by:
      getVelocity in interface com.qualcomm.robotcore.hardware.DcMotorEx
    • getVelocity

      public double getVelocity(org.firstinspires.ftc.robotcore.external.navigation.AngleUnit unit)
      Specified by:
      getVelocity in interface com.qualcomm.robotcore.hardware.DcMotorEx
    • setPIDCoefficients

      public void setPIDCoefficients(com.qualcomm.robotcore.hardware.DcMotor.RunMode mode, com.qualcomm.robotcore.hardware.PIDCoefficients pidCoefficients)
      Specified by:
      setPIDCoefficients in interface com.qualcomm.robotcore.hardware.DcMotorEx
    • setPIDFCoefficients

      public void setPIDFCoefficients(com.qualcomm.robotcore.hardware.DcMotor.RunMode mode, com.qualcomm.robotcore.hardware.PIDFCoefficients pidfCoefficients) throws UnsupportedOperationException
      Specified by:
      setPIDFCoefficients in interface com.qualcomm.robotcore.hardware.DcMotorEx
      Throws:
      UnsupportedOperationException
    • setVelocityPIDFCoefficients

      public void setVelocityPIDFCoefficients(double p, double i, double d, double f)
      Specified by:
      setVelocityPIDFCoefficients in interface com.qualcomm.robotcore.hardware.DcMotorEx
    • setPositionPIDFCoefficients

      public void setPositionPIDFCoefficients(double p)
      Specified by:
      setPositionPIDFCoefficients in interface com.qualcomm.robotcore.hardware.DcMotorEx
    • getPIDCoefficients

      public com.qualcomm.robotcore.hardware.PIDCoefficients getPIDCoefficients(com.qualcomm.robotcore.hardware.DcMotor.RunMode mode)
      Specified by:
      getPIDCoefficients in interface com.qualcomm.robotcore.hardware.DcMotorEx
    • getPIDFCoefficients

      public com.qualcomm.robotcore.hardware.PIDFCoefficients getPIDFCoefficients(com.qualcomm.robotcore.hardware.DcMotor.RunMode mode)
      Specified by:
      getPIDFCoefficients in interface com.qualcomm.robotcore.hardware.DcMotorEx
    • setTargetPositionTolerance

      public void setTargetPositionTolerance(int tolerance)
      Specified by:
      setTargetPositionTolerance in interface com.qualcomm.robotcore.hardware.DcMotorEx
    • getTargetPositionTolerance

      public int getTargetPositionTolerance()
      Specified by:
      getTargetPositionTolerance in interface com.qualcomm.robotcore.hardware.DcMotorEx
    • getCurrent

      public double getCurrent(org.firstinspires.ftc.robotcore.external.navigation.CurrentUnit unit)
      Specified by:
      getCurrent in interface com.qualcomm.robotcore.hardware.DcMotorEx
    • getCurrentAlert

      public double getCurrentAlert(org.firstinspires.ftc.robotcore.external.navigation.CurrentUnit unit)
      Specified by:
      getCurrentAlert in interface com.qualcomm.robotcore.hardware.DcMotorEx
    • setCurrentAlert

      public void setCurrentAlert(double current, org.firstinspires.ftc.robotcore.external.navigation.CurrentUnit unit)
      Specified by:
      setCurrentAlert in interface com.qualcomm.robotcore.hardware.DcMotorEx
    • isOverCurrent

      public boolean isOverCurrent()
      Specified by:
      isOverCurrent in interface com.qualcomm.robotcore.hardware.DcMotorEx
    • getMotorType

      public com.qualcomm.robotcore.hardware.configuration.typecontainers.MotorConfigurationType getMotorType()
      Specified by:
      getMotorType in interface com.qualcomm.robotcore.hardware.DcMotor
    • setMotorType

      public void setMotorType(com.qualcomm.robotcore.hardware.configuration.typecontainers.MotorConfigurationType motorType)
      Specified by:
      setMotorType in interface com.qualcomm.robotcore.hardware.DcMotor
    • getController

      public com.qualcomm.robotcore.hardware.DcMotorController getController()
      Specified by:
      getController in interface com.qualcomm.robotcore.hardware.DcMotor
    • getPortNumber

      public int getPortNumber()
      Specified by:
      getPortNumber in interface com.qualcomm.robotcore.hardware.DcMotor
    • setZeroPowerBehavior

      public void setZeroPowerBehavior(com.qualcomm.robotcore.hardware.DcMotor.ZeroPowerBehavior zeroPowerBehavior)
      Specified by:
      setZeroPowerBehavior in interface com.qualcomm.robotcore.hardware.DcMotor
    • getZeroPowerBehavior

      public com.qualcomm.robotcore.hardware.DcMotor.ZeroPowerBehavior getZeroPowerBehavior()
      Specified by:
      getZeroPowerBehavior in interface com.qualcomm.robotcore.hardware.DcMotor
    • setPowerFloat

      public void setPowerFloat()
      Specified by:
      setPowerFloat in interface com.qualcomm.robotcore.hardware.DcMotor
    • getPowerFloat

      public boolean getPowerFloat()
      Specified by:
      getPowerFloat in interface com.qualcomm.robotcore.hardware.DcMotor
    • setTargetPosition

      public void setTargetPosition(int position)
      Specified by:
      setTargetPosition in interface com.qualcomm.robotcore.hardware.DcMotor
    • getTargetPosition

      public int getTargetPosition()
      Specified by:
      getTargetPosition in interface com.qualcomm.robotcore.hardware.DcMotor
    • isBusy

      public boolean isBusy()
      Specified by:
      isBusy in interface com.qualcomm.robotcore.hardware.DcMotor
    • getCurrentPosition

      public int getCurrentPosition()
      Specified by:
      getCurrentPosition in interface com.qualcomm.robotcore.hardware.DcMotor
    • setMode

      public void setMode(com.qualcomm.robotcore.hardware.DcMotor.RunMode mode)
      Specified by:
      setMode in interface com.qualcomm.robotcore.hardware.DcMotor
    • getMode

      public com.qualcomm.robotcore.hardware.DcMotor.RunMode getMode()
      Specified by:
      getMode in interface com.qualcomm.robotcore.hardware.DcMotor
    • setDirection

      public void setDirection(com.qualcomm.robotcore.hardware.DcMotorSimple.Direction direction)
      Specified by:
      setDirection in interface com.qualcomm.robotcore.hardware.DcMotorSimple
    • getDirection

      public com.qualcomm.robotcore.hardware.DcMotorSimple.Direction getDirection()
      Specified by:
      getDirection in interface com.qualcomm.robotcore.hardware.DcMotorSimple
    • setPower

      public void setPower(double power)
      Specified by:
      setPower in interface com.qualcomm.robotcore.hardware.DcMotorSimple
    • getPower

      public double getPower()
      Specified by:
      getPower in interface com.qualcomm.robotcore.hardware.DcMotorSimple
    • getManufacturer

      public com.qualcomm.robotcore.hardware.HardwareDevice.Manufacturer getManufacturer()
      Specified by:
      getManufacturer in interface com.qualcomm.robotcore.hardware.HardwareDevice
    • getDeviceName

      public String getDeviceName()
      Specified by:
      getDeviceName in interface com.qualcomm.robotcore.hardware.HardwareDevice
    • getConnectionInfo

      public String getConnectionInfo()
      Specified by:
      getConnectionInfo in interface com.qualcomm.robotcore.hardware.HardwareDevice
    • getVersion

      public int getVersion()
      Specified by:
      getVersion in interface com.qualcomm.robotcore.hardware.HardwareDevice
    • resetDeviceConfigurationForOpMode

      public void resetDeviceConfigurationForOpMode()
      Specified by:
      resetDeviceConfigurationForOpMode in interface com.qualcomm.robotcore.hardware.HardwareDevice
    • close

      public void close()
      Specified by:
      close in interface com.qualcomm.robotcore.hardware.HardwareDevice
    • setMaxVelocityTicks

      public void setMaxVelocityTicks(double maxVelocityTicks)
      For use by your test - sets the maximum velocity of the motor in ticks per second
    • setTicksPerRotation

      public void setTicksPerRotation(double ticksPerRotation)
      For use by your test - sets the ticks counted by the encoder on each rotation of the motor
    • setPosition

      public void setPosition(int position)