|
@@ -202,21 +202,29 @@ def stop():
|
|
|
|
|
|
def left(distance):
|
|
|
send_char('a')
|
|
|
- if abs(distance) > 75:
|
|
|
+ if abs(distance) > 300:
|
|
|
print('GO LEFT')
|
|
|
return
|
|
|
+ elif abs(distance) > 50:
|
|
|
+ print('GO LEFT FOR {}s (divisior 175)'.format(1.0*abs(distance)/175.0))
|
|
|
+ time.sleep(1.0*abs(distance)/175.0)
|
|
|
+ stop()
|
|
|
else:
|
|
|
- print('GO LEFT FOR {}s'.format(1.0*abs(distance)/100.0))
|
|
|
+ print('GO LEFT FOR {}s (divisor 100)'.format(1.0*abs(distance)/100.0))
|
|
|
time.sleep(1.0*abs(distance)/100.0)
|
|
|
stop()
|
|
|
|
|
|
def right(distance=None):
|
|
|
send_char('d')
|
|
|
- if abs(distance) > 75:
|
|
|
+ if abs(distance) > 300:
|
|
|
print("GO RIGHT")
|
|
|
return
|
|
|
+ elif abs(distance) > 50:
|
|
|
+ print('GO RIGHT FOR {}s (divisior 175)'.format(1.0*abs(distance)/175.0))
|
|
|
+ time.sleep(1.0*abs(distance)/175.0)
|
|
|
+ stop()
|
|
|
else:
|
|
|
- print('GO RIGHT FOR {}s'.format(1.0*abs(distance)/100.0))
|
|
|
+ print('GO RIGHT FOR {}s (divisor 100)'.format(1.0*abs(distance)/100.0))
|
|
|
time.sleep(1.0*abs(distance)/100.0)
|
|
|
stop()
|
|
|
|
|
@@ -248,18 +256,21 @@ if __name__ == "__main__":
|
|
|
faces = findface(image)
|
|
|
if faces == ():
|
|
|
print("No face found.")
|
|
|
- stop()
|
|
|
- lastAction = "Stop"
|
|
|
rawCapture.truncate(0)
|
|
|
- if timeSinceDetected > time_before_scan and timeSinceDetected < time_after_scan and lastAction != "Scan":
|
|
|
- lastAction = "Scan"
|
|
|
- print("Beginning Scanning...")
|
|
|
- right(1000) # 1000 is arbitrary
|
|
|
+ if timeSinceDetected > time_before_scan and timeSinceDetected < time_after_scan:
|
|
|
+ if lastAction != "Scan":
|
|
|
+ lastAction = "Scan"
|
|
|
+ print("Beginning Scanning...")
|
|
|
+ right(1000.0) # 1000 is arbitrary
|
|
|
+ # Otherwise just keep doing what youre doing
|
|
|
elif timeSinceDetected > time_after_scan:
|
|
|
lastAction = "Stop"
|
|
|
print("Stopping scanning...")
|
|
|
lastDetected = time.time()*1000.0
|
|
|
stop()
|
|
|
+ else:
|
|
|
+ lastAction = "Stop"
|
|
|
+ stop()
|
|
|
continue
|
|
|
|
|
|
lastDetected = time.time() * 1000.0
|