-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharm.py
More file actions
59 lines (41 loc) · 1021 Bytes
/
arm.py
File metadata and controls
59 lines (41 loc) · 1021 Bytes
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
#!/usr/bin/env python
from flask import Flask, render_template, Response
import servo
app = Flask(__name__)
grip =servo.ServoController(17)
grip.setAngle(90)
elbow =servo.ServoController(27)
elbow.setAngle(0)
shoulder =servo.ServoController(22)
shoulder.setAngle(25)
hip =servo.ServoController(23)
hip.setAngle(0)
@app.route('/')
def index():
try:
return render_template('arm.html')
except Exception as e:
print e
pass
@app.route("/<direction>")
def move(direction):
# Choose the direction of the request
if direction == 'gopen':
grip.setAngle(45)
elif direction == 'gclose':
grip.setAngle(90)
elif direction == 'eup':
elbow.incAngle(10)
elif direction == 'edown':
elbow.incAngle(-19)
elif direction == 'sback':
shoulder.incAngle(-10)
elif direction == 'sfwd':
shoulder.incAngle(10)
elif direction == 'hleft':
hip.incAngle(-10)
elif direction == 'hright':
hip.incAngle(10)
return direction
if __name__ == '__main__':
app.run(host='0.0.0.0', debug=True)