地中海实验室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 SDKCFFI包装器。

目录

文件

文档当前位于 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

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java spring 3.2.0 classnotfoundexception   java如何读取文本文件中的字符串并提取单个字符?"0"   使用外部jar文件编译和运行java   Java:包含流的字符串中的数字之和   涉及位的Java Basic编程   java我无法在listview中居中显示文本   java如何将消息从活动发送到intentService?   java通过API调用从Instagram注销   Java泛型类型继承   无Java应用程序上下文的javascript AJAX调用   java如何打印数组索引号?   eclipsejava:删除(组件);不会立即移除按钮   java扫描动态加载类中的组件   tomcat如何将java web应用程序从eclipse传输到服务器   java我可以访问Sphere类的Geometry而不进行扩展吗?   java ArrayList编译器错误   从数据库到hashmap的java值给出了键和值的重复序列   Java BuffereImage:一个映像还是多个映像?   java我需要测试接口的每个实现来测试接口吗?