forked from robotstreamer/robotstreamer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gopigo3_interface.py
37 lines (31 loc) · 1016 Bytes
/
gopigo3_interface.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import sys
import time
import robot_util
sys.path.append("/home/pi/Dexter/GoPiGo3/Software/Python")
import easygopigo3
easyGoPiGo3 = easygopigo3.EasyGoPiGo3()
def handleCommand(command, keyPosition, price=0):
# only uses pressing down of keys
if keyPosition != "down":
return
print("handle command", command, keyPosition)
e = easyGoPiGo3
if command == 'L':
e.set_motor_dps(e.MOTOR_LEFT, -e.get_speed())
e.set_motor_dps(e.MOTOR_RIGHT, e.get_speed())
time.sleep(0.15)
easyGoPiGo3.stop()
if command == 'R':
e.set_motor_dps(e.MOTOR_LEFT, e.get_speed())
e.set_motor_dps(e.MOTOR_RIGHT, -e.get_speed())
time.sleep(0.15)
easyGoPiGo3.stop()
if command == 'F':
easyGoPiGo3.forward()
time.sleep(0.35)
easyGoPiGo3.stop()
if command == 'B':
easyGoPiGo3.backward()
time.sleep(0.35)
easyGoPiGo3.stop()
robot_util.handleSoundCommand(command, keyPosition, price)