Shop OBEX P1 Docs P2 Docs Learn Events
Python & Scribbler — Parallax Forums

Python & Scribbler

rroyalrroyal Posts: 8
edited 2007-02-20 17:58 in Robotics
I've gone through most of the functionality of the python library except the getStall() function. Has anyone gotten this to work in python and could you post an example? The one at http://cvs.cs.brynmawr.edu/cgi-bin/viewcvs.cgi/Myro/Scribbler/examples/ doesn't work.

Also post some of the more interesting or efficient functions you come up with.
This one will follow an oval 22.5 by 17 cm & 2cm thickness:

def fluidLineFollow():
    lost = 0
    r.motors(.4,.4)
    if not getLine('right'):
        r.motors(0,.5)
        lost = lost + 1
    if not getLine('left'):
        r.motors(.5,0)
        lost = lost + 1
    if (lost == 2):
        r.stop()
        r.translate(-.7)
        time.sleep(.1)
    fluidLineFollow()




Clearly there are some ugly constants within the function that require adjustment for each type of line the robot is following and need to be found through experimentation. This one works better for straighter lines.

VELOCITY = .4
TURNSPEED = .75
def lineFollow():
    lostCounter = 0
    r.translate(VELOCITY)
    if not getLine('right'):
        r.stop()
        turnLeft(TURNSPEED)
        r.stop()
        lostCounter = lostCounter + 1
    if not getLine('left'):
        r.stop()
        turnRight(TURNSPEED)
        r.stop()
        lostCounter = lostCounter + 1
    if(lostCounter == 2):
        r.translate(-1)
    lineFollow()



Has anyone been able to write a more general or efficient combination of the two previous functions?

Post Edited (rroyal) : 2/21/2007 3:11:39 PM GMT

Comments

  • HenrymouHenrymou Posts: 128
    edited 2007-02-20 17:58
    wow! nice!
    My bro's really into the sribbler, but we have no idea what you are talkin about... GOOD LUCK!
Sign In or Register to comment.