-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
108 lines (86 loc) · 2.11 KB
/
app.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
var express = require('express'),
app = express(),
path = require('path'),
server = require('http').createServer(app),
wsCtrl = require('./ws-controller'),
arClient = require('ar-drone').createClient();
var SPEED = 0.4;
wsCtrl.start();
arClient.on('navdata', function(data) {
// console.log(data);
wsCtrl.data(data);
});
wsCtrl.on('takeoff', function(data){
console.log('TakeOff');
arClient.takeoff();
});
wsCtrl.on('land', function(data){
console.log('Land');
arClient.land();
});
wsCtrl.on('stop', function(data) {
console.log('Stop');
arClient.stop();
});
wsCtrl.on('up', function(data) {
console.log('Up');
arClient.up(SPEED);
});
wsCtrl.on('down', function(data) {
console.log('Down');
arClient.down(SPEED);
});
wsCtrl.on('front', function(data) {
console.log('front');
arClient.front(SPEED);
});
wsCtrl.on('back', function(data) {
console.log('back');
arClient.back(SPEED);
});
wsCtrl.on('left', function(data) {
console.log('left');
arClient.left(SPEED);
});
wsCtrl.on('right', function(data) {
console.log('right');
arClient.right(SPEED);
});
wsCtrl.on('spinCW', function(data) {
console.log('spinCW');
arClient.clockwise(SPEED);
});
wsCtrl.on('spinCCW', function(data) {
console.log('spinCCW');
arClient.counterClockwise(SPEED);
});
wsCtrl.on('flip', function(data) {
console.log('Flip');
arClient.animate('flipLeft', 500);
});
wsCtrl.on('disableEmergency', function(data) {
console.log('DisableEmergency');
arClient.disableEmergency();
});
wsCtrl.on('fireLeft', function(data) {
console.log('Fire Left');
arClient.animateLeds('leftMissile', 5, 2);
});
wsCtrl.on('fireRight', function(data) {
console.log('Fire Right');
arClient.animateLeds('rightMissile', 5, 2);
});
app.configure(function () {
app.use(express.favicon());
app.use(express.logger('dev'));
app.use(express.static(path.join(__dirname, 'public')));
});
app.configure('development', function () {
app.use(express.errorHandler());
app.locals.pretty = true;
});
app.get('/', function(req, res) {
res.sendfile("index.html");
});
require("dronestream").listen(server);
server.listen(3000);