Lab 9 – Performance Test 2

Description of Code: This is one of the codes that completes the mission. This code runs the AEV until the gate, where it stops for about 5 seconds before it runs again. It connects with R2D2, the cargo, and waits for about 5 seconds again before stopping at the gate for another five seconds. After passing through the gate with the cargo, the AEV slowly comes back to the beginning.


 //reverse all motors                                                                       

 reverse(4);                                                                                                                                                                     

                                                                                            

 //run motors at 21 power until 300 marks                                                                                                                       

 motorSpeed(4,21);                                                                      

 goToAbsolutePosition(300);                                                                

                             

 //reverse                                                              

 reverse(4);                                                                               

 

 //runs backwards at 24 power for 2 seconds                                                                                          

 motorSpeed(4,24);                                                                          

 goFor(2);                                                                                                   

                                                                 

 //brake all motors                                                                     

 brake(4);                                                                                 

 

 //wait time at gate                                                                                          

 goFor(8);       

 

//gates open

 //reverse motors to be put back into pusher mode                                                                       

 reverse(4);                                                                               

 

 //run motors at 35 power for two seconds                                                                                                     

 motorSpeed(4,25);                                                                         

 goFor(2);                                                                                 

          

 //runs motor at 20 power until 640 marks                                                                              

 motorSpeed(4,20);                                                                         

 goToAbsolutePosition(640);                                                                

         

 //coasts to R2D2                                                                                                                                                           

 brake(4);            

 

 //waits at R2D2                                                                     

 goFor(10);                                                                                

                          

 //reverse motors into puller mode                                                                  

 reverse(4);                                                                               

                                                 

 //runs motors at 36 power until 590 marks                                     

 motorSpeed(4,36);                                                                      

 goToAbsolutePosition(590);                      

 

 //runs motors at 21 power until 510 marks                                                                                            

 motorSpeed(4,21);                                                                         

 goToAbsolutePosition(510);                                                                

                                  

 //brakes motors and coasts until 490 marks                         

 brake(4);                                                                                 

 goToAbsolutePosition(490);                                                                

                                                                                            

//reverse motors to act as a brake

reverse(4);                                    

 

 //goes into pusher mode softly at 16 power for 2 seconds                                           

 motorSpeed(4,16);                                                                         

 goFor(2);                                                                              

                                                                                          

 //back into puller mode

 reverse(4);                                                                               

           

 //waits at gate                                                                                

 brake(4);                                                                                  

 goFor(9);                                                                                                                                                   

                         

 //gates open                                                                  

 //return to start                                                                         

           

 //runs all motor at 35 power until 145 marks                                                                             

 motorSpeed(4, 35);                                                                        

 goToAbsolutePosition(145);                                                                 

                                    

 //coasts until the beginning                                                        

 brake(4);