13 Commits

Autor SHA1 Mensagem Data
Laurent Eschenauer 926a0ee8be Updated micro revision 2014-01-10 09:30:44 +01:00
Laurent Eschenauer 2b4fa6b758 Closes issue #3. 2014-01-10 09:29:48 +01:00
Laurent Eschenauer 95b94ff535 Merge pull request #4 from premasagar/patch-1
Fix syntax error in README
2013-10-26 11:48:40 -07:00
Premasagar Rose 989d3ee403 Fix syntax error in README 2013-10-04 14:48:16 +01:00
Laurent Eschenauer ec57cbc21f New release to npm and added changelog 2013-09-01 21:39:32 +02:00
Laurent Eschenauer b230b89265 Added example of square with cw(90) 2013-09-01 21:32:40 +02:00
Laurent Eschenauer 5fce22acea Added ctrl-c logic to examples 2013-09-01 21:32:28 +02:00
Laurent Eschenauer d5173f4c87 Missing callback on go 2013-09-01 21:32:15 +02:00
Laurent Eschenauer 2191dc0d08 Be coherent, yaw always expressed in degrees in the API 2013-08-30 22:09:29 +02:00
Laurent Eschenauer 8831db6a99 Attempt to fix yaw issues 2013-08-30 22:03:17 +02:00
Laurent Eschenauer a81fb37923 Fixed yaw error normalization issue 2013-08-30 16:36:07 +02:00
Laurent Eschenauer 9cf848b816 Yaw error normalization was happening at the wrong place
Duh! This probably was the cause of issue #2, I haven't tested the fix
in a real situation yet.
2013-08-30 10:38:25 +02:00
Laurent Eschenauer c23f0f4bd7 Update README.md 2013-08-30 10:11:28 +02:00
7 arquivos alterados com 157 adições e 20 exclusões
+15
Ver Arquivo
@@ -0,0 +1,15 @@
# Changes
This file is a manually maintained list of changes for each release. Feel free
to send corrections if you spot any mistakes.
## v0.1.1 (2013-09-01)
* Fixed issue with cw/ccw yaw rotation
* Fixed issue with improper yaw reset on some moves
* Added ctrl-c logic to example for emegency landing
## v0.1.0 (2013-08-23)
* Initial release to npm
+6 -2
Ver Arquivo
@@ -57,7 +57,7 @@ mission.takeoff()
.hover(1000) // Hover in place for 1 second
.land();
mission.run(function (err, result)
mission.run(function (err, result) {
if (err) {
console.trace("Oops, something bad happened: %s", err.message);
mission.client().stop();
@@ -110,11 +110,15 @@ Add a wait step to the mission. Will wait for the given delay (in ms) before pro
Add a movement step to the mission. Will go the given position before proceeding to next step. The position is a Controller goal such as {x: 0, y: 0, z: 1, yaw: 90}.
### mission.task(function)
#### mission.task(function(callback){..})
Add a task step to the mission. Will execute the provided function before proceeding to the next step. A callback argument is passed to the function, it should be called when the
task is done.
#### mission.taskSync(function)
Add a task step to the mission. Will execute the provided function before proceeding to the next step.
#### mission.zero()
Add a zeroing step to the mission. This will set the current position/orientation as
+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);
+71
Ver Arquivo
@@ -0,0 +1,71 @@
var df = require('dateformat')
, autonomy = require('../')
, arDrone = require('ar-drone')
, arDroneConstants = require('ar-drone/lib/constants')
, mission = autonomy.createMission()
;
function navdata_option_mask(c) {
return 1 << c;
}
// From the SDK.
var navdata_options = (
navdata_option_mask(arDroneConstants.options.DEMO)
| navdata_option_mask(arDroneConstants.options.VISION_DETECT)
| navdata_option_mask(arDroneConstants.options.MAGNETO)
| 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)
.altitude(2)
.forward(2)
.cw(90)
.forward(2)
.cw(90)
.forward(2)
.cw(90)
.forward(2)
.go({x:0, y:0})
.hover(500)
.land();
// Execute mission
mission.run(function (err, result) {
if (err) {
console.trace("Oops, something bad happened: %s", err.message);
mission.client().stop();
mission.client().land();
} else {
console.log("We are done!");
process.exit(0);
}
});
+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);
+27 -16
Ver Arquivo
@@ -55,7 +55,7 @@ function Controller(client, options) {
// Register the listener on navdata for our control loop
var self = this;
client.on('navdata', function(d) {
if (!this._busy) {
if (!this._busy && d.demo) {
this._busy = true;
self._processNavdata(d);
self._control(d);
@@ -97,7 +97,7 @@ Controller.prototype.state = function() {
* Sets the goal to the current state and attempt to hover on top.
*/
Controller.prototype.hover = function() {
this.go({x: this._state.x, y: this._state.y, z: this._state.z, yaw: this._state.yaw});
this._go({x: this._state.x, y: this._state.y, z: this._state.z, yaw: this._state.yaw});
}
/*
@@ -125,7 +125,7 @@ Controller.prototype.forward = function(distance, callback) {
var gy = state.y + Math.sin(state.yaw) * distance;
// Assign the new goal
this.go({x: gx, y: gy, z: state.z, yaw: state.yaw}, callback);
this._go({x: gx, y: gy, z: state.z, yaw: state.yaw}, callback);
}
/*
@@ -148,7 +148,7 @@ Controller.prototype.right = function(distance, callback) {
var gy = state.y + Math.cos(state.yaw) * distance;
// Assign the new goal
this.go({x: gx, y: gy, z: state.z, yaw: state.yaw}, callback);
this._go({x: gx, y: gy, z: state.z, yaw: state.yaw}, callback);
}
/*
@@ -165,13 +165,13 @@ Controller.prototype.left = function(distance, callback) {
*/
Controller.prototype.cw = function(angle, callback) {
var state = this.state();
var yaw = state.yaw.toDeg();
var yaw = state.yaw.toDeg() + angle;
return this.go({x: state.x, y: state.y, z: state.z, yaw: yaw + angle}, callback);
return this._go({x: state.x, y: state.y, z: state.z, yaw: yaw.toRad()}, callback);
}
/*
* Turn counter clockwise of the given angle
* Turn counter clockwise of the given angle (in degrees)
*/
Controller.prototype.ccw = function(angle, callback) {
return this.cw(-angle, callback);
@@ -182,7 +182,7 @@ Controller.prototype.ccw = function(angle, callback) {
*/
Controller.prototype.up = function(distance, callback) {
var state = this.state();
return this.go({x: state.x, y: state.y, z: state.z + distance, yaw: state.yaw}, callback);
return this._go({x: state.x, y: state.y, z: state.z + distance, yaw: state.yaw}, callback);
}
/*
@@ -197,22 +197,33 @@ Controller.prototype.down = function(distance, callback) {
*/
Controller.prototype.altitude = function(altitude, callback) {
var state = this.state();
return this.go({x: state.x, y: state.y, z: altitude, yaw: state.yaw}, callback);
return this._go({x: state.x, y: state.y, z: altitude, yaw: state.yaw}, callback);
}
/*
* Go to the target yaw
* Go to the target yaw (argument in degree)
*/
Controller.prototype.yaw = function(yaw, callback) {
var state = this.state();
return this.go({x: state.x, y: state.y, z: state.z, yaw: yaw}, callback);
return this._go({x: state.x, y: state.y, z: state.z, yaw: yaw.toRad()}, callback);
}
/*
* Sets a new goal and enable the controller. When the goal
* is reached, the callback is called with the current state.
*
* x,y,z in meters
* yaw in degrees
*/
Controller.prototype.go = function(goal, callback) {
if (goal.yaw != undefined) {
goal.yaw = goal.yaw.toRad();
}
return this._go(goal, callback);
}
Controller.prototype._go = function(goal, callback) {
// Since we are going to modify goal settings, we
// disable the controller, just in case.
this.disable();
@@ -223,7 +234,7 @@ Controller.prototype.go = function(goal, callback) {
// Normalize the yaw, to make sure we don't spin 360deg for
// nothing :-)
if (goal.yaw != undefined) {
var yaw = goal.yaw.toRad();
var yaw = goal.yaw;
goal.yaw = Math.atan2(Math.sin(yaw),Math.cos(yaw));
}
@@ -298,6 +309,10 @@ Controller.prototype._control = function(d) {
, eyaw = (this._goal.yaw != undefined) ? this._goal.yaw - this._state.yaw : 0
;
// Normalize eyaw within [-180, 180]
while(eyaw < -Math.PI) eyaw += (2 * Math.PI);
while(eyaw > Math.PI) eyaw -= (2 * Math.PI);
// Check if we are within the target area
if ((Math.abs(ex) < EPS_LIN) && (Math.abs(ey) < EPS_LIN) && (Math.abs(ez) < EPS_ALT) && (Math.abs(eyaw) < EPS_ANG)) {
// Have we been here before ?
@@ -330,10 +345,6 @@ Controller.prototype._control = function(d) {
}
}
// Normalize eyaw within [-180, 180]
while(eyaw < Math.PI/2) eyaw += Math.PI;
while(eyaw >= Math.PI/2) eyaw -= Math.PI;
// Get Raw command from PID
var ux = this._pid_x.getCommand(ex);
var uy = this._pid_y.getCommand(ey);
+2 -2
Ver Arquivo
@@ -1,6 +1,6 @@
{
"name": "ardrone-autonomy",
"version": "0.1.0",
"version": "0.1.2",
"description": "Building blocks for autonomous flying an AR.Drone.",
"repository": {
"type": "git",
@@ -20,7 +20,7 @@
},
"dependencies": {
"sylvester": "0.0.21",
"async": "~0.2.9"
"async": "0.2.9"
},
"devDependencies": {
"utest": "0.0.6",