Main Content

Generate Code with Strict Single-Precision and Non-Dynamic Memory Allocation from Sensor Fusion and Tracking Toolbox

Introduce functions, objects, and blocks that support strict single-precision and non-dynamic memory allocation code generation in Sensor Fusion and Tracking Toolbox™.

Introduction to Strict Single-Precision and Non-Dynamic Memory Allocation

In Sensor Fusion and Tracking Toolbox (SFTT), many functions, objects, and Simulink blocks support C/C++ code generation. You can see if a function, object, or block supports code generation, as well as any limitations in the Extended Capabilities section of its reference page. For details on how to generate code at the command line, or by using the MATLAB® Coder™ App, see Generate C Code at the Command Line (MATLAB Coder) and Generate C Code by Using the MATLAB Coder App (MATLAB Coder), respectively. For generating code for SFTT applications, see the How to Generate C Code for a Tracker and Generate Code for a Track Fuser with Heterogeneous Source Tracks examples.

Sensor Fusion and Tracking Toolbox widely supports double-precision code generation, and the generated code can use dynamic memory allocation if necessary. Though double-precision variables can provide more accurate calculations, they have increased memory requirements over single-precision variables. Similarly, though dynamic memory allocation allows for flexible variable allocation, this process is typically slower than non-dynamic memory allocation. For these and other reasons, Sensor Fusion and Tracking Toolbox provides strict single-precision and non-dynamic memory allocation support for some algorithms.

In strict single-precision code generation, the generated C/C++ code, including the input, code body, and output, does not use double-precision variables. In other words, it can only use single-precision variables and integer-type variables up to 32 bits. For algorithms that support strict single-precision code generation in SFTT, you can enable it by passing single-precision input arguments. To enable strict single-precision code generation:

  • For a function that supports single-precision code generation, specify single-precision inputs.

  • For an object that supports single-precision code generation, specify the inputs as non-double-precision variables, and specify any custom setups as non-double precision. For example, to generate single-precision code from the trackerGNN System object™:

    • You must specify the inputs, such as the detections, as non-double-precision values.

    • You must specify the FilterInitializationFcn property of the tracker to return a single-precision filter.

In non-dynamic memory allocation code generation, the memory allocation of each variable is determined during compilation time, before running the code. Non-dynamic memory allocation is usually faster than dynamic memory allocation. For information on how to disable dynamic memory allocation, see Generate Code for Variable-Size Data (MATLAB Coder) and Control Memory Allocation for Variable-Size Arrays (MATLAB Coder).

The functions, objects, and blocks listed in the table of the following sections are verified to support strict single-precision and non-dynamic memory allocation code generation. Other unverified functions, object, and blocks in SFTT can possibly support strict single-precision and non-dynamic memory allocation.

Supported Trackers and Tracking Filters

These trackers and tracking filters support single-precision and non-dynamic memory allocation code generation with the specified limitations.

Objects or BlocksSingle-Precision Code Generation LimitationsNon-Dynamic Memory Allocation Code Generation Limitations
trackerJPDA or Joint Probabilistic Data Association Multi Object Tracker
  • Must set the tracker to the K-best JPDA mode.

  • Filter must be one of these, configured in single-precision:

    • trackingEKF

    • trackingUKF

    • trackingCKF

    • trackingIMM

  • Must set the tracker to the K-best JPDA mode.

  • Filter must be one of these:

    • trackingEKF

    • trackingUKF

    • trackingCKF

    • trackingIMM

  • For trackerJPDA, the MaxNumDetections property must be finite.

trackerGNN or Global Nearest Neighbor Multi Object Tracker
  • Filter must be one of these, configured in single-precision:

    • trackingEKF

    • trackingUKF

    • trackingCKF

    • trackingIMM

  • Assignment algorithm must be Jonker-Volgenant.

  • Filter must be one of these:

    • trackingEKF

    • trackingUKF

    • trackingCKF

    • trackingIMM

  • Assignment algorithm must be Jonker-Volgenant or MatchPairs.

  • For trackerGNN, the MaxNumDetections property must be finite.

trackingEKFThe state transition function and measurement function must support single-precision.No limitations
trackingUKFThe state transition function and measurement function must support single-precision.No limitations
trackingCKFThe state transition function and measurement function must support single-precision.No limitations
trackingIMMThe trackingIMM filter must be configured with either trackingEKF, trackingUKF, or trackingCKF objects set in single-precision.The trackingIMM filter must be configured with either trackingEKF, trackingUKF, or trackingCKF objects.

Supported Assignment Functions

These assignment functions support strict single-precision and non-dynamic memory allocation code generation with the specified limitations.

FunctionsSingle-Precision Code Generation LimitationsNon-Dynamic Memory Allocation Code Generation Limitations
assignkbest

Must use the Jonker-Volgenant algorithm.

Must use the Jonker-Volgenant algorithm.

assignjvNo limitationsNo limitations
jpdaEventsMust use K-best joint event.Must use K-best joint event.

Supported Motion Model Functions

These motion model functions support single-precision and non-dynamic memory allocation code generation without limitations.

Supported Filter Initialization Functions

These filter initialization functions support single-precision and non-dynamic memory allocation code generation without limitations.