From 846132f50ecc0d19d1efacc36ae2a90275432134 Mon Sep 17 00:00:00 2001 From: JJTech0130 Date: Thu, 7 Mar 2024 14:53:19 -0500 Subject: [PATCH] stuff that james made eddie do --- .../ftc/teamcode/opmode/Configuration.java | 12 ++- .../ftc/teamcode/opmode/Configurator.java | 77 +++++++++++-------- .../ftc/teamcode/opmode/TestAuto.java | 26 ++++--- 3 files changed, 69 insertions(+), 46 deletions(-) diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/opmode/Configuration.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/opmode/Configuration.java index 9028c229..c1d80174 100644 --- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/opmode/Configuration.java +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/opmode/Configuration.java @@ -1,9 +1,15 @@ package org.firstinspires.ftc.teamcode.opmode; public class Configuration { - String park = "none"; - boolean placePixel = false; - boolean fieldCentric = true; + // - place pixel? + // - use inner or outer paths? + // - park or drop on board? + //String park = "none"; + boolean placePixel = true; + boolean doPark = true; + boolean innerPath = true; // ignored if doPark is false + boolean dropOnBoard = true; // ignored if doPark is false + boolean fieldCentric = true; boolean tensorFlowInInit = false; } diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/opmode/Configurator.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/opmode/Configurator.java index 74b7d49a..8f3e0692 100644 --- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/opmode/Configurator.java +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/opmode/Configurator.java @@ -7,7 +7,6 @@ import com.qualcomm.robotcore.util.ReadWriteFile; import org.firstinspires.ftc.robotcore.internal.system.AppUtil; -import org.firstinspires.ftc.teamcode.util.Debouncer; import org.firstinspires.ftc.teamcode.util.Toggle; import java.io.File; @@ -55,32 +54,44 @@ private static void save(Configuration config, String filename) { @Override public void runOpMode() throws InterruptedException { waitForStart(); - //telemetry.addData("CONTROLS", "A: place pixel toggle \nB: inner park \nY: outer park \nX: board park \ndpad_down: no park \ndpad_up: field centric toggle"); - Toggle purpleToggle = new Toggle(); + Toggle placePixelToggle = new Toggle(); + Toggle doParkToggle = new Toggle(); + Toggle innerPathToggle = new Toggle(); + Toggle dropOnBoardToggle = new Toggle(); + Toggle fieldCentricToggle = new Toggle(); Toggle tensorflowToggle = new Toggle(); - Debouncer innerPark = new Debouncer(); - Debouncer outerPark = new Debouncer(); - Debouncer placePixel = new Debouncer(); - - - //String park = "none"; Configuration config = Configurator.load(); - purpleToggle.state = config.placePixel; + placePixelToggle.state = config.placePixel; + doParkToggle.state = config.doPark; + innerPathToggle.state = config.innerPath; + dropOnBoardToggle.state = config.dropOnBoard; + fieldCentricToggle.state = config.fieldCentric; tensorflowToggle.state = config.tensorFlowInInit; -// Toggle innerParkToggle = new Toggle(); -// Toggle outerParkToggle = new Toggle(); -// Toggle placePixelToggle = new Toggle(); - while (!isStopRequested()) { - purpleToggle.update(gamepad1.a); - telemetry.addData("purple pixel (A)", purpleToggle.state); - config.placePixel = purpleToggle.state; + placePixelToggle.update(gamepad1.a); + telemetry.addData("place pixel (A)", placePixelToggle.state); + config.placePixel = placePixelToggle.state; + + doParkToggle.update(gamepad1.dpad_right); + telemetry.addData("do park (dpad right)", doParkToggle.state); + config.doPark = doParkToggle.state; + + if (config.doPark) { + innerPathToggle.update(gamepad1.y); + telemetry.addData("inner path (Y)", innerPathToggle.state); + config.innerPath = innerPathToggle.state; + + dropOnBoardToggle.update(gamepad1.dpad_up); + telemetry.addData("drop on board (dpad up)", dropOnBoardToggle.state); + config.dropOnBoard = dropOnBoardToggle.state; + } + tensorflowToggle.update(gamepad1.b); @@ -91,22 +102,22 @@ public void runOpMode() throws InterruptedException { telemetry.addData("field centric (X)", fieldCentricToggle.state); config.fieldCentric = fieldCentricToggle.state; - if (config.placePixel) { - - if (innerPark.update(gamepad1.dpad_up)) { - config.park = "inner"; - } else if (outerPark.update(gamepad1.dpad_down)) { - config.park = "outer"; - } else if (placePixel.update(gamepad1.dpad_right)) { - config.park = "board"; - } else if (gamepad1.dpad_left) { - config.park = "none"; - } - - telemetry.addData("park (dpad)", config.park); - } else { - config.park = "none"; - } +// if (config.placePixel) { +// +// if (innerPark.update(gamepad1.dpad_up)) { +// config.park = "inner"; +// } else if (outerPark.update(gamepad1.dpad_down)) { +// config.park = "outer"; +// } else if (placePixel.update(gamepad1.dpad_right)) { +// config.park = "board"; +// } else if (gamepad1.dpad_left) { +// config.park = "none"; +// } +// +// telemetry.addData("park (dpad)", config.park); +// } else { +// config.park = "none"; +// } telemetry.update(); } diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/opmode/TestAuto.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/opmode/TestAuto.java index ee4023ff..2e379b46 100644 --- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/opmode/TestAuto.java +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/opmode/TestAuto.java @@ -22,7 +22,6 @@ import java.util.ArrayList; import java.util.List; -import java.util.Objects; @Autonomous @Config @@ -112,22 +111,29 @@ public void runOpMode() throws InterruptedException { telemetry.log().add("Tensorflow detected: " + tensorPos); } + // MARK: Components + List componentList = new ArrayList<>(); + // Configuration values: + // - place pixel? + // - park at all? + // - use inner or outer paths? + // - park or drop on board? + if (config.placePixel) { - componentList.add(new PurplePixelComponent(robot, tensorPos, Objects.equals(config.park, "inner"))); + componentList.add(new PurplePixelComponent(robot, tensorPos, config.innerPath && config.doPark)); } - switch (config.park) { - case "outer": - componentList.add(new ParkingOut(robot)); - break; - case "inner": + if (config.doPark) { + if (config.innerPath) { componentList.add(new ParkingIn(robot)); - break; - case "board": + } else { + componentList.add(new ParkingOut(robot)); + } + if (config.dropOnBoard) { componentList.add(new GoToBoard(robot, tensorPos)); - break; + } } for (Component component : componentList) {