-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.js
More file actions
35 lines (25 loc) · 694 Bytes
/
Copy pathtest.js
File metadata and controls
35 lines (25 loc) · 694 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
var imu = require("./sensors/imu");
var blenderClient = require("./clients/blenderClient");
//start the imu
imu.initialize();
imu.run();
//packet layout
// rrrrpppptt tt
// 0123456789 0123456789 0123456789
function send() {
process.nextTick( function() {
imu.state(function(data) {
//console.log(data.n50.keys,data.n50.hat);
var buf = new Buffer(24);
buf.writeFloatLE(data.pitchDiff, 0);
buf.writeFloatLE(data.rollDiff, 4);
buf.writeFloatLE(data.trigger, 8);
buf.writeFloatLE(data.n50.wheel, 12);
buf.writeFloatLE(data.n50.hat, 16);
buf.writeFloatLE(data.n50.keys, 20);
blenderClient.send(buf);
send();
});
}.bind(this));
};
send();