forked from cambridgecoding/drone
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdrone-backend.js
More file actions
50 lines (45 loc) · 1.03 KB
/
drone-backend.js
File metadata and controls
50 lines (45 loc) · 1.03 KB
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
var Cylon = require('cylon');
var ws = require('nodejs-websocket');
var bot;
// Initialise the robot
Cylon.robot()
.connection("ardrone", {
adaptor: 'ardrone',
port: '192.168.1.1'
})
.device("drone", {
driver: "ardrone",
connection: "ardrone"
})
.on("ready", fly);
// Fly the bot
function fly(robot) {
bot = robot;
//bot.nav.on("navdata", function(data) {
//console.log(data);
//});
bot.drone.config('general:navdata_demo', 'TRUE');
bot.drone.disableEmergency();
bot.drone.ftrim();
bot.drone.takeoff();
bot.drone.left(0.2);
after(0.85*1000, function() {
bot.drone.front(0.4);
});
after(1.8*1000, function() {
bot.drone.right(0.4);
});
after(2.65*1000, function() {
bot.drone.back(0.4);
});
after(3.5*1000, function() {
bot.drone.left(0.4);
});
after(3.8*1000, function() {
bot.drone.land();
});
after(4.1*1000, function() {
bot.drone.stop();
});
}
Cylon.start();