Algorithms

Example Algorithm for Robot Course

The main() function

 

The current algorithm for running the course is to drive up the shallow ramp, drop off the luggage, drive to the kiosk light to read it, press the correct kiosk button, stamp the passport, drive back down the shallow ramp, flip the correct fueling lever, and then drive into the end button. This will be achieved by making common actions such as turning and driving into functions in the code. Most of the steps will be written as one or two smaller functions.

 

  1. Wait until light sensor sees light
  2. Drive over to and up the shallow ramp
  3. Turn to the left
  4. Drive over to the upper luggage drop off
  5. Turn left again
  6. Drop off the luggage
  7. Turn around
  8. Drive to the light
  9. Read the color of the light
  10. Turn to the right
  11. Drive forward the appropriate amount
  12. Turn to the left
  13. Drive forward, pressing the correct button
  14. Back up and turn to the right
  15. Drive forward to the passport stamper
  16. Lower the head and engage it with the lever arm
  17. Raise the head to flip the lever
  18. Back up then turn to the right
  19. Drive down the shallow ramp
  20. Turn to the right
  21. Record which fuel type to use
  22. Drive to the correct fuel lever
  23. Turn to the left
  24. Drive up to the lever and flip it
  25. Wait at least 5 seconds
  26. Flip the lever back
  27. Back up and turn slightly to the left
  28. Drive into the end button

Since we created a GUI library to edit global variables and call functions, we plan to have the above algorithm implemented in a separate function such as runCourse() as opposed to the main() function. We may also take the larger tasks in this algorithm and turn them into functions as well, so that we can change parameters and test each task quickly and repeatedly without having to recompile each time.