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
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
ConstructorsConstructorDescriptionMockDcMotorEx
(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 TypeMethodDescriptionvoid
close()
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
getMode()
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
getPower()
boolean
int
int
double
double
getVelocity
(org.firstinspires.ftc.robotcore.external.navigation.AngleUnit unit) int
com.qualcomm.robotcore.hardware.DcMotor.ZeroPowerBehavior
boolean
isBusy()
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 secondvoid
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
setPositionPIDFCoefficients
(double p) void
setPower
(double power) void
void
setTargetPosition
(int position) void
setTargetPositionTolerance
(int tolerance) void
setTicksPerRotation
(double ticksPerRotation) For use by your test - sets the ticks counted by the encoder on each rotation of the motorvoid
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)
-
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 interfacecom.qualcomm.robotcore.hardware.DcMotorEx
-
setMotorDisable
public void setMotorDisable()- Specified by:
setMotorDisable
in interfacecom.qualcomm.robotcore.hardware.DcMotorEx
-
isMotorEnabled
public boolean isMotorEnabled()- Specified by:
isMotorEnabled
in interfacecom.qualcomm.robotcore.hardware.DcMotorEx
-
setVelocity
public void setVelocity(double angularRate) - Specified by:
setVelocity
in interfacecom.qualcomm.robotcore.hardware.DcMotorEx
-
getVelocity
public double getVelocity()- Specified by:
getVelocity
in interfacecom.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 interfacecom.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 interfacecom.qualcomm.robotcore.hardware.DcMotorEx
- Throws:
UnsupportedOperationException
-
setVelocityPIDFCoefficients
public void setVelocityPIDFCoefficients(double p, double i, double d, double f) - Specified by:
setVelocityPIDFCoefficients
in interfacecom.qualcomm.robotcore.hardware.DcMotorEx
-
setPositionPIDFCoefficients
public void setPositionPIDFCoefficients(double p) - Specified by:
setPositionPIDFCoefficients
in interfacecom.qualcomm.robotcore.hardware.DcMotorEx
-
getPIDCoefficients
public com.qualcomm.robotcore.hardware.PIDCoefficients getPIDCoefficients(com.qualcomm.robotcore.hardware.DcMotor.RunMode mode) - Specified by:
getPIDCoefficients
in interfacecom.qualcomm.robotcore.hardware.DcMotorEx
-
getPIDFCoefficients
public com.qualcomm.robotcore.hardware.PIDFCoefficients getPIDFCoefficients(com.qualcomm.robotcore.hardware.DcMotor.RunMode mode) - Specified by:
getPIDFCoefficients
in interfacecom.qualcomm.robotcore.hardware.DcMotorEx
-
setTargetPositionTolerance
public void setTargetPositionTolerance(int tolerance) - Specified by:
setTargetPositionTolerance
in interfacecom.qualcomm.robotcore.hardware.DcMotorEx
-
getTargetPositionTolerance
public int getTargetPositionTolerance()- Specified by:
getTargetPositionTolerance
in interfacecom.qualcomm.robotcore.hardware.DcMotorEx
-
isOverCurrent
public boolean isOverCurrent()- Specified by:
isOverCurrent
in interfacecom.qualcomm.robotcore.hardware.DcMotorEx
-
getMotorType
public com.qualcomm.robotcore.hardware.configuration.typecontainers.MotorConfigurationType getMotorType()- Specified by:
getMotorType
in interfacecom.qualcomm.robotcore.hardware.DcMotor
-
setMotorType
public void setMotorType(com.qualcomm.robotcore.hardware.configuration.typecontainers.MotorConfigurationType motorType) - Specified by:
setMotorType
in interfacecom.qualcomm.robotcore.hardware.DcMotor
-
getController
public com.qualcomm.robotcore.hardware.DcMotorController getController()- Specified by:
getController
in interfacecom.qualcomm.robotcore.hardware.DcMotor
-
getPortNumber
public int getPortNumber()- Specified by:
getPortNumber
in interfacecom.qualcomm.robotcore.hardware.DcMotor
-
setZeroPowerBehavior
public void setZeroPowerBehavior(com.qualcomm.robotcore.hardware.DcMotor.ZeroPowerBehavior zeroPowerBehavior) - Specified by:
setZeroPowerBehavior
in interfacecom.qualcomm.robotcore.hardware.DcMotor
-
getZeroPowerBehavior
public com.qualcomm.robotcore.hardware.DcMotor.ZeroPowerBehavior getZeroPowerBehavior()- Specified by:
getZeroPowerBehavior
in interfacecom.qualcomm.robotcore.hardware.DcMotor
-
setPowerFloat
public void setPowerFloat()- Specified by:
setPowerFloat
in interfacecom.qualcomm.robotcore.hardware.DcMotor
-
getPowerFloat
public boolean getPowerFloat()- Specified by:
getPowerFloat
in interfacecom.qualcomm.robotcore.hardware.DcMotor
-
setTargetPosition
public void setTargetPosition(int position) - Specified by:
setTargetPosition
in interfacecom.qualcomm.robotcore.hardware.DcMotor
-
getTargetPosition
public int getTargetPosition()- Specified by:
getTargetPosition
in interfacecom.qualcomm.robotcore.hardware.DcMotor
-
isBusy
public boolean isBusy()- Specified by:
isBusy
in interfacecom.qualcomm.robotcore.hardware.DcMotor
-
getCurrentPosition
public int getCurrentPosition()- Specified by:
getCurrentPosition
in interfacecom.qualcomm.robotcore.hardware.DcMotor
-
setMode
public void setMode(com.qualcomm.robotcore.hardware.DcMotor.RunMode mode) - Specified by:
setMode
in interfacecom.qualcomm.robotcore.hardware.DcMotor
-
getMode
public com.qualcomm.robotcore.hardware.DcMotor.RunMode getMode()- Specified by:
getMode
in interfacecom.qualcomm.robotcore.hardware.DcMotor
-
setDirection
public void setDirection(com.qualcomm.robotcore.hardware.DcMotorSimple.Direction direction) - Specified by:
setDirection
in interfacecom.qualcomm.robotcore.hardware.DcMotorSimple
-
getDirection
public com.qualcomm.robotcore.hardware.DcMotorSimple.Direction getDirection()- Specified by:
getDirection
in interfacecom.qualcomm.robotcore.hardware.DcMotorSimple
-
setPower
public void setPower(double power) - Specified by:
setPower
in interfacecom.qualcomm.robotcore.hardware.DcMotorSimple
-
getPower
public double getPower()- Specified by:
getPower
in interfacecom.qualcomm.robotcore.hardware.DcMotorSimple
-
getManufacturer
public com.qualcomm.robotcore.hardware.HardwareDevice.Manufacturer getManufacturer()- Specified by:
getManufacturer
in interfacecom.qualcomm.robotcore.hardware.HardwareDevice
-
getDeviceName
- Specified by:
getDeviceName
in interfacecom.qualcomm.robotcore.hardware.HardwareDevice
-
getConnectionInfo
- Specified by:
getConnectionInfo
in interfacecom.qualcomm.robotcore.hardware.HardwareDevice
-
getVersion
public int getVersion()- Specified by:
getVersion
in interfacecom.qualcomm.robotcore.hardware.HardwareDevice
-
resetDeviceConfigurationForOpMode
public void resetDeviceConfigurationForOpMode()- Specified by:
resetDeviceConfigurationForOpMode
in interfacecom.qualcomm.robotcore.hardware.HardwareDevice
-
close
public void close()- Specified by:
close
in interfacecom.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)
-