MetaWear matlab

I've been working on a small wrapper library that allows these metwaer sensors to work directly with matlab. There is still some problems with the implementation that needs to be cleaned up and at the moment, but this is mostly just a basic implementation that shows that this works. There are still some fairly outstanding bugs that I need to work out before this is a viable library to use. I wanted to see what people think about this and any suggestions or help would be appreciated.

There is also the problem of proper documentation and licensing.

sensor = metawear('connect','DB:04:F4:40:20:56');
metawear('enable_accelerometer',sensor);
%metawear('configure_accelerometer',sensor,4,25);
%metawear("enable_accelerometer",'DB:04:F4:40:20:56');

[epoch,x,y,z] = metawear('query_accelerometer',sensor);

https://github.com/GaitRehabilitation/mex-metawear

Comments

  • I've cleaned up some of the configuration problems and I have something that works fairly well. I have some plans to support more of the api. I'll have to write some matlab code to wrap the mexw file. This should improve the usability of the library. At the moment the library is only capable of streaming from the gyro and the accelerometer. I'll open it up to the rest of the sensors once I work out a sane way to handle the multiple signals. I'm also looking into a server setup for building.

  • edited September 13

    I updated the api a bit and restructured everything a bit. I will probably work on providing some binaries but the library is still unstable. the handler for connecting the sensor to ble has a chance to crash Matlab.

    here is some sample code from the base implementation but I would prefer if the library was wrapper in a matlab library for usability.

    %%connect
    sensor = metawear('connect','FF:FF:FF:FF:FF:FF');
    
    %% configure sensor
    
    metawear('configure_fusion_mode',sensor,'NDoF');
    metawear('configure_fusion_range',sensor,8);
    metawear('configure_fusion_write',sensor);
    quat_signal_1 = metawear('subscribe_fusion',sensor,'EULER_ANGLE');
    
    
    %% start capture
    metawear('set_sensor_fusion_flag',sensor,'EULER_ANGLE');
    metawear('enable_sensorfusion',sensor);
    
    while(true)
      [epoch_1,yaw, pitch,roll,heading] = metawear('query',sensor,quat_signal_1);
     if(size(epoch_1) > 0)
          %fprintf('angle: yaw: %f pitch: %f roll: %f , heading: %f \n',yaw, pitch,roll,heading);
          disp(['epoch: ' num2str(epoch_1(end)) ', yaw: ' num2str(yaw(end)) ', pitch: ' num2str(pitch(end)) ', roll: ' num2str(roll(end)) ', heading: ' num2str(heading(end)) '\n']);
      end
      pause(.1)
    end
    
    %% stop capture
    metawear('disable_sensorfusion',sensor);
    
  • Cool! Any further info on this?

  • It's pretty rough around the edges and you need to compile the mex code to use this. I haven't had time but I would like to wrap the whole thing in a matlab wrapper to hide the C++ api.

  • Just saw a post on LI on this too. Great job!!! Checking this out...

  • @mpollind,

    Keep us updated on this.

    For now we have a workaround we published that leverages our Python APIs and uses a TCP socket to stream data into Matlab: https://mbientlab.com/tutorials/Matlab.html

  • edited December 6

    might make sense to replicate the python API with this library. I would need to rework the api to an extent. I would like to have someone review the library and suggest changes. I'll have more time after finals.The code is available here: https://github.com/GaitRehabilitation/mex-metawear

Sign In or Register to comment.