Code Logic Representation

Preliminary Complete Run Algorithm:

  1. Call function waitForStartLight() in order to wait for the initial light to begin the course, and proceed to step 2 once it finishes.
  2. Call function moveToButtonPanel() in order to maneuver the robot to the button panel to read in a value, and proceed to step 3 once it finishes.
  3. Call function completeButtonPanelTask() in order to read a value for the light and press the correct button, and proceed to step 4 once it finishes.
  4. Call function moveToCarJack() in order to maneuver the robot to the car jack, and proceed to step 5 once it finishes.
  5. Call function completeCarJackTask() in order to flip the car jack up, and proceed to step 6 once it finishes.
  6. Call function moveToWrench() in order to maneuver the robot to the wrench, and proceed to step 7 once it finishes.
  7. Call function pickUpWrench() in order to pick up and control the wrench as well as prepare it for movement, and proceed to step 8 once it finishes.
  8. Call function moveToGarage() in order to maneuver the robot to the garage for deposition of the wrench, and proceed to step 9 once it finishes.
  9. Call function depositWrenchInGarage() in order to deposit the wrench in the garage, and proceed to step 10 once it finishes.
  10. Call function moveToFuelCrank() in order to maneuver the robot to the fuel crank to complete the fuel crank task, and proceed to step 11 once it finishes.
  11. Call function completeFuelCrankTask() in order to receive a value to determine which way to turn the crank and turn it in that direction, and proceed to step 12 once it finishes.
  12. Call function moveToFinalButton() in order to maneuver the robot to the ending position of the course, and proceed to step 13 once it finishes.
  13. Call function pressFinalButton() to press the final button and complete the course.

 

 

Final main() algorithm:

  1. Create a menu of FEH Icons labeled with specific functions for performance tests 1-4, a complete run, and for testing the motors, electromagnet, cds cell, fuel crank turner, and the RPS orientation.
  2. Check to see if a button is pressed. If a certain button is pressed, run its corresponding function: performance test 1, 2, 3, or 4, a complete run, or testing the motors, cds cell, electromagnet, fuel crank turner, or RPS orientation.
  3. If no buttons have been pressed, return to step 2 to check again.

performanceTest1::run() algorithm:

  1. Wait for the starting light to be activated.
  2. Move forward out of the starting area nine inches, and sleep for a short amount of time, so the robot settles.
  3. Move the robot to its right ten inches in order to align with the jack on the x axis, and sleep for a short amount of time, so the robot settles.
  4. Move the robot forward 12 inches in order to align with the jack on the y axis, and sleep for a short amount of time, so the robot settles.
  5. Move the robot to its left 4 inches in order to flip the jack, and sleep for a short amount of time, so the robot settles.
  6. Move the robot to its right 1.5 inches in order to move away from the jack, and sleep for a short amount of time, so the robot settles.
  7. Move the robot forwards 3 inches in order to align it against the course wall, and sleep for a short amount of time, so the robot settles.
  8. Move the robot backwards 14 inches to clear the jack and the control panel, and sleep for a short amount of time, so the robot settles.
  9. Move the robot to its left 25 inches so it hits and aligns with the rightmost wall, and sleep for a short amount of time, so the robot settles.
  10. Move the robot forwards 3 inches to hit the button panel, and sleep for a short amount of time, so the robot settles.
  11. Move the robot backwards 5 inches to move away from the button panel, and sleep for a short amount of time, so the robot settles.
  12. Move the robot to its left 2.5 inches to hit and align against the rightmost wall, and sleep for a short amount of time, so the robot settles.
  13. Move the robot to its right 1 inch to move away from the wall, and sleep for a short amount of time, so the robot settles.
  14. Move the robot backwards 30 inches to clear the ramp.

performanceTest2::run() algorithm:

  1. Wait for the starting light to be activated.
  2. Move the robot forward 8 inches to align with the light on the surface of the course, and sleep for a short amount of time, so the robot settles.
  3. Move the robot to its left 8.75 inches to line up over the light on the surface of the course, and sleep for a short amount of time, so the robot settles.
  4. Store color of the light on the surface of the course in a variable based on the values given by the cds cell.
  5. If the color stored is blue, move the robot 2 inches to its left to align with the blue button. If the color stored is red, move the robot 2 inches to its right to align with the red button. Sleep for a short amount of time, so the robot settles.
  6. Move the robot forwards 4 inches to press the correct button, and sleep for a short amount of time, so the robot settles.
  7. Move the robot backwards 2 inches to move away from the button panel, and sleep for a short amount of time, so the robot settles.
  8. If the color stored is blue, move the robot to its right 23 inches to touch the wrench. If the color stored is red, move the robot to its left 20 inches to touch the wrench. Sleep for a short amount of time, so the robot settles.
  9. Move the robot to its left 12 inches to align with the final button, and sleep for a short amount of time, so the robot settles.
  10. Move the robot backwards 15 inches to press the final button.

