File Exchange

image thumbnail

Myo SDK MATLAB MEX Wrapper

version 3.0.0.0 (8.24 MB) by Mark Tomaszewski
Access data from Thalmic Labs' Myo Gesture Control Armband in m-code and Simulink!

8 Downloads

Updated 19 Oct 2017

View Version History

GitHub view license on GitHub

Thalmic Labs' Myo Gesture Control Armband (myo.com) features an Inertial Measurement Unit (IMU) and 8 surface Electromyography sensors (sEMG) in addition to a Windows SDK that allows developers to obtain access to this data!
Check out this Preview video on YouTube to see what this package can do,
https://youtu.be/pPh306IgEDo

On the surface, this package contains a simplified m-code class, MyoMex, that enables MATLAB users to stream data from one or two Myo devices at 50Hz (IMU and meta data) and 200Hz (EMG) with only 1 command! Note that EMG data is not available when using two devices due to hardware/software limitations.

mm = MyoMex(); % Upon construction, MyoMex starts accumulating streaming data in its myoData property
m = mm.myoData; % get MyoData object
% Data is now being pushed into log properties of m named,
% quat_log, gyro_log, accel_log, emg_log, etc.
% Data acquisition is non-blocking, too!
mm.delete(); % clean up

The IMU data includes estimated quaternion (orientation), three-axis gyroscope (angular velocity), and three-axis accelerometer (linear acceleration).

The sEMG data includes 8 raw data channels plus the output of Myo's built-in gesture detection.

Here are some of the things that you'll find in this package,

* README.txt - Step-by-step instructions for prerequisite configuration
* install_myo_mex() - installation tool
* build_myo_mex() - MEX-file build tool
* MyoMex_Quickstart - Quickstart guide script with example code and liberal comments
* MyoMexGUI_Monitor - GUI implementation of streaming data with visualization of all available data

New Simulink support includes MEX C/C++ S-Function block and other supporting utility blocks that support two following configurations:

* One Myo - EMG disabled
* One Myo - EMG enabled
* Two Myos - EMG disabled

The Simulink block data outputs mirror the data available from MyoData in m-code. The data is streamed in soft real-time. Thus, Simulink Desktop Real-Time is required to synchronize the model with the system clock.

This is being developed on one machine configuration: MATLAB R2013a; Windows 7 64-bit; VS2012 Pro

Comment and rate below! If you have questions, I answer messages pretty quickly.

You can also email me or send a message through my profile here,
mark (at) mark-toma (dot) com | marktoma (at) buffalo (dot) edu

I'll also stay current with the repo on GitHub,
https://github.com/mark-toma/MyoMex

There's a post about this package at Thalmic Labs' Developer Forums,
https://developer.thalmic.com/forums/topic/2940/

Cite As

Mark Tomaszewski (2021). Myo SDK MATLAB MEX Wrapper (https://github.com/mark-toma/MyoMex), GitHub. Retrieved .

Comments and Ratings (118)

enass mohammed

hi,
the link to download the SDK file is not working, please advice.
when I downloaded SDK file from google I keep get errors.
version 2020a

Ayumi Hayakawa

"An internal error has occurred."
This error occurs when it occurs at runtime.

Please tell me how to resolve.

version
MATLAB 2020a

Laura Rodriguez Moran

Adrian Ibarra Fuentes

Hi Mark, i am working in this proyect, but i do not how can i show the 8 Raw EMG separate.

Maybe you can help to me , to do this.

Thanks

Ronny Tituana

tengo este problema puede ayudarme
MyoMex_Quickstart

Evaluating mex command:
'mex -O -I"C:\Users\Usuario\Downloads\myo-sdk-win-0.9.0\myo-sdk-win-0.9.0\include" -L"C:\Users\Usuario\Downloads\myo-sdk-win-0.9.0\myo-sdk-win-0.9.0\lib" -lmyo64 myo_mex.cpp'
Caught "std::exception" Exception message is:
boost::filesystem::status: El sistema no tiene acceso al archivo: "C:\Users\Usuario\AppData\Local\Microsoft\WindowsApps\MicrosoftEdge.exe"
>>

CHRISTOPHER MILLAR

Excellent Toolbox for interacting with the Myo device

diegomrivera

elonzhao1996

archit fadhilah

archit fadhilah

Halo all,
Anybody using mac for this?

Alex Oña

Hello Mark,

I am using Matlab R2018a, me podrias ayudar con información de como procesar los datos de la IMU. on the monitor when you animate the data of the IMU it looks functional. I am using the quat and the quat2eul function to get the angles, but I have problems in that there are jumps in the variation of the data, I do not know how you are processing them to obtain the appropriate animation.

ender yolal

Hello Mark,

I am using Matlab r20015a and Visual Studio 2012 Express. I have changed the PATH system variable
but keep getting following error. Is there anything you can suggest?

"Evaluating mex command:
'mex -O -I"C:\myo-sdk-win-0.9.0\include" -L"C:\myo-sdk-win-0.9.0\lib" -lmyo64 myo_mex.cpp'
Caught "std::exception" Exception message is:
boost::filesystem::status: Sistem dosyaya erişemiyor: "C:\Users\ender\AppData\Local\Microsoft\WindowsApps\MicrosoftEdge.exe""

Mohsin khan

Hello Mark,
As you told that data stream is available in ''MyoData.m'', how can i get access to 'EMG' file from ''MyoData.m'' function? which i can use in my function, looking forward for the solution.

Beyda TASAR

Dear Sir,
I have got a problem; When I run simulink model, The following error occurs
Error in S-function 'myo_sfun_one_myo_imu/Myo S-Function': S-Function 'myo_sfun' does not exist
how can ı solve this problem??

Egor Vetkin

If someone has a problem with SDK trying to find myo64 or myo32 *.dll file
1. Just change the PATH system variable(it could be made by windows GUI and it's simply to google)
2. Try to start MyoMex, if it's not working, just restart Matlab(I've spent 2 hours trying to find solution of this problem)
:)

Sid Shah

