Comparar commits
13 Commits
release-0.1.0
...
master
| Autor | SHA1 | Data | |
|---|---|---|---|
| 926a0ee8be | |||
| 2b4fa6b758 | |||
| 95b94ff535 | |||
| 989d3ee403 | |||
| ec57cbc21f | |||
| b230b89265 | |||
| 5fce22acea | |||
| d5173f4c87 | |||
| 2191dc0d08 | |||
| 8831db6a99 | |||
| a81fb37923 | |||
| 9cf848b816 | |||
| c23f0f4bd7 |
@@ -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
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -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
@@ -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
@@ -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",
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário