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