Raw data from Myo in Matlab


by krukowa

Raw data from Myo in Matlab

I wonder if anyone has attempted to access raw data from the Myo in Matlab. I would like to work on recognition of gestures, but for this I need raw data from EMGs in (preferably) real time.

Any suggestions how I could achieve this?

Thanks in advance.

Artur
by krukowa

Raw data from Myo in Matlab

I tried loading shared libraries from Myo SDK into Matlab, but unsuccessful.

Has anyone else been able to achieve this?
by boyali

Raw data from Myo in Matlab

Hello,

You can reach from this website.

http://web.sfc.keio.ac.jp/~naohisa/myo_WEB/myo_WEB.html
by krukowa

Raw data from Myo in Matlab

Hello Boyali,

Thank you for your response.

You have forgotten to provide a link to the ZIP file, but using some try and error I worked out its location: http://web.sfc.keio.ac.jp/~naohisa/myo_WEB/MatMYO.zip

When trying to re-compile your solution i faced two problems:
  • Determining the location of the SDK in Build_Myo_mex.m file did not work in Windows so I modified it:

    % Check for sdk
    clc
    clear

    MYO_SDK = ‘d:/SDK_Myo’; % My location of the Myo SDK

    if exist(MYO_SDK)~=7
    error('The “MYO_SDK” folder cannot be found.');
    end

    % determine where the Leap library is located
    if ismac
    libdir_switch=strcat('-L',MYO_SDK,'/lib');
    elseif isunix || ispc
    % check register size
    libdir_switch=strcat('-L',MYO_SDK,'/lib/');
    else
    error('Unknown operating system');
    end

    % create the mex command line
    fn='myo_2a.cpp';
    fprintf('Compiling %s\n',fn);
    cmd=['mex',…
    strcat(' -I',MYO_SDK,'/include ‘),…
    libdir_switch,…
    ’ -lmyo64 ‘,…
    fn];
    fprintf(’Evaluating “%s”\n',cmd)

    % run mex
    eval(cmd)

    fprintf('Done\n')

  • The “myo2.hpp” file is missing in the ZIP archive and it cannot be found in the Myo SDK.

Best regards,

Artur

Last edit: Feb. 14, 2015 01:17 PM

by boyali

Raw data from Myo in Matlab

Hello Artur,

The codes start with

% create the mex command line
fn='myo_2a.cpp';


myo_2a.cpp includes myoclass2a.hpp, there is a myo2,hpp.

myo2.hpp is actually myo.hpp. Since in MYO SDK Include folder, there are other folders which contain hpp files. Instead using SDK as is, I put all the hpp files in include folder. There are 2 Myo and myo header files. It is case sensitive, so I changed the name of myo.hpp to myo2.hpp to solve ambiguity.



Regards

Last edit: Feb. 14, 2015 07:18 PM

by boyali

Raw data from Myo in Matlab

Hello Artur

I have put the library here.

http://web.sfc.keio.ac.jp/~naohisa/myo_WEB/matMYO.zip

Regards
by krukowa

Raw data from Myo in Matlab

Thank you, Boyali,

One more question. I manage to run the acquisition function only once. The second time it runs, it crashes Matlab. Have you noticed such a behaviour on your version? I use Matlab 2014a and MEX function from your archive. I will check compiling it myself if this problem repeats.

Best regards,

Artur
by boyali

Raw data from Myo in Matlab

Hello Artur,

Yes I noticed it but, I had to give a break in developing this. Next month I will continue. The reason for the problem stem from the Matlab - C++ variable conversion. IF you change the following lines in the cpp file it will work probably. These are last booelean variables I put in the code.

lines 171, 172, 173 should be like as follow. If it does the same, please delete last three rows. After I corrected It worked properly.

mxSetFieldByNumber (plhs, 0, 6, mxOnArm);
mxSetFieldByNumber (plhs, 0, 7, mxisUnlocked);
mxSetFieldByNumber (plhs, 0, 8, mxWhichArm);

Last edit: Feb. 17, 2015 05:48 AM

by jeffreydu

Raw data from Myo in Matlab

Hello,

Any instruction or idea to interface with Simulink? like to display the signals on scopes in real time?

Thanks

Last edit: March 17, 2015 07:26 AM

by boyali

Raw data from Myo in Matlab

Hello

In the MYO Matlab library I provided a batch mode raw data collector which run 100 times in cpp environment and save the data as struct variable.

You can change mRow variable in the cpp file to 1. This variable is set to 100. And recompile the mex file, you will obtain a mex file which when it is called in the simulink. You can use mex files in simulink,.

When I set mRow=1 and run the following command is works well.
emg_data=zeros(10,8); 
for i=1:10
f=myo_2a ;
emg_data(i,:)=f.emgData;
end

Thanks

Last edit: April 16, 2015 08:28 PM

Moderator control