Class Camera
- All Implemented Interfaces:
Subsystem
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. BIOBUZZ: the goal
is always that alliance's HIVE's CELL that reads right side up (the up CELL, the one you can score
in), whichever of its two CELLs that is now; a CELL whose tags read upside down is never the goal
(TagGroup.goalTarget(com.crossbotics.ftchelper.vision.TargetSource, java.lang.String)). Tunables
(Tunables.Limelight for device "limelight"): pipeline (Limelight only, default 0), pitchDeg
(webcam or Limelight: its tilt up in degrees, 0 = level: then bearings and distances are along the floor, see
CameraTilt).
A webcam mounted upside down: upsideDown().
No usual 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).
A HuskyLens (huskyLens(java.lang.String)) says the number it was TAUGHT, not the tag's real number: list
them with tag(int, int). It can also look for taught colors or an object (colors(),
objects(), label(int, java.lang.String)). Tunables: hfovDeg (its view angle: measure it) and
sizeIn (for a rough distance). No lighting test.
Docs: docs/reference/robot-java.md (section "Camera"), docs/modules/vision.md
-
Method Summary
Modifier and TypeMethodDescriptionvoidThe part's telemetry line; each module adds its own.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.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.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).voidTeleOp's INIT work for this camera, for an OpMode that does not run the robot's INIT loop (the Shot Tuner): it reads the camera, so the lighting test runs, and shows its lines.colors()HuskyLens: look for the colors you taught it, not AprilTags.goal()The goal for this match's alliance (seegoal(String, String)), or null if it is not seen now (or no goal was named).The goal's tag group for each alliance, e.g.static CameraA DFRobot HuskyLens on an I2C port (configure it as "HuskyLens").booleanTrue for a HuskyLens.booleanTrue for a Limelight.booleanTrue ifupsideDown()is set in Robot.java.booleanisWebcam()True for a webcam.booleanTrue if Robot.java gives this camera agoal(...):goal()can find the alliance's goal.HuskyLens: a name for a taught number, fortarget(name).lighting()The venue-lighting test (status and result), or null when it is off.static CameraA Limelight 3A.booleanTrue when the webcam's live view is on (PRACTICE profile,Tunables liveViewnot false).objects()HuskyLens: look for the ONE object you taught it, not AprilTags.booleanrelight()Does the lighting test again, now: for a button.source()The camera inside (a LimelightTags, WebcamTags or HuskyLensCamera), for anything this module does not offer.voidstarted()TeleOp's START work for this camera (an unfinished lighting test stops and keeps the best setting so far), for an OpMode that does not run the robot's START (the Shot Tuner).voidstop()Stops all motion.tag(int taughtNumber, int tagNumber) HuskyLens: which real AprilTag a taught number is.target(int id) The tag with this number, or null if not seen now.The target with this name (a tag group or a tag's name), or null if not seen now.voidupdate()Called once every loop.The webcam is mounted upside down.static CameraA webcam (USB).
-
Method Details
-
limelight
A Limelight 3A. -
webcam
A webcam (USB). -
huskyLens
-
tag
HuskyLens: which real AprilTag a taught number is. Teach the tags with "Learn Multiple" on: the first is ID1, the next ID2. Needed fortarget(tagNumber)and forgoal(String, String).- Parameters:
taughtNumber- the number on the camera's screen (ID1 = 1)tagNumber- the AprilTag's real number
-
label
HuskyLens: a name for a taught number, fortarget(name).- Parameters:
taughtNumber- the number on the camera's screenname- the name, e.g. "POLLEN"
-
colors
HuskyLens: look for the colors you taught it, not AprilTags. -
objects
HuskyLens: look for the ONE object you taught it, not AprilTags. -
goal
The goal's tag group for each alliance, e.g. "BLUE SCORING" and "RED SCORING" in BIOBUZZ. For BIOBUZZ each name stands for that alliance's HIVE: the aim goes to its CELL that reads right side up now (the up CELL), "RED SCORING" or "RED AUDIENCE", and never to a CELL that reads upside down.- Parameters:
blueGroup- the group the BLUE alliance aims atredGroup- the group the RED alliance aims at
-
autoPipelines
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
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. SeeautoExposure(long...). -
autoExposure
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
-
upsideDown
The webcam is mounted upside down. Without this, an upside-down webcam turns the robot the wrong way when it aims, and it never sees the goal: every tag reads upside down (a down CELL, in BIOBUZZ). With it, left is left again and the tags read right side up. The live view on the Driver Station stays upside down. Webcam only: a Limelight has its own setting on its web page (Settings, Orientation).camera = add(Camera.webcam("Webcam 1").upsideDown().goal("BLUE SCORING", "RED SCORING")); -
isUpsideDown
public boolean isUpsideDown()True ifupsideDown()is set in Robot.java. -
isLimelight
public boolean isLimelight()True for a Limelight. -
isWebcam
public boolean isWebcam()True for a webcam. -
isHuskyLens
public boolean isHuskyLens()True for a HuskyLens. -
liveViewOn
public boolean liveViewOn()True when the webcam's live view is on (PRACTICE profile,Tunables liveViewnot false). -
lighting
The venue-lighting test (status and result), or null when it is off. -
relight
public boolean relight()Does the lighting test again, now: for a button. Aim the camera at a tag, then press. In the match it takes up to 5 s (or TunableslightingAfterStartMswhen that is set), and the camera sees no targets until it is done (so do not press while you aim to shoot). If no setting sees a tag, it keeps the setting it had. NeedsautoExposure()orautoPipelines, and TunablesautoLightingnot false; without them it does nothing, and the TeleOp screen says so for 5 s.- Returns:
- true if the test started again
-
checkInInit
TeleOp's INIT work for this camera, for an OpMode that does not run the robot's INIT loop (the Shot Tuner): it reads the camera, so the lighting test runs, and shows its lines. Call it every INIT loop.- Parameters:
t- the Driver Hub screen
-
started
public void started()TeleOp's START work for this camera (an unfinished lighting test stops and keeps the best setting so far), for an OpMode that does not run the robot's START (the Shot Tuner). Call it once, at START. -
knowsGoal
public boolean knowsGoal()True if Robot.java gives this camera agoal(...):goal()can find the alliance's goal. -
goal
The goal for this match's alliance (seegoal(String, String)), or null if it is not seen now (or no goal was named). BIOBUZZ: that alliance's HIVE's CELL that reads right side up; null when only an upside-down CELL is in view. Always check for null. -
target
The target with this name (a tag group or a tag's name), or null if not seen now. -
target
The tag with this number, or null if not seen now. -
source
The camera inside (a LimelightTags, WebcamTags or HuskyLensCamera), 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<Camera>
-