Throughout the AEV design process the code was updated multiple times to reach the final goal. Below is the evolution of code (bolded text indicates changes from the previous version):
Starting Code:
- reverse(4); // Reverses polarity of all motors, used to counteract direction of motors on AEV
- motorSpeed(4,34); // Sets all motors to 34% power
- goFor(3.9); // Runs motors for 3.9 seconds
- brake(4); // Stops power to motors
- rotateServo(45); // Applies servo brake to stop AEV before gate
- goFor(8); // Pauses at gate for 8 seconds
- rotateServo(0); // Removes servo brake
- motorSpeed(4,25); // Sets all motors to 25% power
- goFor(5); // Runs motors for 5 seconds
- brake(4); //Stops power to all motors
- rotateServo(45); // Applies servo brake to stop AEV before dock
Performance Test 1:
- reverse(4);
- motorSpeed(4,36); // The AEV stopped short of the gate
- goFor(3.8); // Adjusted time to compensate for speed change so AEV stopped at gate correctly
- brake(4);
- rotateServo(45);
- goFor(8);
- rotateServo(0);
- motorSpeed(4,25);
- goFor(4); // The AEV ran into the dock before the servo engaged
- brake(4);
- rotateServo(45);
Changes After Performance Test 1:
- reverse(4);
- motorSpeed(4,33); // The AEV ran too fast after PT1 and overshot the gate
- goFor(3.8);
- brake(4);
- rotateServo(45);
- goFor(8);
- rotateServo(0);
- motorSpeed(4,22); // The AEV had too much speed coming out of the gate
- goFor(3); // The AEV ran into the caboose too hard
- brake(4);
- // Removed the rotateServo in order to coast into caboose/dock
- goFor(14); // Coasts into caboose at dock and pauses for 5 seconds
- reverse(4); // Reverses motor direction to leave the dock
- motorSpeed(4,45); // Sets motor speed to 45%
- goFor(3); // Pulls out of dock and coasts to a stop
Performance Test 2:
- reverse(4);
- motorSpeed(4,33);
- goFor(4); // The AEV started consistently running underpowered. Increased time to make it to the dock
- brake(4);
- rotateServo(45);
- goFor(8);
- rotateServo(0);
- motorSpeed(4,25); // The AEV didn’t have enough speed to make it to the dock
- goFor(3.2); // The AEV started coasting too soon
- brake(4);
- goFor(12); // Reduced the coast time to keep the time at dock at 5 seconds
- reverse(4);
- motorSpeed(4,65); // Increased speed to get out of the dock
- goFor(4); // Increased time to get up the incline after leaving the dock
- brake(4); // Cut power to motors to prepare for stopping at the gate
- rotateServo(45); // Engaged servo brake to stop at the gate
Changes After Performance Test 2:
- reverse(4);
- motorSpeed(4,33);
- goFor(3.9); // The AEV started running too far to the gate again
- brake(4);
- rotateServo(45);
- goFor(8);
- rotateServo(0);
- motorSpeed(4,25);
- goFor(3.8); // The AEV was still coasting too soon
- brake(4);
- goFor(2.5); // Added a short coast before engaging servo brake
- rotateServo(40); // Partially engaged servo brake to slow before connecting to caboose
- goFor(.6); // Short pause with servo engaged
- rotateServo(0); // Remove servo brake to gently coast into caboose
- goFor(8); // Reduced the pause time to keep the time at dock at 5 seconds
- reverse(4);
- motorSpeed(4,63); // Reduced power coming out of the dock
- goFor(3.9); // Reduced time because the AEV started overshooting the gate
- brake(4);
- goFor(.2); // Short coast to clear track bracket before servo braking
- rotateServo(45); // Engaged servo brake to stop at the gate
- goFor(8); // Pause at the gate
- motorSpeed(4,65); // Sets motor speed to 65%
- goFor(3); // Runs motors for 3 seconds at high power to clear the gate
- brake(4); // Cuts power to motors to coast to finish
- goFor(4); // Coasts to finish dock
- rotateServo(45); // Engages servo brake to stop at finish dock
Performance Test 3:
- reverse(4);
- motorSpeed(4,35); //Tried higher power shorter bursts for energy comparison
- goFor(3.7);
- brake(4);
- goFor(0.1); //coast into gate for 0.1 seconds and servo brake for 8 seconds
- rotateServo(45);
- goFor(8);
- rotateServo(0);
- motorSpeed(4,33); //run higher power with shorter coasting
- goFor(4.0);
brake(4);//cut power
goFor(0.6); //coast for 0.6 seconds then servo brake
rotateServo(45); //Harder braking to stop higher speed
goFor(0.1);
rotateServo(0);
motorSpeed(4,1); //coast to caboose for 0.1 seconds
goFor(0.1);
rotateServo(45); //Second servo brake to fully stop
goFor(0.1);
rotateServo(0);
goFor(8.0); - reverse(4);
- motorSpeed(4,63);
- goFor(3.9);
- brake(4);
- goFor(0.9); //coast into gate for 0.9 seconds
- rotateServo(46);
- goFor(8);
- rotateServo(0);
- motorSpeed(4,66); //exit gate with caboose
- goFor(3);
- brake(4);
- goFor(2.7); //Shorter coast
- rotateServo(45); //final stop
Final Code:
//PT1 – Start to Gate
- reverse(4);
- motorSpeed(4,34); //Reduced power for energy savings
- goFor(3.9);
- brake(4);
- goFor(0.1); //coast into gate for 0.1 seconds and servo brake for 8 seconds
- rotateServo(45);
- goFor(8);
//PT2 – Gate to Dock
- rotateServo(0);
- motorSpeed(4,26); //Lower speed longer run
- goFor(3.7);
- brake(4);
- goFor(2.4);
- rotateServo(37); // Reduced angle and time for servo to not stop short
- goFor(.3);
- rotateServo(0);
- goFor(8);
//PT3 – Dock to Gate
- reverse(4);
- motorSpeed(4,62); // Reduced power coming out of the dock
- goFor(3.9);
- brake(4);
- goFor(.6); // Increased coasting time to gate
- rotateServo(45); // Engaged servo brake to stop at the gate
- goFor(8); // Pause at the gate
//PT4- Gate to Finish
- rotateServo(0);
- motorSpeed(4,65);
- goFor(2); // Shortened the power burst and lengthened the coast
- brake(4);
- goFor(3.4);
- rotateServo(45);