The most basic of our code but the most simplified.
public void movefb(double power, double distance, double direction) {
if (getAngle() < -1){ //turn left
tl.setPower(-(power - (0.01 * getAngle())));
tr.setPower((power + (0.01 * getAngle())));
bl.setPower(-(power - (0.01 * getAngle())));
br.setPower((power + (0.01 * getAngle())));
} else if (getAngle() > 1){ //turn right
tl.setPower(-(power - (0.01 * getAngle())));
tr.setPower((power + (0.01 * getAngle())));
bl.setPower(-(power - (0.01 * getAngle())));
br.setPower((power + (0.01 * getAngle())));
} else {
if (direction > 0) {
tl.setPower(power);
tr.setPower(-power);
bl.setPower(power);
br.setPower(-power);
} else if (direction < 0) {
tl.setPower(-power);
tr.setPower(power);
bl.setPower(-power);
br.setPower(power);
} else {
telemetry.addData("WARNING, THERE IS AN ERROR IN THE USAGE OF THE DIRECTION FUNCTION, DIRECTION IS", direction);
}
}
}
// deprecated
public void turn(double power, double angle, double direction) {
if (direction > 0) {
tl.setPower(-(power - (0.01 * angle)));
tr.setPower((power + (0.01 * angle)));
bl.setPower(-(power - (0.01 * angle)));
br.setPower((power + (0.01 * angle)));
}
if (direction < 0) {
tl.setPower(-(-(power - (0.01 * angle))));
tr.setPower(-((power + (0.01 * angle))));
bl.setPower(-(-(power - (0.01 * angle))));
br.setPower(-((power + (0.01 * angle))));
}
if (direction == 0) {
telemetry.addData("THERE IS A PROBLEM WITH THE DIRECTION IN THE TURN FUNCTION", direction);
}
}
public void strafe(double power, double distance, double direction) {
if (direction > 0) {
tl.setPower(power);
tr.setPower(power);
bl.setPower(power);
br.setPower(power);
} else if (direction < 0) {
tl.setPower(-power);
tr.setPower(-power);
bl.setPower(-power);
br.setPower(-power);
} else {
telemetry.addData("THERE IS A PROBLEM IN THE DIRECTION FOR THE strafe() FUNCTION", direction);
}
}