A headtracker is an easy way to add immersion to games, flight simulators and also FPV-flying drones. There are two basic ways to accomplish this: an optical tracking or inertial one, both with their advantages and drawbacks. Where the optical headtracking is mainly used in desktop PC gaming, it is not suitable for use outdoors. I have used both of them and the inertial one seemed to suit better for my needs. Here is a brief comparison of the two technologies:
This is the most common way to track head movements among computer gamers. Optical tracking works using a camera, possibly a head-mounted visual target and a machine vision software, implemented using a computer software or with a purpose-built camera with tracking algorithm running on a hardware.
The optical headtrackers are usually capable of six degrees of freedom (6 DOF) headtracking. They track both the attitude and position of the user head. Within a game user can both look around and also translate the camera: when user raises his head, he can look over a glareshield of a plane within a game, or zoom the view by bringing his head closer to the display. The user must remain within the field of vision of the camera, rather stationary, which limits the use to only desktop applications. Bright sunlight may also interfere with the tracking.
The TrackIR is a commercial device that works with a specialized infrared camera, tracking reflective target stickers that are applied on users headphones, hat or forehead. The TrackIR has a built-in array of infrared LEDs that are reflected from the targets that the camera tracks. It runs a pattern recognition algorithm on the processor of the camera and outputs the processed data to the computer using their proprietary protocol. The protocol interfaces with games, so when user turns his head, the viewpoint gets manipulated accordingly within a game.
FreeTrack is a free implementation of the TrackIR, using a modified generic webcam for target tracking. Unlike the TrackIR which illuminates reflective targets mounted on the gamer, the FreeTrack users like to build rather funny looking IR-led assemblies to their headphones that are tracked by a webcam and the software. For best performance, the web cameras have their built-in infrared filters removed and a visible light filter added, so that visible light does not interfere with the tracking of the infrared LEDs. The infrared filter is usually a special coating on a lens of a camera that can be carefully scraped away using a sharp knife. The visible light filter is usually a piece of a floppy disk magnetic medium or exposed photography film, placed in front of the camera lens.
Wearing reflective or illuminated head-mounted targets for headtracking may get a little annoying after a while. The FreeTrack NoIR was developed to address this problem, using a facial recognition algorithm to track users head. The software works rather good but It requires quite much computing power. It can be however run on a separate networked computer if required.
Unlike camera-based optical headtracking, inertial trackers rely on head-mounted gyroscopes, accelerometers and solid-state compasses. They usually track only three degrees of freedom, the attitude of the users head, but the devices can be used also outdoors with no strict restrictions of being stationary in front of the computer or camera. The sensor data is then processed and transferred to the computer. These kind of headtrackers are used mainly in combination with virtual reality goggles as they allow unobstructed movement of the user, which makes them perfect when flying model aircraft with camera equipment onboard. Which is also why I wanted to build one.
Building the headtracker
The Multiwii is a free open-source Arduino software that is used mostly on multirotor model aircraft. To keep these naturally highly unstable platforms airborne, the MultiWii has a very good algorithm to determine attitude of the aircraft sensors, which is also a desired feature on a headtracker. I have used the MultiWii to fly my multirotors and fixed wing aircraft but also to run my camera stabilizer, and due to its good performance and simplicity, I built my headtracker around it too. Instead of driving motors or moving control surfaces of an aircraft, I modified the MultiWii and the Arduino running it, to output the attitude information as an emulated joystick. The software of the headtracker is based on a modified MultiWii 2.0.
It is no secret that I like the Arduino platform as it is quick and easy to develop embedded electronics with it. There are many versions of the Arduino hardware that fulfill different needs. Arduino Uno, that I selected, features an USB to serial communication unlike many other Arduinos. Where the most of the Arduinos prior the Uno, communicated with the PC using a FTDI USB to Serial converter chip, the Arduino Uno has an AVR microprocessor running a software that provides the USB to Serial functionality. The software of this processor can be updated to make the PC see the Arduino as an joystick, instead of a serial device.
The construction of the headtracker is very simple. A Chinese GY-85 sensor board is wired to the Arduino. The GY-85 has a gyroscope, an accelerometer and a magnetometer which combined provide attitude information in three degrees of freedom. The MultiWii reads and processes the sensor data and then outputs the processed data as joystick position. The GY-85 sensor board is encased inside a heat-shrink tubing and then mounted on my Sony Glasstron virtual reality goggles using two-sided tape. As the magnetometer is able to sense extremely weak magnetic fields it had to be placed carefully as almost any metal or electronic object causes interference to its measurements.
As I wanted to use the device outdoors, the Arduino needed casing. I made one using my CNC mill, of 5 mm thick acrylic sheets. Two buttons were also added to the Arduino, one for starting sensor calibration and one for uploading the firmware to the USB communication chip.
As the headtracker is essentially a virtual joystick, it is easy to use within different software. Flight simulators usually support looking around with a joystick. Software that I use to control my drones and camera gimbals mounted on them, is written using PyGame library, which already supports multiple joysticks. The MultiWii is modified to output attitude data as joystick values. The calibration button functionality is also added; a short press of the calibration button levels the headtracker and a longer press starts the compass calibration routine, which requires me to rotate the headtracker around every axis.