//----------------------------------------------------------------- // File: PBot_MkIII_Sumo-B_VC6.osc // // Project: Sumo Program using PBot_MkIII_1.0_VC6 oUserClass // // Designer: Phil Malone, www.philbot.com // Details: http://www.philbot.com/projects/markIII_sumo // // Details: Mode B Offensive Unit. (Pusher Priority) // // Mode B is an "Agressive" 4 priority Sumo Stance. // // Priority 1: Push the opponent if BOTH eyes see him // Priority 2: Avoid the edge of the Ring, using backup and spin. // Priority 3: Turn towards the opponent if ONE eye sees him. // Priority 3: Move forward. // // Basic program flow is: // // 1) Wait 4 seconds // 2) Calibrate the line sensors // 3) Wait for last second to elapse // 4) Run the main action-priority loop // // Comments: // // This program is NOT fooled by an opponent that has a white line // on it's pusher bar. However it may be distracted by a bystander // and drive off the ring. Keep people away during combat !!! // // Version Date Comment // ------- --------- ------- // 1.00 8/22/2005 First release for VC6 // //----------------------------------------------------------------- // Create instance of MkIII Object. oUserClass BOT = New oUserClass("PBot_MkIII_1.0_VC6.osc"); // Create motion constants (based on specific Bot) Const FAST_FORWARD = 10; Const SLOW_FORWARD = 1; Const FAST_REVERSE = -10; // Main program Void Main(Void) { // Calibrate one second before Match While(BOT.ActionTimer > BOT.ONE_SECOND) ; // Wait for last second BOT.SumoCalibrate(); // Calibrate for Sumo BOT.EnableDiagnostics(); // Turn on status LEDs (optional) // Wait for last second to expire While(BOT.ActionTimer.NonZero) ; // Run main program loop forever. While (cvTrue) { // Run down the SUMO priority list // Priority 1: PUSH the opponent is BOTH eyes see him If (BOT.LeftEyeOn && BOT.RightEyeOn) { // Go forward, no time limit BOT.Drive(FAST_FORWARD,FAST_FORWARD, 0); } // Priority 2: Avoiding the border Else If (BOT.LeftLineWhite) { // If we see the left line, backup & Spin right 180 BOT.Drive(FAST_REVERSE,FAST_REVERSE, 3); BOT.Drive(FAST_FORWARD,FAST_REVERSE, 5); } Else If (BOT.RightLineWhite) { // If we see the right line, backup and spin left 180 BOT.Drive(FAST_REVERSE,FAST_REVERSE, 3); BOT.Drive(FAST_REVERSE,FAST_FORWARD, 5); } // Priority 3: Turn Towards the opponent if seen in ONE eye Else If (BOT.RightEyeOn) { // Turn right towards the target, no time limit BOT.Drive(FAST_FORWARD,SLOW_FORWARD, 0); } Else If (BOT.LeftEyeOn) { // Turn left towards the target, no time limit BOT.Drive(SLOW_FORWARD,FAST_FORWARD, 0); } // Priority 4: Go Straight Else { // Go forward, no time limit BOT.Drive(FAST_FORWARD,FAST_FORWARD, 0); } } }