Performance test 1 required the vehicle to move forward towards the gate, wait a certain amount of time, and pass through. For this test, new set of code was implemented for travel: the fail-safe. Rather than using only time based code (i.e. running the AEV for a certain amount of time), the AEV would travel for a few seconds and then allow the fail-safe to activate. It would measure the remaining distance needed to get to a calculated point on the track and use a lower power setting to “scoot” the AEV to the desired distance. This would ensure that the vehicle would reach its destination safely and accurately.
// Program between here——————————————————————-
// Calculated position of starting dock
int dock = (124*8/3.902);
// All motors set to 40% power and will go to position of dock/gate
motorSpeed(4,40);
goToRelativePosition(dock);
// Coasting to a stop
reverse(4);
motorSpeed(4,40);
goFor(1);
brake(4);
// Fail-safe (so AEV doesn’t crash into gate) – uses and ‘if’ statement to check whether the vehicle has reached the calculated position
goFor(5);
int final = (152*8/3.902);
if(getVehiclePostion() < final){
reverse(4);
motorSpeed(4,25);
goToAbsolutePosition(final);
brake(4);
}else{
reverse(4);
}
// Waiting at the gate for 7 seconds
brake(4);
goFor(7);
// Going to the final destination
int end = (85*8/3.902);
motorSpeed(4,40);
goToRelativePosition(end);
// Coasting to a stop
reverse(4);
motorSpeed(4,40);
goFor(1);
// Mini brake
motorSpeed(4,10);
goFor(1);
// Fail-safe 2
int finalDock = (15*12*8/3.902);
if(getVehiclePostion() < finalDock){
reverse(4);
motorSpeed(4,25);
goToAbsolutePosition(finalDock);
brake(4);
}
} // DO NOT REMOVE. end of void myCode()