Error using build_myo_mex (line 67) C:\myo-sdk-win-0.9.0\lib/myo64.lib: error adding symbols: File in wrong format collect2.exe: error: ld returned 1 exit status

I am getting this error and I have been told that it requires a "requires a C++11 compatible Microsoft Visual compiler."
Can anyone tell me how can i install that specific compiler and then switch over to it?

Jungle Jim

Mark,

Thanks for setting up all of this for us to use! I was able to run myo_mex_Quickstart.m, but I'm getting the same error Hyun-Jong Lee is getting in simulink.

Setup: Matlab 2016b, Windows 7, Microsoft Visual C++ 2012.

Hyun-Jong Lee

Hi Mark
I built myo_sfun_one_myo_imu_emg.slx file through simulink
and I get the following error:

Error: Simulink Coder Error in block: "myo_sfun_one_myo_imu_emg/Myo IMU/quat2rot/ketbra", block type "MATLABFcn": Not yet supported by Simulink Coder

I do not know why this error appears.
I want you to tell me how to set the options.

I am using Windows 10, Matlab R2017b, Visual Studios 2017

Thanks.

Fatma Nur EZBER

@Carly, I'm getting the same mistake. The range () function is defined in Matlab. I even tried a small sample, did not make any mistakes. Did you solve the mistake? I am very happy if you solve it and share the solution with me.

Thanks,

Mark Tomaszewski

Ecmel, Glad to hear you had solved this problem after switching back to MSVC from MinGW

Carly, Thanks for letting me know abou tthe current dependency on the statistics toolbox. I'll plan to patch this to eliminate the dependency on range()

Edgar, Check to make sure that you're using the code from dev-3.1 to use this future feature. It hasn't yet been rolled into the latest release so it hasn't been merged to master.

Edgar Cubillo

Hello Mark,
I am trying to implement the new myNewDataFcn.m
and I get the following error:

mm.newDataFcn = @(src,evt)myNewDataFcn(src,evt);
Unrecognized property 'newDataFcn' for class 'MyoMex'.

Any ideas what the problem can be?

Carly Garrow

Hi Mark,
Thanks for the code! I followed the install and setup instructions in the ReadMe, and can get the MyoMexGUIMonitor to open and run for about .5 seconds, and then the Monitor freezes and stops showing live stream data. Matlab gives me this error:
"Error while evaluating TimerFcn for timer 'MyoMexGUI_Monitor_update_timer'
Undefined function 'range' for input arguments of type 'double'."
I am using Windows 10, Matlab R2017b, Visual Studios 2017. Any ideas about what the problem is? Thanks for the help!

Ecmel Demet

hello Mark,
mm = MyoMex I get this error:
Error using MyoMex (line 83)
MEX-file 'myo_mex' is not on MATLAB's
search path and is required for MyoMex.

How can I get this error?
Thank you very much ..

Kawin Larppichet

Mark Tomaszewski

Karl, The Quickstart file contains examples to show the logging feature.
https://github.com/mark-toma/MyoMex/blob/master/MyoMex_Quickstart.m

See the *_log properties of MyoData. For example, emg_log.

Karl Rueth

Hi Mark, I have managed to run it up and I am finding it very useful .. one last question; is it possible to log the EMG data so that I can classify the data ?

Thanks

Mark Tomaszewski

Karl, Tamara, Thiimira, Please see this link and add the SDK path to the PATH environment variable in Windows:
https://github.com/mark-toma/MyoMex/blob/master/README.md#add-myo-sdk-to-path

Liviu, Myo Connect Test is not "production" code... That is only for testing.

Karl Rueth

Hi .. To add with the previous post, in the MyoMex Quick Start, I have declared that the SDK path is
sdk_path = 'c:\myo-sdk-win-0.9.0';

Liviu Ivanescu

Hi, The build_myo_mex and MyoMex Quickstart works fine. However, myo_connect_test_script gives this:
--------------------------------------------------------------------
Building with 'Microsoft Visual C++ 2015 Professional'.
Error using mex
cl : Command line warning D9021 : no action performed

cl : Command line warning D9024 : unrecognized source file type
'Files\MATLAB\R2015b\extern\include -IC:\Program', object file
assumed
cl : Command line warning D9027 : source file
'Files\MATLAB\R2015b\extern\include -IC:\Program' ignored
cl : Command line warning D9024 : unrecognized source file type
'Files\MATLAB\R2015b\simulink\include
C:\Users\iLivi\Documents\MATLAB\misc\spheromyo\mark-toma-MyoMex-6a6a0d5\MyoConnectTest\myo_connect_test.cpp
/FoC:\Users\iLivi\AppData\Local\Temp\mex_33459702209539_2252\myo_connect_test.obj
', object file assumed
cl : Command line warning D9027 : source file
'Files\MATLAB\R2015b\simulink\include
C:\Users\iLivi\Documents\MATLAB\misc\spheromyo\mark-toma-MyoMex-6a6a0d5\MyoConnectTest\myo_connect_test.cpp
/FoC:\Users\iLivi\AppData\Local\Temp\mex_33459702209539_2252\myo_connect_test.obj
' ignored

Error in myo_connect_test_script (line 8)
eval(cmd)
--------------------------------------------------------

Any idea what is wrong, please? Thanks!

tamara markovich

Hi Mark,
I Have this problem:
>> build_myo_mex(sdk_path); % builds myo_mex

Changing directory to build directory:
'C:\Users\תמרה\Desktop\MYO\mark-toma-MyoMex-6a6a0d5\MyoMex\myo_mex'

Evaluating mex command:
'mex -O -I"C:\Users\תמרה\Desktop\MYO\myo-sdk-win-0.9.0\include" -L"C:\Users\תמרה\Desktop\MYO\myo-sdk-win-0.9.0\lib" -lmyo32 myo_mex.cpp'
Building with 'Microsoft Visual C++ 2015'.

MEX-file 'myo_mex.cpp' did not build successfully!

Changing directory to original directory:
'C:\Users\תמרה\Desktop\MYO\mark-toma-MyoMex-6a6a0d5\MyoMex\myo_mex'

