Skip to content

Instantly share code, notes, and snippets.

@klamping
Created May 30, 2013 19:36
Show Gist options
  • Save klamping/5680499 to your computer and use it in GitHub Desktop.
Save klamping/5680499 to your computer and use it in GitHub Desktop.
ARDrone Helper Methods
function moveForward (speed, duration, cb) {
client.front(speed);
setTimeout(function () {
client.stop();
cb();
}, duration);
}
function rotateTo(finalDirection, spinDirection, cb) {
// TODO set speed based on how much rotation is left
var rotationSpeed = 0.1;
// reset finalDirection if OOB
if (finalDirection > 180) {
// need to convert to -180
finalDirection = finalDirection - 360;
rotateTo(finalDirection, spinDirection, cb);
return false;
} else if (finalDirection < -180) {
// need to convert to 180
finalDirection = finalDirection + 360;
rotateTo(finalDirection, spinDirection, cb);
return false;
}
if (direction !== "unset" && ((direction > finalDirection) || (direction < finalDirection)) ) {
console.log(direction);
client[spinDirection](rotationSpeed);
setTimeout(function () {
rotateTo(finalDirection, spinDirection, cb);
}, 20);
} else {
client.stop();
setTimeout(cb, 200);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment