Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Takeoff fallback and Fix Typos #136

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SHELL := /bin/bash

test:
npm test
npm test

.PHONY: test
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
14 changes: 13 additions & 1 deletion lib/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down
8 changes: 4 additions & 4 deletions lib/navdata/parseNavdata.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
50 changes: 48 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{
"author": "Felix Geisendörfer <[email protected]> (http://debuggable.com/)",
"author": {
"name": "Felix Geisendörfer",
"email": "[email protected]",
"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",
Expand All @@ -26,5 +30,47 @@
"optionalDependencies": {},
"engines": {
"node": "*"
}
},
"bugs": {
"url": "https://github.com/felixge/node-ar-drone/issues"
},
"dist": {
"shasum": "d7b956e23f3f12d94a4e8b7a8f575b25cd69f69b",
"tarball": "https://registry.npmjs.org/ar-drone/-/ar-drone-0.3.3.tgz"
},
"maintainers": [
{
"name": "felixge",
"email": "[email protected]"
},
{
"name": "bkw",
"email": "[email protected]"
},
{
"name": "jfsiii",
"email": "[email protected]"
},
{
"name": "fractal",
"email": "[email protected]"
},
{
"name": "eschnou",
"email": "[email protected]"
},
{
"name": "andrewnez",
"email": "[email protected]"
},
{
"name": "wiseman",
"email": "[email protected]"
},
{
"name": "rschmukler",
"email": "[email protected]"
}
],
"directories": {},
}