I am working on IMU data analysis in C++ and I have integrated the OpenSim API into my project. Even though there are not many examples online, I tried to figure out how the IMUPlacer and IMUInverseKinematics tools and classes work.
The fact is that what I obtain from my code is slightly different from what I can obtain from the OpenSim GUI Application, and I am not able to understand what I am doing wrong.
Here is the C++ snippet:
Code: Select all
auto modelProcessor = OpenSim::ModelProcessor('Rajagopal_2015.osim');
OpenSim::Model osimModel = modelProcessor.process();
osimModel.setName("Rajagopal_2015");
osimModel.finalizeFromProperties();
auto imuPlacer = OpenSim::IMUPlacer();
imuPlacer.set_orientation_file_for_calibration(placement_fileForOpensim);
imuPlacer.set_base_imu_label(sensorPelvis);
SimTK::Vec3 imuPlacerRotations(-90, 0, 0);
imuPlacer.set_sensor_to_opensim_rotations(imuPlacerRotations);
osimModel.initSystem();
imuPlacer.setModel(osimModel);
imuPlacer.run();
OpenSim::Model outputModel = imuPlacer.getCalibratedModel();
outputModel.finalizeFromProperties();
auto inverseKinematics = OpenSim::IMUInverseKinematicsTool();
inverseKinematics.setModel(outputModel);
inverseKinematics.set_orientations_file(legmvmnt_fileForOpensim);
inverseKinematics.set_sensor_to_opensim_rotations(imuPlacerRotations);
inverseKinematics.set_output_motion_file(output_fileForOpensim);
inverseKinematics.run(true);
If I use the same files for the IMU Placer Tool (Orientation file at placement pose as 'placement_fileForOpensim' and Rotation X set to -90) and for the IMU Inverse Kinematics Tool (Sensor orientation file as 'imuPlacerRotations' and Rotation X set to -90), I obtain the expected movement. However, it seems that the code reconstructs the movement in a different reference frame.
Here are the GUI results: https://youtube.com/shorts/dAPu3CIu2bY?feature=share and the C++ motion result https://youtube.com/shorts/dAPu3CIu2bY. Note that they are both 'frontal view'. I am using OpenSim 4.5