Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Initial commit

  • Loading branch information...
commit 33bb36ac2d79d50236cb5ea732198bad1ce3606e 0 parents
jornare authored
Showing with 135 additions and 0 deletions.
  1. +42 −0 README.md
  2. +91 −0 leapdrone.js
  3. +2 −0  node_modules/.gitignore
42 README.md
@@ -0,0 +1,42 @@
+LeapDrone
+=========
+
+To have this working, you need a LeapMotion controller (https://www.leapmotion.com/) and AR.Drone2.0 (http://ardrone2.parrot.com/)
+
+This code represents nothing new, as it has been done before, but it is my go at having these two gadgets in my hands for less than two hours.
+
+With nodejs (http://nodejs.org) it is super easy to get full control and a flying start with hours of coding gadgets fun!! :D
+
+
+To get started
+==============
+
+Install nodejs and npm (node package manager)
+
+Clone the repo
+
+>npm install leapjs
+
+>npm install ar-drone
+
+>node leapdrone.js
+
+When you start
+==============
+
+Be sure the drone is on and connected, the LeapMotion sensor is on and the Leap software running.
+
+Keep your one hand about 10cm above the sensor.
+
+Controls:
+=========
+
+Tilt hand left/right to fly left/right
+
+Tilt hand forwards/backwards to fly forwards/backwards
+
+Move hand to the left/right to turn left/right
+
+Klick a key on the keyboard or move the hand low to land
+
+Have fun!! :D
91 leapdrone.js
@@ -0,0 +1,91 @@
+var Leap = require('leapjs').Leap;
+var util = require('util');
+var arDrone = require('ar-drone');
+var drone = arDrone.createClient();
+var stdin = process.openStdin();
+require('tty').setRawMode(true);
+
+
+drone.disableEmergency();
+drone.takeoff();
+
+stdin.on('keypress', function(chunk, key) {
+ if(key && key.ctrl && key.name=='c') process.exit();
+ drone.land();
+});
+
+Leap.loop( function(frame, done) {
+ var hand = frame.hands[0];
+ if(hand){
+ util.print("\033[2J\033[0;0H");
+ var x=hand.palmPosition[0],
+ y =hand.palmPosition[1],
+ z=hand.palmPosition[2];
+ var pNx = hand.palmNormal[0],
+ pNy = hand.palmNormal[1],
+ pNz = hand.palmNormal[2];
+ var pDxr = hand.direction[0],
+ pDyr = hand.direction[1],
+ pDzr = hand.direction[2];
+
+ if(x<-50){
+ if(x<-100){
+ x=-100;
+ }
+ drone.counterClockwise(-x/100);
+ }else if(x>50){
+ if(x>100){
+ x=100;
+ }
+ drone.clockwise(x/100);
+ }else{
+ drone.clockwise(0);
+ }
+
+ if(y<80){
+ drone.land();
+ }
+ else if(y<250){
+ console.log('down ' + y);
+ var speed=(250-y)/200;
+ drone.down(speed);
+ }else if(y>320){
+ console.log('up ' + y);
+ var speed=(y-320)/200;
+ drone.up(speed);
+ }else{
+ console.log('steady ' + y);
+ }
+
+ if(pNx>0.3){
+ console.log('left '+pNx);
+ drone.left(pNx);
+ }else if(pNx<-0.3){
+ drone.right(-pNx);
+ console.log('right '+pNx);
+ }else{
+ console.log('steady'+pNx);
+ drone.left(0);
+ }
+
+ if(pNz>0.2){
+ console.log('forward '+pNz);
+ drone.front(pNz);
+ }else if(pNz<-0.2){
+ drone.back(-pNz);
+ console.log('backward '+pNz);
+ }else{
+ console.log('steady'+pNz);
+ drone.back(0);
+ }
+
+
+
+ //console.log(hand);
+
+ //console.log(hand.palmPosition[1]);
+ }
+
+
+ done();
+});
2  node_modules/.gitignore
@@ -0,0 +1,2 @@
+ar-drone
+leapjs
Please sign in to comment.
Something went wrong with that request. Please try again.