Simplification of class files

This commit is contained in:
2024-12-25 15:08:36 -08:00
parent c824580b33
commit c63319f9c4
2 changed files with 40 additions and 96 deletions

View File

@ -5,20 +5,20 @@ import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
import org.firstinspires.ftc.teamcode.cometbots.CometBotAutoDevelopment; import org.firstinspires.ftc.teamcode.cometbots.CometBotAutoDevelopment;
@TeleOp(name = "CometBot Auto", group = "Development") @TeleOp(name = "CometBot Auto v2", group = "Development")
public class CometBotDevAuto extends OpMode { public class CometBotDevAuto extends OpMode {
public CometBotAutoDevelopment runMode; public CometBotAutoDevelopment runMode;
@Override @Override
public void init() { public void init() {
this.runMode = new CometBotAutoDevelopment(hardwareMap, telemetry, gamepad1, gamepad2); runMode = new CometBotAutoDevelopment(hardwareMap, gamepad1, gamepad2);
this.runMode.init(); runMode.init();
} }
@Override @Override
public void loop() { public void loop() {
this.runMode.update(); runMode.update();
telemetry.update(); telemetry.update();
} }
} }

View File

@ -15,6 +15,7 @@ import com.qualcomm.robotcore.hardware.HardwareMap;
import org.firstinspires.ftc.robotcore.external.Telemetry; import org.firstinspires.ftc.robotcore.external.Telemetry;
import org.firstinspires.ftc.teamcode.pedroPathing.follower.Follower; import org.firstinspires.ftc.teamcode.pedroPathing.follower.Follower;
import org.firstinspires.ftc.teamcode.states.FieldStates; import org.firstinspires.ftc.teamcode.states.FieldStates;
import org.firstinspires.ftc.teamcode.subsystem.DualMotorSliderSubsystem;
import org.firstinspires.ftc.teamcode.subsystem.MotorsSubsystem; import org.firstinspires.ftc.teamcode.subsystem.MotorsSubsystem;
public class CometBotAutoDevelopment { public class CometBotAutoDevelopment {
@ -22,121 +23,64 @@ public class CometBotAutoDevelopment {
/* /*
Subsystems Subsystems
*/ */
private MotorsSubsystem motors; private DualMotorSliderSubsystem dualSlides;
/* /*
Controllers Controllers
*/ */
public Gamepad GP1; public Gamepad gamepad1;
public Gamepad GP2; public Gamepad gamepad2;
public Gamepad currentGP1; public Gamepad currentGamepad1;
public Gamepad previousGP1; public Gamepad currentGamepad2;
public Gamepad currentGP2; public Gamepad previousGamepad1;
public Gamepad previousGP2; public Gamepad previousGamepad2;
private Telemetry telemetry;
public FieldStates fieldStates;
private boolean centricity = false;
private Follower follower; private Follower follower;
private HardwareMap hardwareMap;
public CometBotAutoDevelopment(HardwareMap hardwareMap, Telemetry telemetry, Gamepad gp1, Gamepad gp2) { public CometBotAutoDevelopment(HardwareMap hardwareMap, Gamepad gamepad1, Gamepad gamepad2) {
this.motors = new MotorsSubsystem(hardwareMap, telemetry); dualSlides = new DualMotorSliderSubsystem(hardwareMap);
this.GP1 = gp1; this.gamepad1 = gamepad1;
this.GP2 = gp2; this.gamepad2 = gamepad2;
this.hardwareMap = hardwareMap; currentGamepad1 = new Gamepad();
this.telemetry = telemetry; currentGamepad2 = new Gamepad();
this.currentGP1 = new Gamepad(); previousGamepad1 = new Gamepad();
this.currentGP2 = new Gamepad(); previousGamepad2 = new Gamepad();
this.previousGP1 = new Gamepad();
this.previousGP2 = new Gamepad();
this.fieldStates = new FieldStates();
this.follower = new Follower(hardwareMap);
}
public class ZeroOutPower implements Action {
@Override
public boolean run(@NonNull TelemetryPacket telemetryPacket) {
follower = new Follower(hardwareMap); follower = new Follower(hardwareMap);
follower.setMaxPower(0);
System.out.println("Running ZeroOutPower");
return follower.isBusy();
}
}
public class ReturnToMaxPower implements Action {
@Override
public boolean run(@NonNull TelemetryPacket telemetryPacket) {
follower = new Follower(hardwareMap);
follower.setMaxPower(MAX_POWER);
follower.startTeleopDrive();
System.out.println("Running ReturnToMaxPower");
return follower.isBusy();
}
}
public Action zeroOutPower() {
return new ZeroOutPower();
}
public Action returnToMaxPower() {
return new ReturnToMaxPower();
} }
public void init() { public void init() {
this.motors.init(); dualSlides.init();
this.fieldStates.setFieldLocation(FieldStates.FieldLocation.TRAVELING);
follower.setMaxPower(MAX_POWER); follower.setMaxPower(MAX_POWER);
follower.startTeleopDrive(); follower.startTeleopDrive();
} }
public void update() { public void update() {
this.previousGP1.copy(currentGP1); previousGamepad1.copy(currentGamepad1);
this.currentGP1.copy(this.GP1); currentGamepad1.copy(gamepad1);
this.previousGP2.copy(currentGP2); previousGamepad2.copy(currentGamepad2);
this.currentGP2.copy(this.GP2); currentGamepad2.copy(gamepad2);
this.toFixMotorBlockingIssueFirstMethod(); /*
this.toFixMotorBlockingIssueSecondMethod(); Check if dpad_up/down is being pressed for slides
this.changeCentricity(); */
dualSlides.update();
dualSlidesToLowBucketPosition();
dualSlidesToHighBucketPosition();
follower.setTeleOpMovementVectors(-this.GP1.left_stick_y, -this.GP1.left_stick_x, -this.GP1.right_stick_x, centricity); follower.setTeleOpMovementVectors(-gamepad1.left_stick_y, -gamepad1.left_stick_x, -gamepad1.right_stick_x);
follower.update(); follower.update();
this.telemetry.addData("Field State", this.fieldStates.getFieldLocation());
} }
public void changeCentricity() { private void dualSlidesToHighBucketPosition() {
if (this.currentGP1.left_bumper && !this.previousGP1.left_bumper) { if (currentGamepad1.dpad_up && !previousGamepad1.dpad_up) {
this.centricity = !centricity; dualSlides.toHighBucketPosition();
this.follower.breakFollowing();
this.follower.startTeleopDrive();
} }
} }
public void toFixMotorBlockingIssueFirstMethod() { private void dualSlidesToLowBucketPosition() {
if (this.currentGP1.cross && !this.previousGP1.cross) { if (currentGamepad1.dpad_down && !previousGamepad1.dpad_down) {
fieldStates.setFieldLocation(FieldStates.FieldLocation.BUCKET); dualSlides.toLowBucketPosition();
Actions.runBlocking(new SequentialAction(
this.zeroOutPower(),
new SleepAction(3),
this.returnToMaxPower()
));
fieldStates.setFieldLocation(FieldStates.FieldLocation.TRAVELING);
} }
} }
public void toFixMotorBlockingIssueSecondMethod() {
if (this.currentGP1.circle && !this.previousGP1.circle) {
this.follower.breakFollowing();
fieldStates.setFieldLocation(FieldStates.FieldLocation.BUCKET);
Actions.runBlocking(new SequentialAction(
new SleepAction(3)
));
fieldStates.setFieldLocation(FieldStates.FieldLocation.TRAVELING);
this.follower.startTeleopDrive();
}
}
} }