File size: 934 Bytes
7f88cfb | 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 | // setup variables, functions, and libraries
var libpath = './Peripherals/build/Release';
var VixenAUV = require(libpath + '/VixenAUV');
var $ = require('jquery-deferred');
var SECONDS = 1000;
function timeout(ms) {
var res = $.Deferred();
setTimeout(res.resolve, ms);
return res.promise();
}
// Connect to the Arduino
var factory = new VixenAUV.ArduinoFactory();
var grid = factory.getPowerGrid();
var engine = factory.getEngine();
// Wait for the signal...
var wait = $.Deferred();
function callback(msg) {
console.log(msg);
wait.resolve();
}
grid.waitForStartSignal(callback);
// ...and BEGIN!
wait
.then(function() {
engine.move(0.50);
})
.then(timeout(1*SECONDS))
.then(function() {
engine.yaw(0.50);
})
.then(timeout(5*SECONDS))
.then(function() {
engine.yaw(0.00);
})
.then(timeout(1*SECONDS))
.then(function() {
engine.yaw(-0.50);
})
.then(timeout(5*SECONDS))
.done(function() {
engine.kill();
}); |