-
-
Save saval/0526f7462436bdfe2c53083ffe59729a to your computer and use it in GitHub Desktop.
drone FORK!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(300); | |
//jumping up-down | |
drone.fly({ | |
roll: 0, // -100/100 | |
pitch: 0, // -100/100 | |
yaw: 0, // -100/100 | |
gaz: -50, // -100/100, = throttle | |
}); | |
await sleep(300); | |
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: 50, // -100/100, = throttle GOES UP | |
}); | |
await sleep(300); | |
drone.fly({ | |
roll: 0, // -100/100 | |
pitch: 0, // -100/100 | |
yaw: 0, // -100/100 | |
gaz: -50, // -100/100, = throttle | |
}); | |
await sleep(300); | |
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: 50, // -100/100, = throttle GOES UP | |
}); | |
await sleep(300); | |
drone.fly({ | |
roll: 0, // -100/100 | |
pitch: 0, // -100/100 | |
yaw: 0, // -100/100 | |
gaz: -50, // -100/100, = throttle | |
}); | |
await sleep(300); | |
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: 50, // -100/100, = throttle GOES UP | |
}); | |
await sleep(300); | |
drone.fly({ | |
roll: 0, // -100/100 | |
pitch: 0, // -100/100 | |
yaw: 0, // -100/100 | |
gaz: -50, // -100/100, = throttle | |
}); | |
await sleep(300); | |
//dancing left - right | |
drone.fly({ | |
roll: -50, // -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: 0, // -100/100, = throttle GOES UP | |
}); | |
await sleep(300); | |
drone.fly({ | |
roll: 100, // -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: 0, // -100/100, = throttle GOES UP | |
}); | |
await sleep(300); | |
drone.fly({ | |
roll: -100, // -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: 0, // -100/100, = throttle GOES UP | |
}); | |
await sleep(300); | |
drone.fly({ | |
roll: 100, // -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: 0, // -100/100, = throttle GOES UP | |
}); | |
await sleep(300); | |
drone.fly({ | |
roll: -50, // -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: 0, // -100/100, = throttle GOES UP | |
}); | |
await sleep(300); | |
//rotation | |
drone.fly({ | |
roll: 0, // -100/100 negative is left positive is rogjt | |
pitch: 0, // -100/100 positive forward negative back | |
yaw: 100, // -100/100 100 yar is 90 degree rotation | |
gaz: 0, // -100/100, = throttle GOES UP | |
}); | |
drone.fly({ | |
roll: 0, // -100/100 negative is left positive is rogjt | |
pitch: 0, // -100/100 positive forward negative back | |
yaw: 100, // -100/100 100 yar is 90 degree rotation | |
gaz: 0, // -100/100, = throttle GOES UP | |
}); | |
drone.fly({ | |
roll: 0, // -100/100 negative is left positive is rogjt | |
pitch: 0, // -100/100 positive forward negative back | |
yaw: 100, // -100/100 100 yar is 90 degree rotation | |
gaz: 0, // -100/100, = throttle GOES UP | |
}); | |
drone.fly({ | |
roll: 0, // -100/100 negative is left positive is rogjt | |
pitch: 0, // -100/100 positive forward negative back | |
yaw: 100, // -100/100 100 yar is 90 degree rotation | |
gaz: 0, // -100/100, = throttle GOES UP | |
}); | |
//revert direction rotation | |
drone.fly({ | |
roll: 0, // -100/100 negative is left positive is rogjt | |
pitch: 0, // -100/100 positive forward negative back | |
yaw: -100, // -100/100 100 yar is 90 degree rotation | |
gaz: 0, // -100/100, = throttle GOES UP | |
}); | |
drone.fly({ | |
roll: 0, // -100/100 negative is left positive is rogjt | |
pitch: 0, // -100/100 positive forward negative back | |
yaw: -100, // -100/100 100 yar is 90 degree rotation | |
gaz: 0, // -100/100, = throttle GOES UP | |
}); | |
drone.fly({ | |
roll: 0, // -100/100 negative is left positive is rogjt | |
pitch: 0, // -100/100 positive forward negative back | |
yaw: -100, // -100/100 100 yar is 90 degree rotation | |
gaz: 0, // -100/100, = throttle GOES UP | |
}); | |
drone.fly({ | |
roll: 0, // -100/100 negative is left positive is rogjt | |
pitch: 0, // -100/100 positive forward negative back | |
yaw: -100, // -100/100 100 yar is 90 degree rotation | |
gaz: 0, // -100/100, = throttle GOES UP | |
}); | |
drone.flatTrim(); | |
//moving by diagonal | |
drone.fly({ | |
roll: -50, // -100/100 negative is left positive is rogjt | |
pitch: 50, // -100/100 positive forward negative back | |
yaw: 0, // -100/100 100 yar is 90 degree rotation | |
gaz: 0, // -100/100, = throttle GOES UP | |
}); | |
await sleep(300); | |
drone.fly({ | |
roll: 100, // -100/100 negative is left positive is rogjt | |
pitch: -100, // -100/100 positive forward negative back | |
yaw: 0, // -100/100 100 yar is 90 degree rotation | |
gaz: 0, // -100/100, = throttle GOES UP | |
}); | |
await sleep(300); | |
drone.fly({ | |
roll: -100, // -100/100 negative is left positive is rogjt | |
pitch: 100, // -100/100 positive forward negative back | |
yaw: 0, // -100/100 100 yar is 90 degree rotation | |
gaz: 0, // -100/100, = throttle GOES UP | |
}); | |
await sleep(300); | |
drone.fly({ | |
roll: 50, // -100/100 negative is left positive is rogjt | |
pitch: -50, // -100/100 positive forward negative back | |
yaw: 0, // -100/100 100 yar is 90 degree rotation | |
gaz: 0, // -100/100, = throttle GOES UP | |
}); | |
await sleep(300); | |
drone.flatTrim(); | |
drone.fly({ | |
roll: 50, // -100/100 negative is left positive is rogjt | |
pitch: -50, // -100/100 positive forward negative back | |
yaw: 0, // -100/100 100 yar is 90 degree rotation | |
gaz: 0, // -100/100, = throttle GOES UP | |
}); | |
await sleep(300); | |
drone.fly({ | |
roll: -100, // -100/100 negative is left positive is rogjt | |
pitch: 100, // -100/100 positive forward negative back | |
yaw: 0, // -100/100 100 yar is 90 degree rotation | |
gaz: 0, // -100/100, = throttle GOES UP | |
}); | |
await sleep(300); | |
drone.fly({ | |
roll: 100, // -100/100 negative is left positive is rogjt | |
pitch: -100, // -100/100 positive forward negative back | |
yaw: 0, // -100/100 100 yar is 90 degree rotation | |
gaz: 0, // -100/100, = throttle GOES UP | |
}); | |
await sleep(300); | |
drone.fly({ | |
roll: -50, // -100/100 negative is left positive is rogjt | |
pitch: 50, // -100/100 positive forward negative back | |
yaw: 0, // -100/100 100 yar is 90 degree rotation | |
gaz: 0, // -100/100, = throttle GOES UP | |
}); | |
await sleep(300); | |
drone.flatTrim(); | |
// 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(1000); | |
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