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
Direct Known Subclasses:
Arm, Lift

public abstract class MotorPositions<M extends MotorPositions<M>> extends Module<M>
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 Details

    • reversed

      public M 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

      public M alsoMotor(String motor)
      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_left reads Tunables.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 other
       

      Which 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

      public M 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).
      Parameters:
      motor - the second motor's configuration name, e.g. "lift_right"
      Returns:
      this part
    • secondMotorName

      public String secondMotorName()
      The second motor's configuration name (alsoMotor(java.lang.String)), or null if it has one motor.
    • goTo

      public void goTo(String position)
      Goes to a named position from Tunables.java and 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: see Module.optional()).
    • isAt

      public boolean isAt(String position)
      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

      public List<String> positions()
      The named positions, lowest first.
    • part

      public PositionMotor part()
      The PositionMotor inside, for anything this module does not offer.
    • update

      public void update()
      Description copied from interface: Subsystem
      Called 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: Subsystem
      Stops all motion. Called at the end of every OpMode.
    • addTelemetry

      public void addTelemetry(RobotTelemetry t)
      Description copied from class: Module
      The part's telemetry line; each module adds its own.
      Specified by:
      addTelemetry in interface Subsystem
      Overrides:
      addTelemetry in class Module<M extends MotorPositions<M>>