Head Tracker

It's taken a little while, but I have managed to build a 3 axis headtracker using a PICAXE 08M2, the um-FPU V2 maths co-processor and a Pololu IMU-9 inertial measurement unit.

DSCF8860.jpg

The small circuit board at the top is the IMU. Other chips are fairly obvious. During construction I grafted on additional wires to allow the um-FPU to be programmed remotely - these have been removed for the picture.

** Have noticed only one picture is allowed - Ian **

Headtracker mounted on VR goggles. Note sticky tape strain relief for cables!

The IMU consists of a 3 axis gyroscope, 3 axis accelerometer and 3 axis magnetometer, on a small PCB with some voltage regulators and through-holes for soldering onto header pins. This allows it to be interfaced fairly painlessly with the PICAXE via the I2C interface.

In use the PICAXE harvests the accelo and magno data from the IMU, and uploads it to the um-FPU, which works out the absolute angles xy, xz and yz. The PICAXE also works out what quadrant the angles lie in (as the V2 cannot work this out on its own). The PICAXE then gets the gyro data from the IMU and uploads it to the FPU, where it is integrated to give an instantaneous reading. The end results are readings around all three axes, using the gyro readings (which are nice and smooth, but not referenced to the absolute readings), and a small contribution from the accelo/magno readings (which stop the end results from wandering too far away from the absolute values).

The PICAXE also applies a centering routine which allows the readings to be centred at a particular orientation. The serial download cable is used to send the output bytes back to the PC (one FF sync byte, and 3 0-FE positional bytes, one for each axis), where they are picked up by a program called PPJoy. This mimics a USB joystick, and a second program (GlovePIE) is used to mimic a TrackIR headtracking setup. When the simulator is run, it latches onto the (virtual) TrackIR and locks the cockpit view onto the incoming headtracker data.

As you can see from the pictures I have mounted the circuit on top of a pair of VR goggles using Blu-Tac (!!!!). It is best to attach the cables to the top of the PC, so there is a sufficiently large loop to allow head movement without tangling with anything or pulling the wires taut.

The circuit could easily be adapted to other applications (such as walking robots) where you want to add a sense of balance. An early version of the program (prior to the co-processor being involved) read back 3 16 bit words to the serial terminal (0-65535 for 0-360).

Ian
 
Last edited:

techElder

Well-known member
That is really something, Ian! Incredibly lifelike, too. I've flown before (with an engine), and it takes a lot of looking around to safely fly in the sky.
 
head tracker

I have also flown gliders in the past (the full sized kind) and the headtracker makes Condor into a very immersive experience.

One of my former work colleagues has recently gone solo and said that the club where he flies is building a simulator using an old glider cockpit. Oddly they do not seem very keen on the idea of a headtracker or VR goggles.

The goggles themselves are only 640X480 resolution. Sony make a pair of VR goggles with a much higher resolution (using OLED screens) but they are ~£800 to buy.

Can upload some code and build notes if people are sufficiently interested.

Ian
 

crowland

Member
Very interesting. The problem with simulators always seems to be the lack of side view. What sort of VR goggles?

I'd certainly be interested in hearing more, my club is also building a simulator.

BTW, did you intend to take off downwind :)

Chris
 
headtracking

The problem with simulators always seems to be the lack of side view.
Not so much that but you generally have to swap between views using the POV hat ..... or the keyboard. It works but it hardly feels natural.

What sort of VR goggles?
http://www.firstpersonview.co.uk/fpv-goggles/fatshark-base-sd

I'd certainly be interested in hearing more, my club is also building a simulator.
My colleague's club is using an old Astir CS cockpit (I believe) although I think they have gone down the large screen / projector route. (Actually he is now a former work colleague, as I lost my job in October :mad: ).

I'm going to start doing some documentation. I think the code itself could be tidied up a little but it fundamentally works. The wiring is not that complex either, although a bit fiddly in places.

BTW, did you intend to take off downwind :)
http://www.condor-club.eu/showtask/0/?id=7046

This is the task in question. Takeoff was just east of north, wind was north-westerly, blowing 19km/h.

Getting higher than the tug aircraft is a cardinal sin, although when being aerotowed in real-life, I don't remember having to hold the glider down anything like as hard as the Condor ones (hence the tail-up posture). The tug also seems very reluctant to take off unless you take off first. Obviously there is a balance to be struck - if you hold a real glider down for too long, there is a chance the nosewheel might be damaged.

Condor does not allow the pilot to select a take-off direction, which often leads to some unrealistic situations. In the Alpine scenery you often take off with a 50km/h crosswind, which no-one in real life would ever attempt.

Ian
 
Last edited:
head tracker files

OK, I have some programs and notes for anyone who is interested.

IMU onboard 4 is the latest version of the PICAXE software.

readgyros is a simple program for returning gyro readings from the IMU-9 to the PICAXE serial terminal

Ian
 

Attachments

head tracker

These are the build notes I have written. Unfortunately, I cannot upload a Word document, so the pictures were nuked when I made it into a .txt file.

I have also included a wiring diagram for the setup.

As always these documents are provided on an "at your own risk" basis. However, if there are any mistakes please let me know and I will correct them.

Reviewing the code shows it's a bit fussy in places, and could be trimmed down.

Ian
 

Attachments

um-FPU configuration file

Copy and paste this into the Integrated development environment, and then upload the functions to your um-FPU.

Code:
xmagno 		equ	f1
ymagno		equ	f2
xaccelo		equ	f3
yaccelo		equ	f4		
zaccelo		equ	f5
anglexy		equ	f6
anglexz		equ	f7
angleyz		equ	f8
smoothxy	equ	F9
smoothxz	equ	F10
smoothyz	equ	F11
gyrox		equ	f12
gyroy		equ	f13
gyroz		equ	f14
zfactor		equ	f15

#function 1 calcangles
angleyz=angleyz+atan(yaccelo/zaccelo)
anglexz=anglexz+atan(xaccelo/zaccelo)
anglexy=anglexy+atan(ymagno/xmagno)

zfactor=abs(1/(cos(anglexz)*cos(angleyz)))

angleyz=angleyz*1000
anglexz=anglexz*1000
anglexy=anglexy*1000
#end

#function 2 calcangles2

gyroz=gyroz*zfactor

smoothxy=(0.99*smoothxy)+(0.01*anglexy/10)-(gyroz/3.8)
smoothxz=(0.99*smoothxz)+(0.01*anglexz/8)-(gyroy/3.4)
smoothyz=(0.99*smoothyz)+(0.01*angleyz/8)+(gyrox/3.4)
xaccelo=smoothxy
yaccelo=smoothxz
zaccelo=smoothyz

#end
Ian
 
Top