-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstarter.js
executable file
·61 lines (44 loc) · 1.1 KB
/
starter.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
#!/usr/bin/env node
const sphero = require("sphero")
const spheroId = process.argv[2]
const orb = sphero(spheroId)
const streamData = require("./lib/dataStream")
const stdin = process.openStdin()
stdin.addListener("data", function(data) {
let command = "orb." + data.toString().trim()
try {
let result = eval(command)
console.log("[EXECUTING]: " + result)
} catch(error) {
console.log(error)
}
})
orb.connect(() => {
console.log("connected... waiting for input:")
orb.color('blue')
// output sphero sensor data
// below is in sphero/lib/devices/custom.js
orb.on("imuAngles", function(data) {
streamData.imuAngles(data)
})
orb.on("odometer", function(data) {
streamData.odometer(data)
})
orb.on("gyroscope", function(data) {
streamData.gyroscope(data)
})
orb.on("velocity", function(data) {
streamData.velocity(data)
})
orb.on("accelOne", function(data) {
streamData.accelOne(data)
})
orb.on("accelerometer", function(data) {
streamData.accelerometer(data)
})
orb.on("motorsBackEmf", function(data) {
streamData.motorsBackEmf(data)
})
})
orb.disconnect(() => {
});