Code

 

 

Coding with Comment

Table 3 show the breakdown distances of supplied energy of the final code

Phases Scenario Final Code
1 Start at the drop area and stop at the first gate -Speed at 35 for 4.5 sec

-Glide for 2.75 sec

-decelerate at 30 for 2 sec

-Wait times for 8 sec

reverse(4);

motorSpeed(4,35);

goFor(4.5);

brake(4);

goFor(2.75);

reverse(4);

celerate(4,30,0,2);

brake(4);

gofor(8);

2 Navigate to the cargo area and stop to pick up R2-D2 -Speed at 35 for 4.3 sec

-Glide for 2.75 sec

-Wait times for 8 sec

reverse(4);

motorSpeed(4,35);

goFor(4.3);

brake(4);

goFor(2.75);

reverse(4);

brake(4);

goFor(6);

3 Travel back and stop at the previous gate -Speed at 42 for 5 sec

-Glide for 2.7 sec

-decelerate at 40 for 3.5 sec

-Wait times for 8 sec

motorSpeed(4,42);

goFor(5);

brake(4);

goFor(2.7);

reverse(4);

celerate(4,40,0,3.5);

brake(4);

goFor(8);

4 Navigate to the drop-off area -Speed at 42 for 5 sec

-Glide for 2.7 sec

-decelerate at 40 for 3.5 sec

reverse(4);

motorSpeed(4,42);

goFor(5);

brake(4);

goFor(2.7);

reverse(4);

celerate(4,40,0,3.5);

brake(4);