Changing directory to build directory:
'C:\Users\תמרה\Desktop\MYO\mark-toma-MyoMex-6a6a0d5\MyoMex\myo_mex'
Error using build_myo_mex (line 67)
Creating library myo_mex.lib and object myo_mex.exp
myo_mex.obj : error LNK2019: unresolved external symbol mxGetM referenced in function mexFunction
myo_mex.obj : error LNK2019: unresolved external symbol mxIsChar referenced in function mexFunction
myo_mex.obj : error LNK2019: unresolved external symbol mxIsComplex referenced in function mexFunction
myo_mex.obj : error LNK2019: unresolved external symbol mxIsDouble referenced in function mexFunction
myo_mex.obj : error LNK2019: unresolved external symbol mxGetPr referenced in function "void __cdecl fillOutputEMG(struct
mxArray_tag * * const,struct FrameEMG,unsigned int,unsigned int)" (?fillOutputEMG@@YAXQEAPEAUmxArray_tag@@UFrameEMG@@II@Z)
myo_mex.obj : error LNK2019: unresolved external symbol mxSetFieldByNumber_700 referenced in function "void __cdecl
assnOutputStruct(struct mxArray_tag *,struct mxArray_tag * * const,int)" (?assnOutputStruct@@YAXPEAUmxArray_tag@@QEAPEAU1@H@Z)
myo_mex.obj : error LNK2019: unresolved external symbol mxCreateNumericMatrix_700 referenced in function "void __cdecl
makeOutputEMG(struct mxArray_tag * * const,unsigned int)" (?makeOutputEMG@@YAXQEAPEAUmxArray_tag@@I@Z)
myo_mex.obj : error LNK2019: unresolved external symbol mxArrayToString referenced in function mexFunction
myo_mex.obj : error LNK2019: unresolved external symbol mxCreateStructMatrix_700 referenced in function mexFunction
myo_mex.obj : error LNK2019: unresolved external symbol mexErrMsgTxt referenced in function mexFunction
myo_mex.obj : error LNK2019: unresolved external symbol mexLock referenced in function mexFunction
myo_mex.obj : error LNK2019: unresolved external symbol mexUnlock referenced in function mexFunction
myo_mex.obj : error LNK2019: unresolved external symbol mexIsLocked referenced in function mexFunction
myo_mex.obj : error LNK2019: unresolved external symbol __imp_libmyo_error_cstring referenced in function "public: __cdecl
myo::ThrowOnError::~ThrowOnError(void)" (??1ThrowOnError@myo@@QEAA@XZ)
myo_mex.obj : error LNK2019: unresolved external symbol __imp_libmyo_error_kind referenced in function "public: __cdecl
myo::ThrowOnError::~ThrowOnError(void)" (??1ThrowOnError@myo@@QEAA@XZ)
myo_mex.obj : error LNK2019: unresolved external symbol __imp_libmyo_free_error_details referenced in function "public: __cdecl
myo::ThrowOnError::~ThrowOnError(void)" (??1ThrowOnError@myo@@QEAA@XZ)
myo_mex.obj : error LNK2019: unresolved external symbol __imp_libmyo_init_hub referenced in function "public: __cdecl
myo::Hub::Hub(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)"
(??0Hub@myo@@QEAA@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
myo_mex.obj : error LNK2019: unresolved external symbol __imp_libmyo_shutdown_hub referenced in function "public: __cdecl
myo::Hub::~Hub(void)" (??1Hub@myo@@QEAA@XZ)
myo_mex.obj : error LNK2019: unresolved external symbol __imp_libmyo_set_locking_policy referenced in function "public: void
__cdecl myo::Hub::setLockingPolicy(enum myo::Hub::LockingPolicy)" (?setLockingPolicy@Hub@myo@@QEAAXW4LockingPolicy@12@@Z)
myo_mex.obj : error LNK2019: unresolved external symbol __imp_libmyo_set_stream_emg referenced in function "public: __cdecl
MyoData::MyoData(class myo::Myo *,unsigned __int64,bool)" (??0MyoData@@QEAA@PEAVMyo@myo@@_K_N@Z)
myo_mex.obj : error LNK2019: unresolved external symbol __imp_libmyo_myo_unlock referenced in function "public: __cdecl
MyoData::MyoData(class myo::Myo *,unsigned __int64,bool)" (??0MyoData@@QEAA@PEAVMyo@myo@@_K_N@Z)
myo_mex.obj : error LNK2019: unresolved external symbol __imp_libmyo_event_get_type referenced in function "public: static enum
libmyo_handler_result_t __cdecl `public: class myo::Myo * __cdecl myo::Hub::waitForMyo(unsigned int)'::`2'::local::handler(void
*,void const *)" (?handler@local@?1??waitForMyo@Hub@myo@@QEAAPEAVMyo@4@I@Z@SA?AW4libmyo_handler_result_t@@PEAXPEBX@Z)
myo_mex.obj : error LNK2019: unresolved external symbol __imp_libmyo_event_get_timestamp referenced in function "protected: void
__cdecl myo::Hub::onDeviceEvent(void const *)" (?onDeviceEvent@Hub@myo@@IEAAXPEBX@Z)
myo_mex.obj : error LNK2019: unresolved external symbol __imp_libmyo_event_get_myo referenced in function "public: static enum
libmyo_handler_result_t __cdecl `public: class myo::Myo * __cdecl myo::Hub::waitForMyo(unsigned int)'::`2'::local::handler(void
*,void const *)" (?handler@local@?1??waitForMyo@Hub@myo@@QEAAPEAVMyo@4@I@Z@SA?AW4libmyo_handler_result_t@@PEAXPEBX@Z)
myo_mex.obj : error LNK2019: unresolved external symbol __imp_libmyo_event_get_firmware_version referenced in function
"protected: void __cdecl myo::Hub::onDeviceEvent(void const *)" (?onDeviceEvent@Hub@myo@@IEAAXPEBX@Z)
myo_mex.obj : error LNK2019: unresolved external symbol __imp_libmyo_event_get_arm referenced in function "protected: void
__cdecl myo::Hub::onDeviceEvent(void const *)" (?onDeviceEvent@Hub@myo@@IEAAXPEBX@Z)
myo_mex.obj : error LNK2019: unresolved external symbol __imp_libmyo_event_get_x_direction referenced in function "protected:
void __cdecl myo::Hub::onDeviceEvent(void const *)" (?onDeviceEvent@Hub@myo@@IEAAXPEBX@Z)
myo_mex.obj : error LNK2019: unresolved external symbol __imp_libmyo_event_get_warmup_state referenced in function "protected:
void __cdecl myo::Hub::onDeviceEvent(void const *)" (?onDeviceEvent@Hub@myo@@IEAAXPEBX@Z)
myo_mex.obj : error LNK2019: unresolved external symbol __imp_libmyo_event_get_warmup_result referenced in function "protected:
void __cdecl myo::Hub::onDeviceEvent(void const *)" (?onDeviceEvent@Hub@myo@@IEAAXPEBX@Z)
myo_mex.obj : error LNK2019: unresolved external symbol __imp_libmyo_event_get_rotation_on_arm referenced in function
"protected: void __cdecl myo::Hub::onDeviceEvent(void const *)" (?onDeviceEvent@Hub@myo@@IEAAXPEBX@Z)
myo_mex.obj : error LNK2019: unresolved external symbol __imp_libmyo_event_get_orientation referenced in function "protected:
void __cdecl myo::Hub::onDeviceEvent(void const *)" (?onDeviceEvent@Hub@myo@@IEAAXPEBX@Z)
myo_mex.obj : error LNK2019: unresolved external symbol __imp_libmyo_event_get_accelerometer referenced in function "protected:
void __cdecl myo::Hub::onDeviceEvent(void const *)" (?onDeviceEvent@Hub@myo@@IEAAXPEBX@Z)
myo_mex.obj : error LNK2019: unresolved external symbol __imp_libmyo_event_get_gyroscope referenced in function "protected: void
__cdecl myo::Hub::onDeviceEvent(void const *)" (?onDeviceEvent@Hub@myo@@IEAAXPEBX@Z)
myo_mex.obj : error LNK2019: unresolved external symbol __imp_libmyo_event_get_pose referenced in function "protected: void
__cdecl myo::Hub::onDeviceEvent(void const *)" (?onDeviceEvent@Hub@myo@@IEAAXPEBX@Z)
myo_mex.obj : error LNK2019: unresolved external symbol __imp_libmyo_event_get_rssi referenced in function "protected: void
__cdecl myo::Hub::onDeviceEvent(void const *)" (?onDeviceEvent@Hub@myo@@IEAAXPEBX@Z)
myo_mex.obj : error LNK2019: unresolved external symbol __imp_libmyo_event_get_battery_level referenced in function "protected:
void __cdecl myo::Hub::onDeviceEvent(void const *)" (?onDeviceEvent@Hub@myo@@IEAAXPEBX@Z)
myo_mex.obj : error LNK2019: unresolved external symbol __imp_libmyo_event_get_emg referenced in function "protected: void
__cdecl myo::Hub::onDeviceEvent(void const *)" (?onDeviceEvent@Hub@myo@@IEAAXPEBX@Z)
myo_mex.obj : error LNK2019: unresolved external symbol __imp_libmyo_run referenced in function "public: void __cdecl
myo::Hub::run(unsigned int)" (?run@Hub@myo@@QEAAXI@Z)
C:\Users\תמרה\Desktop\MYO\myo-sdk-win-0.9.0\lib\myo32.lib : warning LNK4272: library machine type 'X86' conflicts with target
machine type 'x64'
C:\Program Files (x86)\MATLAB\MATLAB Production Server\R2015a\extern\lib\win32\microsoft\libmx.lib : warning LNK4272: library
machine type 'X86' conflicts with target machine type 'x64'
C:\Program Files (x86)\MATLAB\MATLAB Production Server\R2015a\extern\lib\win32\microsoft\libmex.lib : warning LNK4272: library
machine type 'X86' conflicts with target machine type 'x64'
C:\Program Files (x86)\MATLAB\MATLAB Production Server\R2015a\extern\lib\win32\microsoft\libmat.lib : warning LNK4272: library
machine type 'X86' conflicts with target machine type 'x64'
myo_mex.mexw64 : fatal error LNK1120: 38 unresolved externals

