Generate Code with Strict Single-Precision and Non-Dynamic Memory Allocation
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 these 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 strict single-precision code generation, specify single-precision inputs.
For an object that supports strict 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 strict single-precision and non-dynamic memory allocation code generation with the specified limitations.
Objects or Blocks | Strict single-Precision Code Generation Limitations | Non-Dynamic Memory Allocation Code Generation Limitations |
---|---|---|
trackerJPDA or
Joint Probabilistic Data Association Multi Object
Tracker |
|
|
trackerGNN or Global Nearest Neighbor Multi Object Tracker |
|
|
trackerPHD or Probability Hypothesis Density (PHD) Tracker
|
|
|
trackingKF | No limitations | No limitations |
trackingEKF | The state transition function and measurement function must support single-precision. | No limitations |
trackingUKF | The state transition function and measurement function must support single-precision. | No limitations |
trackingCKF | The state transition function and measurement function must support single-precision. | No limitations |
trackingIMM | The trackingIMM filter must be configured with
either trackingKF , trackingEKF ,
trackingUKF , or trackingCKF
objects set in single-precision. | The trackingIMM filter must be configured with
either trackingKF , trackingEKF ,
trackingUKF , or trackingCKF
objects. |
gmphd | The motion model and measurement model used in the filter must support single-precision. | No limitations |
ggiwphd | The motion model and measurement model used in the filter must support single-precision. | No limitations |
Supported Assignment and Partition Functions
These assignment functions support strict single-precision and non-dynamic memory allocation code generation with the specified limitations.
Functions | Strict Single-Precision Code Generation Limitations | Non-Dynamic Memory Allocation Code Generation Limitations |
---|---|---|
assignkbest | Must use the Jonker-Volgenant algorithm. | Must use the Jonker-Volgenant algorithm. |
assignjv | No limitations | No limitations |
jpdaEvents | Must use K-best joint event. | Must use K-best joint event. |
partitionDetections | No limitations | No limitations |
mergeDetections | No limitations | No limitations |
Supported Motion Model Functions
These motion model functions support strict 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.