pi2go - move robot in 90º or move foward just 10 cm and stop?
<p>I bought a pi2go robot, and it's fantastic, but I have some questions, I want to make the robot </p>

<ol>
<li>Spin Left/Right just 90º degrees and stop</li>
<li>Move Foward/Backward just 10 cm and stop </li>
</ol>

<p>I wanted to do 4 scripts in python just to do this like <code>left.py</code>, <code>forward.py</code>. </p>

<p>In the pi2go helpfiles there is a script that allows you to control the robot with the keyboard, but I don't want that I just want to call for example <code>sudo python left.py</code> one time and exit.</p>

<p>Here is the pi2go example :</p>

<pre><code>import pi2go, time

import sys
import tty
import termios

UP = 0
DOWN = 1
RIGHT = 2
LEFT = 3

def readchar():
    fd = sys.stdin.fileno()
    old_settings = termios.tcgetattr(fd)
    try:
        tty.setraw(sys.stdin.fileno())
        ch = sys.stdin.read(1)
    finally:
        termios.tcsetattr(fd, termios.TCSADRAIN, old_settings)
    if ch == '0x03':
        raise KeyboardInterrupt
    return ch

def readkey(getchar_fn=None):
    getchar = getchar_fn or readchar
    c1 = getchar()
    if ord(c1) != 0x1b:
        return c1
    c2 = getchar()
    if ord(c2) != 0x5b:
        return c1
    c3 = getchar()
    return ord(c3) - 65  # 0=Up, 1=Down, 2=Right, 3=Left arrows

speed = 30

pi2go.init()

try:
    while True:
        keyp = readkey()
        if keyp == 'w' or keyp == UP:
            pi2go.forward(speed)
            print 'Forward', speed
        elif keyp == 's' or keyp == DOWN:
            pi2go.reverse(speed)
            print 'Backward', speed
        elif keyp == 'd' or keyp == RIGHT:
            pi2go.spinRight(speed)
            print 'Spin Right', speed
        elif keyp == 'a' or keyp == LEFT:
            pi2go.spinLeft(speed)
            print 'Spin Left', speed
        elif keyp == '.' or keyp == '&gt;':
            speed = min(100, speed+10)
            print 'Speed+', speed
        elif keyp == ',' or keyp == '&lt;':
            speed = max (0, speed-10)
            print 'Speed-', speed
        elif keyp == ' ':
            pi2go.stop()
            print 'Stop'
        elif ord(keyp) == 3:
            break


    pi2go.cleanup()
</code></pre>

<p>But I want to create just one script that does this and exits, like:</p>

<pre><code>pi2go.spinLeft(100) 
pi2go.stop()
</code></pre>