Thanks!

Thiimira Dhananjaya

hi Mark
I am using windows 10 and Matlab 2016 I am getting error message in Matlab like following
Error using MyoMex (line 100)
MEX-file 'myo_mex' failed to initialize with error:
'Invalid MEX-file 'C:\Users\Thimira\Desktop\EMG\MatLab
model\MyoMex-master\MyoMex-master\MyoMex\myo_mex\myo_mex.mexw64': The specified module could not be found.'

Mark Tomaszewski

Sorry for the delay, everyone!

@Cecilia, As a workaround, you can remove 'myo_sfun.cpp' from src_files at line #46 of build_myo_mex() here:
https://github.com/mark-toma/MyoMex/blob/master/MyoMex/myo_mex/build_myo_mex.m#L46
If you'd like to help me debug the nonexistence of simstruc.h then send me an email.

@ Marco, I think you need to add the location of myo64.dll to the PATH environment variable in Windows as described here:
https://github.com/mark-toma/MyoMex#add-myo-sdk-to-path
If this doesn't help, send me an email.

@Ecmel, You can schedule periodic computation on the streaming data using a timer object in MATLAB. I've added a newDataFcn callback that executes every time new data is received by MyoMex. Look at the myNewDataFcn* files here in the devel-3.1 branch:
https://github.com/mark-toma/MyoMex/tree/devel-3.1/MyoMex/example
Keep in mind that the computational overhead for such functions must be minimal or you might lose data. MATLAB m-code isn't the quickest way to compute on streaming data. Feel free to email me with further questions.

