Created
November 21, 2012 10:27
-
-
Save tgoossens/4124151 to your computer and use it in GitHub Desktop.
Evaulate Secure
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void createQueue() { | |
queue = new ArrayDeque<When<Predicate<RobotState>,Fn>>(); | |
queue.push(when(isOnWhiteLine,driveLongBackward)); //if already on white line move backward | |
queue.push(when( and(isIdle, not(isOnWhiteLine)), driveForward)); //start driving forward | |
queue.push(when( and(isMoving, isOnWhiteLine), stopRobot)); //stop when white line is detected | |
queue.push(when( and(isIdle, isOnWhiteLine), driveLongForward)); // drive long forward | |
queue.push(when( isIdle, rotateClockWise)); //start rotating clockwise | |
queue.push(when( and(isMoving, isOnWhiteLine), stopRobot)); //stop rotating when white line detected | |
queue.push(when(isIdle, rotateLeft90)); //put perpendicular | |
} | |
protected IProcedure evaluateSecure(InputData inputData, | |
RobotState robotState) { | |
if (not(queue.isEmpty())) { | |
if (queue.peek().pred.apply(robotState)) { | |
queue.pop().fn.apply(); | |
} | |
} else { | |
terminate(); | |
} | |
return null; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment