Guest User

Untitled

a guest
Jun 25th, 2018
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.37 KB | None | 0 0
  1. const pdrone = require('pdrone');
  2. const drone = pdrone({id: 'mambo', debug: false});
  3. /** Helper function */
  4. function sleep(ms) {
  5. return new Promise(a => setTimeout(a, ms));
  6. }
  7.  
  8. drone.on('connected', async () => {
  9.  
  10. // drone.flatTrim(); // use flatTrim() everytime you want the drone to calm down
  11. drone.takeOff();
  12. await sleep(1000);
  13.  
  14. drone.fly({
  15. roll: 0, // -100/100 negative is left positive is rogjt
  16. pitch: 0, // -100/100 positive forward negative back
  17. yaw: 0, // -100/100 100 yar is 90 degree rotation
  18. gaz: 100, // -100/100, = throttle GOES UP
  19. });
  20. await sleep(300);
  21.  
  22. //jumping up-down
  23. drone.fly({
  24. roll: 0, // -100/100
  25. pitch: 0, // -100/100
  26. yaw: 0, // -100/100
  27. gaz: -50, // -100/100, = throttle
  28. });
  29. await sleep(300);
  30.  
  31. drone.fly({
  32. roll: 0, // -100/100 negative is left positive is rogjt
  33. pitch: 0, // -100/100 positive forward negative back
  34. yaw: 0, // -100/100 100 yar is 90 degree rotation
  35. gaz: 50, // -100/100, = throttle GOES UP
  36. });
  37. await sleep(300);
  38.  
  39. drone.fly({
  40. roll: 0, // -100/100
  41. pitch: 0, // -100/100
  42. yaw: 0, // -100/100
  43. gaz: -50, // -100/100, = throttle
  44. });
  45. await sleep(300);
  46.  
  47. drone.fly({
  48. roll: 0, // -100/100 negative is left positive is rogjt
  49. pitch: 0, // -100/100 positive forward negative back
  50. yaw: 0, // -100/100 100 yar is 90 degree rotation
  51. gaz: 50, // -100/100, = throttle GOES UP
  52. });
  53. await sleep(300);
  54.  
  55. drone.fly({
  56. roll: 0, // -100/100
  57. pitch: 0, // -100/100
  58. yaw: 0, // -100/100
  59. gaz: -50, // -100/100, = throttle
  60. });
  61. await sleep(300);
  62.  
  63. drone.fly({
  64. roll: 0, // -100/100 negative is left positive is rogjt
  65. pitch: 0, // -100/100 positive forward negative back
  66. yaw: 0, // -100/100 100 yar is 90 degree rotation
  67. gaz: 50, // -100/100, = throttle GOES UP
  68. });
  69. await sleep(300);
  70.  
  71. drone.fly({
  72. roll: 0, // -100/100
  73. pitch: 0, // -100/100
  74. yaw: 0, // -100/100
  75. gaz: -50, // -100/100, = throttle
  76. });
  77. await sleep(300);
  78.  
  79. //dancing left - right
  80. drone.fly({
  81. roll: -50, // -100/100 negative is left positive is rogjt
  82. pitch: 0, // -100/100 positive forward negative back
  83. yaw: 0, // -100/100 100 yar is 90 degree rotation
  84. gaz: 0, // -100/100, = throttle GOES UP
  85. });
  86. await sleep(300);
  87.  
  88. drone.fly({
  89. roll: 100, // -100/100 negative is left positive is rogjt
  90. pitch: 0, // -100/100 positive forward negative back
  91. yaw: 0, // -100/100 100 yar is 90 degree rotation
  92. gaz: 0, // -100/100, = throttle GOES UP
  93. });
  94. await sleep(300);
  95.  
  96. drone.fly({
  97. roll: -100, // -100/100 negative is left positive is rogjt
  98. pitch: 0, // -100/100 positive forward negative back
  99. yaw: 0, // -100/100 100 yar is 90 degree rotation
  100. gaz: 0, // -100/100, = throttle GOES UP
  101. });
  102. await sleep(300);
  103.  
  104. drone.fly({
  105. roll: 100, // -100/100 negative is left positive is rogjt
  106. pitch: 0, // -100/100 positive forward negative back
  107. yaw: 0, // -100/100 100 yar is 90 degree rotation
  108. gaz: 0, // -100/100, = throttle GOES UP
  109. });
  110. await sleep(300);
  111.  
  112. drone.fly({
  113. roll: -50, // -100/100 negative is left positive is rogjt
  114. pitch: 0, // -100/100 positive forward negative back
  115. yaw: 0, // -100/100 100 yar is 90 degree rotation
  116. gaz: 0, // -100/100, = throttle GOES UP
  117. });
  118. await sleep(300);
  119.  
  120. //rotation
  121. drone.fly({
  122. roll: 0, // -100/100 negative is left positive is rogjt
  123. pitch: 0, // -100/100 positive forward negative back
  124. yaw: 100, // -100/100 100 yar is 90 degree rotation
  125. gaz: 0, // -100/100, = throttle GOES UP
  126. });
  127. drone.fly({
  128. roll: 0, // -100/100 negative is left positive is rogjt
  129. pitch: 0, // -100/100 positive forward negative back
  130. yaw: 100, // -100/100 100 yar is 90 degree rotation
  131. gaz: 0, // -100/100, = throttle GOES UP
  132. });
  133. drone.fly({
  134. roll: 0, // -100/100 negative is left positive is rogjt
  135. pitch: 0, // -100/100 positive forward negative back
  136. yaw: 100, // -100/100 100 yar is 90 degree rotation
  137. gaz: 0, // -100/100, = throttle GOES UP
  138. });
  139. drone.fly({
  140. roll: 0, // -100/100 negative is left positive is rogjt
  141. pitch: 0, // -100/100 positive forward negative back
  142. yaw: 100, // -100/100 100 yar is 90 degree rotation
  143. gaz: 0, // -100/100, = throttle GOES UP
  144. });
  145.  
  146. //revert direction rotation
  147. drone.fly({
  148. roll: 0, // -100/100 negative is left positive is rogjt
  149. pitch: 0, // -100/100 positive forward negative back
  150. yaw: -100, // -100/100 100 yar is 90 degree rotation
  151. gaz: 0, // -100/100, = throttle GOES UP
  152. });
  153. drone.fly({
  154. roll: 0, // -100/100 negative is left positive is rogjt
  155. pitch: 0, // -100/100 positive forward negative back
  156. yaw: -100, // -100/100 100 yar is 90 degree rotation
  157. gaz: 0, // -100/100, = throttle GOES UP
  158. });
  159. drone.fly({
  160. roll: 0, // -100/100 negative is left positive is rogjt
  161. pitch: 0, // -100/100 positive forward negative back
  162. yaw: -100, // -100/100 100 yar is 90 degree rotation
  163. gaz: 0, // -100/100, = throttle GOES UP
  164. });
  165. drone.fly({
  166. roll: 0, // -100/100 negative is left positive is rogjt
  167. pitch: 0, // -100/100 positive forward negative back
  168. yaw: -100, // -100/100 100 yar is 90 degree rotation
  169. gaz: 0, // -100/100, = throttle GOES UP
  170. });
  171.  
  172. drone.flatTrim();
  173.  
  174. //moving by diagonal
  175. drone.fly({
  176. roll: -50, // -100/100 negative is left positive is rogjt
  177. pitch: 50, // -100/100 positive forward negative back
  178. yaw: 0, // -100/100 100 yar is 90 degree rotation
  179. gaz: 0, // -100/100, = throttle GOES UP
  180. });
  181. await sleep(300);
  182.  
  183. drone.fly({
  184. roll: 100, // -100/100 negative is left positive is rogjt
  185. pitch: -100, // -100/100 positive forward negative back
  186. yaw: 0, // -100/100 100 yar is 90 degree rotation
  187. gaz: 0, // -100/100, = throttle GOES UP
  188. });
  189. await sleep(300);
  190.  
  191. drone.fly({
  192. roll: -100, // -100/100 negative is left positive is rogjt
  193. pitch: 100, // -100/100 positive forward negative back
  194. yaw: 0, // -100/100 100 yar is 90 degree rotation
  195. gaz: 0, // -100/100, = throttle GOES UP
  196. });
  197. await sleep(300);
  198.  
  199. drone.fly({
  200. roll: 50, // -100/100 negative is left positive is rogjt
  201. pitch: -50, // -100/100 positive forward negative back
  202. yaw: 0, // -100/100 100 yar is 90 degree rotation
  203. gaz: 0, // -100/100, = throttle GOES UP
  204. });
  205. await sleep(300);
  206.  
  207. drone.flatTrim();
  208.  
  209. drone.fly({
  210. roll: 50, // -100/100 negative is left positive is rogjt
  211. pitch: -50, // -100/100 positive forward negative back
  212. yaw: 0, // -100/100 100 yar is 90 degree rotation
  213. gaz: 0, // -100/100, = throttle GOES UP
  214. });
  215. await sleep(300);
  216.  
  217. drone.fly({
  218. roll: -100, // -100/100 negative is left positive is rogjt
  219. pitch: 100, // -100/100 positive forward negative back
  220. yaw: 0, // -100/100 100 yar is 90 degree rotation
  221. gaz: 0, // -100/100, = throttle GOES UP
  222. });
  223. await sleep(300);
  224.  
  225. drone.fly({
  226. roll: 100, // -100/100 negative is left positive is rogjt
  227. pitch: -100, // -100/100 positive forward negative back
  228. yaw: 0, // -100/100 100 yar is 90 degree rotation
  229. gaz: 0, // -100/100, = throttle GOES UP
  230. });
  231. await sleep(300);
  232.  
  233. drone.fly({
  234. roll: -50, // -100/100 negative is left positive is rogjt
  235. pitch: 50, // -100/100 positive forward negative back
  236. yaw: 0, // -100/100 100 yar is 90 degree rotation
  237. gaz: 0, // -100/100, = throttle GOES UP
  238. });
  239. await sleep(300);
  240.  
  241. drone.flatTrim();
  242.  
  243. // drone.autoTakeOff(); // will start propellers in low mode and wait for you to throw it in the air (gently)
  244. // drone.flip({direction: 'right'}); // front/back/right/left
  245. await sleep(1000);
  246. drone.flatTrim();
  247. drone.land();
  248. await sleep(1000);
  249. drone.emergency(); // immediately stops the drone, that's what is inside stop.js
  250. await sleep(1000);
  251. process.exit();
  252.  
  253.  
  254.  
  255. });
Add Comment
Please, Sign In to add comment