mark@mark-toma.com

Ecmel Demet

Hello Mark,
Can we perform modulation, demodulation etc. operations on EMG signals that we receive in real time? Or does this package not only visualize EMG signals visually?

Marco Hui

Hello!

When I run the Quickstart, I face an error.

Warning: The following error was caught while executing 'MyoMex' class destructor:
Error using MyoMex/stopStreaming (line 166)
MyoMex is not streaming.

Error in MyoMex/delete (line 115)
this.stopStreaming();

Error in MyoMex (line 58)
function this = MyoMex(countMyos)

Error in MyoMex_Quickstart (line 32)
mm = MyoMex(countMyos)
> In MyoMex (line 58)
In MyoMex_Quickstart (line 32)
Error using MyoMex (line 100)
MEX-file 'myo_mex' failed to initialize with error:
'Invalid MEX-file
'D:\user\Documents\Storage\Matlab\Myo\MyoMex-master\MyoMex\myo_mex\myo_mex.mexw64': Missing
dependent shared libraries:
'myo64.dll' required by
'D:\user\Documents\Storage\Matlab\Myo\MyoMex-master\MyoMex\myo_mex\myo_mex.mexw64'.'

Error in MyoMex_Quickstart (line 32)
mm = MyoMex(countMyos)

Cecilia Monoli

Hello!
We are trying to run MyoMex_Quickstart.m (MATLAB R2016b) but we face an error while the building.
Thanks for your help!

>> MyoMex_Quickstart
[....]

Evaluating mex command:
'mex -O -I"E:\MYO\myo-sdk-win-0.9.0\include" -L"E:\MYO\myo-sdk-win-0.9.0\lib" -lmyo64 myo_sfun.cpp'
Building with 'MinGW64 Compiler (C++)'.

MEX-file 'myo_sfun.cpp' did not build successfully!

Changing directory to original directory:
'E:\MYO\MyoMex-master\MyoMex\myo_mex'

Changing directory to build directory:
'E:\MYO\MyoMex-master\MyoMex\myo_mex'
Error using build_myo_mex (line 67)
E:\MYO\MyoMex-master\MyoMex\myo_mex\myo_sfun.cpp:5:22:
fatal error: simstruc.h: No such file or
directory
#include "simstruc.h"
^
compilation terminated.

Error in MyoMex_Quickstart (line 16)
build_myo_mex(sdk_path); % builds myo_mex

Mark Tomaszewski

Hi YA,

You need to add the location of myoXX.dll to the PATH environment variable in Windows. See the solution here, https://github.com/mark-toma/MyoMex#add-myo-sdk-to-path

Mark

Hi YA

Hello Mark. I have this problem
Error using MyoMex (line 100)
MEX-file 'myo_mex' failed to initialize with error:
'Invalid MEX-file
'C:\mark-toma-MyoMex-6a6a0d5\MyoMex\myo_mex\myo_mex.mexw32':
The specified module could not be found..'

Please help me!

Hi YA

Mark Tomaszewski

Hi m,

No, this package will not work with Mac. The SDK implementation relies on Windows API. If somebody would like to port myo_mex.cpp, that would be great!

Mark

m

Can this application be used on Mac?

Javier Pinzón

Mark Tomaszewski

Miguel, verify that two Myos are connected via Myo Connect then type

mm = MyoMex(2)

Now you can index into the MyoData objects to read the accelerometer data log for example.

a1 = mm.myoData(1).accel_log
a2 = mm.myoData(2).accel_log

If you have any other usage or development support questions, please use *email* to ask them instead of this comment section.

Miguel Saint-Amant

Hi Mark,
I have read a lot on the subject, and currently I am able to collect data from two armbands simultaneously using two computers on matlab.

I would like to see the possibilities of collecting IMU data on a single computer.
Would you have a simple code to send me.

Thank you
Mig
migstamant@hotmail.com

Mark Tomaszewski

Correction to "autocorrect" typo in the previous comment:

Streaming EMG with more than one Myo is not possible WITH applications using a single dongle.

Mark Tomaszewski

Hi Miguel,

Streaming EMG with more than one Myo is not possible without applications using a single dongle. This includes the implementation of Myo Connect and thus this package. There do exist alternatives that may work. You can email me for more info.

Miguel Saint-Amant

Hi Mark,
I want to use your code but I need it for two amrband with EMG enabled. This is a way to get it ?

Thank you
Mig

Sophia Tovornik

Hi Mark, I want to use your package to log EMG and IMU data. But timeEMG and timeIMU get out of sync after a few seconds. How can I fix this?
Thank you

Sophia Tovornik

Mark Tomaszewski

ATTENTION!!!

Do you have MinGW installed on your system? Would you like to help me try to extend support to MinGW for this package?

Stop by this open issue on GitHub to contribute with the information that I need!

https://github.com/mark-toma/MyoMex/issues/14

Mark Tomaszewski

Luz,

The input to build_myo_mex() should be the absolute path to the root directory for Myo SDK. This directory name is "myo-sdk-win-0.9.0" for the current version of the SDK. I recommend extracting the Myo SDK to the root of the C:\ drive if you have a user account with suitable permissions. In this case, you will call the build tool as such:

>> build_myo_mex C:\myo-sdk-win-0.9.0\

Otherwise, if you choose to locate the SDK files in your user's MATLAB directory, then you might use the following:

>> build_myo_mex C:\Users\Dell\Documents\MATLAB\myo-sdk-win-0.9.0\

Luz

Hey Mark, but I have this mistake
build_myo_mex C:\Users\Dell\Documents\MATLAB
Error using build_myo_mex (line 31)
sdk_path = 'C:\Users\Dell\Documents\MATLAB' does not contain subdirectory 'include'

Mark Tomaszewski

Luz, I just added the following information to README.md:
https://github.com/mark-toma/MyoMex/blob/master/README.md#add-myo-sdk-to-path

Thanks again to C. Spiewak for providing the tutorial link!

Mark Tomaszewski

