Final Code

This code was used during the final test and was able to complete the whole run. This code is similar to Code 2, as that code’s consistency was decided to be a bigger asset to completing the run than energy efficiency.

Full Code:

//reverse the motors

reverse(2);

//accelerate to 30%

celerate(0,30,5,2);

motorSpeed(4,30);

//move absolute position close to the gate

goToAbsolutePosition(370);

//brake to gate using motorSpeed and wait 5 seconds

reverse(4);

motorSpeed(4,20);

goFor(2);

brake(4);

goFor(9);

 

//accelerate out of gate to 30% then back off to 25%

reverse(4);

celerate(0,30,5,2);

motorSpeed(4,25);

//move relative position close to the R2D2

goToRelativePosition(443);

//brake to R2D2 using motorSpeed and wait 5 seconds

reverse(4);

motorSpeed(4,20);

goFor(2);

brake(4);

goFor(5);

 

//keep motors reversed

//accelerate to 40% then back off to 35%

celerate(0,40,5,2);

motorSpeed(4,35);

//move back to the gate

goToRelativePosition(-333);

//brake to gate and wait 5 seconds

reverse(4);

motorSpeed(4,30);

goFor(2);

brake(4);

goFor(9);

 

//accelerate to 35%

reverse(4);

motorSpeed(4,35);

//move back to starting point

goToRelativePosition(-340);

//brake to coast to ending position

reverse(4);

motorSpeed(4,20);

goFor(2);

brake(4);