Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EMG data range #5

Closed
ruoshiwen opened this issue Nov 26, 2018 · 4 comments
Closed

EMG data range #5

ruoshiwen opened this issue Nov 26, 2018 · 4 comments
Labels

Comments

@ruoshiwen
Copy link

In official SDK, the emg is represented by 8 bits integer (-128~127). When I tested using your code, it seems the amplitude is more than the above range.

Could you please tell me the unit/range of the EMG data (also IMU sensors)?
I could not appreciate more.

@Alvipe
Copy link
Owner

Alvipe commented Nov 26, 2018

In my code, the raw EMG signals are also represented by 8 bit signed integers. The data unpacking is done as follows:

emg1 = struct.unpack('<8b', data[:8])
emg2 = struct.unpack('<8b', data[8:])

The '<8b' parameter in the unpack command means "unpack passed data as 8 little endian signed chars". You can find more information about unpack commands in the module documentation.

As for the filtered EMG signals, that is, the measure of the amplitude of the EMG, code return 8 values ranging from 0 to 65536, since those data are unpacked as unsigned shorts:

emg_filt = struct.unpack('<8H', data[:16])

The IMU returns 10 signed short values (4 quaternions, 3 acceleration values and 3 gyro values) , so each of them range from −32,767 to +32,767, but they are scaled depending on the kind of data:

values = struct.unpack('<10h', data)
quat = [x/16384.0 for x in values[:4]]
acc = [x/2048.0 for x in values[4:7]]
gyro = [x/16.0 for x in values[7:10]]

I hope you find this information useful.

@ruoshiwen
Copy link
Author

ruoshiwen commented Nov 26, 2018 via email

@Alvipe
Copy link
Owner

Alvipe commented Nov 28, 2018

@ruoshiwen, I forgot to mention that, if you want to use the raw EMG data, the one that takes values from -127 to 127, you have to modify line 43 in main.py and write:

myo_device.services.set_mode(myo.EmgMode.RAW, myo.ImuMode.DATA, myo.ClassifierMode.ON)

I should comment that example code and write some documentation on how to use this module. I originally programmed it for myself, but now that you and some other people are using it, I should make it easier to understand and use.

@ruoshiwen
Copy link
Author

ruoshiwen commented Nov 28, 2018 via email

@Alvipe Alvipe closed this as completed Feb 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants