Class ServoPositions<M extends ServoPositions<M>>

java.lang.Object
com.crossbotics.ftchelper.robot.Module<M>
com.crossbotics.ftchelper.robot.ServoPositions<M>
All Implemented Interfaces:
Subsystem
Direct Known Subclasses:
Claw, Positioner, Wrist

public abstract class ServoPositions<M extends ServoPositions<M>> extends Module<M>
What Claw, Wrist and Positioner share: a servo with named positions (a PositionServo inside). You use one of those three; this class only holds their common commands.

In Tunables.java every number is a named position (raw servo position, 0 to 1), except travelSec: about how long the servo takes to get there (used by "has it arrived?").

A servo does not move until the program first tells it where to go, after START.

  • Method Details

    • reversed

      public M reversed()
      The servo turns the other way (0 and 1 swap).
    • fullRange

      public M fullRange()
      Uses the servo's whole turn. The FTC SDK normally sends 600 to 2400 microseconds for positions 0 to 1, which is only part of what most servos take (500 to 2500): a goBILDA 2000 servo turns 270 degrees, not its full 300. With this, positions 0 to 1 send the servo's whole pulse range (the catalog part's from part(...), else 500-2500 us), so it turns all 300. Measure the positions after turning this on (Servo Finder: Y = full range): the same number points somewhere else once the range changes. A servo that is not on a REV hub keeps its normal range (INIT says so).
      
       wrist = add(Wrist.servo("wrist").part("gobilda-2000-speed").fullRange());   // 0..1 = 300 degrees
       
      Returns:
      this part
    • goTo

      public void goTo(String position)
      Goes to a named position from Tunables.java. Capitals do not matter. An unknown name does nothing and shows a warning.
      Parameters:
      position - e.g. "open"
    • isDone

      public boolean isDone()
      True if it should have arrived at its last position (a guess from travelSec). Always true for a part that is not on the robot (Module.optional()): there is nothing to wait for.
    • isAt

      public boolean isAt(String position)
      True if its last command was this position (whether or not it has arrived).
    • positions

      public List<String> positions()
      The named positions, in the order it cycles through them.
    • part

      public PositionServo part()
      The PositionServo 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 ServoPositions<M>>