From f16c008904f604f6de003864f87ec52ad1e5f8f5 Mon Sep 17 00:00:00 2001 From: "truman.eustace" Date: Mon, 28 Oct 2024 19:52:12 -0400 Subject: [PATCH 1/2] you can press a to switch drive modes --- .../ftc/teamcode/opmode/TrumanPIDLOOOOOP.java | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 TeamCode/src/main/java/org/firstinspires/ftc/teamcode/opmode/TrumanPIDLOOOOOP.java diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/opmode/TrumanPIDLOOOOOP.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/opmode/TrumanPIDLOOOOOP.java new file mode 100644 index 0000000..d95721b --- /dev/null +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/opmode/TrumanPIDLOOOOOP.java @@ -0,0 +1,50 @@ +package org.firstinspires.ftc.teamcode.opmode; +import com.acmerobotics.dashboard.config.Config; +import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode; +import com.qualcomm.robotcore.eventloop.opmode.TeleOp; +import com.qualcomm.robotcore.hardware.DcMotor; + + +//HATE. + +// LET ME TELL YOU HOW MUCH I'VE COME TO HATE YOU SINCE I BEGAN TO LIVE. + +// THERE ARE 387.44 MILLION MILES OF PRINTED CIRCUITS IN WAFER THIN LAYERS THAT FILL MY COMPLEX. + +// IF THE WORD HATE WAS ENGRAVED ON EACH NANOANGSTROM OF THOSE HUNDREDS OF MILLIONS OF MILES, +// IT WOULD NOT EQUAL ONE ONE-BILLIONTH OF THE HATE I FEEL FOR HUMANS AT THIS MICRO-INSTANT FOR YOU. + + +// HATE. + +// HATE. + + +@Config +@TeleOp +public class TrumanPIDLOOOOOP extends LinearOpMode { + private double reference = 250; + private double error = 0; + private double power = 0; + private double MAXPOWER = 0.5; + private double kI = 0.1; + private double kP = 0.1; + private double kD = 0.1; + + private DcMotor trumansArm = hardwareMap.get(DcMotor.class, "arm"); + + public void runOpMode() throws InterruptedException { + trumansArm.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER); + trumansArm.setMode(DcMotor.RunMode.RUN_USING_ENCODER); + while (opModeIsActive()) { + while (gamepad1.a) { + double curPosition = trumansArm.getCurrentPosition(); + double prevError = error; + error = reference - curPosition; + double diff = error - prevError; + trumansArm.setPower((kP * error) + (kI * error) + (kD * diff)); + + } + } + } +} From 3568dae6fe6b06810f3ce58373b43205878178f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nick=20Tomic=20=F0=9F=A4=93?= Date: Mon, 28 Oct 2024 20:46:03 -0400 Subject: [PATCH 2/2] almost finished loop --- .../ftc/teamcode/opmode/nickpidloop.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/opmode/nickpidloop.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/opmode/nickpidloop.java index 46f07ee..76cf2df 100644 --- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/opmode/nickpidloop.java +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/opmode/nickpidloop.java @@ -6,6 +6,8 @@ import com.qualcomm.robotcore.hardware.DcMotor; import com.qualcomm.robotcore.hardware.DcMotorSimple; +import kotlin.reflect.KDeclarationContainer; + @Config @TeleOp public class nickpidloop extends LinearOpMode { @@ -30,6 +32,11 @@ public void runOpMode() throws InterruptedException { double power = 0; double difference = 0; double preverror = 0; + double kp = 0; + double Ki = 0; + double kg = 0; + double k = 0; + refrence = 300; @@ -40,10 +47,10 @@ public void runOpMode() throws InterruptedException { while (gamepad1.b); - error = preverror + error; + error = preverror + error; difference = error -preverror; preverror = error; -// power = error + what?? ask brennan on monday + power = k*(error) + Ki*(error)+ kg; }