Page 1 of 1

IMU frame to OpenSim frame coordinate mapping

Posted: Tue Feb 15, 2022 2:40 pm
by swathihg
Hello,
I am confused on how the coordinate system are changing from IMU frame to OpenSim frame.
The below code is from the paper 'OpenSense: An open-source toolbox for Inertial-Measurement-Unit-based measurement of lower extremity kinematics over long durations'.

Especially why there is rotation around X(line 8) and again around Z(line 16). And what is the coordinates of IMU in IMU frame. A brief explanation on this snippet would be helpful. Thanks !

1 model = Model(modelFile_posed);
2 s = model.initSystem();
3 model.realizePosition(s);
4 osense = OpenSenseUtilities();

5 c = CoordinateDirection(CoordinateAxis(2),1);
6 oTableHC = TimeSeriesTableQuaternion(orientationsFileName);
7 R_HG = Rotation();
8 R_HG.setRotationFromAngleAboutX(-pi/2);
9 osense.rotateOrientationTable(oTableHC, R_HG);

10 v = OpenSenseUtilities.computeHeadingCorrection(model, s, oTableHC, baseIMUName, c);
11 computedAngularCorrection = v.get(1) * 180/pi;

12 osense = OpenSenseUtilities();
13 oTable = TimeSeriesTableQuaternion(orientationsFileName);
14 angularCorrection = computedAngularCorrection - pelvis_rotation;
15 R_HG = Rotation();
16 R_HG.setRotationFromAngleAboutZ(deg2rad( angularCorrection ));

17 osense.rotateOrientationTable(oTable, R_HG);
18 rotatedOrientations = strcat(ground_path,'walking/IMU/xsens/walking_orientations.sto');
19 STOFileAdapterQuaternion.write(oTable, rotatedOrientations);