Finding turning angle from real IMU data

18 ビュー (過去 30 日間)
Joselin George
Joselin George 2023 年 9 月 5 日
コメント済み: Joselin George 2023 年 9 月 9 日
I collected some data while walking straight and then turning left 90 degrees using an IMU placed on the pelvis. I would like to find out the magnitude and direction of turning using Matlab. I have tried using the ‘ahrsfilter’ option to obtain the Euler angles.
  • How can I align IMU axes with the reference frame axes of ahrsfilter to obtain the correct orientation?
  • Will the Euler angles give the magnitude and direction of turning?
  • I have tried to find out angles by integrating angular velocity obtained from the ‘ahrsfilter’. The results show a peak while turning 90 degrees but are unable to obtain the magnitude of the turn.
Please find the attached code, collected data and imu sensor axes.
*Note: The trial1_data.xlsx contains Frame No, Acc_x, Acc_y, Acc_z, Gyr_x, Gyr_y, Gyr_z, Mag_x, Mag_y, Mag_z data
Frame no from 387-567 is straight line walking. Frame no from 568-691 is 90 degrees left turning. Frame no 692-870 is again straight line walking.
clc;
clear all;
close all;
filename ='trial1_data.xlsx';
s=readmatrix(filename);
%Converting mm/s2 to m/s2
for i=2:4
for j=1:length(s)
accdata(j,i-1)=s(j,i)./1000;
end
end
% Converting deg/s to rad/s
for i=5:7
for j=1:length(s)
gyrdata(j,i-4)=s(j,i).*0.017453;
end
end
for i=8:10
for j=1:length(s)
magdata(j,i-7)=s(j,i);
end
end
% Estimating Orientation
fuse = ahrsfilter('SampleRate',300,'DecimationFactor',2);
[orientation,angularVelocity]= fuse(accdata, gyrdata, magdata);
% Plot Euler angles in degrees
y=rad2deg(unwrap(euler( orientation, 'YZX', 'frame')));
plot(y);
title('Orientation Estimate');
legend('Z-rotation', 'Y-rotation', 'X-rotation');
ylabel('Degrees');
% Creating a time vector.
xstart=0;
dx=0.01;
N=726;
x=xstart+(0:N-1)*dx;
x=x';
% Integrating Angular Velocity to obtain the angles
angles=cumtrapz(x,angularVelocity);
anglesd=angles./0.017453;

回答 (1 件)

Brian Fanous
Brian Fanous 2023 年 9 月 8 日
Can you clarify a bit more about what you mean by the "magnitude of the turn?"
What are you expecting to see in the plot? Should the 90 degree turn be on a different axis?
  1 件のコメント
Joselin George
Joselin George 2023 年 9 月 9 日
Thanks for the comment. Magnitude means the degrees of the turn.I would like to see 90 degrees on the plot.For the above data 0 degree for straight walking then 90degrees for the turn then 0 again for straight walking.

サインインしてコメントする。

製品


リリース

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by