Code Optimization

Team A’s next goal is to create two codes for the same AEV design and compare the amount of energy that it uses. This is important because the purpose is to create the most energy efficient vehicle. In order to fully optimize the AEV, these codes can be compared and help create a better vehicle. Team A’s two codes varied in that Code 1, as seen at the bottom of the page, contains the term ‘celerate’ this means accelerate the vehicle from a certain percent of power to another. Code 2, as seen at the bottom of the page, contains only the term ‘motorSpeed’ instead of ‘celerate’ this ‘motorSpeed’ command allows the vehicle to jump straight to the % power rather then climb up to it like ‘celerate’ does.

When testing Code 1, it can be seen from the graph below, that the energy used was a noticeably higher difference compared to Code 2 which used the ‘motorSpeed’ command. This is because the AEV has three types of forces acting against it when it runs on the track. When the vehicle accelerates, one of the forces called inertia, the resistance an object has on accelerating, is applied on the vehicle making it harder to run. When acceleration is eliminated, that inertial force is gone, allowing the vehicle to move easily. Using the ‘motorSpeed’ command speeds up the vehicle in one instance rather than using acceleration which tries to speed up over time. When ‘celerate’ is used, the vehicle is trying to fight inertia as well as complete the task at hand in a certain amount of time which uses a lot more energy. Because of this, the ‘motorSpeed’ command is much more reliable in saving energy.

“celerate” code power vs distance graph

“motorSpeed” only code with power vs distance

 


Codes used:

Refer here for information on command functions.

Code Explanation
celerate(1,0,38,3);

motorSpeed(1,38);

Accelerate motor one to 38% power in three seconds, and then maintain that power.
goToAbsolutePosition(256);

brake(1);

goToAbsolutePosition(323);

Once the AEV reaches mark 256 stop all power to the motor and let the vehicle coast to mark 323.
rotateServo(25);

goFor(1);

rotateServo(0);

Stop the AEV by braking with the servo.
goFor(5);

celerate(1,0,36,3);

motorSpeed(1,36);

Wait at the gate for five seconds before accelerating motor one to 36% power in three seconds and maintain that power.
goToAbsolutePosition(410);

brake(1);

Once the AEV has reached mark 410 stop all power to the motor and let the AEV coast to the cargo

“celerate” code

Code Explanation
motorSpeed(1,38);

goToAbsolutePosition(256);

brake(1);

Run motor one at 38% power until mark 256 is reached, and then stop all power to the motor.
goToAbsolutePosition(323);

rotateServo(25);

goFor(1);

rotateServo(0);

Once the AEV has coasted to mark 323 stop the AEV with the servo motor.
goFor(5); Wait at the gate for five seconds before moving.
motorSpeed(1,36);

goToAbsolutePosition(410);

brake(1);

Run motor one at 36% until the vehicle has reached mark 410 before stopping all power to the motor, this will let the AEV coast into the cargo.

motorSpeed command only code.