Code Development

The following code has been developed for the AEV to achieve its mission:

//reach gate

reverse(1); // make one motor run in reverse for front-back motor design

motorSpeed(1,40); // sets motor 1 to 40% power

goToAbsolutePosition(170); // run the motors until a distance of 170 marks

brake(4); // shut off all motors

goToAbsolutePosition(383); // coast until a distance of 383 marks

reverse(4); // reverse the AEV motors to stop forward movement

motorSpeed(1,40); // sets motor 1 to 40% power

goFor(1); // run the motor at 40% power in the backwards direction for 1 sec to stop the AEV

brake(4); // stops all motors

goFor(7); // wait 7 seconds for gate to open

 

//reach R2-D2

reverse(4); // reverse the motors so the AEV travels forward

motorSpeed(1,42); // sets motor 1 to 42% power

goToAbsolutePosition(557); // run the motor to a distance of 557 marks

brake(4); // shut off all motors

goFor(12); // coast the rest of the way to the R2D2 and then wait 5 seconds

 

//reach gate

reverse(4); // reverse the motors so the AEV travels backwards toward the gate

motorSpeed(4,48.75); // set all motors 48.75% power

goFor(4); // run the motors for 4 seconds to get the AEV moving with the R2D2

brake(1); // shut off motor 1

motorSpeed(2,41); // sets motor 2 to 41% power

goToAbsolutePosition(465); // drive until mark 465

brake(4); // shut off all motors

reverse(4); // reverse the AEV motors to stop forward movement

motorSpeed(1,59.9); // set motor 1 to 59.9% power

goFor(1); // run the motor at 59.9% power in the reverse direction for 1 sec to stop the AEV

brake(4); // stops all motors

goFor(8); // wait 8 seconds for gate to open

 

//reach end

reverse(4); // reverse the motors

motorSpeed(4,49.9); // set all motors 49.9% power

goFor(4); // run the motors for 4 seconds to get the AEV moving with the R2D2

brake(1); // shut off motor 1

motorSpeed(2,40); // set motor 2 to 40% power

goToAbsolutePosition(50); // drive until 50 marks from the start of the track

brake(4); // brake all motors

reverse(4); // reverse the AEV motors to stop forward movement

motorSpeed(2,59.9); // sets motor 2 to 59.9% power

goFor(1); // runs the motors at 59.9% power in the backwards direction for 1 sec to stop the AEV

brake(4); // stops all motors

 

AEV Showcase Scenario 1

 reverse(1); // reverse one motor for front-back motor design

 motorSpeed(4,24); // set all motors to 24% power

 goFor(4); // run the motors for 4 seconds

 motorSpeed(4,16); // set all motors to 16% power

 goFor(5); // run the motors for 5 seconds

 brake(4); // shut off all motors

 reverse(4); // reverse the motors

 motorSpeed(4,35);  //  set all motors to 35% power

 goFor(1); // run the motors for 1 second

 brake(4); // shut off all motors

 goFor(5); // run for 5 more seconds to finish collecting data

 

AEV Showcase Scenario 2

 reverse(4); // all the motors so the AEV can travel backwards with the cargo

 reverse(1); // reverse one motor for front-back motor design

 motorSpeed(4,35); // set all motors to 35% power

 goFor(5); // run the motors for 5 seconds

 motorSpeed(4,28.1); // set all motors to 28.1% power

 goFor(9); // run the motors for 9 seconds

 brake(4); // shut off all motors

 reverse(4); // reverse all motors

 motorSpeed(4,10); // set all motors to 10% power

 goFor(1); // run the motors for 1 second

 brake(4); // shut off all motors

 goFor(5); // run for 5 more seconds to finish collecting data

 

AEV Showcase Scenario 3

 reverse(1); // reverse one motor for front-back motor design

 // 640 marks = 20 ft

 motorSpeed(2, 60); // set motor 2 to 60% power

 goFor(2.2); // run the motor for 2.2 seconds

 brake(4); // shut off all motors

 goFor(10); // coast for 10 seconds to the cargo

 

 // go back

 reverse(4);  // reverse all motors

 motorSpeed(4, 60); // set all motors to 60% power

 goFor(4); // run the motors for 4 seconds

 brake(4); // shut off all motors

 goFor(5); // run for 5 more seconds to finish collecting data

 

Comparing One Motor vs Two Motors:

Code 1

//reach gate

reverse(1); // make one motor run in reverse for front-back motor design

