dzhu / myo-raw

MIT License
219 stars 115 forks source link

Old payload not working for new firmware. #4

Closed vanishing closed 9 years ago

vanishing commented 9 years ago

https://developer.thalmic.com/downloads myo-raw is not working with the newest firmware(Updated Nov 14, 2014).

renhyl commented 9 years ago

Hi,

I am getting this when I try to run phyton myo_raw.py

File "/Library/Python/2.7/site-packages/serial/serialposix.py", line 289, in open self.fd = os.open(self.portstr, os.O_RDWR|os.O_NOCTTY|os.O_NONBLOCK) OSError: [Errno 16] Resource busy: '/dev/cu.usbmodem1'

Please can anyone help?

jwcrawley commented 9 years ago

Yeah, your only hope here is to revert to older firmware. If they've locked that, then you'll have to hack an older firmware to newer version #s.

If you already have the device, then consider this a learning experience (sadfully). If you dont have the device, don't buy one.

Also, it turns out they are a YCombinator funded company, so Hacker News shitcans ALL articles regarding them.

dzhu commented 9 years ago

@renhyl: I'm guessing your problem might be caused by having Myo Connect running at the same time, preventing any other program from accessing the dongle. If it's not running, then I don't know. You might try using the lsof command to see what has the /dev file open.

@vanishing and @diana-js: @jwcrawley is right. Official word from Thalmic is that the EMG data is no longer sent in firmware version 1.0 and up, though it sounded like there was some hope of it being exposed again in the future. I'd appreciate knowing if it's possible to revert to older firmware from 1.0.

vanishing commented 9 years ago

I reverted to 0.8 and using it now.. It's sad that they are taking away the only linux implementation currently possible for now...

dzhu commented 9 years ago

