def trace_line_calb():
    while (True):
        err = rocky.grey("left") - rocky.grey("right")
        # print( "err%d"%err )
        rocky.left(100)
        rocky.right(100)
        time.sleep(0.7)
def car_left_turn_test():
    print("left using forward")
    for speed in list(range(0, 101, 20)):
        print("left speed: %d" % speed)
        rocky.left(speed, 1)

    for speed in list(range(0, 101, 20)):
        print("left speed: %d" % -speed)
        rocky.left(-speed, 1)
def rocky_send():
    print("rocky forward")
    rocky.forward(100, 2)
    print("rocky back")
    rocky.back(100, 2)
    print("rocky left")
    rocky.left(100, 2)
    print("rocky right")
    rocky.right(100, 2)
    print("rocky stop")
Пример #4
0
def on_button1_callback():
    global angerValue
    if angerValue > random.randint(3, 5):
        angerValue = 0
        time.sleep(0.2)
        codey.face('00003c1e0e0400000000040e1e3c0000')
        rocky.back(50)
        time.sleep(0.4)
        codey.say('dog.wav')
        codey.face('00007c3e1e0e040000040e1e3e7c0000')
        rocky.back(100)
        time.sleep(0.05)
        rocky.forward(100)
        time.sleep(0.5)
        rocky.back(100)
        time.sleep(0.01)
        rocky.stop()
        time.sleep(0.2)

    else:
        codey.say('happy.wav')
        codey.face('000c18181c0c000000000c1c18180c00')
        time.sleep(0.3)
        rocky.left(70)
        time.sleep(0.05)
        codey.face('00183030381800000000183830301800')
        rocky.right(70)
        time.sleep(0.05)
        rocky.left(70)
        time.sleep(0.05)
        rocky.right(70)
        time.sleep(0.05)
        rocky.stop()
        codey.face('000c18181c0c000000000c1c18180c00')
        time.sleep(0.3)
        codey.face('00183030381800000000183830301800')
        time.sleep(0.1)
        codey.face('00003c7e7e3c000000003c7e7e3c0000')
        angerValue = (angerValue if isinstance(angerValue, int)
                      or isinstance(angerValue, float) else 0) + 1

    codey.message(str('hello'))