Page 1 of 1

Defining a new controller

Posted: Wed Jun 18, 2014 8:48 pm
by cemart01
I'm trying to use the Leap to fly the crazyflie, and although I found the instructions to use Leap4Joy, I couldn't get it to work. I was wondering if it would be difficult just to use the python scripts for the Leap to define a new controller within the cfclient. I also don't know where to begin with this, since the limited definitions in the cfclient part of the repository don't make much sense to me. Can anyone offer any guidance on how to go about defining a new controller?

Someone previously linked this as helpful, but I'm not sure how. https://github.com/openleap/PyLeapMouse ... Control.py

Re: Defining a new controller

Posted: Mon Jun 23, 2014 12:30 pm
by marcus
Hi,

We have done some tests with the LeapMotion so there's code available that should work on this branch and there's also a blog post about it here.

The implementation is done by switching out the pygamereader.py with a leapreader.py. These input-device "drivers" are polled at a predefined interval (I think it's 10ms). For the pygamereader when the reading is done the events from PyGame is processed and values are returned. For the Leap things are done a little bit different. Since the output from the Leap is acquired though callbacks, these callbacks directly alter the values that will be returned when reading. So the Leap might update the values faster or slower than 100Hz, but the values are still read at 100Hz.

Re: Defining a new controller

Posted: Mon Jun 23, 2014 7:57 pm
by cemart01
I've looked through those and the hacks page, and I can't make it work. Did it end up using the Leap4Joy and VJoy piece?

Re: Defining a new controller

Posted: Tue Jun 24, 2014 8:24 am
by marcus
No, the flying we are doing in the video is using the code in the repo. We haven't tried any other apps/libs.

What issues are you having with the code? I have some recollection of an API change in the Leap API a while back and I'm not sure the code has been updated for that.

Re: Defining a new controller

Posted: Tue Jun 24, 2014 7:39 pm
by cemart01
When I try to run the cfclient file with ./ it asks me to choose an application to run it. When I try to do it with the python compiler, it tells me that it can't run because I don't have pyusb installed (which I do).