Fine-tuning and adding constant correction

This commit is contained in:
NerdyBirdy460
2023-12-02 12:01:58 -06:00
parent 83e88d6f75
commit 2f911879a3
2 changed files with 36 additions and 7 deletions

View File

@@ -85,17 +85,46 @@ public class SodiPizzaAutoTurnState extends CyberarmState {
readyToTurn = engine.blackboardGet("readyToTurn");
targetRot = -90;
currentRot = robot.imu.getRobotYawPitchRollAngles().getYaw(AngleUnit.DEGREES);
CalculateNeededRot();
if (readyToTurn == 1 && Math.abs(neededRot) > 10) {
if (readyToTurn == 0) {
targetRot = 0;
if (currentRot < targetRot - 1) {
turnSpeedRaw = 0.5;
getTurnSpeed();
robot.rightFront.setPower(robot.leftFront.getPower() + turnSpeed);
robot.rightBack.setPower(robot.leftBack.getPower() + turnSpeed);
}
}
if (readyToTurn == 1 && targetRot != -90) {
targetRot = -90;
CalculateNeededRot();
}
if (currentRot >= -88) {
turnSpeedRaw = 0.3;
getTurnSpeed();
robot.leftFront.setPower(-turnSpeed);
robot.leftBack.setPower(-turnSpeed);
robot.rightFront.setPower(turnSpeed);
robot.rightBack.setPower(turnSpeed);
} else if (currentRot <= -92) {
turnSpeedRaw = 0.2;
getTurnSpeed();
robot.leftFront.setPower(turnSpeed);
robot.leftBack.setPower(turnSpeed);
robot.rightFront.setPower(-turnSpeed);

View File

@@ -54,10 +54,10 @@ public class SodiPizzaMinibotObject extends Robot {
leftBack = engine.hardwareMap.dcMotor.get("leftBack");
rightBack = engine.hardwareMap.dcMotor.get("rightBack");
leftFront.setDirection(DcMotorSimple.Direction.REVERSE);
leftBack.setDirection(DcMotorSimple.Direction.REVERSE);
rightFront.setDirection(DcMotorSimple.Direction.FORWARD);
rightBack.setDirection(DcMotorSimple.Direction.FORWARD);
leftFront.setDirection(DcMotorSimple.Direction.FORWARD);
leftBack.setDirection(DcMotorSimple.Direction.FORWARD);
rightFront.setDirection(DcMotorSimple.Direction.REVERSE);
rightBack.setDirection(DcMotorSimple.Direction.REVERSE);
leftFront.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
rightFront.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);