JaeHyoung, I'm not sure what you're attempting to accomplish with your code. If you require additional assistance, please email me at: mark (at) mark-toma (dot) com

Here are a couple thoughts that may be helpful ...

1. The Myo device MUST be paired and connected via Myo Connect when the MyoMex() object is instantiated in MATLAB.

2. After successful instantiation of MyoMex, you must call the delete() method on the object BEFORE you clear it from the workspace (or lose scope on the handle to MyoMex).

mm = MyoMex();
% use MyoMex
mm.delete(); % <-- delete mm BEFORE clearing it!
clear mm

All user code shall properly delete MyoMex. Although the MyoMex constructor attempts to recover from failure status resulting from poorly written code and/or usage, the behavior is undefined otherwise.

JaeHyoung Park

Hi Mark. we want to know the message after mm = MyoMex(countMyos).
Warning: 'MyoMex' class 소멸자(Destructor)를 실행하는 중 다음 오류가 발생했습니다.
다음 사용 중 오류가 발생함: MyoMex/stopStreaming (line 181)
MyoMex is not streaming.

ERROR: MyoMex/delete (line 133)
this.stopStreaming();

ERROR: MyoMex (line 57)
function this = MyoMex(countMyos,logDataFlag)

and want to know how to delete objects based on the old class file. how to use commend 'clear' can you told us? Thank you.

Luz

Hi, everyone. I read the document called "READ.txt", could you please better explain this step: Next, add "SDK_PATH\bin" to your PATH environment variable. This allows
your compiler to find the required DLL (i.e. myo32.dll or myo64.dll) when
linking against the Myo SDK. In this example, we just add
";C:\myo-sdk-win-0.9.0\bin" to the end of the current PATH variable.
Thanks for all.

Mark Tomaszewski

UPDATE: SIMULINK SUPPORT!

Version 3.0 will include a Simulink library supporting streaming data with similar data to MyoMex.

Check out the devel-3.0 branch of this repository to use the development version before release! https://github.com/mark-toma/MyoMex/tree/devel-3.0

This solution currently depends on:

* Windows Real-Time Target: Real-Time Sync block (required)

* DSP System Toolbox: Unbuffer blocks to convert framed data outputs into sample-based signals (standard, but not required)

* Simulink 3D Animation: VRML Sink for visualization of IMU data (only used in 1 example)

sher azam

Awesome work. curious to play with the data in MATLAB.

William Wang

Sumit Raurale

Mark Tomaszewski

Thanks for the link, C. Spiewak!

To be slightly more specific, this is the solution for an error stating, "invalid mex file ... the specified module cannot be found"

C. Spiewak

Disregard my last link, it is wrong. This is the site that you want: http://www.computerhope.com/issues/ch000549.htm

C. Spiewak

If you are getting the "Error using MyoMex (line 103)" error add the myo sdk/bin to the MATLAB path. Follow these instructions: https://www.mathworks.com/help/matlab/matlab_env/add-folders-to-matlab-search-path-at-startup.html

C. Spiewak

Mark Tomaszewski

Santiago, You must add the Myo SDK bin directory to the Windows PATH environment variable. Email me at mark@mark-toma.com for more detail. I've replied to your email with a bit more information.

Santiago Luna

Hello mark i have this problem
Error using MyoMex (line 103)
MEX-file 'myo_mex' failed to initialize with error:
'Invalid MEX-file 'C:\mark-toma-MyoMex-048d7b5\MyoMex\myo_mex\myo_mex.mexw64': The specified module could not be
found..'

can you help me?

Mark Tomaszewski

Hello Peter, I guess it's some sort of problem with MinGW. This is the important line,
"C:\myo-sdk-win-0.9.0\lib/myo64.lib: error adding symbols: File in wrong format
collect2.exe: error: ld returned 1 exit status"
I'm afraid that I'm not qualified to assist with solving this issue -- Some others have also had issues with MinGW.

My best advice is to use some variant of Microsoft Visual C++ that supports C++11.

Otherwise, your best bet is to ask the greater MATLAB community for help here. Feel free to email me with additional questions or if you need me to chime in on a post somewhere.

Peter Balázs

Hello Mark, I have had some problem with the quick start .m . I get the following when I try to run it:
>> MyoMex_Quickstart
Changing directory to build directory:
'C:\Users\TheDefterus\Documents\MATLAB\MyoMex-master\MyoMex-master\MyoMex\myo_mex'
Evaluating mex command:
'mex -O -I"C:\myo-sdk-win-0.9.0\include" -L"C:\myo-sdk-win-0.9.0\lib" -lmyo64 myo_mex.cpp'
Building with 'MinGW64 Compiler (C++)'.
Changing directory to original directory:
'C:\Users\TheDefterus\Documents\MATLAB\MyoMex-master\MyoMex-master\MyoMex\myo_mex'
Changing directory to build directory:
'C:\Users\TheDefterus\Documents\MATLAB\MyoMex-master\MyoMex-master\MyoMex\myo_mex'
Error using build_myo_mex (line 61)
C:\myo-sdk-win-0.9.0\lib/myo64.lib: error adding symbols: File in wrong format
collect2.exe: error: ld returned 1 exit status
Error in MyoMex_Quickstart (line 17)
build_myo_mex(sdk_path); % builds myo_mex

I have no idea how to proceed now as this seems very bizarre. I am useing R2016b and windows 10 pro.

Mark Tomaszewski

Luis, You must add the Myo SDK bin directory to the Windows PATH environment variable. Email me at mark@mark-toma.com for more detail.

Luis Morales Escobar

Hello Mark. I'm work in Matlab R2015a and I have this problem:

Error using MyoMex (line 103)
MEX-file 'myo_mex' failed to initialize with error:
'Invalid MEX-file 'C:\mark-toma-MyoMex\MyoMex\myo_mex\myo_mex.mexw64': Can't find specified module.

Please help me!!

Mark Tomaszewski

Sorry for the delay! I missed notifications for some recent comments.

