Class Camera

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

public final class Camera extends Module<Camera>
A camera that finds AprilTags: a Limelight 3A or a webcam. Other modules use it: a Turret that follows the goal, a Launcher whose speed comes from the distance.

 camera = add(Camera.limelight("limelight").goal("BLUE SCORING", "RED SCORING"));   // Robot.java
 

goal(String, String) names this season's goal for each alliance (the tag group's name); goal() then gives the target for the alliance chosen in autonomous. Tunables (Tunables.Limelight for device "limelight"): pipeline (Limelight only, default 0). No suggested buttons. It starts in INIT (a webcam needs a second or two). A camera missing from the robot configuration never stops the OpMode: it warns on the Driver Station and sees nothing.

Venue lighting: autoPipelines (Limelight) or autoExposure() (webcam) tries a few camera settings in INIT and keeps the one that sees the most AprilTags; the Driver Station shows the result at INIT. Its numbers are optional Tunables: autoLighting (true; false = skip the test and use pipeline, or the webcam's exposureMs and gain), lightingSettleMs (300), lightingPictures (10), lightingMinPictures (3), lightingAfterStartMs (0 = stop at START with the best so far), and for a webcam gain (-1 = the camera's highest). Docs: docs/modules/robot.md (section "Camera"), docs/modules/vision.md

  • Method Details

    • limelight

      public static Camera limelight(String name)
      A Limelight 3A.
    • webcam

      public static Camera webcam(String name)
      A webcam (USB).
    • goal

      public Camera goal(String blueGroup, String redGroup)
      The goal's tag group for each alliance, e.g. "BLUE SCORING" and "RED SCORING" in BIOBUZZ.
      Parameters:
      blueGroup - the group the BLUE alliance aims at
      redGroup - the group the RED alliance aims at
    • autoPipelines

      public Camera autoPipelines(int... pipelines)
      Venue lighting for a Limelight: tries these pipelines in INIT and keeps the one that sees the most AprilTags (set each one up on the Limelight's web page for a kind of light). Your usual pipeline FIRST: it wins ties and is kept if no tag is seen. See docs/modules/vision.md.
      
       camera = add(Camera.limelight("limelight").autoPipelines(0, 1, 2).goal("BLUE SCORING", "RED SCORING"));
       
      Parameters:
      pipelines - the pipeline numbers to try, usual one first
    • autoExposure

      public Camera autoExposure()
      Venue lighting for a webcam: tries the camera's own automatic exposure, then 3, 6 and 12 ms, in INIT and keeps the one that sees the most AprilTags. See autoExposure(long...).
    • autoExposure

      public Camera autoExposure(long... exposuresMs)
      Venue lighting for a webcam: tries these exposures (milliseconds; 0 = the camera's own automatic exposure) in INIT and keeps the one that sees the most AprilTags. Usual one FIRST.
      Parameters:
      exposuresMs - the exposures to try, usual one first
    • lighting

      public LightingSweep lighting()
      The venue-lighting test (status and result), or null when it is off.
    • goal

      public TargetObservation goal()
      The goal for this match's alliance (see goal(String, String)), or null if it is not seen now (or no goal was named). Always check for null.
    • target

      public TargetObservation target(String name)
      The target with this name (a tag group or a tag's name), or null if not seen now.
    • target

      public TargetObservation target(int id)
      The tag with this number, or null if not seen now.
    • source

      public TargetSource source()
      The camera inside (a LimelightTags or WebcamTags), 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<Camera>