Skip to content

Instantly share code, notes, and snippets.

@agrublev
Last active June 24, 2018 20:52
Show Gist options
  • Save agrublev/e984521faf43d934b7064a316673557d to your computer and use it in GitHub Desktop.
Save agrublev/e984521faf43d934b7064a316673557d to your computer and use it in GitHub Desktop.
drone FORK!
const pdrone = require('pdrone');
const drone = pdrone({id: 'mambo', debug: false});
/** Helper function */
function sleep(ms) {
return new Promise(a => setTimeout(a, ms));
}
drone.on('connected', async () => {
// drone.flatTrim(); // use flatTrim() everytime you want the drone to calm down
drone.takeOff();
await sleep(1000);
drone.fly({
roll: 0, // -100/100 negative is left positive is rogjt
pitch: 0, // -100/100 positive forward negative back
yaw: 0, // -100/100 100 yar is 90 degree rotation
gaz: 100, // -100/100, = throttle GOES UP
});
await sleep(1000);
drone.fly({
roll: 0, // -100/100
pitch: 0, // -100/100
yaw: 0, // -100/100
gaz: 0, // -100/100, = throttle
});
// drone.autoTakeOff(); // will start propellers in low mode and wait for you to throw it in the air (gently)
// drone.flip({direction: 'right'}); // front/back/right/left
await sleep(3000);
drone.flatTrim();
drone.land();
await sleep(1000);
drone.emergency(); // immediately stops the drone, that's what is inside stop.js
await sleep(1000);
process.exit();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment