Class Turret

java.lang.Object
com.crossbotics.ftchelper.robot.Module<Turret>
com.crossbotics.ftchelper.robot.Turret
All Implemented Interfaces:
Subsystem

public final class Turret extends Module<Turret>
A turret on one motor that turns inside its limits, by hand or following the goal with a Camera. Angles in degrees, counterclockwise +, 0 = straight forward (where it points when the program starts).

 turret = add(Turret.motor("turret", "gobilda-5203-117").gearRatio(5).follows(camera));   // Robot.java

 public static class Turret {                                // Tunables.java
     public static double min = -90, max = 90;              // its range: it never turns past these
     public static double kP = 0.02, kI = 0, kD = 0.001;
     public static double maxPower = 0.8, tolerance = 1.0, cameraOffset = 0;
 }
 

Follow mode (followMode(), on from START when follows(com.crossbotics.ftchelper.robot.Camera) is used): every loop it turns toward the camera's goal. A goal past the range: it waits at the limit and the Driver Station says "goal out of turret range". The stick takes over while it is moved, then following goes on.

Suggested buttons: operator right stick X turns it by hand; operator BACK switches following on and off. Docs: docs/modules/robot.md (section "Turret")

  • Method Details

    • motor

      public static Turret motor(String motor, String motorId)
      A turret on this motor.
      Parameters:
      motor - the motor's configuration name
      motorId - the motor's parts-catalog id (see Motors)
    • gearRatio

      public Turret gearRatio(double motorTurnsPerTurretTurn)
      Motor turns per turret turn (the gears or belt). Default 1.
    • reversed

      public Turret reversed()
      Positive power turns the other way (if + turns it clockwise).
    • follows

      public Turret follows(Camera c)
      Follows this camera's goal (follow mode on from START). The camera turns with the turret.
    • cameraOnBody

      public Turret cameraOnBody()
      The camera is on the robot's body, not on the turret.
    • followMode

      public Mode followMode()
      Following the camera's goal: switch it with a button (g2.back.toggle(robot.turret.followMode())).
    • aimAt

      public void aimAt(double deg)
      Turns to an angle (inside the limits) and stops following.
      Parameters:
      deg - robot-relative, counterclockwise +, 0 = forward
    • manual

      public void manual(double power)
      By hand, -1 to 1 (a stick, every loop). While it is moved, following pauses.
      Parameters:
      power - + = counterclockwise
    • isAimed

      public boolean isAimed()
      True when it points where it should (within the tolerance).
    • isOutOfRange

      public boolean isOutOfRange()
      True when the goal is past its range (it waits at the limit).
    • angle

      public double angle()
      The angle now, degrees.
    • part

      public Turret part()
      The launcher.Turret 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<Turret>