地中海实验室myo sdk的python绑定
myo-python的Python项目详细描述
公告
[Oct 15, 2018] Thalmic Labs have announced the discontinuation of the Myo armband.
[Jun 28, 2018] Myo-Python 1.0 has been released. It comes with a number of API changes. If you have been following an older tutorial, you might have the new version installed but use code that worked with the old version.
Check the Migrating from v0.2.x section below.
myo sdk的python绑定
myo python是Thalmic Myo SDK的CFFI包装器。
目录
文件
文档当前位于 GitHub Repository。
示例
MyPython在很多方面反映了MyoC+SDK的用法。
要求您实现一个DeviceListener
,然后将为
从myo设备接收到的任何事件。
importmyoclassListener(myo.DeviceListener):defon_paired(self,event):print("Hello, {}!".format(event.device_name))event.device.vibrate(myo.VibrationType.short)defon_unpaired(self,event):returnFalse# Stop the hubdefon_orientation(self,event):orientation=event.orientationacceleration=event.accelerationgyroscope=event.gyroscope# ... do something with thatif__name__=='__main__':myo.init(sdk_path='./myo-sdk-win-0.9.0/')hub=myo.Hub()listener=Listener()whilehub.run(listener.on_event,500):pass
作为实现自定义设备侦听器的替代方法,您可以
使用myp.ApiDeviceListener
类,该类允许您读取最近的
一个或多个myo设备的状态。
importmyoimporttimedefmain():myo.init(sdk_path='./myo-sdk-win-0.9.0/')hub=myo.Hub()listener=myo.ApiDeviceListener()withhub.run_in_background(listener.on_event):print("Waiting for a Myo to connect ...")device=listener.wait_for_single_device(2)ifnotdevice:print("No Myo connected after 2 seconds.")returnprint("Hello, Myo! Requesting RSSI ...")device.request_rssi()whilehub.runninganddevice.connectedandnotdevice.rssi:print("Waiting for RRSI...")time.sleep(0.001)print("RSSI:",device.rssi)print("Goodbye, Myo!")
从v0.2.x迁移
myo python库的v0.2.x系列使用了ctypes
,并且有一些
有点不同的api。最重要的更改是:
- 不再需要显式关闭
Hub
对象 DeviceListener
方法名已更改,以匹配确切的事件名 由myo sdk指定(例如从on_pair()
到on_paired()
)Hub.run()
:参数的顺序是相反的(handler, duration_ms
而不是duration_ms, handler
)myo.init()
:提供更多的参数来控制检测libmyo
的方式。myo.Feed
:重命名为myo.ApiDeviceListener
使用myo python的项目
变化
v1.0.4(2019-04-29)
- 去掉myo.quaternion,它是一个剩余的四元数类,实际上它在myo.types.math中
- 将myo.types.math和myo.types.macaddr移到myo包
- myo.types包现在是向后兼容的存根
- 依赖于
enum34
包,而不是nr.types.enum
中已删除的nr.types>=2.0.0
- 更新在
myo.init()
中引发的
ValueError
的错误消息
v1.0.3(2018-06-28)
Event.mac_address
如果事件的类型是EventType.emg
(62)Hub.run()
现在接受DeviceListener
对象作为其handler参数。 这将转到Hub.run_forever()
和Hub.run_in_background()
。- 代替要求
nr>=2.0.10,<3
,而代之以nr.types>=1.0.3
v1.0.2(2018-06-09)
- 修正
Event.warmup_result
(pr 58@fribeiro1)
v1.0.1(2018-06-09)
- 修正
Event.rotation_on_arm
(59)
v1.0.0(2018-06-03)
- 使用cffi重写
此项目是根据麻省理工学院许可证授权的。
版权所有©2015-2018 Niklas Rosenstein