performanceTest3::run() algorithm:

  1. Store the coordinates of the wrench in the robot using RPS by hand-moving the robot to the position and touching the screen.
  2. Store the coordinates of the button light in the robot using RPS by hand-moving the robot to the position and touching the screen.
  3. Store the coordinates of the position just up the ramp in the robot using RPS by hand-moving the robot to the position and touching the screen.
  4. Store the coordinates of the crank preparation area in the robot using RPS by hand-moving the robot to the position and touching the screen.
  5. Store the coordinates of the crank in the robot using RPS by hand-moving the robot to the position and touching the screen.
  6. Store the coordinates of the start light in the robot using RPS by hand-moving the robot to the position and touching the screen.
  7. Wait for the starting light to be activated.
  8. Move the robot forward 9.5 inches to align with the wrench, and sleep for a short amount of time, so the robot settles.
  9. Move the robot to its right 7 inches to get in position to pick the wrench up, and sleep for a short amount of time, so the robot settles.
  10. Using RPS, ensure that the robot is in the correct position.
  11. Lower the electromagnet arm to pick the wrench up.
  12. Raise the arm with the wrench.
  13. Move the robot backwards 5 inches to clear the button panel, and sleep for a short amount of time, so the robot settles.
  14. Move the robot to its left 14.75 inches to line up with the white button, and sleep for a short amount of time, so the robot settles.
  15. Using RPS, ensure that the robot is in the correct position.
  16. Move the robot forwards until the white button has been pressed for at least 5 seconds.
  17. Move the robot backwards 2 inches to get away from the button panel, and sleep for a short amount of time, so the robot settles.
  18. Move the robot to its left 4.5 inches to align with the ramp, and sleep for a short amount of time, so the robot settles.
  19. Move the robot backwards until it clears the ramp, and sleep for a short amount of time, so the robot settles.
  20. Using RPS, ensure that the robot is in the correct position.
  21. Rotate the robot so the electromagnet arm faces towards the garage.
  22. Lower the electromagnet arm in preparation for the garage.
  23. Move the robot to its right 17 inches to prepare for the garage, and sleep for a short amount of time, so the robot settles.
  24. Rotate the robot so the electromagnet arm faces towards the garage in the case it has become disoriented.
  25. Move the robot to its left 10.5 inches to move the arm into the garage.
  26. Lower the electromagnet arm to prepare to scrape the wrench off.
  27. Move the robot to its left 9 inches to scrape the wrench off and prepare for touching the crank, and sleep for a short amount of time, so the robot settles.
  28. Rotate the robot so the mousepad faces the crank.
  29. Rotate the electromagnet arm up.
  30. Move the robot forward 18 inches to touch the crank.

performanceTest4::run() algorithm:

  1. Store the coordinates of the button light in the robot using RPS by hand-moving the robot to the position and touching the screen.
  2. Store the coordinates of the position just up the ramp in the robot using RPS by hand-moving the robot to the position and touching the screen.
  3. Store the coordinates of the crank preparation area in the robot using RPS by hand-moving the robot to the position and touching the screen.
  4. Store the coordinates of the crank in the robot using RPS by hand-moving the robot to the position and touching the screen.
  5. Store the coordinates of the start light in the robot using RPS by hand-moving the robot to the position and touching the screen.
  6. Wait for the starting light to be activated.
  7. Move the robot forward 7.5 inches to align with the button light, and sleep for a short amount of time, so the robot settles.
  8. Move the robot to its left 7 inches to get in position to pick the wrench up, and sleep for a short amount of time, so the robot settles.
  9. Using RPS, ensure that the robot is in the correct position.
  10. Move the robot forwards until the white button has been pressed for at least 5 seconds.
  11. Move the robot backwards 2 inches to get away from the button panel, and sleep for a short amount of time, so the robot settles.
  12. Move the robot to its left 4.5 inches to align with the ramp, and sleep for a short amount of time, so the robot settles.
  13. Move the robot backwards until it clears the ramp, and sleep for a short amount of time, so the robot settles.
  14. Using RPS, ensure that the robot is in the correct position.
  15. Rotate the robot so the mousepad is facing the crank
  16. Store the type of fuel need in a variable based on values given by RPS.
  17. Move the robot to its left 17 inches to prepare for the garage, and sleep for a short amount of time, so the robot settles.
  18. Using RPS, ensure that the robot is in the correct position.
  19. Rotate the robot so the mousepad will face the crank in the case it has become disoriented.
  20. Move the robot forward 18 inches to come in contact with the crank.
  21. Move the robot forward indefinitely.
  22. If the fuel type stored earlier is octane, rotate the crank for octane. If the fuel type stored earlier is methane, rotate the crank for methane.
  23. Stop the motors.
  24. Move the robot backwards to return to the paved path.
  25. Using RPS, ensure that the robot is in the correct position.
  26. Move the robot to its right 16 inches to prepare for going down the ramp.
  27. Using RPS, ensure that the robot is in the correct position.
  28. Move the robot forwards for three seconds in order to go down the ramp.

 Final completeRun() general algorithm:

  1. Call function waitForStartLight() in order to wait for the initial light to begin the course, and proceed to step 2 once it finishes.
  2. Move to the wrench
  3. Pick up the wrench
  4. Move to the car jack
  5. Run into the car jack to flip it up
  6. Move to the diagnostic light
  7. Read the diagnostic light, and move in front of the corresponding diagnostic button
  8. Move forward to press the correct button, and pause for 5 seconds to enable the RPS button
  9. Move back from the button panel and move up the ramp
  10. Move the robot to the garage
  11. Deposit the wrench in the garage
  12. Move to the fuel crank
  13. Turn the fuel crank
  14. Move from the fuel crank to the ramp
  15. Move down the ramp and towards the final button
  16. Press the final button to complete the course