tags:

views:

3204

answers:

7

After seeing the abilities and hackibility of wiimotes I really want to use it in my 'Intro to programming' final. Everyone must make a python program and present it to the class.

I want to make a game with pygame incorporating a wiimote. I found pywiiuse which is a very basic wrapper for the wiiuse library using c types.

I can NOT get anything beyond LEDs and vibrating to work. Buttons, IR, motion sensing, nothing. I've tried different versions of wiiuse, pywiiuse, even python. I can't even get the examples that came with it to run. Here's the code I made as a simple test. I copied some of the example C++ code.

from pywiiuse import *
from time     import sleep

#Init
wiimotes = wiiuse_init()

#Find and start the wiimote
found    = wiiuse_find(wiimotes,1,5)

#Make the variable wiimote to the first wiimote init() found
wiimote  = wiimotes.contents

#Set Leds
wiiuse_set_leds(wiimote,WIIMOTE_LED_1)

#Rumble for 1 second
wiiuse_rumble(wiimote,1)
sleep(1)
wiiuse_rumble(wiimote,0)

#Turn motion sensing on(supposedly)
wiiuse_motion_sensing(wiimote,1)

while 1:
    #Poll the wiimotes to get the status like pitch or roll
    if(wiiuse_poll(wiimote,1)):
        print 'EVENT'

And here's the output when I run it.

wiiuse version 0.9
wiiuse api version 8
[INFO] Found wiimote [assigned wiimote id 1].
EVENT
EVENT
Traceback (most recent call last):
  File "C:\Documents and Settings\Nick\Desktop\wiimotetext.py", line 26, in <mod
ule>
    if(wiiuse_poll(wiimote,1)):
WindowsError: exception: access violation reading 0x00000004

It seems each time I run it, it prints out EVENT 2-5 times until the trace back. I have no clue what to do at this point, I've been trying for the past two days to get it working.

Thanks!

A: 

pywiimote on Google Code might be helpful, if the library you found is failing out on you... give it a try if you have the time.

It seems like a pretty new offering, though, and may not be any better.

Good luck!

Skeolan
Didn't work either. Won't connect to the wiimote and the library looks too much like a WIP not supporting the accelometer(which is what I really need)Thanks for the link anyways.
A: 

I'll risk missing the point by suggesting you take a look at WiimoteWhiteboard Java version by Uwe Schmidt

http://www.uweschmidt.org/wiimote-whiteboard

It uses the WiiRemoteJ library for Java.

I have tried unsuccessfully in the past to use Python implementations because they were either incomplete or non-functional. Maybe by examining Schmidt's working version in Java you can determine what is missing in Python.

Good luck with your class.

Chris Cameron
A: 

Been searching for a set of Python wrappers to the Wiimote for almost two days now, here's my summary of the state of the art:

pywiimote (from Google): roughly half-finished, didn't compile when I downloaded the latest version (r52), has some nice ideas, but will require significant investment to get working.

pywiiuse (above): nice in theory,

cwiid: not actively developed, only for Linux (not able to compile under Cygwin).

In summary -- there's nothing off the shelf right now (3/24/2009). Will keep surveying ...

--Bryan

A: 

Change your python version to 2.5.2 I believe it will work now

A: 

I know your class is over by now, but for anyone else looking, cwiid is really nice. Installed in Ubuntu like so:

apt-get install libcwiimote-dev python-cwiid

Or get the latest from github.

Reading wiimote sensors (like pitch from accelerometer) is super easy:

import cwiid
print 'place wiimote in discoverable mode (press 1 and 2)...'
wiimote = cwiid.Wiimote()
wiimote.rpt_mode = cwiid.RPT_ACC
#wiimote.state dict now has an acc key with a three-element tuple
print 'pitch: %d' % (wiimote.state['acc'][cwiid.Y])
mitch_feaster
A: 

For those still looking, I found and documented a simple easy way of pairing with the Wii Remote with python using the lightblue library. I tested it on OS X, but it should work cross platform (ie. on Linux)

Here's my writeup: http://www.borismus.com/prototyping-wii-remote-python/

borismus
A: 

I updated the pywiiuse wrapper. It didn't seem to be made for the latest version of wiiuse (0.12 at the time of this answer), since much of it just wouldn't work in the current iteration.

I've got the package and some example scripts posted here: http://code.google.com/p/pywiiuse/downloads/list

You should also just be able to do

easy_install wiiuse

Since I've also hosted it on pypi.

Tim Swast