使用 pywiiuse 模块的 Python 和 Wiimote

发布于 2024-07-12 22:52:58 字数 1539 浏览 9 评论 0原文

在看到 wiimotes 的功能和可修改性后,我真的很想在我的“编程入门”期末考试中使用它。 每个人都必须编写一个 python 程序并将其呈现给全班同学。

我想用 pygame 制作一个包含 Wiimote 的游戏。 我发现 pywiiuse 这是 <使用 c 类型的 href="http://www.wiiuse.net/" rel="nofollow noreferrer">wiiuse 库。

除了 LED 和振动之外,我什么也做不到。 按钮、红外线、动作感应,什么都没有。 我尝试过不同版本的wiiuse、pywiiuse,甚至python。 我什至无法运行它附带的示例。 这是我作为简单测试编写的代码。 我复制了一些示例 C++ 代码。

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'

这是我运行它时的输出。

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

似乎每次我运行它时,它都会打印 EVENT 2-5 次,直到回溯。 我现在不知道该怎么做,过去两天我一直在努力让它发挥作用。

谢谢!

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(9

寒冷纷飞旳雪 2024-07-19 22:52:58

我更新了 pywiiuse 包装器。 它似乎不是为最新版本的 wiiuse (在本答案时为 0.12)制作的,因为其中大部分内容在当前迭代中不起作用。

我在这里发布了该包和一些示例脚本:
http://code.google.com/p/pywiiuse/downloads/list

你也应该能够这样做,

easy_install wiiuse

因为我也在 pypi 上托管了它。

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.

迷迭香的记忆 2024-07-19 22:52:58

近两天来一直在寻找 Wiimote 的一组 Python 包装器,这是我对现有技术的总结:

pywiimote(来自 Google):大致完成了一半,当我下载最新版本(r52)时没有编译),有一些不错的想法,但需要大量投资才能实现。

pywiiuse(上图):理论上不错,

cwiid:没有积极开发,仅适用于Linux(无法在Cygwin下编译)。

总而言之——现在还没有现成的东西(2009 年 3 月 24 日)。 将继续调查...--

布莱恩

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

祁梦 2024-07-19 22:52:58

我知道你的课现在已经结束了,但对于其他人来说,cwiid 真的很好。 像这样在 Ubuntu 中安装:

apt-get install libcwiimote-dev python-cwiid

或者从 github 获取最新版本。

读取 Wiimote 传感器(例如加速度计的俯仰角)非常简单:

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])

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])
何以笙箫默 2024-07-19 22:52:58

我一直在使用 wiimotelib for .NET,它非常稳定。 还包含 Wii 远程扩展,如 nunchcuk 等。

I've been working with wiimotelib for .NET and it is pretty stable. And contains also wii remote extensions like nunchcuk and other.

凉城已无爱 2024-07-19 22:52:58

对于那些仍在寻找的人,我找到并记录了一种使用 lightblue 库通过 python 与 Wii Remote 配对的简单方法。 我在 OS X 上测试了它,但它应该可以跨平台工作(即在 Linux 上)

这是我的文章: http://smus.com/prototyping-wii-remote-python/

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://smus.com/prototyping-wii-remote-python/

深爱成瘾 2024-07-19 22:52:58

如果您发现的库出现故障,Google 代码上的 pywiimote 可能会有所帮助。 ..如果有时间的话可以尝试一下。

不过,这似乎是一个相当新的产品,而且可能也好不到哪去。

祝你好运!

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!

独行侠 2024-07-19 22:52:58

我冒着错过重点的风险,建议您看一下 Uwe Schmidt 的 WiimoteWhiteboard Java 版本

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

它使用 Java 的 WiiRemoteJ 库。

我过去曾尝试使用 Python 实现,但没有成功,因为它们要么不完整,要么不起作用。 也许通过检查 Schmidt 在 Java 中的工作版本,您可以确定 Python 中缺少什么。

祝你上课顺利。

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.

无风消散 2024-07-19 22:52:58

将你的 python 版本更改为 2.5.2 我相信它现在可以工作了

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

夏日落 2024-07-19 22:52:58

我更新了 Python 3 的 pywiiuse: https://github.com/arpruss/pywiiuse

在 Windows 上,您'需要将 libwiiuse.dll 放入 pywiiuse 的 wiiuse 目录中。 为了方便起见,这里提供了 64 位版本: https://github.com/arpruss/wiiuse/releases /

I updated pywiiuse for Python 3: https://github.com/arpruss/pywiiuse

On Windows, you'll want to drop libwiiuse.dll into the wiiuse directory of pywiiuse. A 64-bit build is here for convenience: https://github.com/arpruss/wiiuse/releases/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文