Class PretendMotor
java.lang.Object
com.crossbotics.ftchelper.testkit.PretendMotor
A pretend motor for JUnit tests on a laptop (no robot): it remembers the power it was sent, and its
encoder is a number your test sets. Get one from
PretendDevices.motor(String).
PretendMotor lift = devices.motor("lift");
lift.position = 900; // the encoder now reads 900
robot.all().update();
assertEquals(0, lift.power, 0.01); // at its target: no power
The fields are public on purpose: a test reads and sets them directly. Docs: docs/modules/testkit.md, docs/tests/03-checks-before-practice-and-matches.md
-
Field Summary
FieldsModifier and TypeFieldDescriptiondoubleWhatgetCurrent(...)gives, amps.com.qualcomm.robotcore.hardware.DcMotorSimple.DirectionFORWARD or REVERSE, as set (.reversed()sets REVERSE).booleanTrue:setPowerthrows, like an unplugged motor.doubleThe largest power (either way) ever sent.com.qualcomm.robotcore.hardware.DcMotor.RunModeThe run mode set (STOP_AND_RESET_ENCODER also setspositionto 0).final com.qualcomm.robotcore.hardware.DcMotorExThe SDK motor to hand to code that wants one.double[]The lastsetVelocityPIDFCoefficientsgains {p, i, d, f}, or null.doubleThe encoder count your test sets;getCurrentPosition()gives it rounded.intHow many times the encoder was read.doubleThe last power sent (-1 to 1).intHow many times a power was sent (each is a trip to the hub on a robot).doubleTicks per second, whatgetVelocity()gives.doubleThe lastsetVelocity(...)(ticks per second).com.qualcomm.robotcore.hardware.DcMotor.ZeroPowerBehaviorBRAKE or FLOAT, as set. -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
power
public double powerThe last power sent (-1 to 1). -
position
public double positionThe encoder count your test sets;getCurrentPosition()gives it rounded. -
velocity
public double velocityTicks per second, whatgetVelocity()gives. -
velocityCommand
public double velocityCommandThe lastsetVelocity(...)(ticks per second). -
currentAmps
public double currentAmpsWhatgetCurrent(...)gives, amps. -
powerWrites
public int powerWritesHow many times a power was sent (each is a trip to the hub on a robot). -
positionReads
public int positionReadsHow many times the encoder was read. -
maxAbsPower
public double maxAbsPowerThe largest power (either way) ever sent. -
pidf
public double[] pidfThe lastsetVelocityPIDFCoefficientsgains {p, i, d, f}, or null. -
failSetPower
public boolean failSetPowerTrue:setPowerthrows, like an unplugged motor. -
mode
public com.qualcomm.robotcore.hardware.DcMotor.RunMode modeThe run mode set (STOP_AND_RESET_ENCODER also setspositionto 0). -
zeroPower
public com.qualcomm.robotcore.hardware.DcMotor.ZeroPowerBehavior zeroPowerBRAKE or FLOAT, as set. -
direction
public com.qualcomm.robotcore.hardware.DcMotorSimple.Direction directionFORWARD or REVERSE, as set (.reversed()sets REVERSE). -
motor
public final com.qualcomm.robotcore.hardware.DcMotorEx motorThe SDK motor to hand to code that wants one.
-
-
Constructor Details
-
PretendMotor
public PretendMotor()A new pretend motor at power 0 and position 0.
-