def car_drive_continue_test():
    print("car drive continue")
    for speed in list(range(0, 101)):
        print("drive speed: %d" % speed)
        rocky.drive(speed, speed)
        time.sleep(0.1)
    for speed in list(range(0, 101)):
        print("drive speed: %d" % -speed)
        rocky.drive(-speed, -speed)
        time.sleep(0.1)
    rocky.stop()
def car_drive_test():
    print("right left + power")
    for speed in list(range(0, 101, 20)):
        print("right speed: %d" % speed)
        rocky.drive(speed, speed)
        time.sleep(1)
    print("right left - power")
    for speed in list(range(0, 101, 20)):
        print("right speed: %d" % speed)
        rocky.drive(-speed, -speed)
        time.sleep(1)
    rocky.stop()
Ejemplo n.º 3
0
def runCmd(cmd):
  if len(cmd) < 1:
    return
  for i, j in enumerate(cmd):
    if j == 0:
        rocky.stop()
        codey.set_variable('cmd', "0_0_0")
    else:
        t = type(j)
        if t == str:
            codey.face(j)
        elif t == tuple:
            run(j[0], j[1])
Ejemplo n.º 4
0
def rocky_read():
    print("rocky color is:", rocky.get_color()) # not a demand 
    print("red value is:", rocky.red())
    print("green value is:", rocky.green())
    print("blue value is:", rocky.blue())    
    print("rocky grey is:", rocky.grey())
    print("rocky obstacle is:", rocky.is_obstacle_ahead())
    print("rocky light is:", rocky.light_strength())
    print("rocky light reflect is:", rocky.reflection_strength()) 
    print("rocky ir reflect is:", rocky.ir_reflection_strength()) 
    print("rocky left motor current is ", rocky.motor_current('left'))
    rocky.forward(100)
    time.sleep(1)
    print("rocky left motor current is ", rocky.motor_current('left'))
    rocky.stop()
    print("")
Ejemplo n.º 5
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'))
Ejemplo n.º 6
0
def on_button_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('wrong.wav')
        codey.face('00081c1c3c3820000020383c1c1c0800')
        time.sleep(0.3)
        rocky.back(20)
        codey.face('00040e0e1e1c100000101c1e0e0e0400')
        rocky.back(50)
        time.sleep(0.1)
        codey.face('00081c1c3c3820000020383c1c1c0800')
        rocky.stop()
        time.sleep(0.3)
        codey.face('00183c3c7c7820000020787c3c3c1800')
        time.sleep(0.1)
        codey.face('00003c7e7e3c000000003c7e7e3c0000')
        angerValue = (angerValue if isinstance(angerValue, int)
                      or isinstance(angerValue, float) else 0) + 1

    codey.message(str('hello'))
Ejemplo n.º 7
0
codey.ir_receive()

print("***codey APIS all succeed***")
# about rocky
rocky.color("#334455")
rocky.forward(50, 1)
rocky.backward(50, 1)
rocky.turn_left(50, 1)
rocky.turn_right(50, )
rocky.forward(50)
rocky.backward(50)
rocky.turn_left(50)
rocky.turn_right(50)
rocky.drive(50, 50)
rocky.turn_left_angle(15)
rocky.turn_right_angle(15)
rocky.stop()

rocky.is_obstacle_ahead()
rocky.is_color('red')
rocky.red()
rocky.green()
rocky.blue()
rocky.reflection_strength()
rocky.light_strength()
rocky.ir_reflection_strength()
rocky.grey()
print("***rocky APIS all succeed***")


codey.on_button('A', call_back) 
Ejemplo n.º 8
0
def on_button_b_pressed1():
    rocky.stop()
    codey.speaker.play_melody('sigh.wav', True)
    codey.stop_all_scripts()