Welcome Guest,Register Now
Log In

ANT Forum

Welcome guest, please Login or Register

   

converting count units from sensors

Rank

Total Posts: 9

Joined 2018-02-28

PM

Using the FITtoCSV.bat file in the SDK I obtained the csv from the fit file.
In the csv the accelerometer, gyro and magnetometer data are given in counts and need to be converted in a (physically) meaningfull unit before one can use them.

At page 43, section 6.3 of the document Flexible and Interoperable Data Transfer Protocol Rev 2.3 provided in the SDK package, there is an equation that should be used to convert count to an understandable unit of measure.
However I don't understand what should I do with the matrix... like, should I calculate the determinat of the matrix at samo point? what do I need to divide by the calibration_factor exactely?

I'm no mathematician and I don't know java (so any answer like "use the java plugin" is useless to me).

Any suggestion is welcome!

Filippo      
RankRankRank

Total Posts: 68

Joined 0

PM

The first thing to do is calculate the input vector by performing the subtraction operations and multiplying each element by the CalFactor. After calculating the input vector, calculate the rotated vector using the process described here: https://www.varsitytutors.com/hotmath/hotmath_help/topics/multiplying-vector-by-a-matrix. The output of the calculation should be a 3 element adjusted vector.

You can take a look at the plugins to see how the SDK performs the adjustment.
Here is the C# SDKs Implementation of the adjustment:
private float[] AdjustSensorData(int[] rawDataCalibrationParameters calParams)
{
    float[] calibratedValues 
= new float[rawData.Length];
    
float[] rotatedValues = new float[rawData.Length];

    
//Apply the calibration parameters
    
for (int i 0rawData.Lengthi++)
    
{
        calibratedValues[i] 
= (float)rawData[i];
        
calibratedValues[i] -= calParams.LevelShift;
        
calibratedValues[i] -= calParams.ChannelOffset[i];
        
calibratedValues[i] *= calParams.CalFactor;
        
calibratedValues[i] /= calParams.CalDivisor;
    
}

    
// Apply the rotation matrix
    // [Rotation] * [XYZ]
    
rotatedValues[0] = (calParams.RotationMatrix[00] calibratedValues[0])
        + (
calParams.RotationMatrix[01] calibratedValues[1])
        + (
calParams.RotationMatrix[02] calibratedValues[2]);

    
rotatedValues[1] = (calParams.RotationMatrix[10] calibratedValues[0])
        + (
calParams.RotationMatrix[11] calibratedValues[1])
        + (
calParams.RotationMatrix[12] calibratedValues[2]);

    
rotatedValues[2] = (calParams.RotationMatrix[20] calibratedValues[0])
        + (
calParams.RotationMatrix[21] calibratedValues[1])
        + (
calParams.RotationMatrix[22] calibratedValues[2]);

    return 
rotatedValues;
     
Rank

Total Posts: 9

Joined 2018-02-28

PM

Great Thanks!

you made my day!      
Rank

Total Posts: 1

Joined 2019-05-17

PM

Hey Filippo, were you able to figure this all out?! Attempted to utilize the code above, but to no luck. Not strong enough in C# to understand it fully either (even had some really good data scientists take a crack at it).

Thus, I'm still having an issue converting the (accelerometer_data.compressed_calibrated_accel_x[mG]) data into meaningful information.

Would love to pick your brain on the process you went about and thanks!