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