MATLAB: What is the essential difference between “trackingEKF” and “initctekf” functions? How to choose

Automated Driving Toolboxmotmulti-object trackSensor Fusion and Tracking Toolboxtrack;

I have these two functions when I use "Sensor Fusion and Tracking Toolbox" or "Automated Driving Toolbox", but sometimes I don't know which function is better to use. It is easy to confuse. For example, why is the result different in the following example?
detection = objectDetection(0,[-250;-40;0],'MeasurementNoise',2.0*eye(3), ...
'SensorIndex',1,'ObjectClassID',1,'ObjectAttributes',{'Car',2});
filter = initctekf(detection)
filter =
trackingEKF with properties:
State: [7×1 double]
StateCovariance: [7×7 double]
StateTransitionFcn: @constturn
StateTransitionJacobianFcn: @constturnjac
ProcessNoise: [4×4 double]
HasAdditiveProcessNoise: 0
MeasurementFcn: @ctmeas
MeasurementJacobianFcn: @ctmeasjac
MeasurementNoise: [3×3 double]
HasAdditiveMeasurementNoise: 1
Why is the "state" dimension 7 and what do they mean?
Another "equivalent" is: ?
EKF = trackingEKF(@constturn,@ctmeas,[-250;-40;0], ... % [sx,sy,sz] ?
'MeasurementNoise',2.0*eye(3),...
'StateTransitionJacobianFcn',@constveljac, ...
'MeasurementJacobianFcn',@cvmeasjac)
EKF =
trackingEKF with properties:
State: [3×1 double]
StateCovariance: [3×3 double]
StateTransitionFcn: @constturn
StateTransitionJacobianFcn: @constveljac
ProcessNoise: [3×3 double]
HasAdditiveProcessNoise: 1
MeasurementFcn: @ctmeas
MeasurementJacobianFcn: @cvmeasjac
MeasurementNoise: [3×3 double]
HasAdditiveMeasurementNoise: 1
Another question is why the dimensions of the parameters obtained by the two ways of writing are different? It is not easy to find the answer description from the help document

Best Answer

Hi,
There are many functions that are shared between the Sensor Fusion and Tracking Toolbox and the Automated Driving Toolbox. They include, as you noted correctly, the trackingEKF (with trackingKF and trackingUKF), the motion and measurement models and their Jacobians (of which, constturn is one exampe), and their respective initiailization functions (initctekf is one example). We also share the definitions of objectDetection and objectTrack.
The idea here was that you could move easily between the two toolboxes and integrate your work.
To be clear: there is no difference between the two toolboxes when it comes to these functions.
As for your question:
The initctekf function takes a detection that contains measurement, measurement noise, and measurement parameters and uses it to initialize a tracking filter. You used initctekf, which creates a trackingEKF filter with constant-turn motion model and definition of state that corresponds to that. In your example, the objectDetection has a measurement at [-250;-40;0] which corresponds to the position of the target. The filter has the state definition:
[x;vx;y;vy;omega;z;vz] - so the positions at x,y, and z are converted to the elements 1, 3, and 6 in the state vector. The veolocity components are all unmeasured and assumed to be zero and the angular rate (omega) is also not measured and is assumed to be zero.
In the second code you wrote, you tried to initialize the trackingEKF yourself and passed [-250;-40;0] as a state. So, that becomes the entire state. You ended up with a state that is inconsistent with the defnition of state transition function or measurement function and that would error out the moment you would start to predict or correct the filter.
As for documentation: I would recomment you do:
help initctekf
and it will show the definition of state as I explained above.
If you want to dig deeper into how the filter is being initialized, I recommend doing:
edit initctekf
The function contains a lot of comments to explain the steps to follow in initializing a filter and how to convert measurements into a full state definition.
Elad