Algorithm
- Start
- Set right motor and left motor to a certain power
- turnLeft(degrees) until robot is facing levers
- driveForward(distance) until next to fuel levers
- flipLever(lever) to flip the correct lever up, and then down after 5 seconds
- turnRight(degrees) until robot is facing ramp
- driveForward (distance) until up the ramp
- turnRight(degrees) to face the luggage
- dropLuggage() to drop the luggage off
- turnLeft(degrees)
- driveForward(distance) and then turnRight(degrees) to reach the light
- Read the color of the Light
- driveForward(distance) to the button with the same color as the light from Step 13
- hitButton() to hit the correct button
- turnRight(degrees) to face the passport Stamp
- driveForward(distance) until at the passport Stamp
- flipPassport() to flip the passport lever up, and then back down
- turnRight(degrees) until facing the final button
- driveForward(distance) to drive down the ramp until at the final button
- hitButton() to hit the final button and end the run
- End
The main function has the main logic of the program which controls how the robot is being navigated. It calls all the user written functions so that the robot can perform the tasks needed. For example, it calls functions to drive forward, make turns, move the servo, get readings from the CdS cell sensor, and to hit buttons. Our plan currently is to make the robot go to the fuel levers first, so the robot turns left a certain amount and makes its way to the fueling lever. Then it flips the lever by using the servo, waits for five seconds, and then flips it back. Then it goes to the baggage claim, and drops off the luggage using the servo. Next it will navigate to the light using the shaft encoders, and calls the function to read the color of the light. Based on what color was read, the robot will move to the appropriate button, and push it. Next it will turn right and drive forward to reach the passport station. It will call the function to use the servo and flip the passport lever up, and then back down. Next, it will drive forward and reach the final button and press the button by driving into it.
User Written Functions:
- turnRight(int degrees)
- int degrees: input parameter to determine how many degrees to turn right by
- No outputs
- Sets right motor power to 0 for a certain amount of counts until robot turns clockwise by the amount of degrees inputted
- turnLeft(int degrees)
- int degrees: parameter to determine how many degrees to turn left by
- No outputs
- Sets right motor power 0 for a certain amount of counts until robot turns counterclockwise by the amount of degrees inputted
- turnAround()
- No inputs
- No outputs
- Sets left motor power to 0 for a certain amount of counts until robot turns 180 degrees
- hitButton(int light)
- int light: reading from CdS cell
- No outputs
- Takes reading from CdS cell to choose correct button to press
- flipPassport()
- No input
- No output
- Powers the servo to rotate external arm/lever to rotate passport stamp lever
- flipLever(int lever)
- int lever: input lever for which lever to flip
- No outputs
- Maneuvers around the fuel levers depending on the input lever, drive to correct lever and rotate the servo to flip the lever. Wait 5 seconds and then flip the correct lever back down
- dropLuggage()
- No input
- No output
- Scrapes luggage (magnetically held) off of the side arm/lever into a luggage drop off bin
- driveForward(double distance)
- double distance: input distance for the robot to travel
- No outputs
- Sets robot to a certain power to move forward until at the desired distance using shaft encoding
Description of user written function hitButton():
This function takes in an int value for the color that was read from the light sensor. Based on the color, it calls the appropriate driveForward(distance) and turnLeft(degrees) functions so that the robot can align itself with the appropriate button. Then it calls the driveForward(distance) function to hit the button. The function does not return anything.