def move0(): times = [] lShoulder, rShoulder, lElbow, rElbow, rTouch, lTouch = initializeSensors() ev3.Sound.set_volume(100) ev3.Sound.speak("Let's play a game!") sleep(1.5) hp.setMotors([rShoulder, lShoulder], [450, -450]) times.append(hp.waitForTouch([rTouch, lTouch], "both")) hp.setMotors([rShoulder, lShoulder], [0, 0]) ev3.Sound.speak('Well Done!') client2.publish("topic/rpi/dt", str(times))
def move1(): lShoulder, rShoulder, lElbow, rElbow, rTouch, lTouch = initializeSensors() # ev3.Sound.speak('Hello!') # sleep(1) t = time() print(t) hp.setMotors([rElbow, lElbow], [-100, -100]) hp.setMotors([rElbow, lElbow], [0, 0]) hp.setMotors([rElbow, lElbow], [-100, -100]) hp.setMotors([rElbow, lElbow], [0, 0]) client2.publish("topic/rpi/dt", "Robot said Hello Message")
def move3(): times = [] for i in range(3): lShoulder, rShoulder, lElbow, rElbow, rTouch, lTouch = initializeSensors( ) hp.setMotors([rShoulder, rElbow], [-300, 150]) times.append(hp.waitForTouch([rTouch], "right")) hp.setMotors([lShoulder, lElbow], [+300, 150]) times.append(hp.waitForTouch([lTouch], "left")) hp.setMotors([rShoulder, rElbow], [0, 0]) hp.setMotors([lShoulder, lElbow], [0, 0]) client2.publish("topic/rpi/dt", str(times))
def move1(): lShoulder, rShoulder, lElbow, rElbow, rTouch, lTouch = initializeSensors() t = time() print(t) ev3.Sound.speak("Hello!") sleep(0.4) hp.setMotors([rElbow, lElbow], [350, 350]) hp.setMotors([rElbow, lElbow], [-50, -50]) hp.setMotors([rElbow, lElbow], [350, 350]) hp.setMotors([rElbow, lElbow], [0, 0]) client2.publish("topic/rpi/dt", "Robot said Hello Message")
def move2(): times = [] lShoulder, rShoulder, lElbow, rElbow, rTouch, lTouch = initializeSensors() t1 = time() for i in range(5): hp.setMotors([rShoulder, lShoulder], [-300, +300]) hp.setMotors([rShoulder, lShoulder], [+550, -550]) hp.setMotors([rShoulder, lShoulder], [0, 0]) hp.setMotors([rElbow, lElbow], [-150, -150]) hp.setMotors([rElbow, lElbow], [0, 0]) hp.setMotors([rElbow, lElbow], [150, 150]) hp.setMotors([rShoulder, lShoulder, rElbow, lElbow], [+550, -550, -150, -150]) times.append(hp.waitForTouch([rTouch, lTouch], "both")) hp.setMotors([rElbow, lElbow], [150, 150]) hp.setMotors([rShoulder, lShoulder], [0, 0]) hp.setMotors([rShoulder, lShoulder, rElbow, lElbow], [-250, +250, +150, +150]) hp.setMotors([rElbow, lElbow], [0, 0]) hp.setMotors([rShoulder, lShoulder], [0, 0]) client2.publish("topic/rpi/dt", str(times))
def move13(): lShoulder, rShoulder, lElbow, rElbow, rTouch, lTouch = initializeSensors() hp.setMotors([rElbow], [350]) hp.setMotors([rElbow], [-50]) hp.setMotors([rElbow], [350]) hp.setMotors([rElbow], [-50]) hp.setMotors([rElbow], [350]) hp.setMotors([rElbow], [0]) client2.publish("topic/rpi/dt", "Robot wiggled hand")
def move5(): times = [] lShoulder, rShoulder, lElbow, rElbow, rTouch, lTouch = initializeSensors() for i in range(3): r = random.randint(2, 5) if r == 2: hp.setMotors([rShoulder, lShoulder], [-300, +300]) times.append(hp.waitForTouch([rTouch, lTouch], "both")) hp.setMotors([rElbow, lElbow], [150, -150]) hp.setMotors([rElbow, lElbow], [-150, 150]) hp.setMotors([rElbow, lElbow], [0, 0]) times.append(hp.waitForTouch([rTouch, lTouch], "both")) hp.setMotors([rShoulder, lShoulder], [300, -300]) times.append(hp.waitForTouch([rTouch, lTouch], "both")) hp.setMotors([rElbow, lElbow], [150, -150]) hp.setMotors([rElbow, lElbow], [-150, 150]) hp.setMotors([rElbow, lElbow], [0, 0]) times.append(hp.waitForTouch([rTouch, lTouch], "both")) hp.setMotors([rShoulder, rShoulder], [0, 0]) elif r == 3: lShoulder, rShoulder, lElbow, rElbow, rTouch, lTouch = initializeSensors( ) hp.setMotors([rShoulder, rElbow], [-300, 150]) times.append(hp.waitForTouch([rTouch], "right")) hp.setMotors([lShoulder, lElbow], [+300, 150]) times.append(hp.waitForTouch([lTouch], "left")) hp.setMotors([rShoulder, rElbow], [0, 0]) hp.setMotors([lShoulder, lElbow], [0, 0]) elif r == 4: hp.setMotors([rShoulder, lShoulder], [-300, +300]) hp.setMotors([rShoulder, lShoulder], [+300, -300]) hp.setMotors([rShoulder, lShoulder], [0, 0]) hp.setMotors([rElbow, lElbow], [-150, -150]) hp.setMotors([rElbow, lElbow], [0, 0]) hp.setMotors([rElbow, lElbow], [150, 150]) hp.setMotors([rShoulder, lShoulder, rElbow, lElbow], [+300, -300, -150, -150]) times.append(hp.waitForTouch([rTouch, lTouch], "both")) hp.setMotors([rElbow, lElbow], [150, 150]) hp.setMotors([rShoulder, lShoulder], [0, 0]) hp.setMotors([rShoulder, lShoulder, rElbow, lElbow], [-250, +250, +150, +150]) hp.setMotors([rElbow, lElbow], [0, 0]) hp.setMotors([rShoulder, lShoulder], [0, 0]) client2.publish("topic/rpi/dt", str(times))