-
Notifications
You must be signed in to change notification settings - Fork 51
/
robot.py
executable file
·86 lines (61 loc) · 1.01 KB
/
robot.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#! /usr/bin/python
import wheels
import sys
import sonar
import configure
usage = '''
robot
Tell the robot what to do.
Commands
Actions
-------
forward
backward
left
right
stop
shake
Test Wheels
-----------
wheel1
wheel2
wheel3
wheel4
Test Sonar
----------
leftdist
rightdist
centerdist
'''
print sys.argv
if (len(sys.argv) == 1):
print usage
exit(1)
cmd = sys.argv[1]
if (cmd == 'forward'):
wheels.forward(200, 1)
elif (cmd == 'backward'):
wheels.backward(200, 1)
elif (cmd == 'left'):
wheels.left(200, 1)
elif (cmd == 'right'):
wheels.right(200, 1)
elif (cmd == 'wheel1'):
wheels.spinMotor(1, 200, 1)
elif (cmd == 'wheel2'):
wheels.spinMotor(2, 200, 1)
elif (cmd == 'wheel3'):
wheels.spinMotor(3, 200, 1)
elif (cmd == 'wheel4'):
wheels.spinMotor(4, 200, 1)
elif (cmd == 'shake'):
wheels.left(200, 0.2)
wheels.right(200, 0.2)
elif (cmd == 'leftdist'):
print sonar.ldist()
elif (cmd == 'rightdist'):
print sonar.rdist()
elif (cmd == 'centerdist'):
print sonar.cdist()
else:
print usage