Shop OBEX P1 Docs P2 Docs Learn Events
Need help with code — Parallax Forums

Need help with code

RobocopRobocop Posts: 9
edited 2007-02-21 08:07 in Robotics
I'm trying to modify the roaming with IR on the BOE BOT to escape corners. I have tried using arrays and other techniques, but no luck. Any help would be appreciated. Thanks

Comments

  • ZootZoot Posts: 2,227
    edited 2007-02-20 03:01
    Here's a tip -- check out the code in Robotics with the Boe-bot for roaming with whiskers -- there is code there for escaping corners when navigating with the tactile sensors. The same concept can be applied to roaming with IR.

    In pseudo-code:

    
    if IRleft then
       turn right
       if oldIR = right
           count = count + 1
       else
           count = 0
        endif
       oldIR = left
    else if IRright then
       turn left
       if oldIR = left
           count = count + 1
        else
            count = 0
         endif
        oldIR = right
    endif
    
    if count > 3 then 'or however many bounces back and forth you want to limit it to
        backup and turnaround
        count = 0
    endif
    
    
    



    Make sense? Basically you want to add to your count ONLY if the last thing you did was an IR avoid from the OTHER side (so you are counting the times you are bouncing back and forth between left/right IR avoids). If the count gets too big, do something else.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST
  • RobocopRobocop Posts: 9
    edited 2007-02-20 16:28
    It worked!! Thanks
  • HenrymouHenrymou Posts: 128
    edited 2007-02-21 08:07
    boe bots are fun!
    I won the synopsis science fair last year for doing what you are doing, once you are done with that project, try adding a CMUcam! for vision
    -peace
Sign In or Register to comment.