From 860c93f768da7666ef4de9e1d447fd45a6b0f302 Mon Sep 17 00:00:00 2001 From: KOOLPOOL <141171610+Kooolpool@users.noreply.github.com> Date: Tue, 13 May 2025 17:00:54 -0700 Subject: [PATCH 1/9] added arm essentials --- .../opmodes/tele/JustDrivingTeleOp.java | 2 +- .../subsystems/ClawSubsystem.java | 64 +++++++++++++------ 2 files changed, 44 insertions(+), 22 deletions(-) diff --git a/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/opmodes/tele/JustDrivingTeleOp.java b/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/opmodes/tele/JustDrivingTeleOp.java index 014e007..d54e60a 100644 --- a/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/opmodes/tele/JustDrivingTeleOp.java +++ b/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/opmodes/tele/JustDrivingTeleOp.java @@ -15,7 +15,7 @@ import org.firstinspires.ftc.ptechnodactyl.controllers.OperatorController; import org.firstinspires.ftc.ptechnodactyl.helpers.StartingPosition; -@TeleOp(name = "Driving w/Turbo!") +@TeleOp(name = "PT Driving w/Turbo!") @SuppressWarnings("unused") public class JustDrivingTeleOp extends CommandOpMode implements Loggable { diff --git a/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/subsystems/ClawSubsystem.java b/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/subsystems/ClawSubsystem.java index cc09356..155acf5 100644 --- a/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/subsystems/ClawSubsystem.java +++ b/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/subsystems/ClawSubsystem.java @@ -4,14 +4,16 @@ import com.acmerobotics.roadrunner.control.PIDCoefficients; import com.acmerobotics.roadrunner.control.PIDFController; import com.qualcomm.robotcore.hardware.DcMotorEx; +import com.qualcomm.robotcore.util.Range; import com.technototes.library.hardware.motor.EncodedMotor; import com.technototes.library.hardware.servo.Servo; import com.technototes.library.logger.Log; +import com.technototes.library.logger.Loggable; import com.technototes.library.subsystem.Subsystem; import org.firstinspires.ftc.ptechnodactyl.Hardware; @Config -public class ClawSubsystem implements Subsystem { +public class ClawSubsystem implements Subsystem, Loggable { private Servo clawServo; private EncodedMotor arm; @@ -21,14 +23,16 @@ public class ClawSubsystem implements Subsystem { public double clawPosition = 0; public static double CLAW_OPEN_POSITION = 0.3; - public static double CLAW_CLOSE_POSITION = 0.7; - public static int INCREMENT_DECREMENT = 200; + public static double CLAW_CLOSE_POSITION = 0.9; + public static double MIN_ARM_MOTOR_SPEED = -0.2; + public static double MAX_ARM_MOTOR_SPEED = 0.5; + public static int INCREMENT_DECREMENT = 30; public static double FEEDFORWARD_COEFFICIENT = 0.00014; - public static int ARM_VERTICAL = 3100; - public static int ARM_HORIZONTAL = 1000; - public static int INITIAL_POSITION = 150; - public static int ARM_MAX = 0; - public static int ARM_MIN = 0; + public static int ARM_VERTICAL = 195; + public static int ARM_HORIZONTAL = 42; + public static int INITIAL_POSITION = 20; + public static int ARM_MAX = 320; + public static int ARM_MIN = 8; @Log(name = "armTarget") public int armTargetPos; @@ -36,6 +40,9 @@ public class ClawSubsystem implements Subsystem { @Log(name = "armPos") public int armPos; + @Log(name = "armPow") + public int armPow; + @Log(name = "armFdFwdVal") public double armFeedFwdValue; @@ -46,7 +53,7 @@ private void setArmPos(int e) { armTargetPos = e; } - public static PIDCoefficients armPID = new PIDCoefficients(0.0005, 0.0, 0.0001); + public static PIDCoefficients armPID = new PIDCoefficients(0.0002, 0.0, 0); private void setClawPosition(double d) { if (isHardware) { @@ -55,6 +62,16 @@ private void setClawPosition(double d) { } } + private int getArmUnmodifiedPosition() { + if (isHardware) { + return (int) arm.getSensorValue(); + } else { + return 0; + } + } + + + public ClawSubsystem(Hardware hw) { isHardware = true; clawServo = hw.clawServo; @@ -111,21 +128,14 @@ public ClawSubsystem() { public void increment(double value) { int newArmPos = (int) (armTargetPos + value * INCREMENT_DECREMENT); - // if (newArmPos > ARM_MAX) { - // newArmPos = 3150; - // } else if (newArmPos < ARM_MIN) { - // newArmPos = 0; - // } + if (newArmPos > ARM_MAX) { + newArmPos = ARM_MAX; + } else if (newArmPos < ARM_MIN) { + newArmPos = ARM_MIN; + } setArmPos(newArmPos); } - public void incrementn() { - increment(1.0); - } - - public void decrement() { - increment(-1.0); - } private static double getArmAngle(double ticks) { // our horizontal value starts at ARM_HORIZONTAL, so we need to @@ -140,4 +150,16 @@ public void openClaw() { public void closeClaw() { setClawPosition(CLAW_CLOSE_POSITION); } + private void setArmMotorPower(double speed) { + if (isHardware) { + double clippedSpeed = Range.clip(speed, MIN_ARM_MOTOR_SPEED, MAX_ARM_MOTOR_SPEED); + arm.setPower(clippedSpeed); + } + } + @Override + public void periodic() { + armPos = getArmUnmodifiedPosition(); + armPow = (int) armPidController.update(armPos); + setArmMotorPower(armPow); + } } From 5cef1a5a2045904c7a1f0a66bb3a5384d24e62ea Mon Sep 17 00:00:00 2001 From: KOOLPOOL <141171610+Kooolpool@users.noreply.github.com> Date: Fri, 16 May 2025 18:07:32 -0700 Subject: [PATCH 2/9] pid bump --- .../ftc/ptechnodactyl/subsystems/ClawSubsystem.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/subsystems/ClawSubsystem.java b/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/subsystems/ClawSubsystem.java index 155acf5..4e54e54 100644 --- a/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/subsystems/ClawSubsystem.java +++ b/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/subsystems/ClawSubsystem.java @@ -53,7 +53,7 @@ private void setArmPos(int e) { armTargetPos = e; } - public static PIDCoefficients armPID = new PIDCoefficients(0.0002, 0.0, 0); + public static PIDCoefficients armPID = new PIDCoefficients(0.0005, 0.0, 0.0001); private void setClawPosition(double d) { if (isHardware) { From fab851f4ac371b3bf41a4bd1b9847bdf40145eee Mon Sep 17 00:00:00 2001 From: KOOLPOOL <141171610+Kooolpool@users.noreply.github.com> Date: Tue, 13 May 2025 17:00:54 -0700 Subject: [PATCH 3/9] added arm essentials --- .../ftc/ptechnodactyl/subsystems/ClawSubsystem.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/subsystems/ClawSubsystem.java b/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/subsystems/ClawSubsystem.java index 4e54e54..155acf5 100644 --- a/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/subsystems/ClawSubsystem.java +++ b/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/subsystems/ClawSubsystem.java @@ -53,7 +53,7 @@ private void setArmPos(int e) { armTargetPos = e; } - public static PIDCoefficients armPID = new PIDCoefficients(0.0005, 0.0, 0.0001); + public static PIDCoefficients armPID = new PIDCoefficients(0.0002, 0.0, 0); private void setClawPosition(double d) { if (isHardware) { From ffc0e4185aa59d6823f1b4d1740cc1bfa2a757f2 Mon Sep 17 00:00:00 2001 From: KOOLPOOL <141171610+Kooolpool@users.noreply.github.com> Date: Wed, 21 May 2025 14:55:49 -0700 Subject: [PATCH 4/9] added arm motor power increment and decrement command and opmode --- .../ftc/ptechnodactyl/commands/ClawCmds.java | 8 ++++ .../controllers/TestController.java | 39 +++++++++++++++++++ .../ptechnodactyl/opmodes/tele/MotorTest.java | 29 ++++++++++++++ .../subsystems/ClawSubsystem.java | 30 ++++++++------ 4 files changed, 94 insertions(+), 12 deletions(-) create mode 100644 Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/controllers/TestController.java create mode 100644 Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/opmodes/tele/MotorTest.java diff --git a/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/commands/ClawCmds.java b/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/commands/ClawCmds.java index e1f168a..609413b 100644 --- a/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/commands/ClawCmds.java +++ b/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/commands/ClawCmds.java @@ -14,5 +14,13 @@ public static Command OpenClaw(ClawSubsystem CS) { public static Command CloseClaw(ClawSubsystem CS) { return Command.create(CS::closeClaw); } + + public static Command PowTest(ClawSubsystem CS) { + return Command.create(CS::powIncrement); + } + + public static Command PowTest2(ClawSubsystem CS) { + return Command.create(CS::powDecrement); + } } } diff --git a/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/controllers/TestController.java b/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/controllers/TestController.java new file mode 100644 index 0000000..1d8dae7 --- /dev/null +++ b/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/controllers/TestController.java @@ -0,0 +1,39 @@ +package org.firstinspires.ftc.ptechnodactyl.controllers; + +import com.technototes.library.command.CommandScheduler; +import com.technototes.library.control.CommandButton; +import com.technototes.library.control.CommandGamepad; +import com.technototes.library.control.Stick; +import org.firstinspires.ftc.ptechnodactyl.Robot; +import org.firstinspires.ftc.ptechnodactyl.Setup; +import org.firstinspires.ftc.ptechnodactyl.commands.ClawCmds; +import org.firstinspires.ftc.ptechnodactyl.commands.JoystickIncDecCmd; + +public class TestController { + + public Robot robot; + public CommandGamepad gamepad; + public CommandButton testPower2; + public CommandButton testPower; + + public TestController(CommandGamepad g, Robot r) { + robot = r; + gamepad = g; + AssignNamedControllerButton(); + BindControls(); + } + + private void AssignNamedControllerButton() { + testPower = gamepad.leftBumper; + testPower2 = gamepad.rightBumper; + } + + public void BindControls() { + bindTestControls(); + } + + public void bindTestControls() { + testPower.whenPressed(ClawCmds.cmds.PowTest(robot.clawSubsystem)); + testPower2.whenPressed(ClawCmds.cmds.PowTest2(robot.clawSubsystem)); + } +} diff --git a/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/opmodes/tele/MotorTest.java b/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/opmodes/tele/MotorTest.java new file mode 100644 index 0000000..d65a0b5 --- /dev/null +++ b/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/opmodes/tele/MotorTest.java @@ -0,0 +1,29 @@ +package org.firstinspires.ftc.ptechnodactyl.opmodes.tele; + +import com.acmerobotics.dashboard.FtcDashboard; +import com.acmerobotics.dashboard.telemetry.MultipleTelemetry; +import com.qualcomm.robotcore.eventloop.opmode.TeleOp; +import com.technototes.library.logger.Loggable; +import com.technototes.library.structure.CommandOpMode; +import org.firstinspires.ftc.ptechnodactyl.Hardware; +import org.firstinspires.ftc.ptechnodactyl.Robot; +import org.firstinspires.ftc.ptechnodactyl.controllers.DriverController; +import org.firstinspires.ftc.ptechnodactyl.controllers.TestController; + +@TeleOp(name = "MotorTest") +@SuppressWarnings("unused") +public class MotorTest extends CommandOpMode implements Loggable { + + public Hardware hardware; + public Robot robot; + + public TestController test; + + @Override + public void uponInit() { + telemetry = new MultipleTelemetry(telemetry, FtcDashboard.getInstance().getTelemetry()); + hardware = new Hardware(hardwareMap); + robot = new Robot(hardware); + test = new TestController(driverGamepad, robot); + } +} diff --git a/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/subsystems/ClawSubsystem.java b/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/subsystems/ClawSubsystem.java index 155acf5..5e5adf6 100644 --- a/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/subsystems/ClawSubsystem.java +++ b/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/subsystems/ClawSubsystem.java @@ -24,12 +24,12 @@ public class ClawSubsystem implements Subsystem, Loggable { public static double CLAW_OPEN_POSITION = 0.3; public static double CLAW_CLOSE_POSITION = 0.9; - public static double MIN_ARM_MOTOR_SPEED = -0.2; + public static double MIN_ARM_MOTOR_SPEED = -0.5; public static double MAX_ARM_MOTOR_SPEED = 0.5; public static int INCREMENT_DECREMENT = 30; - public static double FEEDFORWARD_COEFFICIENT = 0.00014; - public static int ARM_VERTICAL = 195; - public static int ARM_HORIZONTAL = 42; + public static double FEEDFORWARD_COEFFICIENT = 0; + public static int ARM_VERTICAL = 165; + public static int ARM_HORIZONTAL = 29; public static int INITIAL_POSITION = 20; public static int ARM_MAX = 320; public static int ARM_MIN = 8; @@ -41,7 +41,7 @@ public class ClawSubsystem implements Subsystem, Loggable { public int armPos; @Log(name = "armPow") - public int armPow; + public double armPow; @Log(name = "armFdFwdVal") public double armFeedFwdValue; @@ -53,7 +53,7 @@ private void setArmPos(int e) { armTargetPos = e; } - public static PIDCoefficients armPID = new PIDCoefficients(0.0002, 0.0, 0); + public static PIDCoefficients armPID = new PIDCoefficients(0.005, 0.0, 0); private void setClawPosition(double d) { if (isHardware) { @@ -70,8 +70,6 @@ private int getArmUnmodifiedPosition() { } } - - public ClawSubsystem(Hardware hw) { isHardware = true; clawServo = hw.clawServo; @@ -110,9 +108,6 @@ The downward torque due to gravity is cos(T) * Gravity (9.8m/s^2) // //increase armFeedFwdValue to avoid slamming or increase D in PID // armFeedFwdValue += ARM_SLAM_PREVENTION; // } - if (Math.abs(armFeedFwdValue) < 0.1) { - armFeedFwdValue = 0.0; - } return armFeedFwdValue; } @@ -136,6 +131,15 @@ public void increment(double value) { setArmPos(newArmPos); } + public void powIncrement() { + armPow = armPow + 0.05; + setArmMotorPower(armPow); + } + + public void powDecrement() { + armPow = armPow - 0.05; + setArmMotorPower(armPow); + } private static double getArmAngle(double ticks) { // our horizontal value starts at ARM_HORIZONTAL, so we need to @@ -150,16 +154,18 @@ public void openClaw() { public void closeClaw() { setClawPosition(CLAW_CLOSE_POSITION); } + private void setArmMotorPower(double speed) { if (isHardware) { double clippedSpeed = Range.clip(speed, MIN_ARM_MOTOR_SPEED, MAX_ARM_MOTOR_SPEED); arm.setPower(clippedSpeed); } } + @Override public void periodic() { armPos = getArmUnmodifiedPosition(); - armPow = (int) armPidController.update(armPos); + armPow = armPidController.update(armPos); setArmMotorPower(armPow); } } From 993520e359e656a843355e7872dad5a33ddaf1d4 Mon Sep 17 00:00:00 2001 From: KOOLPOOL <141171610+Kooolpool@users.noreply.github.com> Date: Fri, 23 May 2025 17:27:59 -0700 Subject: [PATCH 5/9] figured out pid and arm feed fwd --- .../controllers/TestController.java | 10 +++++-- .../subsystems/ClawSubsystem.java | 27 ++++++++++--------- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/controllers/TestController.java b/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/controllers/TestController.java index 1d8dae7..8ef874b 100644 --- a/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/controllers/TestController.java +++ b/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/controllers/TestController.java @@ -15,6 +15,8 @@ public class TestController { public CommandGamepad gamepad; public CommandButton testPower2; public CommandButton testPower; + public CommandButton armHorizontal; + public Stick armStick; public TestController(CommandGamepad g, Robot r) { robot = r; @@ -26,6 +28,8 @@ public TestController(CommandGamepad g, Robot r) { private void AssignNamedControllerButton() { testPower = gamepad.leftBumper; testPower2 = gamepad.rightBumper; + armStick = gamepad.rightStick; + armHorizontal = gamepad.ps_circle; } public void BindControls() { @@ -33,7 +37,9 @@ public void BindControls() { } public void bindTestControls() { - testPower.whenPressed(ClawCmds.cmds.PowTest(robot.clawSubsystem)); - testPower2.whenPressed(ClawCmds.cmds.PowTest2(robot.clawSubsystem)); + testPower.whenPressed(robot.clawSubsystem::powIncrement); + testPower2.whenPressed(robot.clawSubsystem::powDecrement); + armHorizontal.whenPressed(robot.clawSubsystem::setArmHorizontal); + CommandScheduler.scheduleJoystick(new JoystickIncDecCmd(robot.clawSubsystem, armStick)); } } diff --git a/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/subsystems/ClawSubsystem.java b/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/subsystems/ClawSubsystem.java index 5e5adf6..8e3cb1c 100644 --- a/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/subsystems/ClawSubsystem.java +++ b/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/subsystems/ClawSubsystem.java @@ -24,20 +24,20 @@ public class ClawSubsystem implements Subsystem, Loggable { public static double CLAW_OPEN_POSITION = 0.3; public static double CLAW_CLOSE_POSITION = 0.9; - public static double MIN_ARM_MOTOR_SPEED = -0.5; - public static double MAX_ARM_MOTOR_SPEED = 0.5; - public static int INCREMENT_DECREMENT = 30; - public static double FEEDFORWARD_COEFFICIENT = 0; + public static double MIN_ARM_MOTOR_SPEED = -1; + public static double MAX_ARM_MOTOR_SPEED = 1; + public static int INCREMENT_DECREMENT = 10; + public static double FEEDFORWARD_COEFFICIENT = 0.65; public static int ARM_VERTICAL = 165; - public static int ARM_HORIZONTAL = 29; + public static int ARM_HORIZONTAL = 53; public static int INITIAL_POSITION = 20; public static int ARM_MAX = 320; public static int ARM_MIN = 8; @Log(name = "armTarget") + @Log(name = "armPos") public int armTargetPos; - @Log(name = "armPos") public int armPos; @Log(name = "armPow") @@ -53,7 +53,7 @@ private void setArmPos(int e) { armTargetPos = e; } - public static PIDCoefficients armPID = new PIDCoefficients(0.005, 0.0, 0); + public static PIDCoefficients armPID = new PIDCoefficients(0.05, 0.0, 0); private void setClawPosition(double d) { if (isHardware) { @@ -112,7 +112,7 @@ The downward torque due to gravity is cos(T) * Gravity (9.8m/s^2) return armFeedFwdValue; } ); - setArmPos(INITIAL_POSITION); + setArmPos(ARM_HORIZONTAL); } public ClawSubsystem() { @@ -132,13 +132,15 @@ public void increment(double value) { } public void powIncrement() { - armPow = armPow + 0.05; - setArmMotorPower(armPow); + setArmPos(armTargetPos + 1); + } + + public void setArmHorizontal() { + setArmPos(ARM_HORIZONTAL); } public void powDecrement() { - armPow = armPow - 0.05; - setArmMotorPower(armPow); + setArmPos(armTargetPos - 1); } private static double getArmAngle(double ticks) { @@ -160,6 +162,7 @@ private void setArmMotorPower(double speed) { double clippedSpeed = Range.clip(speed, MIN_ARM_MOTOR_SPEED, MAX_ARM_MOTOR_SPEED); arm.setPower(clippedSpeed); } + armPow = speed; } @Override From a3ed41d3e687bd6e4a818ebae652dded7759863a Mon Sep 17 00:00:00 2001 From: KOOLPOOL <141171610+Kooolpool@users.noreply.github.com> Date: Tue, 27 May 2025 17:47:19 -0700 Subject: [PATCH 6/9] interval? --- .../ftc/ptechnodactyl/commands/JoystickIncDecCmd.java | 9 +++++++++ .../ptechnodactyl/opmodes/tele/JustDrivingTeleOp.java | 1 + .../ftc/ptechnodactyl/subsystems/ClawSubsystem.java | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/commands/JoystickIncDecCmd.java b/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/commands/JoystickIncDecCmd.java index 568ce55..6d90a26 100644 --- a/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/commands/JoystickIncDecCmd.java +++ b/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/commands/JoystickIncDecCmd.java @@ -1,5 +1,6 @@ package org.firstinspires.ftc.ptechnodactyl.commands; +import com.qualcomm.robotcore.util.ElapsedTime; import com.technototes.library.command.Command; import com.technototes.library.control.Stick; import com.technototes.library.logger.Loggable; @@ -10,6 +11,11 @@ public class JoystickIncDecCmd implements Command, Loggable { public ClawSubsystem subsystem; public DoubleSupplier x; + public static ElapsedTime timer; + + public static double time; + + public double interval = 1.5; public JoystickIncDecCmd(ClawSubsystem sub, Stick xStick) { addRequirements(sub); @@ -23,7 +29,10 @@ public JoystickIncDecCmd(ClawSubsystem sub, Stick xStick) { @Override public void execute() { double xvalue = -x.getAsDouble(); + // time = timer.time(); + // if (interval < time) subsystem.increment(xvalue); + // timer.reset(); } @Override diff --git a/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/opmodes/tele/JustDrivingTeleOp.java b/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/opmodes/tele/JustDrivingTeleOp.java index d54e60a..6302c59 100644 --- a/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/opmodes/tele/JustDrivingTeleOp.java +++ b/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/opmodes/tele/JustDrivingTeleOp.java @@ -11,6 +11,7 @@ import org.firstinspires.ftc.ptechnodactyl.Robot; import org.firstinspires.ftc.ptechnodactyl.Setup; import org.firstinspires.ftc.ptechnodactyl.commands.EZCmd; +import org.firstinspires.ftc.ptechnodactyl.commands.JoystickIncDecCmd; import org.firstinspires.ftc.ptechnodactyl.controllers.DriverController; import org.firstinspires.ftc.ptechnodactyl.controllers.OperatorController; import org.firstinspires.ftc.ptechnodactyl.helpers.StartingPosition; diff --git a/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/subsystems/ClawSubsystem.java b/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/subsystems/ClawSubsystem.java index 8e3cb1c..31439b4 100644 --- a/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/subsystems/ClawSubsystem.java +++ b/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/subsystems/ClawSubsystem.java @@ -35,9 +35,9 @@ public class ClawSubsystem implements Subsystem, Loggable { public static int ARM_MIN = 8; @Log(name = "armTarget") - @Log(name = "armPos") public int armTargetPos; + @Log(name = "armPos") public int armPos; @Log(name = "armPow") From 59b2dbf308d7cb5a2746419d13e19498cfd74c54 Mon Sep 17 00:00:00 2001 From: KOOLPOOL <141171610+Kooolpool@users.noreply.github.com> Date: Tue, 3 Jun 2025 21:12:19 -0700 Subject: [PATCH 7/9] working pid and theoretical onecontroller opmode with separate controller --- .../controllers/OneController.java | 86 +++++++++++++++++++ .../controllers/OperatorController.java | 6 ++ .../controllers/TestController.java | 1 - .../opmodes/tele/oneController.java | 28 ++++++ .../subsystems/ClawSubsystem.java | 28 ++++-- 5 files changed, 140 insertions(+), 9 deletions(-) create mode 100644 Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/controllers/OneController.java create mode 100644 Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/opmodes/tele/oneController.java diff --git a/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/controllers/OneController.java b/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/controllers/OneController.java new file mode 100644 index 0000000..34f50d7 --- /dev/null +++ b/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/controllers/OneController.java @@ -0,0 +1,86 @@ +package org.firstinspires.ftc.ptechnodactyl.controllers; + +import com.technototes.library.command.CommandScheduler; +import com.technototes.library.control.CommandAxis; +import com.technototes.library.control.CommandButton; +import com.technototes.library.control.CommandGamepad; +import com.technototes.library.control.Stick; +import org.firstinspires.ftc.ptechnodactyl.Robot; +import org.firstinspires.ftc.ptechnodactyl.Setup; +import org.firstinspires.ftc.ptechnodactyl.commands.ClawCmds; +import org.firstinspires.ftc.ptechnodactyl.commands.DrivingCommands; +import org.firstinspires.ftc.ptechnodactyl.commands.JoystickDriveCommand; +import org.firstinspires.ftc.ptechnodactyl.commands.JoystickIncDecCmd; + +public class OneController { + + public Robot robot; + public CommandGamepad gamepad; + public CommandButton openClaw; + public CommandButton closeClaw; + public CommandButton ArmHorizontal; + public CommandButton ArmVertical; + public Stick driveLeftStick, driveRightStick; + public CommandButton resetGyroButton, turboButton, snailButton; + public CommandButton increment; + public CommandButton decrement; + public CommandAxis driveStraighten; + public CommandAxis drive45; + + public OneController(CommandGamepad g, Robot r) { + robot = r; + gamepad = g; + AssignNamedControllerButton(); + BindControls(); + } + + private void AssignNamedControllerButton() { + openClaw = gamepad.leftBumper; + closeClaw = gamepad.rightBumper; + ArmHorizontal = gamepad.ps_square; + ArmVertical = gamepad.ps_triangle; + increment = gamepad.ps_circle; + decrement = gamepad.ps_cross; + resetGyroButton = gamepad.ps_options; + driveLeftStick = gamepad.leftStick; + driveRightStick = gamepad.rightStick; + driveStraighten = gamepad.rightTrigger; + drive45 = gamepad.leftTrigger; + turboButton = gamepad.leftBumper; + snailButton = gamepad.rightBumper; + } + + public void BindControls() { + if (Setup.Connected.CLAWSUBSYSTEM) { + bindClawSubsystemControls(); + } + if (Setup.Connected.DRIVEBASE) { + bindDriveControls(); + } + } + + public void bindClawSubsystemControls() { + openClaw.whenPressed(ClawCmds.cmds.OpenClaw(robot.clawSubsystem)); + closeClaw.whenPressed(ClawCmds.cmds.CloseClaw(robot.clawSubsystem)); + ArmVertical.whenPressed(robot.clawSubsystem::setArmVertical); + ArmHorizontal.whenPressed(robot.clawSubsystem::setArmHorizontal); + } + + public void bindDriveControls() { + CommandScheduler.scheduleJoystick( + new JoystickDriveCommand( + robot.drivebaseSubsystem, + driveLeftStick, + driveRightStick, + driveStraighten, + drive45 + ) + ); + + turboButton.whenPressed(DrivingCommands.TurboDriving(robot.drivebaseSubsystem)); + turboButton.whenReleased(DrivingCommands.NormalDriving(robot.drivebaseSubsystem)); + snailButton.whenPressed(DrivingCommands.SnailDriving(robot.drivebaseSubsystem)); + snailButton.whenReleased(DrivingCommands.NormalDriving(robot.drivebaseSubsystem)); + resetGyroButton.whenPressed(DrivingCommands.ResetGyro(robot.drivebaseSubsystem)); + } +} diff --git a/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/controllers/OperatorController.java b/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/controllers/OperatorController.java index db0744f..f535e68 100644 --- a/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/controllers/OperatorController.java +++ b/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/controllers/OperatorController.java @@ -18,6 +18,8 @@ public class OperatorController { public CommandButton openClaw; public CommandButton closeClaw; public Stick armStick; + public CommandButton ArmHorizontal; + public CommandButton ArmVertical; public OperatorController(CommandGamepad g, Robot r) { robot = r; @@ -30,6 +32,8 @@ private void AssignNamedControllerButton() { openClaw = gamepad.leftBumper; closeClaw = gamepad.rightBumper; armStick = gamepad.rightStick; + ArmHorizontal = gamepad.ps_circle; + ArmVertical = gamepad.ps_triangle; } public void BindControls() { @@ -41,6 +45,8 @@ public void BindControls() { public void bindClawSubsystemControls() { openClaw.whenPressed(ClawCmds.cmds.OpenClaw(robot.clawSubsystem)); closeClaw.whenPressed(ClawCmds.cmds.CloseClaw(robot.clawSubsystem)); + ArmVertical.whenPressed(robot.clawSubsystem::setArmVertical); + ArmHorizontal.whenPressed(robot.clawSubsystem::setArmHorizontal); CommandScheduler.scheduleJoystick(new JoystickIncDecCmd(robot.clawSubsystem, armStick)); } } diff --git a/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/controllers/TestController.java b/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/controllers/TestController.java index 8ef874b..88f6f42 100644 --- a/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/controllers/TestController.java +++ b/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/controllers/TestController.java @@ -39,7 +39,6 @@ public void BindControls() { public void bindTestControls() { testPower.whenPressed(robot.clawSubsystem::powIncrement); testPower2.whenPressed(robot.clawSubsystem::powDecrement); - armHorizontal.whenPressed(robot.clawSubsystem::setArmHorizontal); CommandScheduler.scheduleJoystick(new JoystickIncDecCmd(robot.clawSubsystem, armStick)); } } diff --git a/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/opmodes/tele/oneController.java b/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/opmodes/tele/oneController.java new file mode 100644 index 0000000..1c81f97 --- /dev/null +++ b/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/opmodes/tele/oneController.java @@ -0,0 +1,28 @@ +package org.firstinspires.ftc.ptechnodactyl.opmodes.tele; + +import com.acmerobotics.dashboard.FtcDashboard; +import com.acmerobotics.dashboard.telemetry.MultipleTelemetry; +import com.qualcomm.robotcore.eventloop.opmode.TeleOp; +import com.technototes.library.logger.Loggable; +import com.technototes.library.structure.CommandOpMode; +import org.firstinspires.ftc.ptechnodactyl.Hardware; +import org.firstinspires.ftc.ptechnodactyl.Robot; +import org.firstinspires.ftc.ptechnodactyl.controllers.OneController; + +@TeleOp(name = "OneController") +@SuppressWarnings("unused") +public class oneController extends CommandOpMode implements Loggable { + + public Hardware hardware; + public Robot robot; + + public OneController driver; + + @Override + public void uponInit() { + telemetry = new MultipleTelemetry(telemetry, FtcDashboard.getInstance().getTelemetry()); + hardware = new Hardware(hardwareMap); + robot = new Robot(hardware); + driver = new OneController(driverGamepad, robot); + } +} diff --git a/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/subsystems/ClawSubsystem.java b/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/subsystems/ClawSubsystem.java index 31439b4..f03230f 100644 --- a/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/subsystems/ClawSubsystem.java +++ b/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/subsystems/ClawSubsystem.java @@ -26,12 +26,12 @@ public class ClawSubsystem implements Subsystem, Loggable { public static double CLAW_CLOSE_POSITION = 0.9; public static double MIN_ARM_MOTOR_SPEED = -1; public static double MAX_ARM_MOTOR_SPEED = 1; - public static int INCREMENT_DECREMENT = 10; - public static double FEEDFORWARD_COEFFICIENT = 0.65; + public static int INCREMENT_DECREMENT = 5; + public static double FEEDFORWARD_COEFFICIENT = 0.25; public static int ARM_VERTICAL = 165; public static int ARM_HORIZONTAL = 53; public static int INITIAL_POSITION = 20; - public static int ARM_MAX = 320; + public static int ARM_MAX = 327; public static int ARM_MIN = 8; @Log(name = "armTarget") @@ -53,7 +53,7 @@ private void setArmPos(int e) { armTargetPos = e; } - public static PIDCoefficients armPID = new PIDCoefficients(0.05, 0.0, 0); + public static PIDCoefficients armPID = new PIDCoefficients(0.02, 0.0, 0); private void setClawPosition(double d) { if (isHardware) { @@ -131,12 +131,16 @@ public void increment(double value) { setArmPos(newArmPos); } - public void powIncrement() { - setArmPos(armTargetPos + 1); + public void incrementn() { + increment(1); } - public void setArmHorizontal() { - setArmPos(ARM_HORIZONTAL); + public void decrement() { + increment(-1); + } + + public void powIncrement() { + setArmPos(armTargetPos + 1); } public void powDecrement() { @@ -157,6 +161,14 @@ public void closeClaw() { setClawPosition(CLAW_CLOSE_POSITION); } + public void setArmVertical() { + setArmPos(ARM_VERTICAL); + } + + public void setArmHorizontal() { + setArmPos(ARM_HORIZONTAL); + } + private void setArmMotorPower(double speed) { if (isHardware) { double clippedSpeed = Range.clip(speed, MIN_ARM_MOTOR_SPEED, MAX_ARM_MOTOR_SPEED); From bd424869379daa92ebdf79fc45f4b6160eadc7bf Mon Sep 17 00:00:00 2001 From: KOOLPOOL <141171610+Kooolpool@users.noreply.github.com> Date: Thu, 5 Jun 2025 17:12:23 -0700 Subject: [PATCH 8/9] got rid of claw cmds file because there was no use and got a button binding for single controller inc & dec for arm and have new arm intake pos which all needs to be tested --- .../ftc/ptechnodactyl/commands/ClawCmds.java | 26 ------------------- .../controllers/DriverController.java | 12 +-------- .../controllers/OneController.java | 24 +++++++---------- .../controllers/OperatorController.java | 10 +++---- .../controllers/TestController.java | 2 -- .../subsystems/ClawSubsystem.java | 19 ++++++++++++-- 6 files changed, 32 insertions(+), 61 deletions(-) delete mode 100644 Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/commands/ClawCmds.java diff --git a/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/commands/ClawCmds.java b/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/commands/ClawCmds.java deleted file mode 100644 index 609413b..0000000 --- a/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/commands/ClawCmds.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.firstinspires.ftc.ptechnodactyl.commands; - -import com.technototes.library.command.Command; -import org.firstinspires.ftc.ptechnodactyl.subsystems.ClawSubsystem; - -public class ClawCmds { - - public static class cmds { - - public static Command OpenClaw(ClawSubsystem CS) { - return Command.create(CS::openClaw); - } - - public static Command CloseClaw(ClawSubsystem CS) { - return Command.create(CS::closeClaw); - } - - public static Command PowTest(ClawSubsystem CS) { - return Command.create(CS::powIncrement); - } - - public static Command PowTest2(ClawSubsystem CS) { - return Command.create(CS::powDecrement); - } - } -} diff --git a/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/controllers/DriverController.java b/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/controllers/DriverController.java index 0bf7390..2727ddd 100644 --- a/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/controllers/DriverController.java +++ b/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/controllers/DriverController.java @@ -18,8 +18,6 @@ public class DriverController { public Stick driveLeftStick, driveRightStick; public CommandButton resetGyroButton, turboButton, snailButton; public CommandButton override; - public CommandAxis driveStraighten; - public CommandAxis drive45; public DriverController(CommandGamepad g, Robot r) { this.robot = r; @@ -36,21 +34,13 @@ private void AssignNamedControllerButton() { resetGyroButton = gamepad.ps_options; driveLeftStick = gamepad.leftStick; driveRightStick = gamepad.rightStick; - driveStraighten = gamepad.rightTrigger; - drive45 = gamepad.leftTrigger; turboButton = gamepad.leftBumper; snailButton = gamepad.rightBumper; } public void bindDriveControls() { CommandScheduler.scheduleJoystick( - new JoystickDriveCommand( - robot.drivebaseSubsystem, - driveLeftStick, - driveRightStick, - driveStraighten, - drive45 - ) + new JoystickDriveCommand(robot.drivebaseSubsystem, driveLeftStick, driveRightStick) ); turboButton.whenPressed(DrivingCommands.TurboDriving(robot.drivebaseSubsystem)); diff --git a/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/controllers/OneController.java b/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/controllers/OneController.java index 34f50d7..dced2aa 100644 --- a/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/controllers/OneController.java +++ b/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/controllers/OneController.java @@ -1,5 +1,6 @@ package org.firstinspires.ftc.ptechnodactyl.controllers; +import android.support.v4.app.INotificationSideChannel; import com.technototes.library.command.CommandScheduler; import com.technototes.library.control.CommandAxis; import com.technototes.library.control.CommandButton; @@ -7,10 +8,8 @@ import com.technototes.library.control.Stick; import org.firstinspires.ftc.ptechnodactyl.Robot; import org.firstinspires.ftc.ptechnodactyl.Setup; -import org.firstinspires.ftc.ptechnodactyl.commands.ClawCmds; import org.firstinspires.ftc.ptechnodactyl.commands.DrivingCommands; import org.firstinspires.ftc.ptechnodactyl.commands.JoystickDriveCommand; -import org.firstinspires.ftc.ptechnodactyl.commands.JoystickIncDecCmd; public class OneController { @@ -24,8 +23,7 @@ public class OneController { public CommandButton resetGyroButton, turboButton, snailButton; public CommandButton increment; public CommandButton decrement; - public CommandAxis driveStraighten; - public CommandAxis drive45; + public CommandButton intake; public OneController(CommandGamepad g, Robot r) { robot = r; @@ -44,10 +42,9 @@ private void AssignNamedControllerButton() { resetGyroButton = gamepad.ps_options; driveLeftStick = gamepad.leftStick; driveRightStick = gamepad.rightStick; - driveStraighten = gamepad.rightTrigger; - drive45 = gamepad.leftTrigger; turboButton = gamepad.leftBumper; snailButton = gamepad.rightBumper; + intake = gamepad.dpadRight; } public void BindControls() { @@ -60,21 +57,18 @@ public void BindControls() { } public void bindClawSubsystemControls() { - openClaw.whenPressed(ClawCmds.cmds.OpenClaw(robot.clawSubsystem)); - closeClaw.whenPressed(ClawCmds.cmds.CloseClaw(robot.clawSubsystem)); + openClaw.whenPressed(robot.clawSubsystem::openClaw); + closeClaw.whenPressed(robot.clawSubsystem::closeClaw); ArmVertical.whenPressed(robot.clawSubsystem::setArmVertical); ArmHorizontal.whenPressed(robot.clawSubsystem::setArmHorizontal); + increment.whenPressed(robot.clawSubsystem::incrementn); + decrement.whenPressed(robot.clawSubsystem::decrement); + intake.whenPressed(robot.clawSubsystem::setArmIntake); } public void bindDriveControls() { CommandScheduler.scheduleJoystick( - new JoystickDriveCommand( - robot.drivebaseSubsystem, - driveLeftStick, - driveRightStick, - driveStraighten, - drive45 - ) + new JoystickDriveCommand(robot.drivebaseSubsystem, driveLeftStick, driveRightStick) ); turboButton.whenPressed(DrivingCommands.TurboDriving(robot.drivebaseSubsystem)); diff --git a/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/controllers/OperatorController.java b/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/controllers/OperatorController.java index f535e68..0cd9495 100644 --- a/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/controllers/OperatorController.java +++ b/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/controllers/OperatorController.java @@ -1,15 +1,12 @@ package org.firstinspires.ftc.ptechnodactyl.controllers; -import com.technototes.library.command.Command; import com.technototes.library.command.CommandScheduler; import com.technototes.library.control.CommandButton; import com.technototes.library.control.CommandGamepad; import com.technototes.library.control.Stick; import org.firstinspires.ftc.ptechnodactyl.Robot; import org.firstinspires.ftc.ptechnodactyl.Setup; -import org.firstinspires.ftc.ptechnodactyl.commands.ClawCmds; import org.firstinspires.ftc.ptechnodactyl.commands.JoystickIncDecCmd; -import org.firstinspires.ftc.ptechnodactyl.subsystems.ClawSubsystem; public class OperatorController { @@ -20,6 +17,7 @@ public class OperatorController { public Stick armStick; public CommandButton ArmHorizontal; public CommandButton ArmVertical; + public CommandButton intake; public OperatorController(CommandGamepad g, Robot r) { robot = r; @@ -34,6 +32,7 @@ private void AssignNamedControllerButton() { armStick = gamepad.rightStick; ArmHorizontal = gamepad.ps_circle; ArmVertical = gamepad.ps_triangle; + intake = gamepad.dpadRight; } public void BindControls() { @@ -43,10 +42,11 @@ public void BindControls() { } public void bindClawSubsystemControls() { - openClaw.whenPressed(ClawCmds.cmds.OpenClaw(robot.clawSubsystem)); - closeClaw.whenPressed(ClawCmds.cmds.CloseClaw(robot.clawSubsystem)); + openClaw.whenPressed(robot.clawSubsystem::openClaw); + closeClaw.whenPressed(robot.clawSubsystem::closeClaw); ArmVertical.whenPressed(robot.clawSubsystem::setArmVertical); ArmHorizontal.whenPressed(robot.clawSubsystem::setArmHorizontal); + intake.whenPressed(robot.clawSubsystem::setArmIntake); CommandScheduler.scheduleJoystick(new JoystickIncDecCmd(robot.clawSubsystem, armStick)); } } diff --git a/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/controllers/TestController.java b/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/controllers/TestController.java index 88f6f42..e9ddeaf 100644 --- a/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/controllers/TestController.java +++ b/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/controllers/TestController.java @@ -5,8 +5,6 @@ import com.technototes.library.control.CommandGamepad; import com.technototes.library.control.Stick; import org.firstinspires.ftc.ptechnodactyl.Robot; -import org.firstinspires.ftc.ptechnodactyl.Setup; -import org.firstinspires.ftc.ptechnodactyl.commands.ClawCmds; import org.firstinspires.ftc.ptechnodactyl.commands.JoystickIncDecCmd; public class TestController { diff --git a/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/subsystems/ClawSubsystem.java b/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/subsystems/ClawSubsystem.java index f03230f..8ae3665 100644 --- a/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/subsystems/ClawSubsystem.java +++ b/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/subsystems/ClawSubsystem.java @@ -27,6 +27,7 @@ public class ClawSubsystem implements Subsystem, Loggable { public static double MIN_ARM_MOTOR_SPEED = -1; public static double MAX_ARM_MOTOR_SPEED = 1; public static int INCREMENT_DECREMENT = 5; + public static int INCREMENT_DECREMENT_BUTTON = 50; public static double FEEDFORWARD_COEFFICIENT = 0.25; public static int ARM_VERTICAL = 165; public static int ARM_HORIZONTAL = 53; @@ -131,12 +132,22 @@ public void increment(double value) { setArmPos(newArmPos); } + public void increment_button(double value) { + int newArmPos = (int) (armTargetPos + value * INCREMENT_DECREMENT_BUTTON); + if (newArmPos > ARM_MAX) { + newArmPos = ARM_MAX; + } else if (newArmPos < ARM_MIN) { + newArmPos = ARM_MIN; + } + setArmPos(newArmPos); + } + public void incrementn() { - increment(1); + increment_button(1); } public void decrement() { - increment(-1); + increment_button(-1); } public void powIncrement() { @@ -169,6 +180,10 @@ public void setArmHorizontal() { setArmPos(ARM_HORIZONTAL); } + public void setArmIntake() { + setArmPos(ARM_MAX); + } + private void setArmMotorPower(double speed) { if (isHardware) { double clippedSpeed = Range.clip(speed, MIN_ARM_MOTOR_SPEED, MAX_ARM_MOTOR_SPEED); From ae951b2a4de4d37d55a476138ca259fe28577f98 Mon Sep 17 00:00:00 2001 From: KOOLPOOL <141171610+Kooolpool@users.noreply.github.com> Date: Fri, 6 Jun 2025 17:33:52 -0700 Subject: [PATCH 9/9] ptechnodactyl works now and is done --- .../ftc/ptechnodactyl/commands/JoystickDriveCommand.java | 4 ++-- .../ftc/ptechnodactyl/controllers/OneController.java | 3 --- .../ftc/ptechnodactyl/opmodes/tele/oneController.java | 3 +++ 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/commands/JoystickDriveCommand.java b/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/commands/JoystickDriveCommand.java index 1602b2c..74ef7ba 100644 --- a/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/commands/JoystickDriveCommand.java +++ b/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/commands/JoystickDriveCommand.java @@ -107,8 +107,8 @@ public void execute() { // The math & signs looks wonky, because this makes things field-relative // (Remember that "3 O'Clock" is zero degrees) - double yvalue = -y.getAsDouble(); - double xvalue = -x.getAsDouble(); + double yvalue = y.getAsDouble(); + double xvalue = x.getAsDouble(); if (driveStraighten != null) { if (driveStraighten.getAsDouble() > 0.7) { if (Math.abs(yvalue) > Math.abs(xvalue)) xvalue = 0; diff --git a/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/controllers/OneController.java b/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/controllers/OneController.java index dced2aa..2098522 100644 --- a/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/controllers/OneController.java +++ b/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/controllers/OneController.java @@ -23,7 +23,6 @@ public class OneController { public CommandButton resetGyroButton, turboButton, snailButton; public CommandButton increment; public CommandButton decrement; - public CommandButton intake; public OneController(CommandGamepad g, Robot r) { robot = r; @@ -44,7 +43,6 @@ private void AssignNamedControllerButton() { driveRightStick = gamepad.rightStick; turboButton = gamepad.leftBumper; snailButton = gamepad.rightBumper; - intake = gamepad.dpadRight; } public void BindControls() { @@ -63,7 +61,6 @@ public void bindClawSubsystemControls() { ArmHorizontal.whenPressed(robot.clawSubsystem::setArmHorizontal); increment.whenPressed(robot.clawSubsystem::incrementn); decrement.whenPressed(robot.clawSubsystem::decrement); - intake.whenPressed(robot.clawSubsystem::setArmIntake); } public void bindDriveControls() { diff --git a/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/opmodes/tele/oneController.java b/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/opmodes/tele/oneController.java index 1c81f97..69cd1dc 100644 --- a/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/opmodes/tele/oneController.java +++ b/Ptechnodactyl/src/main/java/org/firstinspires/ftc/ptechnodactyl/opmodes/tele/oneController.java @@ -3,10 +3,12 @@ import com.acmerobotics.dashboard.FtcDashboard; import com.acmerobotics.dashboard.telemetry.MultipleTelemetry; import com.qualcomm.robotcore.eventloop.opmode.TeleOp; +import com.technototes.library.command.CommandScheduler; import com.technototes.library.logger.Loggable; import com.technototes.library.structure.CommandOpMode; import org.firstinspires.ftc.ptechnodactyl.Hardware; import org.firstinspires.ftc.ptechnodactyl.Robot; +import org.firstinspires.ftc.ptechnodactyl.commands.EZCmd; import org.firstinspires.ftc.ptechnodactyl.controllers.OneController; @TeleOp(name = "OneController") @@ -24,5 +26,6 @@ public void uponInit() { hardware = new Hardware(hardwareMap); robot = new Robot(hardware); driver = new OneController(driverGamepad, robot); + CommandScheduler.register(robot.clawSubsystem); } }