motorSpeed(4,30); // set all motors 30% power

// run the motors until a distance of 170 marks

goToAbsolutePosition(170);

brake(4); // shut off all motors

goToAbsolutePosition(375); // coast until a distance of 375 marks

reverse(4); // reverse the AEV motors to stop forward movement

motorSpeed(4,30); // sets all motors to 30% power

goFor(1); // runs the motors at 30% power in the backwards direction for 1 sec to stop the AEV

brake(4); // stops all motors

goFor(7); // wait 7 seconds for gate to open

 

//reach R2-D2

reverse(4); // reverse the motors so the AEV travels forward

motorSpeed(4,30); // sets all motors to 30% power

goToAbsolutePosition(555); // run the motors to a distance of 555 marks

brake(4); // shut off all motors

goFor(12); // coast the rest of the way to the R2D2 and then wait 5 seconds

 

//reach gate

reverse(4); // reverse the motors so the AEV travels backwards toward the gate

motorSpeed(4,50); // set all motors 50% power

//run the motors for 4 seconds to get the AEV moving with the R2D2

goFor(4);

motorSpeed(4,30); // set all motors to 30% power

goToAbsolutePosition(465); // drive until mark 465

brake(4); // shut off all motors

reverse(4); // reverse the AEV motors to stop forward movement

motorSpeed(4,50); // sets all motors to 50% power

goFor(1); // runs the motors at 50% power in the reverse direction for 1 sec to stop the AEV

brake(4); // stops all motors

goFor(7); // wait 7 seconds for gate to open

 

//reach end

reverse(4); // reverse the motors

motorSpeed(4,50); // set all motors 50% power

goFor(5); // run the motors at a high power for 5 seconds to get the AEV with cargo moving

motorSpeed(4,35);  // reduce power to 35% for all motors

goToAbsolutePosition(60); // continue to 60 marks from the start of the track

brake(4);  // brake all motors

reverse(4); // reverse the AEV motors to stop forward movement

motorSpeed(4,50); // sets all motors to 50% power

goFor(1); // runs the motors at 50% power in the backwards direction for 1 sec to stop the AEV

brake(4); // stops all motors

 

Code 2

//reach gate

reverse(1); // make one motor run in reverse for front-back motor design

motorSpeed(1,40); // set one motor to 40% power

// run the motor until a distance of 170 marks

goToAbsolutePosition(170);

brake(4); // shut off all motors

goToAbsolutePosition(376); // coast until a distance of 376 marks

reverse(4); // reverse the AEV motors to stop forward movement

motorSpeed(1,40); // set the motor to 40% power

goFor(1); // runs the motor at 40% power in the backwards direction for 1 sec to stop the AEV

brake(4); // stops all motors

goFor(7); // wait 7 seconds for gate to open

 

//reach R2-D2

reverse(4); // reverse the motors so the AEV travels forward

motorSpeed(1,40); // sets the motor to 40% power

goToAbsolutePosition(560); // run the motor to a distance of 560 marks

brake(4); // shut off all motors

goFor(12); // coast the rest of the way to the R2D2 and then wait 5 seconds

 

//reach gate

reverse(4); // reverse the motors so the AEV travels backwards toward the gate

motorSpeed(2,75); // sets the second motor to 75% power

//run the motor for 4 seconds to get the AEV moving with the R2D2

goFor(4);

motorSpeed(2,20); // set the second motor to 15% power

goToAbsolutePosition(465); // drive until mark 465

brake(4); // shut off all motors

reverse(4); // reverse the AEV motors to stop forward movement

motorSpeed(2,65); // sets the second motor to 50% power

goFor(1); // runs the motor at 50% power in the reverse direction for 1 sec to stop the AEV

brake(4); // stops all motors

goFor(7); // wait 7 seconds for gate to open

 

//reach end

reverse(4); // reverse the motors

motorSpeed(2,75); // sets the second motor to 75% power

goFor(4); // run the motor at a high power to get the AEV moving with the cargo

motorSpeed(2,30); // set the second motor to 30% power

goToAbsolutePosition(55); // run until 55 marks from the start of the track

brake(4); // shuts off all motors

reverse(4); // reverse the AEV motors to stop forward movement

motorSpeed(2,60); // sets the second motor to 30% power

goFor(1); // runs the motor at 30% power in the backwards direction for 1 sec to stop the AEV

brake(4); // stops all motors