Fixed some things with search ball.
This commit is contained in:
@@ -40,6 +40,7 @@ public class SearchBallBehavior extends BaseBehavior {
|
||||
private FeatureDetectorsHandler detectorHandler;
|
||||
private RobotStateSingleton state;
|
||||
private boolean turnLeft;
|
||||
private boolean supress;
|
||||
|
||||
/**
|
||||
* Creates a new {@link SearchBallBehavior}.
|
||||
@@ -58,6 +59,7 @@ public class SearchBallBehavior extends BaseBehavior {
|
||||
this.detectorHandler = FeatureDetectorsHandler.getInstance();
|
||||
this.state = RobotStateSingleton.getInstance();
|
||||
this.turnLeft = true;
|
||||
this.supress = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -69,6 +71,7 @@ public class SearchBallBehavior extends BaseBehavior {
|
||||
/* If the current state is SEARCH_BALL then set the detectors and take control. */
|
||||
if(state.getState() == States.SEARCH_BALL) {
|
||||
setDetectors();
|
||||
this.supress = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -82,6 +85,8 @@ public class SearchBallBehavior extends BaseBehavior {
|
||||
while(queue.hasNextLightSensorEvent())
|
||||
queue.getNextLightSensorEvent();
|
||||
|
||||
this.supress = false;
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
@@ -91,6 +96,7 @@ public class SearchBallBehavior extends BaseBehavior {
|
||||
|
||||
@Override
|
||||
public void action() {
|
||||
while(!supress) {
|
||||
if(queue.hasNextRangeSensorEvent()) {
|
||||
/* If the pedestal has been found then stop the robot and set the state to BALL_FOUND. */
|
||||
if(pilot.isMoving())
|
||||
@@ -152,11 +158,13 @@ public class SearchBallBehavior extends BaseBehavior {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void suppress() {
|
||||
if(pilot.isMoving())
|
||||
pilot.stop();
|
||||
this.supress = true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user