Shop OBEX P1 Docs P2 Docs Learn Events
Boe-Bot Robot Corridor Navigation — Parallax Forums

Boe-Bot Robot Corridor Navigation

edited 2014-11-10 05:13 in Learn with BlocklyProp
This is a place holder for additional material (coming soon) for corridor navigation with infrared sensors after you have completed Chapters 7 and 8 in Robotics with the Boe-Bot. Just a couple paragraphs now, more later...

In Robotics with the Boe-Bot v3.0, your Boe-Bot used infrared object detection to avoid obstacles and drop-offs and follow objects and wide electrical tape stripes. Another popular Boe-Bot activity is navigating corridors and small mazes. This thread demonstrates two approaches to corridor navigation. The first approach utilizes simple code along with the parts in your Boe-Bot(R) Robot kit. The second approach utilizes a few extra infrared LEDs and receivers along with some subroutines for intersection detection.

Back to:
Parallax Go Boe-Bot page
Stamps in Class Mini Projects

i-box: These activities focus on navigating in corridors delimited by walls. For an electrical tape delimited course and techniques for navigating it, take a look at the Boe-Bot + QTI section in the Stamps in Class Mini Projects thread.

Comments

  • edited 2010-12-22 15:17
    Corridor Sensing
    The left front and right front sensors on the Boe-Bot are probably familiar from Robotics with the Boe-Bot chapters 7 and 8. Activities in those chapters used them for object avoidance, drop-off avoidance, and object following. For corridor navigation, we’ll use them to decide when to veer away from the corridor’s walls. Then, the left side, center front, and right side detectors can be used for detecting the difference between a wall and a corridor opening.

    attachment.php?attachmentid=85263&d=1316561628

    Circuit
    The corridor sensing circuit requires the two IR object detection sensors in the Robotics with the Boe-Bot kit along with three extra ones. If you need to buy three additional IR object detectors, the IR Receiver and IR Transmitter Assembly in the Parts List are linked to their product pages. The schematic shows one copy of the IR circuit and the table below it lists the I/O pin connections and IR LED series resistor values for each detector. Below that, there’s a placement and wiring close-up picture that will help with building the circuit.

    Parts List
    (5) Resistors – 220 Ω (red-red-brown)
    (3) Resistors – 1 kΩ (brown-black-red)
    (2) Resistors – 2 kΩ (red-black-red)
    (5) IR Receiver
    (5) IR Transmitter Assembly Kits
    (IR LEDs, standoffs and shields)
    (misc) Jumper wires

    Schematic
    There are five copies of the IR LED and IR Detect circuits on the breadboard. Use the table below for I/O pin connections and series resistance values in the IR LED circuits.

    attachment.php?attachmentid=85261&d=1316561627

    Placement and Wiring

    attachment.php?attachmentid=85262&d=1316561628

    Testing the Corridor Sensing Circuit
    Before navigating any corridors, make sure to test your circuit with the Display program below. Each sensor location should display a 1 when there’s no object within a few inches of it, and 0 when there is an object.

    attachment.php?attachmentid=85264&d=1316561628

    √ Run Test IR Detection.bs2.
    √ Verify that each detector displays 1 when no object is in front of it and 0 when there is an object in front of it.
    √ Find an fix any circuit mistakes that might be preventing your IR detection circuits from working before you continue to the next program.
    ' File: Test IR Detection.bs2
    
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    
    i              VAR     Nib
    pinIrLed       VAR     Nib
    pinIrDet       VAR     Nib
    ir             VAR     Bit
    obj            VAR     Bit(5)
    x              VAR     Byte
    
    FREQOUT 4, 1000, 3000
    
    DEBUG "left  left   center  right  right", CR,
          "side  front  front   front  side"
    
    DO
      GOSUB Wall_Detect
      GOSUB Wall_Sensor_Display
    LOOP
    
    Wall_Detect:
      FOR i = 4 TO 0
        LOOKUP i, [15, 8, 6, 2, 0], pinIrLed
        LOOKUP i, [14, 9, 7, 3, 1], pinIrDet
        FREQOUT pinIrLed, 1, 37500
        ir = IN0(pinIrDet)
        obj(i) = ir
      NEXT
      RETURN
    
    Wall_Sensor_Display:
      FOR i = 4 TO 0
        LOOKUP i, [1, 8, 15, 23, 29], x
        DEBUG CRSRXY, x, 2, BIN1 obj(i)
      NEXT
      PAUSE 20
      RETURN
    

    Calibrate Corridor Sensing
    Now that the sensors work, they still need to be adjusted to sense a corridor. A good corridor for this circuit is two walls 12 inches apart. The Test Basic Corridor.bs2. program just monitors the right front and left front IR detectors, and makes the Boe-Bot turn slightly to correct its direction if it’s going toward one of the walls or getting too close.

    The most important part of this calibration is pointing your left front and right front IR LEDs and detectors in the right direction. If they are pointing too far right/left, they might see the walls all the time and the Boe-Bot will seem confused and move forward very slowly, if at all. If they are pointing too far forward, they won’t detect a wall until it’s too late and the Boe-Bot is already sliding along the wall.

    Your adjustments will be correct if you can send your Boe-Bot into a corridor like this at the angle shown (ether from the left or right), and it straightens itself out and makes it through the 12 inch wide corridor.

    attachment.php?attachmentid=85260&d=1316561627

    √ Run Test Corridor Wall Avoidance.bs2.
    √ Start running your Boe-Bot through the corridor. If it seems to stall, it’s probably seeing too much wall, and the left front and right front IR detectors need to be turned more in the straight ahead direction.
    √ If it gets so close to the wall that you say “uh-oh”, or if it runs into the wall, the left front and right front sensors need to be turned slightly outward.
    √ Keep adjusting until you can send it in at the angle shown in the picture above. It should be able to straighten itself out and go all the way through the corridor, regardless of whether it’s coming info the corridor from the left or the right.
    ' File: Test Corridor Wall Avoidance.bs2
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    
    ' Constants
    
    L_S CON 0 : L_F CON  1 : C_F CON 2 : R_F CON 3 : R_S CON 4
    Fwd CON 0 : Veer_R CON 1 : Veer_L CON 2: Turn_L CON 3 : Turn_R CON 4
    U_Turn CON 5 : FreqFar CON 37500 : FreqNear CON 40500
    
    ' Variables
    
    pulseLeft      VAR     Word
    pulseRight     VAR     Word
    freq           VAR     Word
    go             VAR     Byte
    reps           VAR     Byte
    i              VAR     Byte
    pinIrLed       VAR     Nib
    pinIrDet       VAR     Nib
    wall           VAR     Bit(5)
    ir             VAR     Bit
    
    ' Initialization
    
    FREQOUT 4, 1000, 3000
    DEBUG "Program running!"
    freq = FreqFar
    
    ' Main Routine
    
    DO
      GOSUB Wall_Detect
      IF (wall(L_F)=1 AND wall(R_F)=1) OR (wall(L_F)=0 AND wall(R_F)=0) THEN
        go = fwd
      ELSEIF wall(L_F) = 0 THEN
        go = Veer_R
      ELSEIF wall(R_F) = 0 THEN
        go = Veer_L
      ENDIF
    LOOP
    
    ' Subroutine: Wall_Detect
    
    Wall_Detect:
      FOR i = L_S TO R_S
        LOOKUP i, [15, 8, 6, 2, 0], pinIrLed
        LOOKUP i, [14, 9, 7, 3, 1], pinIrDet
        LOOKUP i, [FreqFar, FreqNear, FreqNear, FreqNear, FreqFar], freq
        FREQOUT pinIrLed, 1, freq
        ir = IN0(pinIrDet)
        wall(i) = ir
      NEXT
      RETURN
    
    ' Subroutine: Maneuver
    
    Maneuver:    'Fwd,  Veer_R, Veer_L, Turn_L, Turn_R, U_Turn
      LOOKUP go, [1,    1,      1,      65,     65,     40 ], reps
      LOOKUP go, [850,  850,    750,    765,    850,    850], pulseLeft
      LOOKUP go, [650,  750,    650,    650,    735,    850], pulseRight
      FOR i = 1 TO reps
        PULSOUT 13, pulseLeft
        PULSOUT 12, pulseRight
        PAUSE 20
      NEXT
      RETURN
    
  • edited 2010-12-22 15:19
    Another reserved for the post.
  • edited 2010-12-22 15:20
    Second to last reserved for post.
  • edited 2010-12-22 15:20
    Last reserved for post (forum doesn't allow duplicate posts, so you get a narration of reservations. :-)
  • bomberbomber Posts: 297
    edited 2011-09-18 08:04
    **************************ERROR***ERROR***ERROR************************************************
    **************************THIS*DOES*NOT*COMPUTE***********************************************
    It has been nine months since you reserved this space, I would think you would have used it by now!

    ***************************END*TRANSMISSION**********************************************************
    ***************************BOMBER*OUT*,PEACE********************************************************
  • edited 2011-09-19 18:55
    Well, now that I see some interest in the topic, I'll move it up in my project list. In the meantime, try this: Boe-Bot Maze Navigation with QTIs
  • edited 2011-09-20 17:18
    Update: Sensors setup/testing and initial calibration procedure posted. Hey bomber, try it out.
  • ercoerco Posts: 20,256
    edited 2011-10-01 10:02
    Andy & Matt: This is very cool. As you state, aiming the LEDs & sensors is critical to this application. Yet one ugly & overlooked truth about BoeBot is that the sensors are usually hanging out in the breeze, their only mechanical "mounting" is being plugged into the breadboard by their flimsy leads. One crash or careless touch undoes hours of calibration. I suggest it's time to make a laser-cut acrylic bumper that attaches firmly to the front of BoeBot, which has numerous mounting holes for rigidly mounting the IR parts with proper hardware or zip ties at a minimum. The Dagu Magician chassis has lots of holes for just this purpose. Something along these lines would be quite to implement, save students lots of frustration and re-elevate BoeBot to the "Best in Class".

    Alternatively, you could make a whole new upper deck for BoeBot 2, but definitely make a backwards-compatible part for all the BoeBots out there.
  • edited 2011-10-03 08:08
    I was actually thinking of using small pieces of Boe-Bot chassis bent in 45, 90, and 180 degree. We already use the 180 degree version in the Ping))) mounting bracket kit, and we built some 45 and 90 a few years back. Then, the IR hardware could be designed into a QTI-like module that could be mounted anywhere on the chassis with servo extension cables. That's why the chassis has all those holes and grooves.
  • ercoerco Posts: 20,256
    edited 2011-10-03 08:48
    Sure, you could get by with aluminum scraps from the 50's, but why? Matt and the rest of the world have gone laser-cutter crazy, cranking out new Ping/IR brackets for every possible combination in record time. As long as there's talent, capability & momentum, carpe laserum! A smoked acrylic upper deck would add a whole new high tech look to BoeBot, not to mention purpose & functionality.

    Heck, I'll do it if you guys don't. But I'll use plywood. After that, I will tackle the tricky iPhone control interface...
  • xanaduxanadu Posts: 3,347
    edited 2011-11-01 11:17
    I've always wondered why Parallax doesn't sell molded IR pairs. The Boe-Bot is an amazing kit, and that was the only complaint I ever had, except for the tank tracks falling off but that went to Tamiya.
  • daveduggandaveduggan Posts: 9
    edited 2011-11-01 14:29
    Would using the ping sensor be a more sophisticated solution?

    If so, can you give some coding examples like this one?

    If not, please educate (and forgive me).

    thank you
  • MoutasemMoutasem Posts: 11
    edited 2013-01-29 10:15
    Hello All,
    I'm currently enrolled in a high school engineering course and my project is to make my boe-bot navigate through the halls and come back into the classroom. My boe-bot has two IR transmitters/sensors on it. My problem is that when it gets out of my classroom and into the halls the IR sensors work perfectly but it doesn't navigate its way back to the classroom it simple avoids crashing into objects. Would making it move a certain distance and stop when it senses something solve my problem? What suggestions do you guys have??
  • bomberbomber Posts: 297
    edited 2013-01-29 19:17
    @Moutasem,
    Do you use the PropBOE or the BS2 BOE? I would recommend recording the movements the servo motors make in EEPROM or on an SD card (SD card if you're using the PropBOE) and replaying them in reverse order so that your bot retraces it's steps.
  • ercoerco Posts: 20,256
    edited 2013-01-30 15:35
    bomber's method will work fine if you have encoders. Without them, it's a hit or miss proposition. Even if you record properly, open-loop CR servos won't necessarily play back the same route.

    I'd suggest a wall-following approach for an out and back path. You'll have to program around doorways and obstacles. Several posts & videos are here. Martin_H has some, here are mine:

    http://www.youtube.com/watch?v=kxP7kHXBzf0

    http://www.youtube.com/watch?v=glOwN-kRD4U
  • MoutasemMoutasem Posts: 11
    edited 2013-02-02 12:25
    thank you for the quick reply,

    Bomber, im using the BS2 BOE,
    Erco i think using the wall following approach would be best for this situation ill adjust for that and get back to you guys

    Thank you.
  • NikosGNikosG Posts: 705
    edited 2013-04-05 13:30
    Hi all,

    Following Andy's suggestion of 1# post here is my 2nd attempt for a Boe bot wall maze navigator.

    However the program I made is not the best solution for wall maze navigation. This is only a test.

    The main reason I posted the video is to show the wall maze!

    As I have seen from several videos with boe bots people very often use books, boxes or other thingks in order to crete wall mazes.
    My wall maze suggestion is very simple, very stable and eazy to build and it is also offer the ability to build wall mazes in different shapes
  • MoutasemMoutasem Posts: 11
    edited 2013-04-16 22:52
    Hello all,

    Since my last post I had great progress, but i am still having trouble with my boe-bot navigating my school halls and coming back to the classroom it started from. I am using 2 IR sensors and receivers and i am using a wall following approach. The boe-bot now leaves class follows the first wall until it gets to a doorway where I am trying to program it to sense the gap and turn left as to go to the parallel wall. Any suggestion on how to do that?
    My current program has a loop within a loop that is meant to do so, the loop within programs the boe-boe to turn left when the right IR receiver senses a gap. Now it senses the gap turns left but since it is within a loop it goes back to the top of the program and turns left again. What do you suggest in such a situation?
  • ercoerco Posts: 20,256
    edited 2013-04-17 12:59
    Mousatem: If the door consistently closed, you could just follow the door by setting your distance to wall routine to a larger value. Otherwise you might consider adding a reflective marker to the wall or floor just before the door. The robot follows the wall until it senses the door marker, then it does a calibrated turn subroutine to get it past the door and then resumes wall following.
  • TtailspinTtailspin Posts: 1,326
    edited 2013-04-18 11:20
    the loop within, programs the boe-boe to turn left when the right IR receiver senses a gap... it senses the gap, turns left
    Go forward until the right IR receiver no longer senses a gap, Then go back to the main loop??...


    -Tommy
  • MoutasemMoutasem Posts: 11
    edited 2013-04-23 22:26
    Unfortunately adding a reflective marker is not an option in this case.
    Can someone please tell me how to fix the loop within the loop as to make it only do it once, i mean i only want the IR sensor to sense the gap turn left and sense the opposite wall.
    Here is my program:
    DO
    FREQOUT 8, 1, 38500 ' Store IR detection values in
    irDetectLeft = IN9 ' bit variables.
    FREQOUT 2, 1, 38500
    irDetectRight = IN0
    IF (irDetectLeft = 0) AND (irDetectRight = 0) THEN
    GOSUB Turn_Left
    ELSEIF (irDetectLeft = 0) THEN ' Left IR pair detects
    GOSUB Turn_Right
    ELSEIF (irDetectRight = 0) THEN
    GOSUB Turn_Left
    GOSUB Forward_Pulse1
    GOSUB Turn_Right
    GOSUB Forward_Pulse
    ELSEIF (irDetectRight = 1) THEN
    GOSUB Turn_left
    DO
    GOSUB Foraward_Pulse2
    LOOP UNTIL (irDetectLeft = 1)
    ELSE
    GOSUB Forward_Pulse
    ENDIF ' and check again
    LOOP
    '
    [ Subroutines ]
    Forward_Pulse: ' Send a single forward pulse.
    PULSOUT 15,850
    PULSOUT 14,650
    PAUSE 20
    RETURN
    Turn_Left: ' Left turn, about 45-degrees.
    FOR pulseCount = 0 TO 20
    PULSOUT 15, 750
    PULSOUT 14, 650
    PAUSE 20
    NEXT
    RETURN
    Turn_Right:
    FOR pulseCount = 0 TO 20 ' Right turn, about 45-degrees.
    PULSOUT 15, 850
    PULSOUT 14, 750
    PAUSE 20
    NEXT
    RETURN
    Back_Up: ' Back up.
    FOR pulseCount = 0 TO 40
    PULSOUT 15, 650
    PULSOUT 14, 850
    PAUSE 20
    NEXT
    RETURN
    Forward_Pulse1: 'moves forward for a short time
    FOR pulseCount = 0 TO 80
    PULSOUT 15, 850
    PULSOUT 14, 650
    PAUSE 20
    NEXT
    RETURN
    Foraward_Pulse2:
    FOR pulsecount = 0 TO 300
    PULSOUT 15, 850
    PULSOUT 14, 650
    PAUSE 20
    NEXT
    RETURN
  • MoutasemMoutasem Posts: 11
    edited 2013-05-19 01:28
    Dear friends,
    How do I write a command that stops after a certain time, i want to my boe-bot to turn right if it senses a gap for 5 seconds but all the commands I tried did not work.
    Thank you
  • MoutasemMoutasem Posts: 11
    edited 2013-05-19 01:29
    Dear friends,
    How do I write a command that stops after a certain time, i want to my boe-bot to turn right if it senses a gap for 5 seconds but all the commands I tried did not work.
    Thank you
  • ercoerco Posts: 20,256
    edited 2013-05-19 11:54
    You want it to continue going straight for 5 seconds after it loses the "right wall" signal, in case it's a doorway?
  • MoutasemMoutasem Posts: 11
    edited 2013-05-20 23:18
    yes, and for that to happen i need to know how to program it to turn left if the right sensor senses a gap for 5 seconds, any suggestions on how to do that?
  • ercoerco Posts: 20,256
    edited 2013-05-21 08:29
    OK, so the door may be open or closed. Are you bouncing off the wall, like Martin_H always suggests? You need to be far enough from the wall and moving nice & straight parallel to the wall to make sure you're aimed properly so you won't crash into the far side of the doorway. Sensor location (WAY up front looking sideways to the right), smooth motion routines, and accurate straight line tracking are very important here. Need a pic or two of your robot showing sensor location and a video of it following a regular wall for a while.

    For instance, my simple little routine here is too erratic to do what you want: http://www.youtube.com/watch?v=kxP7kHXBzf0

    Motion needs to be very smooth and always parallel to the wall, so that once a doorway appears, you are headed reasonably straight across to pick up the other side.
  • demetrax1demetrax1 Posts: 2
    edited 2013-12-04 08:07
    Hi

    Could you give me a better quality of the 5 ir schematic/photo above?

    Thanks, Demetri :lol:
  • edited 2014-11-10 05:13
    Corridor Sensing
    The left front and right front sensors on the Boe-Bot are probably familiar from Robotics with the Boe-Bot chapters 7 and 8. Activities in those chapters used them for object avoidance, drop-off avoidance, and object following. For corridor navigation, we’ll use them to decide when to veer away from the corridor’s walls. Then, the left side, center front, and right side detectors can be used for detecting the difference between a wall and a corridor opening.

    attachment.php?attachmentid=85263&d=1316561628

    Circuit
    The corridor sensing circuit requires the two IR object detection sensors in the Robotics with the Boe-Bot kit along with three extra ones. If you need to buy three additional IR object detectors, the IR Receiver and IR Transmitter Assembly in the Parts List are linked to their product pages. The schematic shows one copy of the IR circuit and the table below it lists the I/O pin connections and IR LED series resistor values for each detector. Below that, there’s a placement and wiring close-up picture that will help with building the circuit.

    Parts List
    (5) Resistors – 220 Ω (red-red-brown)
    (3) Resistors – 1 kΩ (brown-black-red)
    (2) Resistors – 2 kΩ (red-black-red)
    (5) IR Receiver
    (5) IR Transmitter Assembly Kits
    (IR LEDs, standoffs and shields)
    (misc) Jumper wires

    Schematic
    There are five copies of the IR LED and IR Detect circuits on the breadboard. Use the table below for I/O pin connections and series resistance values in the IR LED circuits.

    attachment.php?attachmentid=85261&d=1316561627

    Placement and Wiring

    attachment.php?attachmentid=85262&d=1316561628

    Testing the Corridor Sensing Circuit
    Before navigating any corridors, make sure to test your circuit with the Display program below. Each sensor location should display a 1 when there’s no object within a few inches of it, and 0 when there is an object.

    attachment.php?attachmentid=85264&d=1316561628

    √ Run Test IR Detection.bs2.
    √ Verify that each detector displays 1 when no object is in front of it and 0 when there is an object in front of it.
    √ Find an fix any circuit mistakes that might be preventing your IR detection circuits from working before you continue to the next program.
    ' File: Test IR Detection.bs2
    
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    
    i              VAR     Nib
    pinIrLed       VAR     Nib
    pinIrDet       VAR     Nib
    ir             VAR     Bit
    obj            VAR     Bit(5)
    x              VAR     Byte
    
    FREQOUT 4, 1000, 3000
    
    DEBUG "left  left   center  right  right", CR,
          "side  front  front   front  side"
    
    DO
      GOSUB Wall_Detect
      GOSUB Wall_Sensor_Display
    LOOP
    
    Wall_Detect:
      FOR i = 4 TO 0
        LOOKUP i, [15, 8, 6, 2, 0], pinIrLed
        LOOKUP i, [14, 9, 7, 3, 1], pinIrDet
        FREQOUT pinIrLed, 1, 37500
        ir = IN0(pinIrDet)
        obj(i) = ir
      NEXT
      RETURN
    
    Wall_Sensor_Display:
      FOR i = 4 TO 0
        LOOKUP i, [1, 8, 15, 23, 29], x
        DEBUG CRSRXY, x, 2, BIN1 obj(i)
      NEXT
      PAUSE 20
      RETURN
    

    Calibrate Corridor Sensing
    Now that the sensors work, they still need to be adjusted to sense a corridor. A good corridor for this circuit is two walls 12 inches apart. The Test Basic Corridor.bs2. program just monitors the right front and left front IR detectors, and makes the Boe-Bot turn slightly to correct its direction if it’s going toward one of the walls or getting too close.

    The most important part of this calibration is pointing your left front and right front IR LEDs and detectors in the right direction. If they are pointing too far right/left, they might see the walls all the time and the Boe-Bot will seem confused and move forward very slowly, if at all. If they are pointing too far forward, they won’t detect a wall until it’s too late and the Boe-Bot is already sliding along the wall.

    Your adjustments will be correct if you can send your Boe-Bot into a corridor like this at the angle shown (ether from the left or right), and it straightens itself out and makes it through the 12 inch wide corridor.

    attachment.php?attachmentid=85260&d=1316561627

    √ Run Test Corridor Wall Avoidance.bs2.
    √ Start running your Boe-Bot through the corridor. If it seems to stall, it’s probably seeing too much wall, and the left front and right front IR detectors need to be turned more in the straight ahead direction.
    √ If it gets so close to the wall that you say “uh-oh”, or if it runs into the wall, the left front and right front sensors need to be turned slightly outward.
    √ Keep adjusting until you can send it in at the angle shown in the picture above. It should be able to straighten itself out and go all the way through the corridor, regardless of whether it’s coming info the corridor from the left or the right.
    ' File: Test Corridor Wall Avoidance.bs2
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    
    ' Constants
    
    L_S CON 0 : L_F CON  1 : C_F CON 2 : R_F CON 3 : R_S CON 4
    Fwd CON 0 : Veer_R CON 1 : Veer_L CON 2: Turn_L CON 3 : Turn_R CON 4
    U_Turn CON 5 : FreqFar CON 37500 : FreqNear CON 40500
    
    ' Variables
    
    pulseLeft      VAR     Word
    pulseRight     VAR     Word
    freq           VAR     Word
    go             VAR     Byte
    reps           VAR     Byte
    i              VAR     Byte
    pinIrLed       VAR     Nib
    pinIrDet       VAR     Nib
    wall           VAR     Bit(5)
    ir             VAR     Bit
    
    ' Initialization
    
    FREQOUT 4, 1000, 3000
    DEBUG "Program running!"
    freq = FreqFar
    
    ' Main Routine
    
    DO
      GOSUB Wall_Detect
      IF (wall(L_F)=1 AND wall(R_F)=1) OR (wall(L_F)=0 AND wall(R_F)=0) THEN
        go = fwd
      ELSEIF wall(L_F) = 0 THEN
        go = Veer_R
      ELSEIF wall(R_F) = 0 THEN
        go = Veer_L
      ENDIF
    LOOP
    
    ' Subroutine: Wall_Detect
    
    Wall_Detect:
      FOR i = L_S TO R_S
        LOOKUP i, [15, 8, 6, 2, 0], pinIrLed
        LOOKUP i, [14, 9, 7, 3, 1], pinIrDet
        LOOKUP i, [FreqFar, FreqNear, FreqNear, FreqNear, FreqFar], freq
        FREQOUT pinIrLed, 1, freq
        ir = IN0(pinIrDet)
        wall(i) = ir
      NEXT
      RETURN
    
    ' Subroutine: Maneuver
    
    Maneuver:    'Fwd,  Veer_R, Veer_L, Turn_L, Turn_R, U_Turn
      LOOKUP go, [1,    1,      1,      65,     65,     40 ], reps
      LOOKUP go, [850,  850,    750,    765,    850,    850], pulseLeft
      LOOKUP go, [650,  750,    650,    650,    735,    850], pulseRight
      FOR i = 1 TO reps
        PULSOUT 13, pulseLeft
        PULSOUT 12, pulseRight
        PAUSE 20
      NEXT
      RETURN
    
Sign In or Register to comment.