From b8244526e5ab47d17cce01b960b324feb032872d Mon Sep 17 00:00:00 2001 From: John Meyer Date: Fri, 12 Aug 2016 15:57:15 -0400 Subject: [PATCH 1/5] Initial Commit --- Makefile | 2 +- README.md | 4 +-- lib/Client.js | 14 ++++++++- lib/navdata/parseNavdata.js | 8 ++--- package.json | 59 +++++++++++++++++++++++++++++++++++-- 5 files changed, 77 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index c0bb004..ca19d92 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ SHELL := /bin/bash test: - npm test + npm test .PHONY: test diff --git a/README.md b/README.md index 4c0e7a1..95d93c7 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ developers to write autonomous programs for the upcoming robot revolution. ## Status -This module is still under [heavy development](CONTRIBUTING.md), so please don't be surprised if +This module is still under [heavy development](CONTRIBUTING.md), so please don't be suprised if you find some functionality missing or undocumented. However, the documented parts are tested and should work well for most parts. @@ -99,7 +99,7 @@ very least be able to receive `droneState` and `demo` data. A good initial challenge might be to try flying to a certain altitude based on the `navdata.demo.altitudeMeters` property. -Once you have managed this, you may want to try looking at the camera image. Here +Once you have manged this, you may want to try looking at the camera image. Here is a simple way to get this as PngBuffers (requires a recent ffmpeg version to be found in your `$PATH`): diff --git a/lib/Client.js b/lib/Client.js index d8a65e7..12e3aaa 100644 --- a/lib/Client.js +++ b/lib/Client.js @@ -191,7 +191,19 @@ Client.prototype.disableEmergency = function() { }; Client.prototype.takeoff = function(cb) { - this.once('hovering', cb || function() {}); + // Create a fallback for when the drone takes off but forgets to emit a 'hovering' event + // Assume that after 7 seconds, the drone has taken off + var self = this; + var eventFallback = setTimeout(function () { + console.warn("Emitting fallback event for takeoff command"); + self.emit('hovering'); + }, 7000); + // Set drone to takeoff + this.once('hovering', function() { + clearTimeout(eventFallback); + if (typeof(cb) == "function") + cb(); + }); this._ref.fly = true; return true; }; diff --git a/lib/navdata/parseNavdata.js b/lib/navdata/parseNavdata.js index ca07a8b..991a6b4 100644 --- a/lib/navdata/parseNavdata.js +++ b/lib/navdata/parseNavdata.js @@ -73,10 +73,10 @@ exports.OPTION_PARSERS = { var flyState = exports.FLY_STATES[reader.uint16()]; var controlState = exports.CONTROL_STATES[reader.uint16()]; var batteryPercentage = reader.uint32(); - var theta = reader.float32() / 1000; // [mdeg] - var phi = reader.float32() / 1000; // [mdeg] - var psi = reader.float32() / 1000; // [mdeg] - var altitude = reader.int32() / 1000; // [mm] + var theta = reader.float32() / 1000; // [mdeg] converted to [deg] + var phi = reader.float32() / 1000; // [mdeg] converted to [deg] + var psi = reader.float32() / 1000; // [mdeg] converted to [deg] + var altitude = reader.int32() / 1000; // [mm] converted to [m] var velocity = reader.vector31(); // [mm/s] var frameIndex = reader.uint32(); var detection = { diff --git a/package.json b/package.json index 2994141..a681fdf 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,9 @@ { - "author": "Felix Geisendörfer (http://debuggable.com/)", + "author": { + "name": "Felix Geisendörfer", + "email": "felix@debuggable.com", + "url": "http://debuggable.com/" + }, "name": "ar-drone", "description": "A node.js client for controlling Parrot AR Drone 2.0 quad-copters.", "version": "0.3.3", @@ -26,5 +30,56 @@ "optionalDependencies": {}, "engines": { "node": "*" - } + }, + "bugs": { + "url": "https://github.com/felixge/node-ar-drone/issues" + }, + "_id": "ar-drone@0.3.3", + "dist": { + "shasum": "d7b956e23f3f12d94a4e8b7a8f575b25cd69f69b", + "tarball": "https://registry.npmjs.org/ar-drone/-/ar-drone-0.3.3.tgz" + }, + "_from": "ar-drone@0.3.3", + "_npmVersion": "1.4.3", + "_npmUser": { + "name": "felixge", + "email": "felix@debuggable.com" + }, + "maintainers": [ + { + "name": "felixge", + "email": "felix@debuggable.com" + }, + { + "name": "bkw", + "email": "bkw@codingforce.com" + }, + { + "name": "jfsiii", + "email": "npmjs.org@JFSIII.org" + }, + { + "name": "fractal", + "email": "contact@wearefractal.com" + }, + { + "name": "eschnou", + "email": "laurent@eschenauer.be" + }, + { + "name": "andrewnez", + "email": "andrewnez@gmail.com" + }, + { + "name": "wiseman", + "email": "jjwiseman@gmail.com" + }, + { + "name": "rschmukler", + "email": "ryan@slingingcode.com" + } + ], + "directories": {}, + "_shasum": "d7b956e23f3f12d94a4e8b7a8f575b25cd69f69b", + "_resolved": "https://registry.npmjs.org/ar-drone/-/ar-drone-0.3.3.tgz" } From f28fc89e6bb775459ffeaf90952d4871041c38ce Mon Sep 17 00:00:00 2001 From: John Meyer <0x326@users.noreply.github.com> Date: Tue, 16 Aug 2016 09:00:13 -0400 Subject: [PATCH 2/5] Add info about takeoff fallback In some cases, the drone takes off but fails to report it is hovering. This seven-second fallback acts as a backup for these cases so that a program can continue. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 95d93c7..74d7b37 100644 --- a/README.md +++ b/README.md @@ -142,7 +142,7 @@ events. Multiple calls to this method returns the same object. Connection lifecy #### client.takeoff(callback) Sets the internal `fly` state to `true`, `callback` is invoked after the drone -reports that it is hovering. +reports that it is hovering or after seven seconds since, in some cases, the drone takes off but fails to report it is hovering. #### client.land(callback) From 5798d815234a67f1bdfea8007a702c251146703d Mon Sep 17 00:00:00 2001 From: John Meyer <0x326@users.noreply.github.com> Date: Tue, 16 Aug 2016 13:24:55 -0400 Subject: [PATCH 3/5] Fix Typo in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 74d7b37..232e176 100644 --- a/README.md +++ b/README.md @@ -99,7 +99,7 @@ very least be able to receive `droneState` and `demo` data. A good initial challenge might be to try flying to a certain altitude based on the `navdata.demo.altitudeMeters` property. -Once you have manged this, you may want to try looking at the camera image. Here +Once you have managed this, you may want to try looking at the camera image. Here is a simple way to get this as PngBuffers (requires a recent ffmpeg version to be found in your `$PATH`): From c2174b8c8ae2640d317b7a8b202c8106dfd07fdd Mon Sep 17 00:00:00 2001 From: John Meyer <0x326@users.noreply.github.com> Date: Wed, 7 Sep 2016 13:30:10 -0400 Subject: [PATCH 4/5] Fix Typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 232e176..c799a9b 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ developers to write autonomous programs for the upcoming robot revolution. ## Status -This module is still under [heavy development](CONTRIBUTING.md), so please don't be suprised if +This module is still under [heavy development](CONTRIBUTING.md), so please don't be surprised if you find some functionality missing or undocumented. However, the documented parts are tested and should work well for most parts. From 1635e30f4373caae812270f895399cb7164a8ad8 Mon Sep 17 00:00:00 2001 From: John Meyer <0x326@users.noreply.github.com> Date: Wed, 7 Sep 2016 13:31:14 -0400 Subject: [PATCH 5/5] Update package.json --- package.json | 9 --------- 1 file changed, 9 deletions(-) diff --git a/package.json b/package.json index a681fdf..d7aefe0 100644 --- a/package.json +++ b/package.json @@ -34,17 +34,10 @@ "bugs": { "url": "https://github.com/felixge/node-ar-drone/issues" }, - "_id": "ar-drone@0.3.3", "dist": { "shasum": "d7b956e23f3f12d94a4e8b7a8f575b25cd69f69b", "tarball": "https://registry.npmjs.org/ar-drone/-/ar-drone-0.3.3.tgz" }, - "_from": "ar-drone@0.3.3", - "_npmVersion": "1.4.3", - "_npmUser": { - "name": "felixge", - "email": "felix@debuggable.com" - }, "maintainers": [ { "name": "felixge", @@ -80,6 +73,4 @@ } ], "directories": {}, - "_shasum": "d7b956e23f3f12d94a4e8b7a8f575b25cd69f69b", - "_resolved": "https://registry.npmjs.org/ar-drone/-/ar-drone-0.3.3.tgz" }