|
With a high-resolution camera, a 3-axis accelerometer, buttons, speaker, vibration feedback, and a Bluetooth wireless link, the Nintendo Wii Controller (Wiimote) offers exciting possibilities beyond use as a video game controller for the Nintendo Wii. 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 several examples that show how you can access a Wiimote with LabVIEW.
Unzip the attached file into a new folder.
IMPORTANT: Both examples rely on a third party .NET Managed Library to establish the link. This library is freely downloadable from this site: http://www.codeplex.com/WiimoteLib. Download the managed library and ensure that the dll ("WiimoteLib.dll") from the managed library is in the same folder as the files that you unzipped in step 1.
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.d
If you are new to LabVIEW, start with the example Simple Polled Acquisition.vi. It contains the simplest LabVIEW programming. Polls for new data (accelerometer data and button status) from the Wiimote within a loop. Start here if you are new to LabVIEW.
The example Simple Event Callback Roll Pitch.vicontains 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 Event Callback with IR.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.
Have fun.
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
Analyze the accelerometer / IR data to identify “gestures”—patterns of motion.
Access the vibration feedback output of the Wiimote
Access the sound output of the Wiimote
Access data from a Nunchuck connected to your Wiimote
Another LabVIEW to Wiimote interface example is discussed and available through this discussion thread.
Check out this VI Roadshow video from NI AE Evan Dozier. He found an old robotic arm with a broken controller and revamped it using NI hardware, LabVIEW and the Nintendo Wiimote. Evan uses special Bluetooth LabVIEW VIs to control the robot.
Additional Wii-mote developments can be found here;
www.cs.cmu.edu/~johnny/projects/wii/