R2024b cannot reproduce documented example result
Show older comments
When I am ready to use imufilter, "Tune imufilter to Optimize Orientation Estimate",the current latest version R2024b cannot reproduce the documented example results? Please fix it in time!
TEST in MATLAB online and desktop MATLAB
ld = load('imufilterTuneData.mat');
qTrue = ld.groundTruth.Orientation; % true orientation
fuse = imufilter;
qEstUntuned = fuse(ld.sensorData.Accelerometer, ...
ld.sensorData.Gyroscope);
% reset(fuse);
cfg = tunerconfig('imufilter');
tune(fuse, ld.sensorData, ld.groundTruth, cfg)
qEstTuned = fuse(ld.sensorData.Accelerometer, ...
ld.sensorData.Gyroscope);
dUntuned = rad2deg(dist(qEstUntuned, qTrue));
dTuned = rad2deg(dist(qEstTuned, qTrue));
rmsUntuned = sqrt(mean(dUntuned.^2))
rmsTuned = sqrt(mean(dTuned.^2))
N = numel(dUntuned);
t = (0:N-1)./ fuse.SampleRate;
plot(t, dUntuned, 'r', t, dTuned, 'b');
legend('Untuned', 'Tuned');
title('imufilter - Tuned vs Untuned Error')
xlabel('Time (s)');
ylabel('Orientation Error (degrees)');
9 Comments
The problem seems to be the default objective limit is too high for this example. Set it to a low value and it works fine. Basically this means the initial imufilter parameters in the newer Matlab versions are a lot better then the previous implementations :P
ld = load('imufilterTuneData.mat');
qTrue = ld.groundTruth.Orientation; % true orientation
fuse = imufilter;
qEstUntuned = fuse(ld.sensorData.Accelerometer, ...
ld.sensorData.Gyroscope);
reset(fuse);
cfg = tunerconfig('imufilter');
cfg.ObjectiveLimit = 0.01; % HERE set objective limit so that it can do more iterations
tune(fuse, ld.sensorData, ld.groundTruth, cfg)
qEstTuned = fuse(ld.sensorData.Accelerometer, ...
ld.sensorData.Gyroscope);
dUntuned = rad2deg(dist(qEstUntuned, qTrue));
dTuned = rad2deg(dist(qEstTuned, qTrue));
rmsUntuned = sqrt(mean(dUntuned.^2))
rmsTuned = sqrt(mean(dTuned.^2))
N = numel(dUntuned);
t = (0:N-1)./ fuse.SampleRate;
plot(t, dUntuned, 'r', t, dTuned, 'b');
legend('Untuned', 'Tuned');
title('imufilter - Tuned vs Untuned Error')
xlabel('Time (s)');
ylabel('Orientation Error (degrees)');
xingxingcui
on 7 Oct 2024
Edited: xingxingcui
on 7 Oct 2024
I only ran the code here, which uses the latest version of matlab, 2024b. From my experience, it is hard to get the default parameters used in a function in version history.
If you have access to previous versions, check what the default parameters imufilter is using via running the below command in previous versions. That might give an idea on whether the initial parameters are changed or the implementation is changed.
a = imufilter
a.InitialProcessNoise
Cris LaPierre
on 7 Oct 2024
I was able to run the example in R2021b. The default ObjectiveLimit there is 0.1
xingxingcui
on 8 Oct 2024
xingxingcui
on 9 Oct 2024
xingxingcui
on 9 Oct 2024
Paul
on 10 Oct 2024
If tune doesn't reset the filter on input and again on output, then I'd question the code snippet in the example. Seems like that would cause the tuning to be corrupted by the state of the filter on the call to tune, and subsquent use of the filter will be corrupted by its state after tune completes. That doesn't sound like a good system, and it should be documented in bold that that's how the function works.
As for displaying the output on Answers, what happens after you enter code (using cod formatting as you've done) and the click the green triangle in the Run section of the ribbon?
Accepted Answer
More Answers (0)
Categories
Find more on Inertial Sensor Fusion in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
