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.
- Wait until light sensor sees light
- Drive over to and up the shallow ramp
- Turn to the left
- Drive over to the upper luggage drop off
- Turn left again
- Drop off the luggage
- Turn around
- Drive to the light
- Read the color of the light
- Turn to the right
- Drive forward the appropriate amount
- Turn to the left
- Drive forward, pressing the correct button
- Back up and turn to the right
- Drive forward to the passport stamper
- Lower the head and engage it with the lever arm
- Raise the head to flip the lever
- Back up then turn to the right
- Drive down the shallow ramp
- Turn to the right
- Record which fuel type to use
- Drive to the correct fuel lever
- Turn to the left
- Drive up to the lever and flip it
- Wait at least 5 seconds
- Flip the lever back
- Back up and turn slightly to the left
- 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.