Adding semi-autonomous functions and transferring Teleop code, variable names are *NOT* inspired by the story of Spirit and Opportunity, the names are a coincidence.

This commit is contained in:
Sodi
2023-01-26 20:34:12 -06:00
parent 8bed3ffefd
commit 5baefbccf7
2 changed files with 25 additions and 2 deletions

View File

@@ -11,7 +11,7 @@ public class TeleOPArmDriver extends CyberarmState {
private long lastStepTime = 0;
private int CyclingArmUpAndDown = 0;
private GamepadChecker gamepad2Checker;
private int Opportunity, Endeavour;
private int Opportunity, Endeavour, Peanut;
private double drivePower;
private double MinimalPower = 0.25, topServoOffset = -0.05, lowServoOffset = -0.05;
private double servoCollectLow = 0.40; //Low servos, A button
@@ -189,5 +189,28 @@ public void exec() {
}
}
if (engine.gamepad2.dpad_left && Peanut != 1) {
Peanut = 1;
}
if (engine.gamepad2.dpad_right && Peanut != 2) {
Peanut = 2;
}
if (engine.gamepad2.dpad_left && Peanut == 1 || engine.gamepad2.dpad_right && Peanut == 2) {
robot.collectorLeft.setPower(0);
robot.collectorRight.setPower(0);
}
if (Peanut == 1) {
robot.collectorRight.setPower(1);
robot.collectorLeft.setPower(-1);
}
if (Peanut == 2) {
robot.collectorLeft.setPower(1);
robot.collectorRight.setPower(-1);
}
}
}

View File

@@ -104,7 +104,7 @@ public class TeleOPTankDriver extends CyberarmState {
currentDriveCommand = engine.gamepad1.right_stick_x;
} else if (Math.abs(engine.gamepad1.right_stick_y) > 0.1) {
currentDriveCommand = engine.gamepad1.right_stick_y;
} else if (Math.abs(engine.gamepad1.left_stick_y) > 0.1 && Math.abs(engine.gamepad1.left_stick_x) > 0.1 && Math.abs(engine.gamepad1.right_stick_x) > 0.1 && Math.abs(engine.gamepad1.right_stick_y) > 0.1) {
} else if ((Math.abs(engine.gamepad1.left_stick_y)) > 0.1 && Math.abs(engine.gamepad1.left_stick_x) > 0.1 && Math.abs(engine.gamepad1.right_stick_x) > 0.1 && Math.abs(engine.gamepad1.right_stick_y) > 0.1 && !FreeSpirit) {
currentDriveCommand = 0;
}