Sunday, 14 July 2013

Quadricopter training school!

Controlling a quadricopter with a computer joystick is cool, but controlling it with two joysticks doubles the fun! The goal here is of course to use the Wi-Fi transmission system as a way to teach people how to fly.

Maverick feels good about it
Here is how it works:
  • On the ground, two joysticks are connected to the transmitter computer (the laptop or the Raspberry Pi as explained in a previous post)
  • One joystick goes to the "instructor" (me!) and the other one to the "student"
  • The instructor can take total control of the aircraft at any time by holding a particular button down. 
  • When this button is not held, the commands are shared between the instructor and the student. The student is assigned a well defined subset of the 4 basic commands: throttle, rudder, elevators, ailerons. The instructor is implicetly assigned the remaining commands.
Here's a concrete example: let say we're at the beginning of the "training". I set up the transmitter so the student is only given one command on his joystick, say the elevators. His goal is to understand its effects on the aircraft (basically it makes the aircraft lean forward and backward). This means that while he's concentrating on it, the instructor (still me!) has to handle the three other commands (throttle, rudder and ailerons). Typically I'll try my best to hover a meter or two above ground as steadily as possible, so the role of the elevators in this examples is clear to the student.

After a while, when the student appears to be comfortable with a command, I give him another one to try (combinations are possible).

Of course, if he makes a mistake and the aircraft starts going nuts, I can take back full control with the push of a button! 

Here's my 6-step weight loss training program. 
Joysticks are using RC Mode 2 layout

  1. Elevators only (pitch)
  2. Elevators and ailerons (roll). The whole right stick on the controller.
  3. Throttle only
  4. Throttle and rudder (yaw). The whole left stick.
  5. Rudder, elevators and ailerons
  6. EVERYTHING!
The whole experiment took place with three different guinea pigs (thanks Daniel, Cédric and Cécile!) and it worked like a charm! Well almost... only a single benign crash at step 6 :) I won't give names!

Here are some photos and footage!






Trois, deux, un, go!




Saturday, 13 July 2013

Oculus Rift, servo-controlled camera and a bit of Raspberry Pi

I got my hands on an Oculus Rift this week (thanks Paul!). The OVR SDK is really neat and clean!

This is what I've done so far:


This runs on my desktop PC. Just out of curiosity, I tried the OVR SDK on the Raspberry Pi as well.

The ARM architecture isn't officially supported by the Oculus guys but it compiled almost OK. The only thing I had to change was a bit of assembler code. As far as understand, the "dmb" instruction doesn't exist on armv6 (which is the Pi's instruction set). After a bit of research, here is the black magic alternative I've found:

In file Kernel/OVR_Atomic.h, struct AtomicOpsRawBase (around line 100):

#elif defined(OVR_CPU_ARM)
// http://www.jonmasters.org/blog/2012/11/13/arm-atomic-operations/
#define MB()  __asm__ __volatile__ ("mcr p15, 0, r0, c7, c10, 5" : : : "memory")

struct FullSync { inline FullSync() { MB(); } ~FullSync() { MB(); } };
struct AcquireSync { inline AcquireSync() { } ~AcquireSync() { MB(); } };
struct ReleaseSync { inline ReleaseSync() { MB(); } };

Another thing I didn't fix was the name of the output directory for the lib which is still "i386".

Unfortunately, the OculusWorldDemo doesn't work. First, it doesn't find the HMD device. Also there seems to be a more global issue with X11+OpenGL on the Raspberry Pi. I haven't had a chance to look at that yet.

On the good side though, the Sensor is properly detected, and by adding few lines to the initialization code, I could get some readings...  (oh and thanks Synergy for the remote mouse! Instructions to build it for the Pi here)


The Sensor is not particularly useful on its own, but that means that the servo-controlled camera test above would also work on the Pi.

Now I need to work on displaying useful stuff on the Rift.You've probably guessed where this is all going...