In the previous post I demonstrated live wii-mote data going into Google Android. Here is how to replicate this for yourself.
A C program communicates with the wii-mote over bluetooth and outputs the accelerometer readings to a file. This is then read by a patched version of the OpenIntents sensor simulator and relayed into Android.
There are four main parts you'll need to get this going:
- http://dalethatcher.com/android-wii/wiiacc.tar.bz2 A small home grown C app that uses the CWiid library V0.6.
- http://dalethatcher.com/android-wii/wiimote-sensor-simulator.jar A patched version of the OpenIntents sensor simulator program that supports input from wiiacc.
- http://openintents.googlecode.com/files/openintents-binary-0.1.5.zip The OpenIntents binaries, which includes the sensors demo program.
- http://code.google.com/android/download.html The Android emulator.
Setting up each of the parts.
- Get cwiid-0.6.00.tgz if you need to and install it.
- Download wiiacc.tar.bz2 and unpack it.
- Run bootstrap.sh and then follow the instructions in the INSTALL file to build and install it.
- Run the program with the output filename as an argument. I use '
wiiacc wii' in my home directory.
- Follow the instructions from the program and if all is well you should start to see wii accelerometer data in the output file.
Patched Sensor Simulator
- Download wiimote-sensor-simulator.jar or build from the source if you prefer.
- Run "
java -jar wiimote-sensor-simulator.jar"
- Scroll down to the bottom of the settings window to the "Real sensor bridge" section.
- Enter the path to the output file in the text field (I use '
/home/dale/wii') and select "Use Wii-mote accelerometer".
- If all is well you should see the image of the mobile phone in the top left mostly match the movement of the wii-mote. I say mostly because the wii-mote works out it's orientation by gravity which means that it doesn't measure yaw. There is a good explanation here.
OpenIntents and Android
There are some instructions on the OpenIntents wiki here. However this is the short version:
- Unpack android and run "
- Unpack the open intents binary package and install the OpenGL viewer by running:
android_install/tools/adb install openintents-binary-0.1.5/OpenIntents.apk android_install/tools/adb install openintents-binary-0.1.5/samples/OpenGLSensors.apk
- When the emulator starts launch the OpenGL Sensors program and go to the settings menu, enter the most plausible IP address found under 'Possible IP addresses'.
- You can then test it's working by going to the "Testing" tab and clicking connect, you should see the wii accelerometer data.
- For some reason I usually find at this point you'll need to come out of the OpenGL Sensors app and go back in. However once I've done this selecting 'connect' in the menu works.
hi, does this also work on a real android device or just in the simulator?
thx for your effort!
Sorry I don't have access to a real device best to ask the OpenIntents guys.
I tried to duplicate what you did with OpenIntents and OpenGLSensors. I can install these two packages on my Android emulator or device, but they crash every time I try to run them. I think it's probably because they are of very old version--the latest opinintents binary and source files I can find and download is for Android 0.9. Are there any later solutions on this subject?
@cdwong Yeah looks like OpenIntents has moved on quite a bit. Unfortunately I've not had time to update this program. However as there are now Android handsets available it's probably easier to use one of those for development.
I found the right Android version to use so the OpenIntents and OpenGLSensor apps won't crash: Android 1.1. So now I can run these two apps along with the Java Sensor Simulator without problem.
What I need to do now is have something like the wiiacc program that communicates with the WII device and sends its output data to a file. Instead of a WII device, what I have here is a proprietary accelerometer sensor board that I can control and have it send out data in the same format as you did with your wiiacc program. Could you explain what format you use for such data output? Or better yet, if you could, produce a sample datafile for me to try?
@cdwong The data format is the acceleration numbers for each axis "x,y,z\n" with a new file created for each update.
I have problem in making "wiiacc", I don't know how to create a "configure" file.
@Wen_Jiun_Yap Try running the 'bootstrap.sh' file. Apologies for not putting this in the README.
i cant run ./configure it says that it cant fint the file.
@mattias see above
i have alredy run bootstrap.sh, i clicked on it and chose run. then i used cd to get to the extracted wiiac file then i typed in ./configure.
is there something i missed or did wrong?
@mattias If you run bootstrap.sh from the command line you'll probably see some errors about programs you'll need to install. This code was just a quick sketch so it's not production quality. If you're not a moderately experienced programmer then I'd suggest spending some more time learning about C and autoconf/automake.
./configure works but now it says
checking for cwiid_open in -lcwiid... no
configure: error: Cannot find cwiid library, do you need an --with-cwiid-dir?
This might be a stupid question but how do you start the program and connect it to the wiimote?
I got it
Post a Comment