Package com.crossbotics.ftchelper.robot
Class MotorPositions<M extends MotorPositions<M>>
java.lang.Object
com.crossbotics.ftchelper.robot.Module<M>
com.crossbotics.ftchelper.robot.MotorPositions<M>
- All Implemented Interfaces:
Subsystem
What
Lift and Arm share: a motor that goes to named positions and holds them
(a PositionMotor inside), with its numbers from Tunables.java. You use Lift or Arm;
this class only holds their common commands.
Known fields: min, max (the safe range; not changeable from the tuning menu, so
tuning can never drive past a hard stop), kP, kI, kD, kF (the
steady push that holds it up), maxPower, slowZone, slowZonePower,
tolerance. Every other number is a named position.
-
Method Summary
Modifier and TypeMethodDescriptionvoidThe part's telemetry line; each module adds its own.A second motor on the same lift or arm (a slide with a motor on each side, an arm driven from both ends).alsoMotorReversed(String motor) alsoMotor(java.lang.String), with the second motor turning the other way from the first for the same power (two motors that face each other, mirror images: the usual way on a two-sided slide).voidGoes to a named position fromTunables.javaand holds it.voidhold()Holds where it is now.booleanTrue when it is at this named position (not on the robot: when it was last sent there).booleanTrue when it is at its target (always, for a part that is not on the robot: seeModule.optional()).voidmanual(double power) Moves by hand, -1 to 1 (a stick).part()The PositionMotor inside, for anything this module does not offer.doubleposition()Where it is now, in its units.The named positions, lowest first.reversed()Positive power turns the other way (if it moves down when it should go up).The second motor's configuration name (alsoMotor(java.lang.String)), or null if it has one motor.voidstepDown()Goes to the next position down.voidstepUp()Goes to the next position up (by value).voidstop()Stops all motion.voidupdate()Called once every loop.
-
Method Details
-
reversed
Positive power turns the other way (if it moves down when it should go up). With a second motor (alsoMotor(java.lang.String)) both turn the other way. -
alsoMotor
A second motor on the same lift or arm (a slide with a motor on each side, an arm driven from both ends). It gets exactly the same power as the first, at the same moment: in every command, stop, pause, limit and interlock rule. Only the FIRST motor's encoder is read, so plug the encoder cable into the first motor. Its Tunables section stays the first motor's name (lift_leftreadsTunables.LiftLeft).lift = add(Lift.slide("lift_left").alsoMotor("lift_right")); // both turn the same way lift = add(Lift.slide("lift_left").alsoMotorReversed("lift_right")); // they face each otherWhich one? Take the chain or belt off, then push the lift up with the stick (Motor Finder): both motors must turn so the lift would go up. If one turns the wrong way, use the other method. Two motors pushing against each other get hot and can break a gearbox.
- Parameters:
motor- the second motor's configuration name, e.g. "lift_right"- Returns:
- this part
-
alsoMotorReversed
alsoMotor(java.lang.String), with the second motor turning the other way from the first for the same power (two motors that face each other, mirror images: the usual way on a two-sided slide).- Parameters:
motor- the second motor's configuration name, e.g. "lift_right"- Returns:
- this part
-
secondMotorName
The second motor's configuration name (alsoMotor(java.lang.String)), or null if it has one motor. -
goTo
Goes to a named position fromTunables.javaand holds it. Capitals do not matter. An unknown name does nothing and shows a warning (a typo must not stop a match).- Parameters:
position- e.g. "high"
-
stepUp
public void stepUp()Goes to the next position up (by value). -
stepDown
public void stepDown()Goes to the next position down. -
manual
public void manual(double power) Moves by hand, -1 to 1 (a stick). Call every loop; 0 holds where it was let go.- Parameters:
power- + = up (toward max)
-
hold
public void hold()Holds where it is now. -
isAtTarget
public boolean isAtTarget()True when it is at its target (always, for a part that is not on the robot: seeModule.optional()). -
isAt
True when it is at this named position (not on the robot: when it was last sent there). -
position
public double position()Where it is now, in its units. -
positions
The named positions, lowest first. -
part
The PositionMotor inside, for anything this module does not offer. -
update
public void update()Description copied from interface:SubsystemCalled once every loop. Do the hardware work here. Must be quick: no sleep, no waiting. While update() waits, the whole robot is frozen (no driving, no limits, no STOP). -
stop
public void stop()Description copied from interface:SubsystemStops all motion. Called at the end of every OpMode. -
addTelemetry
Description copied from class:ModuleThe part's telemetry line; each module adds its own.- Specified by:
addTelemetryin interfaceSubsystem- Overrides:
addTelemetryin classModule<M extends MotorPositions<M>>
-