setFuel(); moveForward(HIGH_FORWARD, 11); moveToY(22.5); turnRight(-77); turnTo(358); moveForward(HIGH_FORWARD, 17); moveToX(25.5); pressButton(isBlue()); moveForward(HIGH_FORWARD, 13) turnRight(-35); //THE WRENCH wrenchServo.SetDegree(140); // Set the servos moveForward(50, 12); moveToY(18.55); showInfo(); // Line up with wrench turnRight(30); turnTo(180); showInfo(); // Turn towards wrench moveForward(LOW_FORWARD, 17); showInfo(); // Approach wrench while(RPS.X() > 8.5) { moveForward(-1 * LOW_FORWARD, 3); if(RPS.Y() > 16.8) { turnRight(-5); } else { turnRight(5); } moveForward(LOW_FORWARD, 10); } wrenchServo.SetDegree(40); Sleep(HALF_SECOND); turnTo(180); moveForward(-50, 6); showInfo(); // Back off from wrench turnRight(-66); showInfo(); // Turn to approach jack moveForward(50, 12); moveToY(11); showInfo(); // Approach jack area turnRight(-92); showInfo(); // Turn to jack moveForward(50, 12); showInfo(); // Push the jack moveForward(-50, 5); showInfo(); // Back off turnRight(85); showInfo(); // Turn to ramp moveForward(-50, 15.5); moveToY(21.5); showInfo(); // Move to ramp turnRight(-42); turnTo(315); showInfo(); // Adjust on ramp moveForward(-50, 10); moveToX(4); showInfo(); // Move to ramp turnRight(35); turnTo(274); showInfo(); // Adjust on ramp bool deadzone; deadzone = (RPS.IsDeadzoneActive() != 2); // UP TOP rightMotor.SetPercent(-12); leftMotor.SetPercent(-12); Sleep(0.3); rightMotor.SetPercent(-100); leftMotor.SetPercent(-100); Sleep(1.2); rightMotor.SetPercent(-50); leftMotor.SetPercent(-50); Sleep(1.05); rightMotor.Stop(); leftMotor.Stop(); Sleep(300); moveForward(MID_FORWARD, 30); moveForward(-1 * MID_FORWARD, 10); turnRight(-90); moveForward(-1 * MID_FORWARD, 8); if(!deadzone) { moveToY(46); } turnRight(38); if(!deadzone && RPS.X() != -1) { turnTo(226); } moveForward(-1 * HIGH_FORWARD, 20); if(!deadzone && RPS.X() != -1) { turnTo(226); } moveForward(-1 * HIGH_FORWARD, 20); moveForward(-1 * HIGH_FORWARD, 10); turnFuel(); // FUEL STUFF moveForward(HIGH_FORWARD, 16); if(!deadzone && RPS.X() != -1) { moveToX(19); } turnRight(75); if(!deadzone && RPS.X() != -1) { turnTo(134); } moveForward(HIGH_FORWARD, 30); moveForward(-1 * MID_FORWARD, 2); wrenchServo.SetDegree(150); // Place wrench in garage Sleep(FULL_SECOND); Sleep(0.5); moveForward(-1 * FAST, 45); // Go to the ramp again wrenchServo.SetDegree(40); turnRight(47); // Turn to ramp moveForward(-1 * FAST, 17); // Down we go turnRight(105); moveForward(-1 * HIGH_FORWARD, 20); turnRight(105); moveForward(-1 * HIGH_FORWARD, 30); break;
Algorithm for Main Competition:
- Check fuel direction, and turn the fuel servo accordingly
- Move forward, then correct the Y position
- Turn left, then correct heading
- Move forward, then correct the X position
- Read the color of the light and press the corresponding button
- Move forward
- Turn right
- Lower wrench servo
- Move forward, then correct Y position
- Turn right, then correct heading
- Move forward at a low speed
- If at the incorrect X position, turn 5 degrees in the correct direction and go back to step 13
- Raise wrench servo
- Move backwards
- Turn left
- Move forward, then correct Y position
- Turn left
- Move forward, pushing jack
- Move backwards
- Turn right
- Move backwards, then correct Y position
- Turn left, then correct heading
- Move backwards, then correct X position
- Turn right, then correct heading
- Store whether or not the deadzone is active
- If the deadzone is active, ignore all RPS checks on the upper level
- Move backwards at slowest speed
- Move backwards at full power
- Move backwards at half power
- Move forward to square with wall
- Move backwards
- Turn left
- Move backwards
- Turn right, then correct heading
- Move backwards, correcting heading during movement
- Turn the fuel crank in the correct direction
- Move forward, then correct X position
- Turn right, then correct heading
- Move forward
- Lower wrench servo
- Move backwards
- Raise wrench servo
- Turn right
- Move backwards down the ramp
- Turn right
- Move backwards
- Turn right
- Move backwards into final button