From 37c74fc85fb49ea771718831d177c42d710992b0 Mon Sep 17 00:00:00 2001 From: DanTheMan-byte Date: Fri, 9 Jan 2026 22:20:22 -0600 Subject: [PATCH] limelight test updated --- .../ftc/teamcode/tests/LimelightTest.java | 106 ++++++++++-------- 1 file changed, 57 insertions(+), 49 deletions(-) diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/tests/LimelightTest.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/tests/LimelightTest.java index 87932cd..5cb9b21 100644 --- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/tests/LimelightTest.java +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/tests/LimelightTest.java @@ -3,66 +3,74 @@ package org.firstinspires.ftc.teamcode.tests; import com.acmerobotics.dashboard.FtcDashboard; import com.acmerobotics.dashboard.config.Config; import com.acmerobotics.dashboard.telemetry.MultipleTelemetry; -import com.qualcomm.robotcore.eventloop.opmode.Autonomous; +import com.qualcomm.hardware.limelightvision.LLResult; +import com.qualcomm.hardware.limelightvision.LLResultTypes; +import com.qualcomm.hardware.limelightvision.Limelight3A; import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode; +import com.qualcomm.robotcore.eventloop.opmode.TeleOp; -import org.firstinspires.ftc.teamcode.variables.HardwareConfig; -import org.firstinspires.ftc.teamcode.utils.Robot; -import org.firstinspires.ftc.teamcode.utils.subsystems.Limelight; +import java.util.List; -@Autonomous +//TODO: fix to get the apriltag that it is reading @Config - +@TeleOp public class LimelightTest extends LinearOpMode { - - public static String MODE = "AT"; - public static int pipe = 1; - - MultipleTelemetry TELE; - - - - - - - Robot robot; - + public static int pipeline = 0; //0 is for test; 1 for obelisk; 2 is for blue track; 3 is for red track + public static int mode = 0; //0 for bare testing, 1 for obelisk, 2 for blue track, 3 for red track @Override public void runOpMode() throws InterruptedException { - - - - HardwareConfig.USING_LL= true; - - - robot = new Robot(hardwareMap); - + Limelight3A limelight = hardwareMap.get(Limelight3A.class, "Limelight"); TELE = new MultipleTelemetry(telemetry, FtcDashboard.getInstance().getTelemetry()); - - Limelight limelight = new Limelight(robot, TELE); - - limelight.setMode(MODE); - - limelight.setTelemetryOn(true); - + limelight.pipelineSwitch(pipeline); waitForStart(); + if (isStopRequested()) return; + limelight.start(); + while (opModeIsActive()){ + if (mode == 0){ + limelight.pipelineSwitch(pipeline); + LLResult result = limelight.getLatestResult(); + if (result != null) { + if (result.isValid()) { + TELE.addData("tx", result.getTx()); + TELE.addData("ty", result.getTy()); + TELE.update(); + } + } + } else if (mode == 1){ + limelight.pipelineSwitch(1); + LLResult result = limelight.getLatestResult(); + if (result != null && result.isValid()) { + List fiducials = result.getFiducialResults(); + for (LLResultTypes.FiducialResult fiducial : fiducials) { + int id = fiducial.getFiducialId(); + TELE.addData("ID", id); + } - if(isStopRequested()) return; - - while(opModeIsActive()){ - - limelight.setPipeline(pipe); - - limelight.setMode(MODE); - - limelight.update(); - - TELE.update(); - - - + } + } else if (mode == 2){ + limelight.pipelineSwitch(4); + LLResult result = limelight.getLatestResult(); + if (result != null) { + if (result.isValid()) { + TELE.addData("tx", result.getTx()); + TELE.addData("ty", result.getTy()); + TELE.update(); + } + } + } else if (mode == 3){ + limelight.pipelineSwitch(5); + LLResult result = limelight.getLatestResult(); + if (result != null) { + if (result.isValid()) { + TELE.addData("tx", result.getTx()); + TELE.addData("ty", result.getTy()); + TELE.update(); + } + } + } else { + limelight.pipelineSwitch(0); + } } - } }