tunerCostFcnParam
Description
Examples
Tune insEKF
with MEX-Accelerated Custom Cost Function
Create an insEKF
filter object. Then create a cost function using the createTunerCostTemplate
object function.
filter = insEKF;
createTunerCostTemplate(filter);
doc = matlab.desktop.editor.getActive;
doc.saveAs(fullfile(pwd,"tunercost.m"));
Load prerecorded sensor data and ground truth data.
load("accelGyroINSEKFData.mat");
Create a MEX cost function using MATLAB Coder.
p = tunerCostFcnParam(filter);
disp("Generating MEX-accelerated cost function");
Generating MEX-accelerated cost function
codegen tunercost.m -args {p,sensorData,groundTruth};
Code generation successful.
Specify an initial orientation state and its covariance.
stateparts(filter,"Orientation",compact(initOrient)); statecovparts(filter,"Orientation",1e-2);
Create a measurement noise structure using the tunernoise
function.
mnoise = tunernoise(filter);
Create a tunerconfig
object using the created MEX cost function.
cfg = tunerconfig(filter, MaxIterations=1, ... ObjectiveLimit=1e-4, ... Cost="custom", ... CustomCostFcn=@tunercost_mex);
Tune the filter. Show the tuned measurement noise and process noise in the filter.
tunedmn = tune(filter,mnoise,sensorData, ...
groundTruth,cfg)
Iteration Parameter Metric _________ _________ ______ 1 AdditiveProcessNoise(1) 0.3413 1 AdditiveProcessNoise(15) 0.3381 1 AdditiveProcessNoise(29) 0.3353 1 AdditiveProcessNoise(43) 0.3334 1 AdditiveProcessNoise(57) 0.3214 1 AdditiveProcessNoise(71) 0.3121 1 AdditiveProcessNoise(85) 0.3110 1 AdditiveProcessNoise(99) 0.3107 1 AdditiveProcessNoise(113) 0.3106 1 AdditiveProcessNoise(127) 0.3105 1 AdditiveProcessNoise(141) 0.2972 1 AdditiveProcessNoise(155) 0.2872 1 AdditiveProcessNoise(169) 0.2855 1 AccelerometerNoise 0.2852 1 GyroscopeNoise 0.2851
tunedmn = struct with fields:
AccelerometerNoise: 0.9000
GyroscopeNoise: 0.9000
orientationNoise = statecovparts(filter,"Orientation")
orientationNoise = 4×4
0.0100 0 0 0
0 0.0100 0 0
0 0 0.0100 0
0 0 0 0.0100
Input Arguments
filter
— INS filter
insEKF
object
INS filter, specified as an insEKF
object.
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Version History
Introduced in R2022a
See Also
predict
| fuse
| residual
| correct
| stateparts
| statecovparts
| stateinfo
| estimateStates
| tune
| createTunerCostTemplate
MATLAB 命令
您点击的链接对应于以下 MATLAB 命令:
请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 MATLAB 命令。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)