Well, it should be possible to figure out the protocol that the new firmware uses, just the same as I did here, unless they've gone and encrypted it or added a secure handshake or something. I'll go and do that at some point when I have time. (Even if it gets encrypted, since we have access to the SDK binary, it'll be possible in principle to dive in and reverse engineer that, although it would be very easy on their part to move it far outside the range of feasibility, at least for me.)

vanishing commented 9 years ago

@dzhu Thank you dzhu for your work, currently controlling mpd and mpv with myo. I am wondering how did you figure out the protocol?

renhyl commented 9 years ago

thanks dzhu you were right, disconnecting it from everything did the trick. Awesome, thanks man!

vanishing commented 9 years ago

@diana-js Here you go: https://s3.amazonaws.com/thalmicdownloads/firmware/myo-firmware-0.8.18-revd.hex

jwcrawley commented 9 years ago

If I understand the firmware and the compute platform on the device, they're using the following:

Cortex M4 - cpu (confirmed) nRF8001 - low power BT (unconfirmed) MPU9150 9DoF accelerometer (unconfirmed) 8 muscle sensors - ADC's with AgCl sensors (unconfirmed)

If my back of napkin calculations are right, they can do the calculations of basic gestures on chip. Ugly.But they do all processing on the device. Which sucks for us.

Romkabouter commented 9 years ago

Hi, I can't seem to get data. My pygame screenwork and I see some channels filled. But when I make a fist, there seems to be no reaction or highly lagged. Also, in the classify program, I see no reading on the right hand side, like in the video.

I am running python 2.7.8 and Mac OS Yosimety. Using firmware 0.8.18 What OS are you guys running?

jwcrawley commented 9 years ago

Hello!

In my video, I'm using Xubuntu 14.04 with my fork of Dzsu/Myo-raw .

First, lets make sure your firmware version. So, go ahead and plug in the BleGiga USB adapter. Now, you will have to disable the current SDK software. It keeps the data port open so myo_raw cant access it.

Now, once the offical programs are closed, you want to run the following:

python myo_raw.py

That should show you the 8 bars. Each horizontal bar is one of the 8 sensors. If you flex your muscles, you should real realtime muscle activity. You don't have to interpret that data, but just know that you see it realtime.

Next you want to run the gesture creation tool.

python classify_myo.py

Now, you see a screen with 0 through 9 and a green bar through one of them. What this is is how you train the MYO. So first, you want to train a resting gesture. So, you hold 0 when you keep your arm relaxed. Move it around to give the software lots of solutions of what resting is. You want around 1000 samples (the number that goes up when you hold 0).

Now, you can train other gestures. Just decide on what gesture you want to detect. Then, you make that gesture, and then press the # you want associated to that gesture. Say we want a meditation pose of thumb touched to middle finger. Hold your hand that way, and THEN press the number you want associated to that gesture.

When you aren't training (holding down a number, giving it supervised data), you can go from different gesture to see where the green bar goes to. It should follow from gesture to gesture. Of course, the more you have, the more similarity the muscles show. So you may have to do more teaching (hold hand in that position and press appropriate #).

Then, once you are done teaching it, then you can run the final program and interface:

python myo.py

It simply outputs the gesture as a #. So when you are at rest, it outputs a single 0 (assuming your rest is 0). When you change your gesture, it's when this program outputs the number associated to that gesture.

This program can easily be outputted to any number of programs, either in console or to other Python programs.

jwcrawley commented 9 years ago

I would also say, that running myo_raw.py should show you the firmware version.

I've found great performance with firmware 0.8.18.2 . It works super smooth on my machine. And obviously, I'm not using the SDK on Linux.

At the moment, if you wish to replicate this work, change your firmware to above. This week's firmware locked users out of raw access, which 0.8.18.2 manual firmware update fixes.

Although, the ideal solution is proper SDK including raw access. Which in December, we all shall have.

Romkabouter commented 9 years ago

Hi Josh.

I am using firmware 0.8.18.2, it looks like there is data collected, no errors whatsowever. I have the SDK and Myo Connect disabled. The pygame window runs fine, but there is no realtime data. That is: when I make a fist, the bars just continue the way there were. Sometimes they change though, I will make a video.

Regardless of having the data in december, I think this is great work and fun above all

jwcrawley commented 9 years ago

Then try this.

Connect BlueGiga usb dongle. Shake MYO to connect.

run myo_raw.py

Then if you have MYO on your arm, take it off. Hold the band so the usb port/light is up. The bottom sensor is #1. Now, touch it. That channel should pop up white almost instantly. Now, if you go around the band, you should see a stairstep pattern on the raw output display. It also should refresh at 50 Hz or 50 times per second. There should be absolute minimal lag.

Also on your Mac, I'd completely uninstall the SDK, or drop into terminal and kill -9 the offending programs that are potentially jamming up the serial port.

Romkabouter commented 9 years ago

Hey there Josh, here is my (unlisted) video https://www.youtube.com/watch?v=zTNVAIzmY_Y (still processing) You can see, there is data coming in but really laggy, I will try it on a fresh linux distro when I have time.

vanishing commented 9 years ago

@Romkabouter: Make sure your cpufreq is not set to powersaving/conservitive/lowest freq. Also, do you feel your computer is slow?

Romkabouter commented 9 years ago

I have a MacBook Pro 15" retina with 16GB, core i7 2.8 Ghz, no, my computer does not feel slow ;) Can I set the cpufreq somehow?

I also thought it looks slow, because in the video form Josh the pygame window is much faster. But I am using everting default settings, no tinkering whatsoever and I presumed my Mac would and should be fast enough. Is the cpufreq a setting in pygame?

vanishing commented 9 years ago

@Romkabouter I am not sure how mac handles cpu frequency, but if somehow your cpufreq is locked to say 0.5Ghz, its gonna be slow. Maybe check your power settings...

Romkabouter commented 9 years ago

I have set the pygame to FULLSCREEN, then the myo_raw outputs are almost realtime. The classify program is still a bit of a problem, but I will tinker with it somewhat

vanishing commented 9 years ago

I think issue can be closed now, working beautifully now. Especially with the new 1.1.4 firmware!