Added ctrl-c logic to examples

Esse commit está contido em:
Laurent Eschenauer
2013-09-01 21:32:28 +02:00
commit 5fce22acea
2 arquivos alterados com 36 adições e 0 exclusões
+18
Ver Arquivo
@@ -3,8 +3,25 @@ var df = require('dateformat')
, mission = autonomy.createMission()
;
// Land on ctrl-c
var exiting = false;
process.on('SIGINT', function() {
if (exiting) {
process.exit(0);
} else {
console.log('Got SIGINT. Landing, press Control-C again to force exit.');
exiting = true;
mission.control().disable();
mission.client().land(function() {
process.exit(0);
});
}
});
// Log mission data for debugging
mission.log("mission-" + df(new Date(), "yyyy-mm-dd_hh-MM-ss") + ".txt");
// Plan pano mission
mission.takeoff()
.zero()
.hover(1000)
@@ -17,6 +34,7 @@ mission.takeoff()
.altitude(0.5)
.land();
// Execute mission
mission.run(function (err, result) {
if (err) {
console.trace("Oops, something bad happened: %s", err.message);
+18
Ver Arquivo
@@ -17,14 +17,31 @@ var navdata_options = (
| navdata_option_mask(arDroneConstants.options.WIFI)
);
// Land on ctrl-c
var exiting = false;
process.on('SIGINT', function() {
if (exiting) {
process.exit(0);
} else {
console.log('Got SIGINT. Landing, press Control-C again to force exit.');
exiting = true;
mission.control().disable();
mission.client().land(function() {
process.exit(0);
});
}
});
// Connect and configure the drone
mission.client().config('general:navdata_demo', true);
mission.client().config('general:navdata_options', navdata_options);
mission.client().config('video:video_channel', 1);
mission.client().config('detect:detect_type', 12);
// Log mission for debugging purposes
mission.log("mission-" + df(new Date(), "yyyy-mm-dd_hh-MM-ss") + ".txt");
// Plan mission
mission.takeoff()
.zero()
.hover(500)
@@ -36,6 +53,7 @@ mission.takeoff()
.hover(500)
.land();
// Execute mission
mission.run(function (err, result) {
if (err) {
console.trace("Oops, something bad happened: %s", err.message);