Shop OBEX P1 Docs P2 Docs Learn Events
Ping Servo Programming — Parallax Forums

Ping Servo Programming

EleutherEleuther Posts: 20
edited 2012-11-27 00:44 in General Discussion
Hi I have been trying to write a program to make my Boe-Bot Robot be able to avoid obstacles without stopping to Ping Around. I want it to navigate smoothly and I was wondering how you would write the program to make the bot turn left/right AND have the Ping Servo fave right/left. please post any ideas or thoughts thanks.:smile:

Comments

  • Martin_HMartin_H Posts: 4,051
    edited 2012-11-26 16:31
    Allocate a variable for the Ping servo pulse width. With each iteration through the main program loop increment the pulse width until it reach a max value. Then for each iteration decrement the same variable until it reaches a minimum. Also in the main loop sample the Ping value when the offset equals certain fixed values.

    The one downside to this approach is your robot is looking and moving, so it's possible to be looking the wrong way when an obstacle is encountered.
  • ercoerco Posts: 20,259
    edited 2012-11-26 16:42
    A different approach would be to do S-turns, alternating left & right regularly. Could be as simple as alternating left/right drive wheels, on/off. Constantly sample the forward-facing PING and when an obstacle is detected, keep circling in that same direction until a clear path is detected, then resume S-turns.

    Heck, I like that, I'll try it myself. Forget I even mentioned it. This conversation never happened! erco? Dunno him. He never worked here.
  • EleutherEleuther Posts: 20
    edited 2012-11-26 17:14
    well ya both would work and I like both but I want maximum potential in my bot. I want something like this: here is a video,
    http://www.youtube.com/watch?v=_roaoDC7NyQ
  • ercoerco Posts: 20,259
    edited 2012-11-26 17:25
    Nice POV video, I'll have to stick my Keychain Spycam on Boebot & Scribbler and turn 'em loose!
  • EleutherEleuther Posts: 20
    edited 2012-11-26 17:39
    I will try the S-turns and see if I could make some adjustments to my liking.
  • ercoerco Posts: 20,259
    edited 2012-11-26 17:43
    My lead Scribbler here is doing gentle S-turns, you probably need more aggressive turns to avoid objects. But it might be an interesting way to scan on the fly. Kinda snaky-looking serpentine motion.
  • EleutherEleuther Posts: 20
    edited 2012-11-26 17:52
    So I forgot how to program the S-turns will you please post them thank you.
  • ercoerco Posts: 20,259
    edited 2012-11-26 17:59
    BoeBot code is very different than Scribbler, unfortunately.
  • EleutherEleuther Posts: 20
    edited 2012-11-26 18:14
    have any idea what it could be are you using BASIC stamp?
  • ercoerco Posts: 20,259
    edited 2012-11-27 00:44
    Yessir, you suckered me into it...
    My video of simple BoeBot S-turns at http://www.youtube.com/watch?v=Z_YUsDeuT-c

    You'll tweak the code to make your bot run similarly (curve L/R the same amount) and add the PING routine during/instead of the PAUSE 20, and decide when/how long/which direction to turn. Let us know how you make out.
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    
    
    'boebot S turns
    'left  wheel pin 13 slow 775   fast 850
    'right wheel pin 12 slow 725   fast 650
    
    
    left:
    FOR B0=1 TO 100
    PULSOUT 13,780
    PULSOUT 12,650
    PAUSE 20
    NEXT
    
    right:
    FOR B0=1 TO 100
    PULSOUT 13,900
    PULSOUT 12,735
    PAUSE 20
    NEXT
    
    GOTO left
    
Sign In or Register to comment.