Apr 8, 2012

GlovePIE: wiimote tracking

One of the sub goal of my project is to track the user's head direction and orientation. And I am mostly preferred low cost approach although there are many commercial trackers which are obviously outer range of undergraduate research budget.
When I was conducting my survey, I found many RnD work on affordable head tracking. Among them wiimote tracking is highlighted (and we already have such resource). Therefore I am trying on some APIs which allows wiimote tracing. One such good application is GlovePIE. I have follow some tutorials via the internet and also there is a descriptive documentation with GlovePIE. I have shortlisted some practicals which I have tried myself.

If you have a good oo programing knowladge like c++, this is not that much hard. A comprehensive tutorial can be found here.

So let's take an example expression.  It will emulate wii mote right button to the right arrow key of the keyboard.
Key.Right = Wiimote.Right            //This can be identified as an object or a variable.
a = var.A                                        //makes a variable A which is equal to the letter a.

In programming syntax,

LValue  =  expression                    //set the LValue to the value of the expression.
  • GlovePIE is constantly looping through your script. 

Hello World Program

The 'debug' command will out put next to the stop/run button.
debug = "Hello World!"

This debugger tool is very powerful and it allows us to figure out what is going on in the emulator.

Check Wiimote's Availability and Battery

debug = "Wiimote On:" + Wiimote1.Exists + " Wiimote Battery Level:" + Wiimote1.Battery

 Wiimote1.Exists -  will be True or False based on whether or not wiimote is ever connected.
 Wiimote1.Battery - put up wiimote Battery Level with a number from 0-192 (192 being a full battery).

example output: Wiimote On:True Wiimote Battery Level:104

Calculate Degree of  Wiimote is at

  • Roll -   debug  =  "Wiimote Roll:" + Wiimote1.Roll 
  • Pitch -  debug  =  "Wiimote Pitch:" + Wiimote1.Pitch
  • Yaw -   debug  =  "Wiimote Yaw:"  + Wiimote1.Yaw
Also note that you should consider the amount of data communicated via Bluetooth.


So up to now I got some basic knowledge to calculate the coordinates of wiimotes. As I have inspired with GlovePIE I have also tried out following stuffs.
  • If condition then statement [ ; ]
 if(Wiimote1.A) then
debug = "Button A is pressed"
else
debug = "Other button is pressed"
endif

Once you press a button 'A', it will print  "Button A is pressed" and "Other button is pressed" otherwise. According to above example I tried extend it further hence I can figure out what is actually going on in my code.

Can we port this to a game controller ?

 if(Wiimote1.A) then
         debug = "Accelerate"
else if(Wiimote1.B) then
         debug = “Break..!”
else if(Wiimote1.Up) then
         debug = “Drive”
else if(Wiimote1.Down) then
         debug = “Reverse..!”
else if(Wiimote1.Left) then
         debug = “Turn Left”
else if(Wiimote1.Left) then
         debug = “Turn Right”
else
         debug = "Constant velocity"
endif

Now I thought this conceptual game controller. It will make easier me to debugging.. :)

No comments:

Post a Comment