Page 1 of 1

### Post Process Matlab CSV and quaternion

Posted: Tue May 21, 2019 1:23 pm
Hi,

I have some problems to calculate angle on Matlab.
In the CSV file with quaternion, I think that Qy and Qz are inverted. Is it OK ?

In order to calculate the trunk flexion, I wrote this code, is it ok ?

% initialisation of quaternions
qa(:,1) = MoCap.data(:,6); %qa_w
qa(:,2) = MoCap.data(:,3); %qa_x
qa(:,3) = MoCap.data(:,5); %qa_y
qa(:,4) = MoCap.data(:,4); %qa_z
RigidBody(1).name='tronc';
RigidBody(1).datas=qa;

%% Offset TPOSE

indTPose=find(t>=durationTPose+beginTpose,1,'first');
% 2 quaternions of TPose (without NaN points)
TPoseA = nanmean(RigidBody(1).datas(beginTpose*framerate+1:indTPose,:));

%% Data process : angle between 2 rigidBody A and B

% Calculation of rotation in order to align the 2 RigidBody

RigidBody(1).datas = quatmultiply(quatinv(RigidBody(1).datas),TPoseA);
% Note : Motive display euler's is X (Pitch), Y (Yaw), Z (Roll), Right-Handed (RHS), Relative Axes
% so we decode eulers heres
[yaw, roll, pitch] = quat2angle(RigidBody(1).datas(:,:),'ZYX');