-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
80 lines (67 loc) · 1.6 KB
/
server.js
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
let five = require('johnny-five')
let TAU = Math.PI * 2
let tap = new five.Board()
let Arm = require('./arm')
let Home = require('./home')
let Position = require('./position')
let Tapper = require('./tapper')
let zAxis = require('./z-axis')
tap.on('ready', () => {
tap.name = tap.io.firmware.name.split('.')[0]
let enablePin = new five.Pin({pin: 8, type: 'digital', mode: 1})
let a = new Arm({
stepPin: 2,
dirPin: 5,
limitPin: 9,
label: "A",
homeDirection: 1,
theta_home: 240,
theta_max: 30,
x0: -24,
y0: 0,
r0: 8*9,
r1: 8*13
})
let b = new Arm({
stepPin: 3,
dirPin: 6,
limitPin: 10,
label: "B",
homeDirection: 0,
theta_home: -60,
theta_max: 150,
x0: 24,
y0: 0,
r0: 8*9,
r1: 8*13
})
let z = new zAxis()
let home = new Home({a:a, b:b, z:z})
let position = new Position({a:a, b:b})
// End Effector (Solenoid)
let tapper = new Tapper(17, 18) // On Arduino, pin A3 = 17, A4 = 18
let t0 = {
name: this.name,
a: a,
b: b,
z: z,
e: tapper,
enablePin: enablePin,
home: home,
position: position,
go: position.go.bind(position)
}
a.on('position', data => {
//console.log(a.label + ' position update: ' + data.x1 + ', ' + data.y1)
position.update()
})
b.on('position', data => {
//console.log(b.label + ' position update: ' + data.x1 + ', ' + data.y1)
position.update()
})
tap.repl.cmd.ignoreUndefined = true
tap.repl.inject({ five, tap, t0 })
console.log(tap.name + ' Ready!')
setTimeout( () => { t0.home.ZAB() }, 500)
tap.setMaxListeners(100)
})