fray, Perhaps build_myo_mex isn't being pointed to the Myo SDK properly. Call build_myo_mex(SDK_PATH) where SDK_PATH is the absolute path to Myo SDK root. For example, 'C:\myo-sdk-win-0.9.0' if Myo SDK is extracted to the root of C:\

Tayachew, This should work fine with r2015b.

Elvis, I'm sorry I can't help without more detail. Please send me an email at mark@mark-toma.com with the commands you used and full error message.

Elvis Galvis

Hello Mark, when I try to run build_myo_mex I'm getting a long error log starting like this "Error using build_myo_mex (line 61)

when I write >>mex -setup too... But I do not know what it is the error with my compiler.

Fernanda Villalba

Jacob Ruprecht

Jacob Ruprecht

Tayachew Agidew

Is it possible to run it on Matlab 2015b?

Daniel Pak

I am logging on just to rate this file. Helped out amazingly for hackathon

fray cobeña

Hello Mark I'm having a problem installing the myo mex, I have the 32 bit matlab R2013a version, windows 10 32-bit and the visual studio professional 2012 version but when I'm building the myo mex I'm getting an error link of 'myo_mex.mexw32' failed. Please I need help and also have the same problem for a 64-bit and the same matlab and visual studio version

Mark Tomaszewski

The timeXXX properties are computed from number of samples received and sample time. If they're growing at different rates, then perhaps MyoMex is receiving incomplete data from Myo (or maybe there's a bug).

You can look at rateXXX to do a sanity check on the actual data rates into MyoMex.

If timeEMG tends to be lesser than timeIMU, then there's some EMG data being dropped (or maybe just lagging behind). This could be happening in the BLE connection or in Myo SDK.

Send me an email if you'd like to discuss this further.

Michael

Thanks so much for your work on this Mark!

I am running into some inconsistencies between the IMUtime and EMGtime. It doesn't always vary in the same manner but in general the longer I stay connected to the Myo the greater the discrepancy; with EMGtimes being smaller than IMUtimes. I tested this by creating some action with the Myo and seeing when it appears in each of the signals. Over time I can also see the final values in IMUtime and EMGtime growing farther apart.

Have others run into this issue? Are IMUtime and EMGtime read from the Myo itself?

Maria Rivera

Mark Tomaszewski

Anil, I'll answer here just to illuminate this issue for others. The C++ source code requires a C++11 compatible compiler. No need to reply here, we can continue support as needed via email.

Anil Ayvaz

Hello Mark, when I try to run build_myo_mex I'm getting a long error log starting like this "Error using build_myo_mex (line 61)
In file included from
C:/MATLAB/SupportPackages/R2016a/MW_MinGW_4_9/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++/array:35:0,...".
Do you have an idea what might be the error?

Sumit Raurale

Yi Jui Lee

Marcos Tomaszewski... thanks, i gonna prove your hint, if i have any problem, i'll write you!!! thank you very very much... bye

Mark Tomaszewski

Rodrigo, See the description above,

This is being developed on two machines,
1) MATLAB R2013a; Windows 8.1 64-bit; VS2012 Pro.
2) MATLAB R2013a; Windows 7 64-bit; VS2010 and Microsoft SDK 7.1

Other combinations may work as well. These are the ones I'm using.

Since there may be many subtle failure points when building the MEX function, please send me an email for more assistance (mark@mark-toma.com). My server will be down in a couple days so follow up if I don't respond within a day.

Hi... what compiler we need to configure using mex -setup funtion in MATLAB... I tryed whith several configurations and don't work the mex bulding... thanks...

Mark Tomaszewski

GIANLUCA, I currently don't implement myo::vibrate(). I don't plan to add this feature since my main goal is "perfect" data acquisition.

If you'd like to do this yourself, fork GitHub repo and I can try to help you out.

GIANLUCA LENTINI

can I send a command to make it vibrate?

Mark Tomaszewski

Yadira,

When the MyoMex(countMyos) constructor is called, exactly countMyos Myo devices (1 by default) must be paired, connected, and not asleep nor locked in the Myo Connect application. This can be verified by using the ping feature of Myo Connect Armband Manager.

If you need additional support, you can email me.

Yadira Moran

Hi, Mark thanks for you code, but i have a problem... I'm traying to run the Quickstart, and this error appear:
MyoMex_Quickstart
Warning: MEX-file 'myo_mex' is locked. Attemping to unlock and re-initialize.
> In MyoMex/myo_mex_assert_ready_to_init (line 293)
In MyoMex (line 88)
In MyoMex_Quickstart (line 32)
Error using MyoMex (line 100)
MEX-file 'myo_mex' failed to initialize with error:
'myo_mex failed to initialize with countMyos.
'

Error in MyoMex_Quickstart (line 32)
mm = MyoMex(countMyos)

R L

Mark Tomaszewski

JNIE (and others),

FYI - Here's the bugfix for timeEMG* properties. Its super simple (3 characters). I won't be merging this into master quite yet.

https://github.com/mark-toma/MyoMex/commit/20049ef4a35c9f66e2b809cc1d9215296eda05a3

JNIE

Mark,

Thanks for the quick reply, and for your work. It is very helpful.

Mark Tomaszewski

JNIE, Correction to my previous comment: 5ms sampling time (200Hz) for EMG data.

Mark Tomaszewski

JNIE, I found the bug with assignment of the timeEMG* properties. You can continue using emg_log assuming uniform 2ms sampling time (ignore timeEMG* values) with confidence until I patch it in the next few days.

Mark Tomaszewski

JNIE, You may have caught a bug! Can you email me to discuss this further? If there's a problem here, I'd like to fix it within a few days.

mark (at) mark-toma (dot) com

N.B. The emg_log itself is read with best-effort from the Myo SDK. Assuming adequate performance (MATLAB process, Myo connect, Windows etc.) the rows of emg_log will be correspond with 200Hz sample rate at which EMG data is provided. The timeXXX_log vectors are simply computed for convenience to correspond with the data at this assumed sample time.

JNIE

I'm using this exclusively for EMG data. I noticed that my timeEMG_log doesn't always have increasing values, that is a given sample may have a value lower than the one directly previous to it. Is this expected? Do you know what this means?

