Exemple #1
0
import iRobotCreate
import numpy as np
import time

r = iRobotCreate.iRobotCreate(1)
dist = 0.2
r.trajectory()
r.set_trail_size(100)
x = 5
y = 2

xobst = np.zeros(4)
yobst = np.zeros(4)
xobst[0] = 3
yobst[0] = 1
xobst[1] = 3
yobst[1] = 0.6
xobst[2] = 3
yobst[2] = 0.2
xobst[3] = 3
yobst[3] = 0

time = 0
d=10000
r.forward(0.1)
print d
while dist<d and time<100:
    [rx,ry,rt] = r.get_pose()
    xt = x-rx
    yt = y-ry
    d = ((xt)**2+(yt)**2)**0.5
Exemple #2
0
import iRobotCreate
import numpy as np
import time

r = iRobotCreate.iRobotCreate(1)
dist = 0.2
r.trajectory()
r.set_trail_size(100)
x = 5
y = 2

xobst = np.zeros(4)
yobst = np.zeros(4)
xobst[0] = 3
yobst[0] = 1
xobst[1] = 3
yobst[1] = 0.6
xobst[2] = 3
yobst[2] = 0.2
xobst[3] = 3
yobst[3] = 0

time = 0
d = 10000
r.forward(0.1)
print d
while dist < d and time < 100:
    [rx, ry, rt] = r.get_pose()
    xt = x - rx
    yt = y - ry
    d = ((xt)**2 + (yt)**2)**0.5
# Lily's voice control
	#open communication to phrasesToSay
sp = IPC.process(False, 'phrasesToSay.py')
	#when input is received from phrasesToSay,
		#check if the TTS program is ready to receive input
sp.setOnReadLine(checkReady)

# Open Speech Recognition Control
vm = IPC.process(False, 'VoiceMonitor.py')
vm.setOnReadLine(VocalQueue)

# Initialize synchronization
IPC.InitSync()

# Open a serial connection to the create
r = iRobotCreate.iRobotCreate(0, 5, "COM3")
time.sleep(1)

# Execute start-up commands
# request input from the TTS
sp.tryReadLine()
readyTT = False
print "Lily is awake."
# command TTS
sp.write("hello\n")

#wait for the TTS to be ready
while readyTT == False:
	sp.tryReadLine()
readyTT = False
print "Lily is ready!"