Error handling woo
This commit is contained in:
parent
3171c89202
commit
6949c666b8
|
@ -15,7 +15,7 @@ public class AutoBlueColorSensor extends LinearOpMode {
|
||||||
waitForStart();
|
waitForStart();
|
||||||
|
|
||||||
movementAPI.move(0, 0.7);
|
movementAPI.move(0, 0.7);
|
||||||
api.pause(0.5);
|
api.pause(0.25);
|
||||||
movementAPI.stop();
|
movementAPI.stop();
|
||||||
|
|
||||||
api.pause(5);
|
api.pause(5);
|
||||||
|
@ -23,8 +23,24 @@ public class AutoBlueColorSensor extends LinearOpMode {
|
||||||
int g = sensor.green();
|
int g = sensor.green();
|
||||||
int b = sensor.blue();
|
int b = sensor.blue();
|
||||||
|
|
||||||
|
if (r < 100 && g < 100 && b < 100) {
|
||||||
|
movementAPI.move(-180, 0.7);
|
||||||
|
api.pause(0.25);
|
||||||
|
movementAPI.move(-180, 0.7);
|
||||||
|
api.pause(0.5);
|
||||||
|
movementAPI.move(90, 0.7);
|
||||||
|
api.pause(0.7);
|
||||||
|
movementAPI.stop();
|
||||||
|
|
||||||
|
terminateOpModeNow();
|
||||||
|
}
|
||||||
|
|
||||||
int largest = api.getLargest(r, g, b);
|
int largest = api.getLargest(r, g, b);
|
||||||
|
|
||||||
|
api.print("r", String.valueOf(r));
|
||||||
|
api.print("g", String.valueOf(g));
|
||||||
|
api.print("b", String.valueOf(b));
|
||||||
|
|
||||||
if (largest == g) {
|
if (largest == g) {
|
||||||
// move to position 1
|
// move to position 1
|
||||||
movementAPI.move(90, 0.7);
|
movementAPI.move(90, 0.7);
|
||||||
|
@ -37,12 +53,6 @@ public class AutoBlueColorSensor extends LinearOpMode {
|
||||||
// move to position 3
|
// move to position 3
|
||||||
movementAPI.move(-90, 0.7);
|
movementAPI.move(-90, 0.7);
|
||||||
api.pause(0.25);
|
api.pause(0.25);
|
||||||
} else {
|
|
||||||
// Color sensor broke, move to backup position
|
|
||||||
movementAPI.move(-180, 0.7);
|
|
||||||
api.pause(0.5);
|
|
||||||
movementAPI.move(90, 0.7);
|
|
||||||
api.pause(0.7);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
movementAPI.stop();
|
movementAPI.stop();
|
||||||
|
|
Loading…
Reference in a new issue