-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_IMU_inverse_kinematics.m
38 lines (25 loc) · 1 KB
/
run_IMU_inverse_kinematics.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
%% run_imu_inverse_kinematics
% Script that sets up and runs IMU inverse kinematics.
% The methods are located in the Matlab Class orientationTracker.m
% Data has to be first converted using the convert_imu_data.m script.
clear all; close all; clc;
%% Set file paths.
imuFileName = 'MT_012005D6_009-001_orientations.sto';
accFileName = 'MT_012005D6_009-001_linearAccelerations.sto';
modelName = 'imuTrackingModel.osim';
baseIMUName = 'pelvis_imu';
baseIMUdirection = 'z';
%% Instantiate an orientationTracker
ot = orientationTracker(modelName, imuFileName, accFileName);
%% Convert the quternions to orientations
ot.convertQuaternionToRotations()
%% Rotate Data to OpenSim World
ot.rotateOrientations2OpenSimFrame()
%% Set the base IMU and direction
ot.setBaseIMUDirection(baseIMUName, baseIMUdirection);
%% Compute the rotation of the base frame given the Base IMU and direction
R_HG = ot.computeHeadingCorrection();
%% Calibrate the model
ot.calibrateModelFromOrientations();
%% Run IK
ot.InverseKinematics(1)