Shop OBEX P1 Docs P2 Docs Learn Events
Help!! Ping maze Navigation. — Parallax Forums

Help!! Ping maze Navigation.

kolaikolai Posts: 9
edited 2011-02-11 02:41 in Accessories
I saw this video on youtube, and I'm impressed on how the bot solved the maze (on the last part with red walls) using the "Ping ultrasonic Sensor". Any Ideas on the bots algorithm and how the code works?.

I'm planning to join a Walled maze solving competition and I'm planning to use the "Ping sensor" or with both IR detectors and Ping))). I'm sure ping will be enough for the maze.

Thanks for all your help.

the youtube link:

Comments

  • doggiedocdoggiedoc Posts: 2,241
    edited 2011-02-05 06:06
    It appears from the video that the algorithm is more of a "left turn wall following" routine. I didn't see any real maze solving logic there. Looked like great use of the Ping))) mounting bracket kit - notice the left to center scanning action of the sensor?

    Paul
  • kolaikolai Posts: 9
    edited 2011-02-05 07:17
    thanks paul,it likes a " left hand rule " right?. Another Question does the ping sensor output Binary numbers (PingDetectLeft = 0 'object detected @ left' and PingDetectCenter = 0 'Object dtected @ center').? Or in does it output only distance in decimal?(if decimal, you would compare the two cm by cm). If so, any ideas on the algorithm? and have any ideas on how to scan and compare to directions.?

    thanks. very much appreciated :)
  • doggiedocdoggiedoc Posts: 2,241
    edited 2011-02-05 07:29
    There are some excellent examples and details on the PING)))'s product page under "Resources an Downloads".
  • doggiedocdoggiedoc Posts: 2,241
    edited 2011-02-05 07:32
    I found a plethora of information on maze solving algorithms here.

    Hope that helps you. :D

    Paul
  • kolaikolai Posts: 9
    edited 2011-02-05 07:49
    Thanks so much paul. The algorithm looks easy if your going to apply it to the " IR Detectors "
    But for a "PING" its hard (for me as a mediate programmer) I tried to understand some of the examples on the "PING product page" and I stumbled on one source. And its "RoamingwithPing", to apply the Rule showed on the video, should I delete the parts where in a "Right Sweep" place?. Can you also show me how it is done on coding, through editing the "RoamingwithPing"? The "RoamingWithPing" gives me a headache as the codes is really hard to understand.

    Thanks
  • kolaikolai Posts: 9
    edited 2011-02-11 02:41
    For quite some time, at last i figured it out!!!

    Since i only want to use the ping sensor as a front sensor, i didnt mount it with the servo.
    Here's the code, its 2 ir Sensors with ping as the front sensor.

    ' {$STAMP BS2}
    ' {$PBASIC 2.5}

    time VAR Word
    cm VAR Word
    in VAR Word
    ft VAR Word
    cmcons CON 2260
    incons CON 890
    ftcons CON 74

    counter VAR Byte
    irDetectLeft VAR Bit
    irDetectRight VAR Bit

    DO

    PULSOUT 15, 5
    PULSIN 15, 1, time


    cm = cmcons ** time
    in = incons ** time
    ft = ftcons ** time

    FREQOUT 9, 1, 38500 ' Check IR Detectors
    irDetectLeft = IN10

    FREQOUT 8, 1, 38500
    irDetectRight = IN0


    DEBUG HOME, "time = ", DEC5 time
    DEBUG CR, "cm = ", DEC3 cm, "cm"
    DEBUG CR, "in = ", DEC3 in, "in"
    DEBUG CR, "ft = ", DEC3 ft, "ft"

    IF (((in = 3) AND (cm = 8)) OR (in = 2) OR (in = 1) ) THEN 'distances which the ping will react
    FREQOUT 4, 200, 7000
    GOSUB Back_pulse
    GOSUB Right_pulse
    GOSUB Right_pulse
    GOSUB Right_pulse


    ELSEIF (irDetectLeft = 0) AND (irDetectRight = 0)THEN
    GOSUB Forward_pulse
    HIGH 1
    HIGH 11



    ELSEIF (irDetectLeft = 0)THEN
    GOSUB Back_pulse
    GOSUB Right_pulse
    HIGH 11


    ELSEIF (irDetectRight = 0) THEN
    GOSUB Back_pulse
    GOSUB Left_pulse
    HIGH 1

    ELSEIF (irDetectLeft = 1) AND (irDetectRight = 1)THEN
    GOSUB End_pulse
    LOW 1
    LOW 11

    ELSE
    LOW 1
    LOW 11
    PULSOUT 13, 850
    PULSOUT 12, 650
    PAUSE 15

    PAUSE 100


    ENDIF

    LOOP

    Forward_pulse:
    FOR counter = 0 TO 7
    PULSOUT 13, 850
    PULSOUT 12, 600
    PAUSE 20
    NEXT
    RETURN

    Right_pulse:
    FOR counter = 0 TO 3
    PULSOUT 13, 850
    PULSOUT 12, 850
    PAUSE 20
    NEXT
    RETURN

    Left_pulse:
    FOR counter = 0 TO 3
    PULSOUT 13, 650
    PULSOUT 12, 650
    PAUSE 20
    NEXT
    RETURN

    Back_pulse:

    PULSOUT 13, 650
    PULSOUT 12, 850
    PAUSE 15

    RETURN


    Stop_pulse:
    PULSOUT 13, 750
    PULSOUT 12, 750
    PAUSE 50
    RETURN

    End_pulse:
    FOR counter = 0 TO 5
    PULSOUT 13, 850
    PULSOUT 12, 600
    PAUSE 50
    NEXT

    RETURN

    well its still a prototype, but it works!!!
    will accept code upgrades..
Sign In or Register to comment.