Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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();
- });
Add Comment
Please, Sign In to add comment