Class TrackingSe​nsorConfig​uration is not supported by coder. Type as it as handle class

1 view (last 30 days)
Im trying to code generate for tracker PHD, where tracker PHD needs sensor configurations as input. But i cannot input sensor configurations because it is of type handle class. Im attacking the code please suggest a solution for this.
function [confirmedTracks] = mexGMPHD(detections,sensorConfigurations, time)
persistent tracker
if isempty(tracker)
% Use the same starting seed as MATLAB to reproduce results in SIL
% simulation.
sensorConfigurations.FilterInitializationFcn = @helperInitRectangularFilter; % Initialize a rectangular target gmphd
sensorConfigurations.SensorTransformFcn = @ctrectcorners;
% Create a multiObjectTracker
tracker = trackerPHD('SensorConfigurations', sensorConfigurations,...
'AssignmentThreshold',600,...% Minimum negative log-likelihood of a detection cell to add birth components
'ExtractionThreshold',0.85,...% Weight threshold of a filter component to be declared a track
'ConfirmationThreshold',0.95,...% Weight threshold of a filter component to be declared a confirmed track
'MergingThreshold',50,...% Threshold to merge components
'HasSensorConfigurationsInput',true... % Tracking is performed in scenario frame and hence sensor configurations change with time
confirmedTracks = tracker(detections,configurations,time);

Answers (1)

Prashant Arora
Prashant Arora on 8 Oct 2021
Hi Vimal,
The trackerPHD must be constructed with a cell array of trackingSensorConfiguration objects. By setting HasSensorConfigurationsInput to true, you can "update" the configurations of the sensors used by trackerPHD.
The trackingSensorConfiguration object defines both tunable (properties which can be updated) and non-tunable properties of a sensor. The list of "tunable" properties include - "IsValidTime", "SensorLimits", "SensorResolution", "SensorTransformParameters". This list of tunable properties can be passed as an input to the tracker step either as a struct array, a cell array of struct or a cell array of trackingSensorConfiguration objects. Passing cell array of trackingSensorConfiguration objects is a convenience offered by trackerPHD, but only the above-mentioned "tunable" fields are updated.
Now, as you noticed, you cannot pass the cell array of trackingSensorConfiguration to an entry-point function for code generation. Therefore, you must use an array or cell array of struct with the tunable fields as an input to the tracker.
To construct the tracker (inside isempty(tracker)), you can convert this struct array into cell array of trackingSensorConfiguration objects by taking "tunable" fields from the input and adding "non-tunable" fields on top of it.
Shown below is an example entry-point function for trackerPHD which demonstrates this.
function tracks = phdEntryPoint(detections, configurations, time)
% Define tracker as persistent object
persistent tracker
% Define the tracker on the first call
if isempty(tracker)
% Create sensor configurations for constructing a PHD tracker
sensorConfigurations = cell(numel(configurations),1);
for i = 1:numel(sensorConfigurations)
sensorConfigurations{i} = trackingSensorConfiguration(...
% Define the rest of properties, which don't change with time and
% depends on the sensor characteristics. Here you should define
% these values based on the "SensorIndex". For example, if
% SensorIndex = 1 is a Camera and outputs a single detection per
% object. In that case, you can set its MaxNumDetsPerObject = 1.
sensorConfigurations{i}.ClutterDensity = 1e-6;
sensorConfigurations{i}.DetectionProbability = 0.9;
sensorConfigurations{i}.MaxNumDetsPerObject = inf;
% Construct the tracker
tracker = trackerPHD(...
% Update the tracker every step
tracks = tracker(detections, configurations, time);
To generate code from a function like this, you will need to define the data types of all the inputs. This can be achieved by using sample detections from the scenario simulation or you can manually define data types as shown in the below script. After defining the data types of inputs, you can simply use the "codegen" command to generate code.
sampleDetection = objectDetection(0,[0;0;0],...
detections = coder.typeof({sampleDetection},[100 1],[1 0]); % Max detections = 100
sampleConfigurationInput = struct('SensorIndex',1,...
configurations = coder.typeof(sampleConfigurationInput,[8 1],[0 0]); % Assume 8 sensors
time = coder.typeof(0);
codegen phdEntryPoint -args {detections, configurations, time}
function st = measParams()
st = repmat(struct('Frame','Rectangular',...
function st = configParams()
st = repmat(struct('Frame','Spherical',...

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!