Miguel Simão

Mark,
Thanks for the prompt reply. It's working great for poses now, which is what I needed. So, thank you so much for spending the time fixing that bug. In respect to xDir and arm, I think they are still bugged. xDir_unknown and arm_unknown are still 1 (xDir and arm are both showing the value 2).

Mark Tomaszewski

Carol, yes it's possible to plot the individual emg samples... mm.myoData.emg_log(kk,ii) is the data from the ii-th pod and the kk-th sample (time instance).

Furthermore, if [P,M] = size(mm.myoData.emg_log ),

M is constant 8 (number of sEMG channels).

P increases on average by 200 per second, and it's updated about 25 times per second.

I won't be able to answer questions about initializing and/or updating plots in a GUI here. The information above should be enough to guide you in seeking help elsewhere in a forum.

Carol Ch

Is possible to plot the seperate pods of the Myo armband in the GUI? Because I modify this line: hp.emg = plot(handles.ax_emg_strip,0,zeros(1,8)); to hp.emg = plot(handles.ax_emg_strip (:,1); I have a mistake

Mark Tomaszewski

@Miguel, check out this commit to devel-2.2 for a patch,
https://github.com/mark-toma/MyoMex/commit/cb26c903cb4aa358ad7833e1486d6ea549871d17

I checked behavior by inspecting the pose values using MyoDataGUI_Monitor, and I would guess that arm and xDir are working now too (same bug, same fix).

Mark Tomaszewski

Miguel,

Early in development {pose,arm,xDir} worked perfectly. Since then, many changes have been made, and I lost interest in validating this functionality. I actually considered stripping it out of MyoMex, but left it in as boilerplate for a future fix.

The relevant code is all in myo_class.hpp. If you'd like to discuss this further, and possibly dig into the code to fix it, please email me.

mark (at) mark-toma (dot) com

Miguel Simão

Great job here, Mark.
Question: I'm using one Myo and I'm not getting some (or all, not sure) of the meta data, such as the poses. I'm getting IMU and EMG data though. Do you have any idea of why this could be happening?

taha janjua

umut demirel

Thank you very much for this wrapper. It really helps to complete my thesis project!

Mark Tomaszewski

Sorry there are some breaking changes in version 2.1 ...

* EMG data is not enabled when using two Myos.

* Properties pose, arm, xDir are now sampled against timeIMU (instead of timeEMG).

PS, Miguel, you're very welcome -- I'm glad you find this useful!

Miguel Martinez

Mark, I been testing the program and it is a great job.

Thank you for sharing.

Mostafa Ghobadi

Sounds good. It's pretty well developed.

Mark Tomaszewski

FYI, Everyone (Miguel, specifically),

I just updated to a new version. Much of the code was rewritten to add support for full EMG sample rate and multiple Myo devices (two). I also switched this over to GitHub repo for future maintenance.

Before my last commit to the GitHub repo it was a broken mess... From now on the master branch will remain stable with documented changes. Pull requests are welcome!

Mark Tomaszewski

Miguel,

The current release only supports polling for the most recent data from all sources at 50Hz. Modifying this code to support full sample rate from IMU (50Hz) and EMG (200Hz) is nontrivial and involves changes to days handling in myo_class.hpp and myo_mex.cpp.

The good news is that I currently have a working alpha version with these features! You can check it out the GitHub repo (url below) before I tidy it up for an updated release here.

https://github.com/mark-toma/MyoMex/tree/master/MyoMex

Miguel Martinez

Hello Mark,
How can I get the 200 Hz for the EMG signals?

great job.

Mark Tomaszewski

Carlo, this is because MATLAB cannot find the file "myo64.dll"

There are two approaches you can use to solve this. I prefer option (1).

1.) Add the path to myo64.dll to the PATH environment variable in Windows and then restart MATLAB. If you extracted the Myo SDK to C:\ then this path is "C:\myo-sdk-win-x.x.x\bin"

2) Find the myo64.dll file and copy it into your current folder in MATLAB. This option is not preferred since it requires your MATLAB session to run from this folder (or copying the DLL all over the place).

Carlo Gotti

Hello Mark, thx for your release! I get this error while executing the command m=MyoMex().. I've done everything i read on the Readme file:
" m = MyoMex()
Error using MyoMex (line 224)
MEX-file 'myo_mex' failed to initialize with error:
'Invalid MEX-file
'C:\Users\Carlo\Documents\MATLAB\Myo_SDK_MEX_Wrapper\MyoMex\myo_mex\myo_mex.mexw64':
Can't find specified module.'

Mark Tomaszewski

Hamdi, yes this should work for you once you set up a compiler for mex.

Type "mex -setup c++" to set up a compiler before running build_myo_mex again. See this link for more information,

http://www.mathworks.com/help/matlab/matlab_external/choose-c-or-c-compilers.html

Hamdi Albunashee

Hamdi Albunashee

Hello, Does is work under Windows7, 64bit? if yes, Why I get this error ?

>> build_myo_mex c:\myo-sdk-win-0.9.0\

Changing directory to build directory:
'C:\Users\Eng\Google Drive\1new r2015 fall\EMG\Myo_SDK_MEX_Wrapper\MyoMex\myo_mex'

Evaluating mex command:
'mex -I"c:\myo-sdk-win-0.9.0\include" -L"c:\myo-sdk-win-0.9.0\lib" -lmyo64 myo_mex.cpp'
Error: Could not detect a compiler on local system
which can compile the specified input file(s)

Changing directory to original directory:
'C:\Users\Eng\Google Drive\1new r2015 fall\EMG\Myo_SDK_MEX_Wrapper\MyoMex\myo_mex'

Changing directory to build directory:
'C:\Users\Eng\Google Drive\1new r2015 fall\EMG\Myo_SDK_MEX_Wrapper\MyoMex\myo_mex'
Error using build_myo_mex (line 48)
Unable to complete successfully.

Amir

MATLAB Release Compatibility
Created with R2013a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!