IMU sensor fusion: imufilter command reduces number of samples
5 views (last 30 days)
Show older comments
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 Comments
Paul
on 26 Mar 2023
Can you post example data ( use the paperclip icon) and the code that illustrates the problem?
Answers (2)
Jack
on 26 Mar 2023
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.
Paul
on 27 Mar 2023
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?
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!