Why the results of factorIMU predict and insfilter predict are exactly opposite to each other?

52 views (last 30 days)
I used the imuSensor to generate the measurement data of the imu, and then used the factorIMU to perform the predicted integration calculation of the generated data. However, I found that the result was not consistent with the expectation. So, I further compared the predict results of the insfilter with the expected ones.
For example, when the coordinate system is defined as NED, and there is a positive 1 m/s^2 acceleration in the x-axis and z-axis, when predicting the data 1 second later, the speed obtained by factorIMU is -1 m/s and -1 m/s, while the predicted data by insfilter is 1 m/s and 1 m/s.
I verified both the NED and ENU coordinate systems separately, and the phenomenon was the same.
I'm very curious as to why different results occurred. Looking forward to your reply very much.
Below is the code I used for verification. The version of Matlab is 2025b.
clear;clc;close all
FRAME_TYPE = "NED" % NED/ENU
%% DEMO 1 Verify the relationship between the output of the IMU and the actual motion acceleration.
disp("DEMO 1")
trueAcceleration = [1 0 1];
trueAngularVelocity = [0 0 0];
IMU = imuSensor('ReferenceFrame',FRAME_TYPE);
[accelerometerReadings,gyroscopeReadings] = IMU(trueAcceleration,trueAngularVelocity);
accelerometerReadings
% Summing-up
% --FRAME_TYPE = NED
% trueAcceleration AccelReading
% [0, 0, 0] [0, 0, 9.8]
% [1, 0, 1] [-1, 0, 8.8]
% --FRAME_TYPE = ENU
% trueAcceleration AccelReading
% [0, 0, 0] [0, 0, -9.8]
% [1, 0, 1] [-1, 0, -10.8]
%% DEMO 2
disp("DEMO 2")
% Add an IMU factor to a factor graph
nodeID = [1,2,3,4,5,6];
sampleRate = 100; % Hz
gyroBiasNoise = 1.5e-9 * eye(3);
accelBiasNoise = diag([9.62e-9,9.62e-9,2.17e-8]);
gyroNoise = 6.93e-5 * eye(3);
accelNoise = 2.9e-6 * eye(3);
gyroReadings = repmat(gyroscopeReadings, 100,1);
accelReadings = repmat(accelerometerReadings, 100, 1);
params = factorIMUParameters( ...
SampleRate = sampleRate, ...
GyroscopeBiasNoise = gyroBiasNoise, ...
AccelerometerBiasNoise = accelBiasNoise, ...
GyroscopeNoise = gyroNoise, ...
AccelerometerNoise = accelNoise, ...
ReferenceFrame = FRAME_TYPE ...
);
f = factorIMU(nodeID, gyroReadings, accelReadings, params);
G = factorGraph;
G.addFactor(f);
prevPose = [0 0 0 1 0 0 0]; % Pose + Quaternion
prevVel = [0 0 0];
prevBias = [0 0 0];
[~,predictedVel] = predict(f,prevPose,prevVel,prevBias)
%% DEMO 3
disp("DEMO 3")
filter = insfilter('ReferenceFrame',FRAME_TYPE);
filter.IMUSampleRate = sampleRate;
% Fuse a gyroscope measurement of [0.1 0.2 –0.04] with a measurement noise covariance of diag([0.2 0.2 0.2]) .
for ii=1:100
predict(filter,accelReadings(ii,:),gyroReadings(ii,:));
end
% Show the fused state.
insPredVelocity = filter.State(stateinfo(filter).Velocity)'

Answers (1)

Akshai Manchana
Akshai Manchana on 21 Oct 2025 at 7:42
As explained in the following imuSensor simulation assumes platform motion. Meaning the platform experiences the said linear acceleration. The acceleration experienced by IMU sensor at the same time is the opposite of platform linear acceleration. This effect is similar to what you experience while sitting in a car. When you accelerate the car forward you experience the opposite while sitting within the car. This is evident from the equations used within the following documentation.
The insfilter predicts the motion of the platform where as the factorIMU predicts the motion of the imu sensor. Meaning the insfilter assumes an imaginary platform that expericences a motion in the negative direction as accelerometer measurement and predicts it's motion. Where as factorIMU just accumulates the accelerometer measurement and no platform motion assumption. When you accumulate accel readings with just gravity removed then you predict the motion of the sensor with the given accel radings. That is why they both predict opposite motions.
  7 Comments
Akshai Manchana
Akshai Manchana on 31 Oct 2025 at 4:56
Hi Paul,
I do agree that imuSensor returning opposite polarity measurements is slightly confusing. Which is one of the reasons in motivating us to take a different decision for factorIMU apart from majority of SLAM community using what factorIMU does. Having said this, what imuSensor does is not wrong either. It's all about the use-case. In imuSensor and insfilter the worksflows focus on most requent simulation scenario and IMU-GPS state estimation workflows. In their usecases the current default behaviors fit best. We will plan on improving the doc to make the behavior more visible than simply hiding it in the equations and enhance our tools to support more behaviors choosable as per use-case than restricting the default.
Paul
Paul on 31 Oct 2025 at 20:37
Another choosable behavior for the @doc:imusensor should be to allow the user to specify that the algorithm not add (or subtract as the case may be) g to the acceleration input to from totalAcc. That way the user can use whatever gravity model is appropriate and deal with it themselves rather than be locked in to the model assumed by imusensor, as can be done with the three axis accelerometer model in the Aerospace Blockset.

Sign in to comment.

Products


Release

R2025b

Community Treasure Hunt

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

Start Hunting!