IMU sensor fusion: imufilter command reduces number of samples

5 次查看(过去 30 天)
Hi Everyone.
I have collected the accelerometer and gyroscope data from IMU and want to find an angle estimate from it. I am using the 'imufilter' command with decimation factor 2. I find that the number of samples reduce after I convert the quaternion obtained into euler angles. Is there any way I can retain the sample size and get accurate angle estimate? How to do it numerically?
  2 个评论
Paul
Paul 2023-3-26
Can you post example data ( use the paperclip icon) and the code that illustrates the problem?
Aishwarya Rao
Aishwarya Rao 2023-3-27
编辑:Aishwarya Rao 2023-3-27
Here is the code for attached data
dd = importdata('sampledata.csv'); %%% Import the data
acc = dd.data(:,1:3); %%% Acceleration data XYZ
vel = dd.data(:,5:7); %%% Velocity data XYZ
aca = (pi/180).*acc;
vca = (pi/180).*vel; %%% deg to rad per sec or sec^2
Fs = 370;
decim = 2;
fuse = imufilter('SampleRate',Fs,'DecimationFactor',decim);
q = fuse(aca,vca);
x = eulerd(q,'XYZ','frame'); %%% quaternion to euler
The dimensions of each vector is 33334. I am getting final sample size as 16667. And the angles are around 128 radians which is weird.

请先登录,再进行评论。

回答(2 个)

Jack
Jack 2023-3-26
Hi,
When you convert the quaternion obtained from the imufilter command to Euler angles, you are essentially converting from a four-dimensional representation to a three-dimensional representation. This conversion can lead to a loss of information, which is why the number of samples is reduced.
To retain the sample size and get accurate angle estimates, you can avoid converting the quaternion to Euler angles and instead directly use the quaternion representation. Quaternions are a more efficient and numerically stable way of representing orientation than Euler angles.
You can use the quaternion function in MATLAB to create a quaternion object from the four values of the quaternion obtained from the imufilter command. Once you have the quaternion object, you can use the eulerd function to compute the Euler angles directly from the quaternion. This approach will allow you to retain the original sample size and avoid the loss of information that occurs when converting to Euler angles.
Here's an example code snippet to illustrate this approach:
% Load IMU data
load imu_data.mat;
% Set the decimation factor
decimationFactor = 2;
% Create an imufilter object
imuFilter = imufilter('SampleRate', imuData.SampleRate, 'DecimationFactor', decimationFactor);
% Process the IMU data
[orientations, angVelocities] = imuFilter(imuData.Acceleration, imuData.AngularVelocity);
% Convert the quaternion to Euler angles directly using the quaternion object
q = quaternion(orientations);
[roll, pitch, yaw] = eulerd(q, 'ZYX', 'frame');
In this example, imuData is a structure containing the accelerometer and gyroscope data, and decimationFactor is the decimation factor used for the imufilter command. The quaternion function is used to create a quaternion object from the orientations obtained from imufilter. The eulerd function is then used to compute the Euler angles directly from the quaternion object.
  1 个评论
Aishwarya Rao
Aishwarya Rao 2023-3-26
I have already done the same procedure which you suggested. But it doesn't work for me. Is there any alternative? Can I directly operate on euler angles without using quaternions?

请先登录,再进行评论。


Paul
Paul 2023-3-27
Hi Aishwarya,
Because the decimation factor is 2, shoudn't it be expected that there be half as many output samples as there are input samples? Why not use a (default) decimation factor of 1?
Why multiply the acceleration data by pi/180? Are the units already m/s^2?
Presumably the vel data is actually angular velocity? Are you sure the units aren't already in rad/sec?

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by