mirror of
https://github.com/TimeCrafters/FTC_2022
synced 2025-12-15 17:52:34 +00:00
Adding run-to on arm heights
This commit is contained in:
@@ -27,14 +27,11 @@ public class PhoenixTeleOPState extends CyberarmState {
|
||||
public void CalculateDeltaRotation() {
|
||||
if (RotationTarget >= 0 && RobotRotation >= 0) {
|
||||
DeltaRotation = Math.abs(RotationTarget - RobotRotation);
|
||||
}
|
||||
else if (RotationTarget <= 0 && RobotRotation <= 0) {
|
||||
} else if (RotationTarget <= 0 && RobotRotation <= 0) {
|
||||
DeltaRotation = Math.abs(RotationTarget - RobotRotation);
|
||||
}
|
||||
else if (RotationTarget >= 0 && RobotRotation <= 0) {
|
||||
} else if (RotationTarget >= 0 && RobotRotation <= 0) {
|
||||
DeltaRotation = Math.abs(RotationTarget + RobotRotation);
|
||||
}
|
||||
else if (RotationTarget <=0 && RobotRotation >= 0) {
|
||||
} else if (RotationTarget <= 0 && RobotRotation >= 0) {
|
||||
DeltaRotation = Math.abs(RobotRotation + RotationTarget);
|
||||
}
|
||||
}
|
||||
@@ -77,9 +74,7 @@ public class PhoenixTeleOPState extends CyberarmState {
|
||||
robot.backRightDrive.setPower(drivePower);
|
||||
robot.frontLeftDrive.setPower(drivePower);
|
||||
robot.frontRightDrive.setPower(drivePower);
|
||||
}
|
||||
|
||||
else if (engine.gamepad1.left_trigger > 0) {
|
||||
} else if (engine.gamepad1.left_trigger > 0) {
|
||||
drivePower = engine.gamepad1.left_trigger;
|
||||
robot.backLeftDrive.setPower(-drivePower);
|
||||
robot.backRightDrive.setPower(-drivePower);
|
||||
@@ -126,15 +121,13 @@ public class PhoenixTeleOPState extends CyberarmState {
|
||||
robot.backRightDrive.setPower(-drivePower);
|
||||
robot.frontLeftDrive.setPower(drivePower);
|
||||
robot.frontRightDrive.setPower(-drivePower);
|
||||
}
|
||||
else if (RobotRotation >= 0) {
|
||||
} else if (RobotRotation >= 0) {
|
||||
drivePower = (-1 * DeltaRotation / 180) - MinimalPower;
|
||||
robot.backLeftDrive.setPower(drivePower);
|
||||
robot.backRightDrive.setPower(-drivePower);
|
||||
robot.frontLeftDrive.setPower(drivePower);
|
||||
robot.frontRightDrive.setPower(-drivePower);
|
||||
}
|
||||
else if (RobotRotation <= -179 || RobotRotation >= 179) {
|
||||
} else if (RobotRotation <= -179 || RobotRotation >= 179) {
|
||||
drivePower = 0;
|
||||
robot.backLeftDrive.setPower(drivePower);
|
||||
robot.backRightDrive.setPower(-drivePower);
|
||||
@@ -344,28 +337,145 @@ public class PhoenixTeleOPState extends CyberarmState {
|
||||
}
|
||||
}//end of a
|
||||
|
||||
if (engine.gamepad2.back) {
|
||||
robot.backLeftDrive.setPower(1);
|
||||
robot.backRightDrive.setPower(1);
|
||||
robot.frontLeftDrive.setPower(1);
|
||||
robot.frontRightDrive.setPower(1);
|
||||
if (System.currentTimeMillis() - lastStepTime >= 1500) {
|
||||
robot.backLeftDrive.setPower(0);
|
||||
robot.backRightDrive.setPower(0);
|
||||
robot.frontLeftDrive.setPower(0);
|
||||
robot.frontRightDrive.setPower(0);
|
||||
}
|
||||
if (System.currentTimeMillis() - lastStepTime >= 150) {
|
||||
if (robot.HighRiserLeft.getPosition() < 1) {
|
||||
// if (engine.gamepad2.back) {
|
||||
// robot.backLeftDrive.setPower(1);
|
||||
// robot.backRightDrive.setPower(1);
|
||||
// robot.frontLeftDrive.setPower(1);
|
||||
// robot.frontRightDrive.setPower(1);
|
||||
// if (System.currentTimeMillis() - lastStepTime >= 1500) {
|
||||
// robot.backLeftDrive.setPower(0);
|
||||
// robot.backRightDrive.setPower(0);
|
||||
// robot.frontLeftDrive.setPower(0);
|
||||
// robot.frontRightDrive.setPower(0);
|
||||
// }
|
||||
// if (System.currentTimeMillis() - lastStepTime >= 150) {
|
||||
// if (robot.HighRiserLeft.getPosition() < 1) {
|
||||
// if (System.currentTimeMillis() - lastStepTime >= 150) {
|
||||
// lastStepTime = System.currentTimeMillis();
|
||||
// robot.HighRiserLeft.setPosition(robot.HighRiserLeft.getPosition() + 0.05);
|
||||
// robot.HighRiserRight.setPosition(robot.HighRiserRight.getPosition() + 0.05);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if (System.currentTimeMillis() - lastStepTime >= 150) {
|
||||
// if (robot.LowRiserLeft.getPosition() < 1 && robot.HighRiserLeft.getPosition() == 1) {
|
||||
// if (System.currentTimeMillis() - lastStepTime >= 150) {
|
||||
// lastStepTime = System.currentTimeMillis();
|
||||
// robot.LowRiserLeft.setPosition(robot.LowRiserLeft.getPosition() + 0.05);
|
||||
// robot.LowRiserRight.setPosition(robot.LowRiserRight.getPosition() + 0.05);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if (System.currentTimeMillis() >= 250) {
|
||||
// robot.backLeftDrive.setPower(1);
|
||||
// robot.backRightDrive.setPower(1);
|
||||
// robot.frontLeftDrive.setPower(1);
|
||||
// robot.frontRightDrive.setPower(1);
|
||||
// if (System.currentTimeMillis() - lastStepTime >= 250) {
|
||||
// robot.backLeftDrive.setPower(0);
|
||||
// robot.backRightDrive.setPower(0);
|
||||
// robot.frontLeftDrive.setPower(0);
|
||||
// robot.frontRightDrive.setPower(0);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
if (engine.gamepad2.left_bumper) {
|
||||
if (robot.HighRiserLeft.getPosition() < 0.73) {
|
||||
if (System.currentTimeMillis() - lastStepTime >= 150) {
|
||||
lastStepTime = System.currentTimeMillis();
|
||||
robot.HighRiserLeft.setPosition(robot.HighRiserLeft.getPosition() + 0.05);
|
||||
robot.HighRiserRight.setPosition(robot.HighRiserRight.getPosition() + 0.05);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!engine.gamepad2.left_bumper) {
|
||||
if (robot.HighRiserLeft.getPosition() < 0.73) {
|
||||
if (System.currentTimeMillis() - lastStepTime >= 150) {
|
||||
if (robot.LowRiserLeft.getPosition() < 1 && robot.HighRiserLeft.getPosition() == 1) {
|
||||
lastStepTime = System.currentTimeMillis();
|
||||
robot.HighRiserLeft.setPosition(0.73);
|
||||
robot.HighRiserRight.setPosition(0.73);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (engine.gamepad2.right_bumper) {
|
||||
if (robot.HighRiserLeft.getPosition() < 0.85) {
|
||||
if (System.currentTimeMillis() - lastStepTime >= 150) {
|
||||
lastStepTime = System.currentTimeMillis();
|
||||
robot.HighRiserLeft.setPosition(robot.HighRiserLeft.getPosition() + 0.05);
|
||||
robot.HighRiserRight.setPosition(robot.HighRiserRight.getPosition() + 0.05);
|
||||
}
|
||||
}
|
||||
|
||||
if (robot.LowRiserLeft.getPosition() < 0.6 && robot.HighRiserLeft.getPosition() >= 0.85) {
|
||||
if (System.currentTimeMillis() - lastStepTime >= 150) {
|
||||
lastStepTime = System.currentTimeMillis();
|
||||
robot.LowRiserLeft.setPosition(robot.LowRiserLeft.getPosition() + 0.05);
|
||||
robot.LowRiserRight.setPosition(robot.LowRiserRight.getPosition() + 0.05);
|
||||
}
|
||||
}
|
||||
if (robot.LowRiserLeft.getPosition() > 0.8)
|
||||
if (robot.HighRiserLeft.getPosition() > 0.87 && robot.LowRiserLeft.getPosition() < 0.7) {
|
||||
if (System.currentTimeMillis() - lastStepTime >= 150) {
|
||||
lastStepTime = System.currentTimeMillis();
|
||||
robot.HighRiserLeft.setPosition(robot.HighRiserLeft.getPosition() - 0.05);
|
||||
robot.HighRiserRight.setPosition(robot.HighRiserRight.getPosition() - 0.05);
|
||||
}
|
||||
}
|
||||
if (!engine.gamepad2.right_bumper) {
|
||||
if (robot.HighRiserLeft.getPosition() < 0.85) {
|
||||
if (System.currentTimeMillis() - lastStepTime >= 150) {
|
||||
lastStepTime = System.currentTimeMillis();
|
||||
robot.HighRiserLeft.setPosition(robot.HighRiserLeft.getPosition() + 0.05);
|
||||
robot.HighRiserRight.setPosition(robot.HighRiserRight.getPosition() + 0.05);
|
||||
}
|
||||
}
|
||||
|
||||
if (robot.LowRiserLeft.getPosition() < 0.6 && robot.HighRiserLeft.getPosition() >= 0.85) {
|
||||
if (System.currentTimeMillis() - lastStepTime >= 150) {
|
||||
lastStepTime = System.currentTimeMillis();
|
||||
robot.LowRiserLeft.setPosition(robot.LowRiserLeft.getPosition() + 0.05);
|
||||
robot.LowRiserRight.setPosition(robot.LowRiserRight.getPosition() + 0.05);
|
||||
}
|
||||
}
|
||||
if (robot.HighRiserLeft.getPosition() > 0.87) {
|
||||
if (System.currentTimeMillis() - lastStepTime >= 150) {
|
||||
lastStepTime = System.currentTimeMillis();
|
||||
robot.HighRiserLeft.setPosition(robot.HighRiserLeft.getPosition() - 0.05);
|
||||
robot.HighRiserRight.setPosition(robot.HighRiserRight.getPosition() - 0.05);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (engine.gamepad2.right_stick_button) {
|
||||
if (robot.HighRiserLeft.getPosition() < 0.85) {
|
||||
if (System.currentTimeMillis() - lastStepTime >= 150) {
|
||||
lastStepTime = System.currentTimeMillis();
|
||||
robot.HighRiserLeft.setPosition(robot.HighRiserLeft.getPosition() + 0.05);
|
||||
robot.HighRiserRight.setPosition(robot.HighRiserRight.getPosition() + 0.05);
|
||||
}
|
||||
}
|
||||
|
||||
if (robot.LowRiserLeft.getPosition() < 0.75 && robot.HighRiserLeft.getPosition() > 0.7) {
|
||||
if (System.currentTimeMillis() - lastStepTime >= 150) {
|
||||
lastStepTime = System.currentTimeMillis();
|
||||
robot.LowRiserLeft.setPosition(robot.LowRiserLeft.getPosition() + 0.05);
|
||||
robot.LowRiserRight.setPosition(robot.LowRiserRight.getPosition() + 0.05);
|
||||
}
|
||||
}
|
||||
if (!engine.gamepad2.right_stick_button) {
|
||||
if (robot.HighRiserLeft.getPosition() < 0.85) {
|
||||
if (System.currentTimeMillis() - lastStepTime >= 150) {
|
||||
lastStepTime = System.currentTimeMillis();
|
||||
robot.HighRiserLeft.setPosition(robot.HighRiserLeft.getPosition() + 0.05);
|
||||
robot.HighRiserRight.setPosition(robot.HighRiserRight.getPosition() + 0.05);
|
||||
}
|
||||
}
|
||||
|
||||
if (robot.LowRiserLeft.getPosition() < 0.75 && robot.HighRiserLeft.getPosition() > 0.7) {
|
||||
if (System.currentTimeMillis() - lastStepTime >= 150) {
|
||||
lastStepTime = System.currentTimeMillis();
|
||||
robot.LowRiserLeft.setPosition(robot.LowRiserLeft.getPosition() + 0.05);
|
||||
@@ -373,27 +483,14 @@ public class PhoenixTeleOPState extends CyberarmState {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (System.currentTimeMillis() >= 250) {
|
||||
robot.backLeftDrive.setPower(1);
|
||||
robot.backRightDrive.setPower(1);
|
||||
robot.frontLeftDrive.setPower(1);
|
||||
robot.frontRightDrive.setPower(1);
|
||||
if (System.currentTimeMillis() - lastStepTime >= 250) {
|
||||
robot.backLeftDrive.setPower(0);
|
||||
robot.backRightDrive.setPower(0);
|
||||
robot.frontLeftDrive.setPower(0);
|
||||
robot.frontRightDrive.setPower(0);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
gamepad1Checker.update();
|
||||
gamepad2Checker.update();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void buttonUp(Gamepad gamepad, String button) {
|
||||
if (engine.gamepad1 == gamepad && button.equals("start")) {
|
||||
|
||||
Reference in New Issue
Block a user