NiklasRosenstein / myo-python

Python bindings for the Myo SDK
Other
259 stars 102 forks source link

Get orientation from Feed #71

Closed holybeaver closed 4 years ago

holybeaver commented 6 years ago

Hello, I’m actually working on myo-python in order to get orientations of 2 myo. But I’m stuck because you seem to have update your codes a little bit since you wrote all the documentation. I’m trying to use this code (from here : https://myo-python.readthedocs.io/en/latest/myo.html):

import myo as libmyo
feed = libmyo.device_listener.Feed()
hub = libmyo.Hub()
hub.run(1000, feed)

try:
    while True:
        myos = feed.get_connected_devices()
        if myos:
            print myos[0], myos[0].orientation
        time.sleep(0.5)
finally:
    hub.stop(True)
    hub.shutdown()

I would like to get myos[0] et myos[1]. get_connected_devices() seems to doesn’t exist I tried to rewrite it :

import myo
from myo import init, Hub, ApiDeviceListener
import time

print("Hello")
myo.init()
feed = myo.ApiDeviceListener()
hub = myo.Hub()
hub.run_in_background(1000, feed)
myos = feed.devices()
print(myos)

print(myos[0].orientation)
time.sleep(0.1)
print(myos[1].orientation)
print("Bye")

but I get: TypeError: 'list' object is not callable May I have your help please ? =)

Thank you William

lxdfrank commented 4 years ago

did you solve the the problem?

NiklasRosenstein commented 4 years ago

Hey @holybeaver and @lxdfrank , this is a bit late but ApiDeviceListener.devices and ApiDeviceListener.connected_devices are not function but properties, so you would simply write

myos = feed.devices
print(myos[0], myos[0].orientation)