Skip to content
Snippets Groups Projects
Commit 40c86446 authored by Wouda, Frank (UT-EEMCS)'s avatar Wouda, Frank (UT-EEMCS)
Browse files

Variable naming updated.

parent a9be8de5
No related branches found
No related tags found
No related merge requests found
function data = intSignals(data,index) function data = intSignals(data, calibration, index)
% Pre-allocate structures for rotated signals. % Pre-allocate structures for rotated signals.
if index == 1 if index == 1
data.rG = nan(data.N,3); data.posLocal = nan(data.N,3);
data.vG = nan(data.N,3); data.velLocal = nan(data.N,3);
data.aG = nan(data.N,3); data.accLocal = nan(data.N,3);
end end
% start with initial orientation of unit rotation matrix. % start with initial orientation of unit rotation matrix.
rt=eye(3); unitRotMat=eye(3);
% Current part of analysis. % Current part of analysis.
indexes = data.tMiddle(index):data.tMiddle(index+1); indexes = data.tMiddle(index):data.tMiddle(index+1);
% Rotate the gyroscope data to Foot-frame. % Rotate the gyroscope data to Foot-frame.
gF = (data.Rcal*data.dgyr(indexes,:)'); gyroLocal = (calibration.rotMatrix*data.filtGyr(indexes,:)');
% Integrate the signals from this orientation, such that everything is % Integrate the signals from this orientation, such that everything is
% mapped in that frame. % mapped in that frame.
% RgsHat = intOmega(rt,data.dgyr(indexes,:),1/data.fs); rotMatHat = math.intOmega(unitRotMat,gyroLocal',1/data.fs);
RgsHat = intOmega(rt,gF',1/data.fs);
aR = (data.Rcal*data.dacc(indexes,:)')'; accLocal = (calibration.rotMatrix*data.filtAcc(indexes,:)')';
% Pre-allocate space. % Pre-allocate space.
aG = nan(length(indexes),3); accFreeLocal = nan(length(indexes),3);
% Gravity. % Gravity.
g = data.AccOffsetR; g = calibration.accOffsetR;
%% Get the free acceleration. %% Get the free acceleration.
for i = indexes for i = indexes
aG(i-indexes(1)+1,:) = permute(RgsHat(i-indexes(1)+1,:,:),[2 3 1])*... accFreeLocal(i-indexes(1)+1,:) = permute(rotMatHat(i-indexes(1)+1,:,:),[2 3 1])*...
aR(i-indexes(1)+1,:)'-g'; accLocal(i-indexes(1)+1,:)'-g';
end end
%% Integrate the free acceleration to obtain velocity. %% Integrate the free acceleration to obtain velocity.
vG = nan(length(indexes),3); velLocal = nan(length(indexes),3);
vG(1,:) = zeros(1,3); velLocal(1,:) = zeros(1,3);
for i = 2:length(indexes) for i = 2:length(indexes)
vG(i,:) = vG(i-1,:) + aG(i,:)./data.fs; velLocal(i,:) = velLocal(i-1,:) + accFreeLocal(i,:)./data.fs;
end end
timeAxis=(0:length(vG)-1)/data.fs; timeAxis=(0:length(velLocal)-1)/data.fs;
%% Linear velocity drift compensation. %% Linear velocity drift compensation.
for i = 2:length(indexes) for i = 2:length(indexes)
vG(i,:) = vG(i,:) - timeAxis(i)/timeAxis(end) * vG(end,:); velLocal(i,:) = velLocal(i,:) - timeAxis(i)/timeAxis(end) * velLocal(end,:);
end end
%% Strapdown integration: obtain position. %% Strapdown integration: obtain position.
rG = nan(length(indexes),3); posLocal = nan(length(indexes),3);
rG(1,:) = zeros(1,3); posLocal(1,:) = zeros(1,3);
for i = 2:length(indexes) for i = 2:length(indexes)
rG(i,:) = rG(i-1,:) + vG(i,:)./data.fs; posLocal(i,:) = posLocal(i-1,:) + velLocal(i,:)./data.fs;
end end
data.FPA(index) = atand(rG(end,2)/rG(end,1)); data.FPA(index) = atand(posLocal(end,2)/posLocal(end,1));
data.rG(indexes,:) = rG; data.posLocal(indexes,:) = posLocal;
data.vG(indexes,:) = vG; data.velLocal(indexes,:) = velLocal;
data.aG(indexes,:) = aG; data.accLocal(indexes,:) = accFreeLocal;
end end
\ No newline at end of file
...@@ -40,11 +40,11 @@ for iStep = steps ...@@ -40,11 +40,11 @@ for iStep = steps
% Pre-allocate space for the FPA values. % Pre-allocate space for the FPA values.
if iStep == 1 if iStep == 1
dataStruct.FPA = nan(length(steps),1); data.FPA = nan(length(steps),1);
end end
% Integrate the signals to obtain the FPA within a step. % Integrate the signals to obtain the FPA within a step.
dataStruct = math.intSignals(dataStruct, iStep); data = math.intSignals(data, calibration, iStep);
end end
end end
\ No newline at end of file
function [Rgs Rdot] = intOmega(Rgs_init, omega, t_sample) function rotMat = intOmega(initRotMat, omega, ts)
% intOmega.m - Calculates orientation matrix by integrating gyroscope signal % intOmega.m - Calculates orientation matrix by integrating gyroscope signal
% %
% Inputs: % Inputs:
% Rgs_init Initial orientation matrix % initRotMat Initial orientation matrix
% omega Angular velocity (rad/s) % omega Angular velocity (rad/s)
% t_sample Sample time % ts Sample time
% %
% Outputs: % Outputs:
% Rgs Orientation matrix [Nsamples x 3 x 3] % rotMat Orientation matrix [Nsamples x 3 x 3]
% %
% Martin Schepers, July 2005 % Martin Schepers, July 2005
% Henk Kortier, Sep 2011 % Henk Kortier, Sep 2011
% Frank Wouda, Aug 2023
N = size(omega,1); N = size(omega,1);
omega_sg_s_tilde = zeros(N,3,3); omegaMatrix = zeros(N,3,3);
for i=1:N for i=1:N
omega_sg_s_tilde(i,:,:) = [0 -omega(i,3) omega(i,2); omegaMatrix(i,:,:) = [0 -omega(i,3) omega(i,2);
omega(i,3) 0 -omega(i,1); omega(i,3) 0 -omega(i,1);
-omega(i,2) omega(i,1) 0]; -omega(i,2) omega(i,1) 0];
end end
Rgs = zeros(N,3,3); rotMat = zeros(N,3,3);
Rgs(1,:,:) = Rgs_init; % initial value rotMat(1,:,:) = initRotMat; % initial value
for i=2:N for i=2:N
R = permute(Rgs(i-1, :, :),[2 3 1]); R = permute(rotMat(i-1, :, :),[2 3 1]);
Rdot = R*permute(omega_sg_s_tilde(i,:,:),[2 3 1]); % Integrate R Rdot = R*permute(omegaMatrix(i,:,:),[2 3 1]); % Integrate R
R = R + t_sample.*Rdot; R = R + ts.*Rdot;
[A,~]=qr(R); % create proper rotation matrix [A,~]=qr(R); % create proper rotation matrix
Rgs(i,:,:) = sqrt(A.*A).*sign(R); % get correct sign rotMat(i,:,:) = sqrt(A.*A).*sign(R); % get correct sign
end end
\ No newline at end of file
%% This is the main file that runs on IMU data in csv format to obtain %% This is the main file that runs on IMU data in csv format to obtain
% foot progression angle. % foot progression angle.
clear all; close all; clc
% Run the settings file. % Run the settings file.
settingsFile settingsFile
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment