Print this page

The incredible Wiimote

Last modified: August'11

Wiimote is nowadays well-known by community as a really amazing low-cost device. As an amazing device & as well-known device.

So, I've ask a wii-owner friend (thanks Jose!) as soon as I read the bluetooth codes had been hacked. It was a great surprise for me to see about 4 or 5 libraries ready to work with it. Because I use to code using c++, I chose wiiyourself! one, that actually works fine for me.

Moreover, I bought some IR diodes and other electronics stuff, and after googleing a little bit, I remembered Omn's Law :)

First Approach

What I've made was simply a wrapper to an OpenSceneGraph manipulator, in order to control osgviewer with the wiimote. With this I could have a visual idea about the precission of the accelerometers.

After that, I made my own sensor bar, just using a couple of resistances and four IR diodes, connected to a 9v battery. There are lots of howtos about doing that, just make the right search.


Homemade SensorBar


(Just Another) Head Tracking Experiment

Inspired in the Johnny Lee great work, I've imitated his experiment about head tracking from scratch, in order to have a virtual window to a 3D world through the screen.

As I wanted to have a precise tracking, I decided to use ray casting techniques, specifying as input to the software the relative position of the wiimote on the screen (using screen center as origin).

So first step was have the field of view angles of the wii IR camera. After some measurements, my aproximations were HFOV: 42º, VFOV: 32º.

I needed some device to wear the IR diodes, so I made the ultimate-fashion-omate hat :)


Wii Peak


Depth (Z) Computing. Now, we can obtain the ecuations of both lines, from wiimote to each IR diode, but we need a value for the depth. After a couple of failed attempts using the diode size detected by the camera, the solutions was take some measurements, composing a table with pairs: (distance to wiimote , distance of the IR dots in the camera space). With this table you can make a simple numerical regression, and realize that the ecuation is just a parametriced first order inverse function, something like

f(x) = k.x^-1

where x is the distance between the IR dots in camera space, f(x) is the depth from the camera of the IR diode, and k is a parameter depending on the distance of the IR diodes in real world terms.

Update (May'09): someone asked me about the k parameter of last equation, fow depth computing, so I am going to do a approach to this issue, using a couple o draws...

Depth computing scheme


Depth Computing Equations


This is a simplification, with the assumption of we are perpendicular to the camera. The error in other cases should be small, as the IR LEDs are so directional, and we use to look to the screen. The z variable is what we want to know, the depth. The L parameter is the distance between LEDs, measured in world units. As we said before, the Field of View Horizontal (FoVH) of the IR camera of the wiimote is about 42º. Finally, int the camera view (enclosed by 0,0 and 1,1), the distance between LEDs is s. We are assuming that we are not rolling the head, so the equations are just for an horizontal plane (very easy to extend to any case).

The equations show a resulting function to estimate the z value depending on s.

Tracking using this technique was better than I spected, with very low error, about 2 or 3 centimeters in a general case. In extreme cases, as very very close to the camera, or very far, the error increases, of course.

Aplication and results

For the software, I just made a funny 3D scene, with a 5m long wireframe frame covering screen towards the virtual world. All the measures in the model was using real world scale. Again, I used OpenSceneGraph library to build and aplication showing the scene and placing the camera in the right place. But it still didn't work :) So I invited my colleague Antonio Seoane, who have a big brain :) to have a coffee, and we realize that we had to use an dynamic asymetric frustum for the virtual camera, as seen in the picture: green lines symbolize the FOV of the human, and red ones the right asymetric frustum to set up.


Dynamic Frustum


So after some dirty maths (thanks again, Antonio :) we got the right view-projection matrix.

So... now it should be cool ! No, it was quite disappointing. Because I didn't remember that humans have two eyes. But after filming it with a camera is so impressive...

Two solutions for that: the easy, put a post-it in an eye of the user (it really works!). The expensive, use an stereoscopic device, as a polarized dual projection (passive stereo) or a doble frecuency screen, both with special glasses (as old SGI glasstrons), where the IR diodes could be mounted in.

A funny day! It's obvious that wiimote has hundred of possibilities. I've worked with some other gyroscopes and accelerometers for tracking, and, far away from being a professional high precision device, it's as cheap (less than 50$!) that let people with good ideas to try out new interfaces to interact with a machine.

I'm thinking about new ideas for wiimote, I'll post about it as soon as have time to release them. Hope you enjoy!