From 7e03fa59842b8d63aff19b35e9887c4b57c47aa1 Mon Sep 17 00:00:00 2001 From: penguinencounter <49845522+penguinencounter@users.noreply.github.com> Date: Sat, 10 Feb 2024 15:31:34 -0800 Subject: [PATCH] Pre-comp tweaks --- .../java/org/firstinspires/ftc/teamcode/Var.kt | 14 ++++++++++++++ .../ftc/teamcode/opmodes/HWTest.java | 18 +++++++++++++++++- .../ftc/teamcode/opmodes/TeleOp.java | 17 +++++------------ .../ftc/teamcode/opmodes/TwentyAuto.java | 1 + 4 files changed, 37 insertions(+), 13 deletions(-) diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/Var.kt b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/Var.kt index a072e8b84eb5..0e09305aa4da 100644 --- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/Var.kt +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/Var.kt @@ -56,6 +56,20 @@ object Var { const val back = 1.0 } + object DropDownServo { + @JvmField + val positions = doubleArrayOf( + 0.60, +// 0.4944, +// 0.4538, +// 0.3999, +// 0.3760, + 0.2892 + ) + @JvmField + val up = positions[0] + } + object TeleOp { /** * Target distance for approaching objects with the 'x' button on Gamepad 1. diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/opmodes/HWTest.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/opmodes/HWTest.java index a495145596e0..adcccffb6b61 100644 --- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/opmodes/HWTest.java +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/opmodes/HWTest.java @@ -17,6 +17,8 @@ public class HWTest extends LinearOpMode { boolean lastA = false; boolean lastB = false; + boolean verbalize = false; + RobotConfiguration robot; /** @@ -31,6 +33,9 @@ boolean confirm(String message) { for (String line : message.split("\n")) { telemetry.addLine(line); } + if (verbalize) { + telemetry.speak(message); + } telemetry.addLine(); telemetry.addLine("[A]: YES or [B]: NO"); telemetry.update(); @@ -55,6 +60,9 @@ void alert(String message) { for (String line : message.split("\n")) { telemetry.addLine(line); } + if (verbalize) { + telemetry.speak(message); + } telemetry.addLine(); telemetry.addLine("[A]: Confirm"); telemetry.update(); @@ -68,11 +76,15 @@ void alert(String message) { } void testMotor(String label, DcMotor theMotor) { + testMotor(label, theMotor, "moving forward"); + } + + void testMotor(String label, DcMotor theMotor, String action) { lastA = gamepad1.a; lastB = gamepad1.b; theMotor.setPower(0.25); telemetry.addLine("The " + label + " motor should"); - telemetry.addLine("be moving forward..."); + telemetry.addLine("be " + action + "..."); telemetry.addLine(); telemetry.addLine("[A]: OK [B]: STOP"); telemetry.update(); @@ -100,6 +112,9 @@ void testMotors() { testMotor("Front Right", motors.frontRight); testMotor("Back Left", motors.backLeft); testMotor("Back Right", motors.backRight); + testMotor("Intake", robot.intake(), "turning reverse (outtaking)"); + alert("Remove the drone from the launcher if it is present..."); + testMotor("Drone", robot.drone(), "spinning"); } void testEncoder(String label, DcMotor encoded) { @@ -175,6 +190,7 @@ public void runOpMode() { robot = RobotConfiguration.currentConfiguration().invoke(hardwareMap); waitForStart(); try { + verbalize = confirm("Say instructions out loud?"); testMotors(); testEncoders(); testSensors(); diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/opmodes/TeleOp.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/opmodes/TeleOp.java index cefb660ce628..d9065a914020 100644 --- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/opmodes/TeleOp.java +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/opmodes/TeleOp.java @@ -62,14 +62,6 @@ public double OdoToInches(double ticks) { return (num_wheel_rotations * 2 * Math.PI * radius_inches); } - public static final double[] DropdownPositions = { - 0.60, // X button - 0.49, - 0.45, - 0.41, - 0.35 - }; - @Override public void runOpMode() { @@ -87,7 +79,7 @@ public void runOpMode() { MotorSet driveMotors = robot.driveMotors(); int dropCycle = 0; - robot.dropDownServo().setPosition(DropdownPositions[dropCycle]); + robot.dropDownServo().setPosition(Var.DropDownServo.positions[dropCycle]); Servo dumperServo = robot.dumperRotate(); Servo latch = robot.dumperLatch(); @@ -275,13 +267,14 @@ public void runOpMode() { if (gamepad2.y && !lastAdvDropper) { dropCycle++; - if (dropCycle >= DropdownPositions.length) dropCycle = DropdownPositions.length - 1; - robot.dropDownServo().setPosition(DropdownPositions[dropCycle]); + if (dropCycle >= Var.DropDownServo.positions.length) + dropCycle = Var.DropDownServo.positions.length - 1; + robot.dropDownServo().setPosition(Var.DropDownServo.positions[dropCycle]); } lastAdvDropper = gamepad2.y; if (gamepad2.x) { dropCycle = 0; - robot.dropDownServo().setPosition(DropdownPositions[dropCycle]); + robot.dropDownServo().setPosition(Var.DropDownServo.up); } if (gamepad2.right_bumper) { diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/opmodes/TwentyAuto.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/opmodes/TwentyAuto.java index f6dbe7cee5da..edbaacff1f6a 100644 --- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/opmodes/TwentyAuto.java +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/opmodes/TwentyAuto.java @@ -297,6 +297,7 @@ public void runOpMode() throws InterruptedException { // Set up robot hardware robot.clearEncoders(); robot.purpleDropper().setPosition(Var.PixelDropper.up); + robot.dropDownServo().setPosition(Var.DropDownServo.up); double buttonRepeatDelay = 0.4; double buttonRepeatRate = 0.2;