Main Content

initcvpf

Create constant velocity tracking particle filter from detection report

Description

pf = initcvpf(detection) initializes a constant velocity particle filter for object tracking based on information provided in an objectDetection object, detection.

The function initializes a constant velocity state with the same convention as constvel and cvmeas, [x vx y vy z vz].

example

Examples

collapse all

Create a constant velocity tracking particle filter object, trackingPF, from an initial detection report. The detection report is made from an initial 3-D position measurement of the particle filter state in rectangular coordinates. You can obtain the 3-D position measurement using the constant velocity measurement function, cvmeas.

This example uses the coordinates, x = 1, y = 3, z = 0 and a 3-D position measurement noise of [1 0.2 0; 0.2 2 0; 0 0 1].

detection = objectDetection(0, [1;3;0], 'MeasurementNoise', [1 0.2 0; 0.2 2 0; 0 0 1]);

Use initcvpf to create a trackingPF filter initialized at the provided position and using the measurement noise defined above.

pf = initcvpf(detection)
pf = 
  trackingPF with properties:

                       State: [6⨯1 double]
             StateCovariance: [6⨯6 double]
     IsStateVariableCircular: [0 0 0 0 0 0]

          StateTransitionFcn: @constvel
     ProcessNoiseSamplingFcn: []
                ProcessNoise: [3x3 double]
     HasAdditiveProcessNoise: 0

              MeasurementFcn: @cvmeas
    MeasurementLikelihoodFcn: []
            MeasurementNoise: [3x3 double]

                   Particles: [6x1000 double]
                     Weights: [1.0000e-03 1.0000e-03 1.0000e-03 1.0000e-03 1.0000e-03 1.0000e-03 1.0000e-03 1.0000e-03 1.0000e-03 1.0000e-03 1.0000e-03 1.0000e-03 1.0000e-03 1.0000e-03 1.0000e-03 1.0000e-03 1.0000e-03 1.0000e-03 ... ] (1x1000 double)
            ResamplingPolicy: [1x1 trackingResamplingPolicy]
            ResamplingMethod: 'multinomial'

Check the values of the state and the measurement noise. Verify that the filter state, pf.State, has approximately the same position components as the detection measurement, detection.Measurement.

pf.State
ans = 6×1

    0.9674
    0.3690
    3.0471
    0.2733
    0.0306
   -0.5904

Verify that the filter measurement noise, pf.MeasurementNoise, is the same as the detection.MeasurementNoise values.

pf.MeasurementNoise
ans = 3×3

    1.0000    0.2000         0
    0.2000    2.0000         0
         0         0    1.0000

Create a constant velocity tracking particle filter object, trackingPF, from an initial detection report. The detection report is made from an initial 3-D position measurement of the particle filter state in spherical coordinates. You can obtain the 3-D position measurement using the constant velocity measurement function, cvmeas.

This example uses the coordinates, az = 30, e1 = 5, r = 100, rr = 4 and a measurement noise of diag([2.5, 2.5, 0.5, 1].^2).

meas = [30;5;100;4];
measNoise = diag([2.5, 2.5, 0.5, 1].^2);

Use the MeasurementParameters property of the detection object to define the frame. When not defined, the fields of the MeasurementParameters struct use default values. In this example, sensor position, sensor velocity, orientation, elevation, and range rate flags are default.

measParams = struct('Frame','spherical');
detection = objectDetection(0,meas,'MeasurementNoise',measNoise,...
    'MeasurementParameters',measParams) 
detection = 
  objectDetection with properties:

                     Time: 0
              Measurement: [4x1 double]
         MeasurementNoise: [4x4 double]
              SensorIndex: 1
            ObjectClassID: 0
    ObjectClassParameters: []
    MeasurementParameters: [1x1 struct]
         ObjectAttributes: {}

Use initcvpf to create a trackingPF filter initialized at the provided position and using the measurement noise defined above.

pf = initcvpf(detection)
pf = 
  trackingPF with properties:

                       State: [6⨯1 double]
             StateCovariance: [6⨯6 double]
     IsStateVariableCircular: [0 0 0 0 0 0]

          StateTransitionFcn: @constvel
     ProcessNoiseSamplingFcn: []
                ProcessNoise: [3x3 double]
     HasAdditiveProcessNoise: 0

              MeasurementFcn: @cvmeas
    MeasurementLikelihoodFcn: []
            MeasurementNoise: [4x4 double]

                   Particles: [6x1000 double]
                     Weights: [1.0000e-03 1.0000e-03 1.0000e-03 1.0000e-03 1.0000e-03 1.0000e-03 1.0000e-03 1.0000e-03 1.0000e-03 1.0000e-03 1.0000e-03 1.0000e-03 1.0000e-03 1.0000e-03 1.0000e-03 1.0000e-03 1.0000e-03 1.0000e-03 ... ] (1x1000 double)
            ResamplingPolicy: [1x1 trackingResamplingPolicy]
            ResamplingMethod: 'multinomial'

Verify that the filter state produces approximately the same measurement as detection.Measurement.

meas2 = cvmeas(pf.State, detection.MeasurementParameters)
meas2 = 4×1

   29.9188
    5.0976
   99.8303
    4.0255

Input Arguments

collapse all

Detection report, specified as an objectDetection object.

Example: detection = objectDetection(0,[1;4.5;3],'MeasurementNoise', [1.0 0 0; 0 2.0 0; 0 0 1.5])

Output Arguments

collapse all

Constant velocity particle filter for object tracking, returned as a trackingPF object.

Algorithms

  • The function configures the filter with 1000 particles. In creating the filter, the function computes the process noise matrix assuming a unit acceleration standard deviation.

  • You can use this function as the FilterInitializationFcn property of trackerTOMHT and trackerGNN System objects.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Version History

Introduced in R2018b