Code Optimization

In this portion of the Performance Test lab, team C engineers were tasked with creating two separate codes for their vehicle to run on. The vehicle being used was the model which was ultimate selected in the Design Optimization portion of the lab. The goal of the engineers were to test both of the codes on the vehicle, and to conclude which code is more energy efficient, and effective for completing the goal given to the engineers. The engineers were able to conclude which code was more effective by conducting test runs, and collecting data which would be analyzed to come up with  a conclusion. Shown below is the data generated from the test run with the first code created.

 

Code #1 Energy vs Distance Plot

 

Code #2 Energy vs Distance Plot

As shown by the plots above, both codes used somewhat similar amount of energy. Code #1 used less energy for about 1 meter, but the amount of time it required for Code #1 to complete the track caused the engineers to decide to continue working with Code #2. The overall cost of using Code #2, considering time spent on the track, was less than Code #1.


Code Used:

Refer here for information on command functions.

 

Performance Test 2 – Code #1 (Less energy longer time)

            Code                                                Explanation

reverse(4); Reverse all motors.
motorSpeed(1,35); Run motor 1 at 35% power.
goToAbsolutePosition(280); Go to mark 280.
brake(4); Brake all motors.
goToAbsolutePosition(313); Go to mark 313.
rotateServo(50.00); Rotate servo motor to 50 degrees.
goFor(1); Run for 1 second.
rotateServo(0.00); Rotate servo motor to 0 degrees.
goFor(5); Run for 5 seconds.
motorSpeed(1,30); Run motor 1 at 30% power.
goToAbsolutePosition(380); Go to mark 380.
brake(4); Brake all motors.
goToAbsolutePosition(664); Go to mark 664.
rotateServo(50.00); Rotate the servo to 50 degrees.
goFor(1); Run for 1 second.
rotateServo(0.00); Rotate the servo to 0 degrees.

 


Performance Test 2 – Code #2 (Higher energy shorter time)

 

 

                     Code                                         Explanation

reverse(4); Reverse all motors.
motorSpeed(1,35); Run motor 1 at 35% power.
goToAbsolutePosition(280); Go to mark 280.
brake(4); Brake all motors.
goToAbsolutePosition(313); Go to mark 313.
rotateServo(50.00); Rotate servo motor to 50 degrees.
goFor(1); Run for 1 second.
rotateServo(0.00); Rotate servo motor to 0 degrees.
goFor(5); Run for 5 seconds.
motorSpeed(1,30); Run motor 1 at 30% power.
goToAbsolutePosition(440); Go to mark 440.
brake(4); Brake all motors.
goToAbsolutePosition(649); Go to mark 649.
rotateServo(50.00); Rotate servo to 50 degrees.
goFor(1); Run for 1 second.
rotateServo(0.00); Rotate servo to 0 degrees.