With a high-resolution camera, a 3-axis accelerometer, buttons, speaker, LEDs, vibration feedback, and a Bluetooth wireless link, the Nintendo Wii Remote Controller ("Wiimote") offers exciting possibilities beyond use as a video game controller for the Nintendo Wii video game console. With the examples in this document, you can easily access these data sources in NI LabVIEW.
The attached zip file includes a LabVIEW project with examples that show how you can access a Wiimote with LabVIEW.
Download and Unzip the attached file into a new folder.
IMPORTANT: These examples rely on a third party .NET Managed Library called “WiimoteLib” to establish the link. This library is freely downloadable from this site: http://www.codeplex.com/WiimoteLib. The download includes a version of WiimoteLib that I used to build the examples--you may want to check the WiimoteLib site for a newer version. Ensure that the dll ("WiimoteLib.dll") from the managed library is in the same folder as the files that you unzipped.
IMPORTANT: Establish a Bluetooth link "pair" with the Wii controller and your PC. The specific instructions for doing so will depend on the specifics of your Bluetooth software / hardware. (I found some instructions for how to do so in the "Getting Connected" section of this article.)
Open the LabVIEW project file WiimoteExamples.lvproj in LabVIEW and access the examples from the project explorer window.
If you are new to LabVIEW, start with the examples Simple Flash LEDs (Polled).vi and Simple Acquisition (Polled).vi. These contain the simplest LabVIEW programming of the example set. The Simple Acquisition (Polled).vi example polls for new data (accelerometer data and button status) from the Wiimote within a loop.
The example Roll Pitch (Event).vi contains more involved LabVIEW programming, but is a more efficient implementation that relies on event callbacks to acquire the Wiimote state.The example registers a callback VI to acquire accelerometer data and button status from the Wiimote as it is available. It's more involved than the polling in a loop method of the Simple Polled Acquisition.vi example, but it's more efficient and returns events as they occur.
The example Acquisition + IR (Event).vi registers a callback VI to acquire accelerometer data, button status, and IR camera data from the Wiimote as it is available. Uses a picture control “IR Camera” to display the location of the IR sources from the IR flashlight bar.The IR Camera display will be blank unless Wiimote is pointed at a pair of valid IR sources (such as those from the IR flashlight bar).
For LabVIEW programming help, be sure to see the comments found on the block diagrams.
In an ideal world, with infinite time to code for fun I might address the following. Lacking infinite time, I’ll present these as ideas for future development…
The current code returns basic X, Y, Z acceleration values and some simple trig is applied to convert these values to roll and pitch. The conversion routine isn’t ideal and has at least a few problems. For instance, it jumps to incorrect orientation when the Wiimote is rotated more than 180 degrees on one axis. Another issue is that one axis will lose precision when a related axis is tilted close to an extreme.
Apply data from the accelerometers and the IR camera for better absolute position measurement