Datasheet
Chapter 4: Navigation Tips ยท Page 163
ELSEIF irLF = 1 THEN ' Just left?
DO UNTIL (irLF = 1 AND irRF = 1) OR counter > 15
maneuver = CurveLeft ' Curve left 15
GOSUB Servos_And_Sensors
counter = counter + 1
LOOP
DO UNTIL (irLF = 1 AND irRF = 1) OR counter > 30
maneuver = RotateLeft ' Rotate left 30
GOSUB Servos_And_Sensors
counter = counter + 1
LOOP
The Main Routine below incorporates this code for both sides, and is a drop-in
replacement for the main routine in FrontIrNavigation.bs2.
โ Save FrontIrNavigation.bs2 as FrontIrNavigationYourTurn.bs2.
โ Replace the Main Routine in the program with the one shown below.
โ Test the program and note the differences in the way the SumoBot faces and
lunges toward your hand.
' -----[ Main Routine ]-------------------------------------------------------
DO
IF irLF = 1 AND irRF = 1 THEN ' Both?
maneuver = Forward ' State = Lunge forward
GOSUB Servos_And_Sensors
ELSEIF irLF = 1 THEN ' Just left?
counter = 0 ' State = track front left object
DO UNTIL (irLF = 1 AND irRF = 1) OR counter > 15
maneuver = CurveLeft ' Curve left 15
GOSUB Servos_And_Sensors
counter = counter + 1
LOOP
DO UNTIL (irLF = 1 AND irRF = 1) OR counter > 30
maneuver = RotateLeft ' Rotate left 30
GOSUB Servos_And_Sensors
counter = counter + 1
LOOP
ELSEIF irRF = 1 THEN ' Just right?
counter = 0 ' State=track front right object
DO UNTIL (irLF = 1 AND irRF = 1) OR counter > 15
maneuver = CurveRight ' Curve right 15
GOSUB Servos_And_Sensors
counter = counter + 1
LOOP
DO UNTIL (irLF = 1 AND irRF = 1) OR counter > 30
maneuver = RotateRight ' Rotate right 30