Skip to content

Commit

Permalink
Fixes constant (init) meta data values
Browse files Browse the repository at this point in the history
Previously pose, arm, xDir were reporting ZOH on initial values for all
time due to a bug in the sync<data>() and add<data> functions in
myo_class.hpp
  • Loading branch information
mark-toma committed May 17, 2016
1 parent b4178a0 commit cb26c90
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion MyoMex/MyoMex.m
Expand Up @@ -48,7 +48,7 @@
timerStreamingData
nowInit
DEFAULT_STREAMING_FRAME_TIME = 0.040
NUM_INIT_SAMPLES = 4
NUM_INIT_SAMPLES = 5
end

methods
Expand Down
6 changes: 3 additions & 3 deletions MyoMex/myo_mex/myo_class.hpp
Expand Up @@ -104,11 +104,11 @@ class MyoData
timestampIMU = ts;
// fill pose, arm, and xDir up to the new countEMG
myo::Pose p = pose.back();
while ( pose.size()<countIMU ) { pose.push(p); }
while ( pose.size()<(countIMU-1) ) { pose.push(p); }
myo::Arm a = arm.back();
while ( arm.size()<countIMU ) { arm.push(a); }
while ( arm.size()<(countIMU-1) ) { arm.push(a); }
myo::XDirection x = xDir.back();
while ( xDir.size()<countIMU ) { xDir.push(x); }
while ( xDir.size()<(countIMU-1) ) { xDir.push(x); }
}
}

Expand Down
9 changes: 5 additions & 4 deletions MyoMex/myo_mex/myo_mex.cpp
Expand Up @@ -31,6 +31,7 @@ const char* output_fields[] = {"quat","gyro","accel","pose","arm","xDir","emg"};
#define STREAMING_TIMEOUT 5
#define INIT_DELAY 1000
#define RESTART_DELAY 500
#define READ_BUFFER 2

// program state
volatile bool runThreadFlag = false;
Expand Down Expand Up @@ -231,15 +232,15 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
mxArray *outData2[NUM_FIELDS];

// Initialize output matrices for myo 1
szIMU1 = collector.getCountIMU(1)-1;
szEMG1 = collector.getCountEMG(1)-1;
szIMU1 = collector.getCountIMU(1)-READ_BUFFER;
szEMG1 = collector.getCountEMG(1)-READ_BUFFER;
makeOutputIMU(outData1,szIMU1);
makeOutputEMG(outData1,szEMG1);

// Initialize output matrices for myo 2
if (countMyos>1) {
szIMU2 = collector.getCountIMU(2)-1;
szEMG2 = collector.getCountEMG(2)-1;
szIMU2 = collector.getCountIMU(2)-READ_BUFFER;
szEMG2 = collector.getCountEMG(2)-READ_BUFFER;
makeOutputIMU(outData2,szIMU2);
makeOutputEMG(outData2,szEMG2);
}
Expand Down

0 comments on commit cb26c90

Please sign in to comment.