Registered users can read the full content for free
Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.
Page
1
Sensor Fusion and Tracking Toolbox™ Reference R2021b
Page
2
How to Contact MathWorks Latest news: www.mathworks.com Sales and services: www.mathworks.com/sales_and_services User community: www.mathworks.com/matlabcentral Technical support: www.mathworks.com/support/contact_us Phone: 508-647-7000 The MathWorks, Inc. 1 Apple Hill Drive Natick, MA 01760-2098 Sensor Fusion and Tracking Toolbox™ Reference Guide © COPYRIGHT 2018 – 2021 by The MathWorks, Inc. The software described in this document is furnished under a license agreement. The software may be used or copied only under the terms of the license agreement. No part of this manual may be photocopied or reproduced in any form without prior written consent from The MathWorks, Inc. FEDERAL ACQUISITION: This provision applies to all acquisitions of the Program and Documentation by, for, or through the federal government of the United States. By accepting delivery of the Program or Documentation, the government hereby agrees that this software or documentation qualifies as commercial computer software or commercial computer software documentation as such terms are used or defined in FAR 12.212, DFARS Part 227.72, and DFARS 252.227-7014. Accordingly, the terms and conditions of this Agreement and only those rights specified in this Agreement, shall pertain to and govern the use, modification, reproduction, release, performance, display, and disclosure of the Program and Documentation by the federal government (or other entity acquiring for or through the federal government) and shall supersede any conflicting contractual terms or conditions. If this License fails to meet the government's needs or is inconsistent in any respect with federal procurement law, the government agrees to return the Program and Documentation, unused, to The MathWorks, Inc. Trademarks MATLAB and Simulink are registered trademarks of The MathWorks, Inc. See www.mathworks.com/trademarks for a list of additional trademarks. Other product or brand names may be trademarks or registered trademarks of their respective holders. Patents MathWorks products are protected by one or more U.S. patents. Please see www.mathworks.com/patents for more information. Revision History September 2018 Online only New for Version 1.0 (Release 2018b) March 2019 Online only Revised for Version 1.1 (Release 2019a) September 2019 Online only Revised for Version 1.2 (Release 2019b) March 2020 Online only Revised for Version 1.3 (Release 2020a) September 2020 Online only Revised for Version 2.0 (Release 2020b) March 2021 Online only Revised for Version 2.1 (Release 2021a) September 2021 Online only Revised for Version 2.2 (Release 2021b)
Page
3
Functions 1 Classes 2 System Objects 3 Blocks 4 Apps 5 iii Contents
Page
4
(This page has no text content)
Page
5
Functions 1
Page
6
allanvar Allan variance Syntax [avar,tau] = allanvar(Omega) [avar,tau] = allanvar(Omega,m) [avar,tau] = allanvar(Omega,ptStr) [avar,tau] = allanvar(___,fs) Description Allan variance is used to measure the frequency stability of oscillation for a sequence of data in the time domain. It can also be used to determine the intrinsic noise in a system as a function of the averaging time. The averaging time series τ can be specified as τ = m/fs. Here fs is the sampling frequency of data, and m is a list of ascending averaging factors (such as 1, 2, 4, 8, …). [avar,tau] = allanvar(Omega) returns the Allan variance avar as a function of averaging time tau. The default averaging time tau is an octave sequence given as (1, 2, ..., 2floor{log2[(N-1)/2]}), where N is the number of samples in Omega. If Omega is specified as a matrix, allanvar operates over the columns of omega. [avar,tau] = allanvar(Omega,m) returns the Allan variance avar for specific values of tau defined by m. Since the default frequency fs is assumed to be 1, the output tau is exactly same with m. [avar,tau] = allanvar(Omega,ptStr) sets averaging factor m to the specified point specification, ptStr. Since the default frequency fs is 1, the output tau is exactly equal to the specified m. ptStr can be specified as 'octave' or 'decade'. [avar,tau] = allanvar(___,fs) also allows you to provide the sampling frequency fs of the input data omega in Hz. This input parameter can be used with any of the previous syntaxes. Examples Determine Allan Variance of Single Axis Gyroscope Load gyroscope data from a MAT file, including the sample rate of the data in Hz. Calculate the Allan variance. load('LoggedSingleAxisGyroscope','omega','Fs') [avar,tau] = allanvar(omega,'octave',Fs); Plot the Allan variance on a loglog plot. loglog(tau,avar) xlabel('\tau') ylabel('\sigma^2(\tau)') title('Allan Variance') grid on 1 Functions 1-2
Page
7
Determine Allan Deviation at Specific Values of τ Generate sample gyroscope noise, including angle random walk and rate random walk. numSamples = 1e6; Fs = 100; nStd = 1e-3; kStd = 1e-7; nNoise = nStd.*randn(numSamples,1); kNoise = kStd.*cumsum(randn(numSamples,1)); omega = nNoise+kNoise; Calculate the Allan deviation at specific values of m = τ. The Allan deviation is the square root of the Allan variance. m = 2.^(9:18); [avar,tau] = allanvar(omega,m,Fs); adev = sqrt(avar); Plot the Allan deviation on a loglog plot. loglog(tau,adev) xlabel('\tau') ylabel('\sigma(\tau)') allanvar 1-3
Page
8
title('Allan Deviation') grid on Input Arguments Omega — Input data N-by-1 vector | N-by-M matrix Input data specified as an N-by-1 vector or an N-by-M matrix. N is the number of samples, and M is the number of sample sets. If specified as a matrix, allanvar operates over the columns of Omega. Data Types: single | double m — Averaging factor scalar | vector Averaging factor, specified as a scalar or vector with ascending integer values less than (N-1)/2, where N is the number of samples in Omega. Data Types: single | double ptStr — Point specification of m 'octave' (default) | 'decade' Point specification of m, specified as 'octave' or 'decade'. Based on the value of ptStr, m is specified as following: 1 Functions 1-4
Page
9
• If ptStr is specified as 'octave', m is: 20, 21...2 log2 N − 1 2 • If ptStr is specified as 'decade', m is: 100, 101...10 log10 N − 1 2 N is the number of samples in Omega. fs — Basic frequency of input data in Hz scalar Basic frequency of the input data, Omega, in Hz, specified as a positive scalar. Data Types: single | double Output Arguments avar — Allan variance of input data vector | matrix Allan variance of input data at tau, returned as a vector or matrix. tau — Averaging time of Allan variance vector | matrix Averaging time of Allan variance, returned as a vector, or a matrix. See Also gyroparams | imuSensor Introduced in R2019a allanvar 1-5
Page
10
ctrect Constant turn-rate rectangular target motion model Syntax updatedstates = ctrect(states) updatedstates = ctrect(states,dt) updatedstates = ctrect(states,w,dt) Description updatedstates = ctrect(states) returns the updated rectangular states from the current rectangular states based on the rectangular target motion model. The default time step is 1 second. updatedstates = ctrect(states,dt) specifies the time step, dt, in seconds. updatedstates = ctrect(states,w,dt) additionally specifies the process noise, w. Examples Predict Constant Turn-Rate Rectangular State Define a rectangular state. state = [1 2 2 30 1 4.7 1.8]; Predict the state dt = 1 second forward using the default syntax. state = ctrect(state,0.1) state = 1×7 1.1731 2.1002 2.0000 30.1000 1.0000 4.7000 1.8000 Predict the state dt = 0.1 second forward without noise. state = ctrect(state,0.1) state = 1×7 1.3461 2.2006 2.0000 30.2000 1.0000 4.7000 1.8000 Predict the state dt = 0.1 second forward with noise. state = ctrect(state,0.01,0.1) state = 1×7 1.5189 2.3014 2.0010 30.3000 1.0010 4.7000 1.8000 1 Functions 1-6
Page
11
Predict Multiple Constant Turn-Rate Rectangular States Define a state matrix. states = [1 3 4;-1 2 10;5 3 1.3;1 1.3 2.1;30 0 -30;4.7 3.4 4.5;1.8 2 3]; Predict the state dt = 1 second ahead. states = ctrect(states) states = 7×3 5.7516 5.9992 5.2528 0.3625 2.0681 9.7131 5.0000 3.0000 1.3000 31.0000 1.3000 -27.9000 30.0000 0.0000 -30.0000 4.7000 3.4000 4.5000 1.8000 2.0000 3.0000 Predict the state dt = 0.1 second ahead without noise. states = ctrect(states,0.1) states = 7×3 6.1732 6.2992 5.3660 0.6311 2.0749 9.6493 5.0000 3.0000 1.3000 34.0000 1.3000 -30.9000 30.0000 0.0000 -30.0000 4.7000 3.4000 4.5000 1.8000 2.0000 3.0000 Predict the state dt = 0.1 second ahead with noise. states = ctrect(states,0.1*randn(2,3),0.1) states = 7×3 6.5805 6.5979 5.4759 0.9216 2.0816 9.5795 5.0054 2.9774 1.3032 37.0009 1.3004 -33.9007 30.0183 0.0086 -30.0131 4.7000 3.4000 4.5000 1.8000 2.0000 3.0000 Input Arguments states — Current rectangular states 1-by-7 real-valued vector | 7-by-1 real-valued vector | 7-by-N real-valued matrix ctrect 1-7
Page
12
Current rectangular states, specified as a 1-by-7 real-valued vector, 7-by-1 real-valued vector, or a 7- by-N real-valued matrix, where N is the number of states. The seven dimensional rectangular target state is defined as [x; y; s; θ; ω; L; W]: Variable Meaning Unit x Position of the rectangle center in x direction m y Position of the rectangle center in y direction m s Speed in the heading direction m/s θ Orientation angle of the rectangle with respect to x direction degree ω Turn-rate degree/s L Length of the rectangle m W Width of the rectangle m Example: [1;2;2;30;1;4.7;1.8] Data Types: single | double dt — Time step real-valued positive scalar Time step, specified as a real-valued positive scalar in second. Data Types: single | double w — Process noise real scalar | 2-by-N real-valued matrix Process noise, specified as a 2-by-N real-valued matrix, where N is the number of states specified in the states input. If specified as a scalar, it is expanded to a 2-by-N matrix with all elements equal to 1 Functions 1-8
Page
13
the scalar. The first row of the matrix specifies the process noise in acceleration (m/s2). The second row specifies the process noise in yaw acceleration (degrees/s2). Data Types: single | double Output Arguments updatedstates — Updated states 1-by-7 real-valued vector | 7-by-1 real-valued vector | 7-by-N real-valued matrix Updated states, specified as a 1-by-7 real-valued vector, a 7-by-1 real-valued vector, or a 7-by-N real- valued matrix, where N is the number of states. The dimensions and setups of updatedstates output are exactly the same as those of the states input. Data Types: single | double Extended Capabilities C/C++ Code Generation Generate C and C++ code using MATLAB® Coder™. See Also gmphd | trackerPHD | ctrectmeas | ctrectmeasjac | ctrectjac | initctrectgmphd | ctrectcorners Introduced in R2019b ctrect 1-9
Page
14
ctrectmeas Constant turn-rate rectangular target measurement model Syntax measurements = ctrectmeas(states,detections) Description measurements = ctrectmeas(states,detections) returns the expected measurements from the current rectangular states and detections. Examples Expected Detections Using Rectangular Measurement Model Load detections and truth generated from a rectangular target. load('rectangularTargetDetections.mat','detections','truthState'); Generate expected detections from the target's rectangular state and actual detections using ctrectmeas. tgtState = [3;48;0;60;0;5;1.9]; zExp = ctrectmeas(tgtState,detections); Set up visualization environment using theaterPlot. theaterP = theaterPlot; stateP = trackPlotter(theaterP,'DisplayName','State','MarkerFaceColor','g'); truthP = trackPlotter(theaterP,'DisplayName','Truth','MarkerFaceColor', 'b'); detP = detectionPlotter(theaterP,'DisplayName','Detections','MarkerFaceColor','r'); expDetP = detectionPlotter(theaterP,'DisplayName','Expected Detections','MarkerFaceColor','y'); l = legend(theaterP.Parent); l.AutoUpdate = 'on'; hold on; assignP = plot(theaterP.Parent,NaN,NaN,'-.','DisplayName','Association'); Plot actual and expected detections. inDets = [detections{:}]; inMeas = horzcat(inDets.Measurement); detP.plotDetection(inMeas'); zExpPlot = reshape(zExp,3,[]); expDetP.plotDetection(zExpPlot'); Plot association lines. zLines = nan(2,numel(detections)*3); zLines(1,1:3:end) = zExpPlot(1,:); 1 Functions 1-10
Page
15
zLines(2,1:3:end) = zExpPlot(2,:); zLines(1,2:3:end) = inMeas(1,:); zLines(2,2:3:end) = inMeas(2,:); assignP.XData = zLines(1,:); assignP.YData = zLines(2,:); Plot truth and state. truthPos = [truthState(1:2);0]; truthDims = struct('Length',truthState(6),... 'Width',truthState(7),... 'Height', 0,... 'OriginOffset', [0 0 0]); truthOrient = quaternion([truthState(4) 0 0],'eulerd', 'ZYX','frame'); truthP.plotTrack(truthPos',truthDims,truthOrient); statePos = [tgtState(1:2);0]; stateDims = struct('Length',tgtState(6),... 'Width',tgtState(7),... 'Height',0,... 'OriginOffset', [0 0 0]); stateOrient = quaternion([tgtState(4) 0 0],'eulerd', 'ZYX','frame'); stateP.plotTrack(statePos', stateDims, stateOrient); ctrectmeas 1-11
Page
16
Input Arguments states — Current rectangular states 7-by-N real-valued matrix Current rectangular states, specified as a 7-by-N real-valued matrix, where N is the number of states. The seven-dimensional rectangular target state is defined as [x; y; s; θ; ω; L; W]: Variable Meaning Unit x Position of the rectangle center in x direction m y Position of the rectangle center in y direction m s Speed in the heading direction m/s θ Orientation angle of the rectangle with respect to x direction degree ω Turn-rate degree/s L Length of the rectangle m W Width of the rectangle m Example: [1;2;2;30;1;4.7;1.8] Data Types: single | double detections — Detections of target 1-by-M cell array of objectDetection objects Detections of target, specified as a 1-by-M cell array of objectDetection objects. The MeasurementParameters property (that specifies the transformation from the state-space to measurement-space) for each object must be the same for all the detections in the cell array. 1 Functions 1-12
Page
17
Output Arguments measurements — Expected measurements P-by-N-by-M real-valued array Expected measurements, returned as a P-by-N-by-M real-valued array. P is the dimension of each measurement specified in the detections input, N is the number of states specified in the states input, and M is the number of detections specified in the detections input. Extended Capabilities C/C++ Code Generation Generate C and C++ code using MATLAB® Coder™. See Also trackerPHD | gmphd | ctrect | ctrectmeasjac | ctrectjac | initctrectgmphd | ctrectcorners Introduced in R2019b ctrectmeas 1-13
Page
18
ctrectmeasjac Jacobian of constant turn-rate rectangular target measurement model Syntax jacobian = ctrectmeasjac(state,detections) Description jacobian = ctrectmeasjac(state,detections) returns the Jacobian based on the current rectangular target state and detections. Examples Generate Jacobian for Rectangular Target Model Load detections generated from a rectangular target. load('rectangularTargetDetections.mat','detections'); Calculate Jacobian based on the rectangular state of the target and detections. tgtState = [3;48;0;60;0;5;1.9]; jac = ctrectmeasjac(tgtState,detections); jac1 = jac(:,:,1) jac1 = 3×7 1.0000 0 0 0.0461 0 -0.2500 0.4330 0 1.0000 0 -0.0075 0 -0.4330 -0.2500 0 0 0 0 0 0 0 Input Arguments state — Current rectangular target state 7-by-1 real-valued vector Current rectangular target state, specified as a 7-by-1 real-valued vector. The seven dimensional rectangular target state is defined as [x; y; s; θ; ω; L; W]. The meaning of these variables and their units are: Variable Meaning Unit x Position of the rectangle center in x direction m y Position of the rectangle center in y direction m 1 Functions 1-14
Page
19
s Speed in the heading direction m/s θ Orientation angle of the rectangle with respect to x direction degree ω Turn-rate degree/s L Length of the rectangle m W Width of the rectangle m Example: [1;2;2;30;1;4.7;1.8] Data Types: single | double detections — Detections of target 1-by-M cell array of objectDetection objects Detections of target, specified as a 1-by-M cell array of objectDetection objects. The MeasurementParameters property (that specifies the transformation from the state-space to measurement-space) for each object must be the same for all the detections in the cell array. Output Arguments jacobian — Jacobian of measurement model M-by-7-by-D real-valued array Jacobian of measurement model, returned as a M-by-7-by-D real-valued array. M is the dimension of each measurement specified in detections, and D is the number of detections specified in the detections input. Extended Capabilities C/C++ Code Generation Generate C and C++ code using MATLAB® Coder™. ctrectmeasjac 1-15
Page
20
See Also trackerPHD | gmphd | ctrect | ctrectmeas | ctrectjac | initctrectgmphd | ctrectcorners Introduced in R2019b 1 Functions 1-16
The above is a preview of the first 20 pages. Register to read the complete e-book.
AI Reading Assistant
Whole-book reading guide from stratified index samples; jump to passages in the text
AI guide
【One-Line Pitch】
A function-by-function reference for MATLAB's Sensor Fusion and Tracking Toolbox (R2021b) that lets you look up exact syntax, options, and defaults for inertial filters, trackers, and scenario modeling—best for engineers already building fusion/tracking pipelines who need authoritative API detail rather than a tutorial.
【Book Arc】
- **Opening (~0%–10%)**: Establishes the toolbox's core vocabulary through reference entries—`insfilter` and its MARG variant, detection partitioning (`partitionDetections` with distance-partitioning and DBSCAN), and quaternion array construction—solving the "what object/function do I call and with what arguments" problem.
- **Early (~13%–32%)**: Moves into filter initialization and correction workflows: building CKF/constant-acceleration trackers from detection reports, the `correct` step for state/covariance updates, measurement-frame conventions (rectangular vs. spherical), sonar/underwater channel modeling, and grid-map state queries and visualization.
- **Middle (~39%–48%)**: Covers sensor-specific fusion plumbing—GPS residual computation for `insfilterMARG`, pose extraction for the nonholonomic IMU/GPS fuser, track-to-struct conversion, and scenario/platform configuration (reference frames, trajectories, signatures, pose estimators).
- **Late (beyond ~48%)**: The sampled excerpts thin out here; the remaining reference entries (additional classes, extended capabilities, code-generation notes) are not covered in detail by the provided material.
- **Ending**: Excerpts do not cover the closing sections; treat the tail of the book as unverified by this guide.
【Book Arc note】
This is a reference manual, not a narrative—the "arc" is really a progression from primitive objects (filters, detections, quaternions) to composed workflows (fusion, tracking, scenario simulation).
【Key Takeaways】
- **The toolbox is object-centric, not function-centric** (Opening): You instantiate filters (`insfilterMARG`, `trackingCKF`, `trackingEKF`) and then call methods like `correct` and `pose` on them; understanding object properties (noise variances, state covariance) matters more than memorizing signatures.
- **`insfilter` defaults to a MARG filter with a 22-element state** (Opening): Calling it with no arguments yields an `insfilterMARG` fusing accelerometer, gyroscope, GPS, and magnetometer data, with `ReferenceFrame` selectable as `'NED'` (default) or `'ENU'`—a quick way to see the expected state and noise structure.
- **Detection partitioning is a first-class preprocessing step** (Opening): `partitionDetections` splits detections into mutually exclusive cells using distance thresholds or DBSCAN, with Mahalanobis or Euclidean distance selectable—directly relevant to clustering before tracking.
- **Measurement frames drive vector layout** (Early): Whether you pass `[x;y;z]` or `[az;el;r;rr]` depends on the `Frame`, `HasElevation`, and `HasVelocity` fields in `MeasurementParameters`; getting this wrong silently corrupts filter updates.
- **`correct` has filter-specific syntax variants** (Early): Extra measurement covariance is only valid for `trackingKF`, and the `zcorr` output only for `trackingABF`—a common source of errors if you copy examples across filter types.
- **GPS residuals are exposed for custom fusion logic** (Middle): `residualgps` returns residual and residual covariance from position (and optionally velocity) in LLA/NED, useful when you need to inspect or hand-tune the MARG filter's GPS update.
- **Pose output format is configurable** (Middle): `pose` on the nonholonomic fuser returns position, orientation (quaternion by default or rotation matrix), and velocity in the local frame—handy for downstream visualization or control.
- **Scenario configuration ties frames, trajectories, and signatures together** (Middle): Platform setup requires matching trajectory type to `IsEarthCentered` (kinematic/waypoint vs. `geoTrajectory`) and supports RCS, IR, and target-strength signatures plus a pluggable pose estimator.
【Reading Tips】
- **Use it as a lookup, not a read-through**: Jump via the index to the specific function or class you need; the entries are self-contained and cross-referenced under "See Also."
- **Deep-read the Opening and Early sections once**: The filter-object model, measurement-frame conventions, and `correct` variants are the conceptual load-bearing walls; everything later assumes them.
- **Watch the "Extended Capabilities" and "Introduced in R" notes**: They flag C/C++ code generation support and version availability—critical if you're targeting deployment or pinned to an older release.
- **Cross-check examples against your filter type**: Many syntaxes are restricted to specific objects (`trackingKF`, `trackingABF`, `insfilterMARG`); verify before adapting.
- **Skim the quaternion and math asides** unless you're debugging rotation conventions; they're reference background, not workflow steps.
【Coverage Limits】
This guide is based on a sampled subset of reference entries (roughly the first half of the indexed chunks); later chapters, full class listings, and any tutorial or "Getting Started" material are not represented, so treat the Late/Ending portions as unverified.
Passage locations
Excerpt 1
ons(detections,tLower,tUpper,'MaxNumPartitions', maxNumber) partitions = partitionDetections(detections,allThresholds) [partitions,indexDP] = partitionDetect...
View in text
Excerpt 2
jectDetection. detections = cell(20,1); location = [1;2;3]; dimensions = [1.2;2.3;3.5]; rng(2019); measurements = location + dimensions.*(-1 + 2*rand(3,20));...
View in text
Excerpt 3
grid map Syntax show(map) show(map,Name,Value) Description show(map) plots the dynamic occupancy grid map in local coordinates. The static cells are shown us...
View in text
Excerpt 4
cified as an array of objectTrack objects. Output Arguments S — Structures converted from objectTrack array of structure Structures converted from objectTrac...
View in text
Recommended for You
{{#thumbnailUrl}}
{{/thumbnailUrl}}
{{^thumbnailUrl}}
{{/thumbnailUrl}}
Loading recommended books...
Failed to load, please try again later
Tip the Site
Scan the WeChat Pay or Alipay code to tip. No login required.
WeChat Pay
Alipay