Issues for code generation of trackerPHD and trackingSe​nsorConfig​uration using Matlab Coder

5 visualizaciones (últimos 30 días)
Hello,
I was trying to generate C++ for the following function codegenTracker. After a careful study of the extended capabilities section of the trackerPHD document and a lot of experiments, I was able to generate the code successfully.
However, I found that I have to set the number of sensors, which is n in the code below expectily ( to 3, in mycase), so that it does not give me the error: 'Loop unrolling failed because the number of iterations is unknown' during 'Check for Run-Time Issues'. From an application point of view, I prefer n to be specified in a configuration file, so that I could load n like the tempConfig struct in the code below, instead of set it to a number expectily. For example, if I want to change the ClutterDensity property of trackingSensorConfiguration, I can just change it in my configuration file without the need to change it in my matlab code and regenerate the entire code.
Similarly, for trackerPHD, I have to specify the properties expectily. If I try to set a property of trackerPHD,say, BirthRate, through the configuration file, I got the following error: 'Failed to compute constant value for nontunable property 'BirthRate'. In code generation, nontunable properties can only be assigned constant values'.
How do I modify my code so that I do not need to specify all the parameters expectily and it still supports code generation? Thanks in advance. I have attach my code for code generation, which is based on the matlab project 'Asynchronous Angle-only Tracking with GM-PHD Tracker'.
function tracks = codegenTracker(detections, configs, time) %#codegen
tracks = repmat(DummyTracks(),0,1);
coder.varsize('tracks',[Inf,1],[1,0]);
persistent tracker;
if isempty(tracker)
% read parameters from the configuration file, tempConfig is a struct that
% contains these parameters.
tempConfig = config.readSensorConfig();
% Prefer Load n from a configuration file instead of set it to a number
% expectily
%
n = 3;
sensorConfigs = cell(n,1) ;
for i = 1 : n
sensorConfigs{i,1} = trackingSensorConfiguration("SensorIndex",single(i), ...
"IsValidTime",true, ...
"SensorLimits", tempConfig.SensorLimits,...
"SensorResolution", tempConfig.SensorResolutions,...
"SensorTransformFcn",'cvmeas', ...
"SensorTransformParameters", DummyMps(),...
"ClutterDensity", tempConfig.ClutterDensity, ...
"MinDetectionProbability", tempConfig.MinDetectionProbability,...
"FilterInitializationFcn", 'initcvAngleOnlyGMPHD',...
"MaxNumDetsPerObject", uint32(1), ...
"MaxNumDetections", uint32(100));
end
tracker = trackerPHD(SensorConfigurations = sensorConfigs, ...
BirthRate = 0.1, ...
DeathRate = 1e-6, ...
AssignmentThreshold = 25 , ...
ExtractionThreshold = 0.85, ...
ConfirmationThreshold = 0.95, ...
DeletionThreshold = 1e-3, ...
MergingThreshold = 25, ...
LabelingThresholds = [1.1 1 0.8], ...
HasSensorConfigurationsInput = true, ...
MaxNumSensors = 20, ...
MaxNumTracks = uint32(1000), ...
MaxNumComponents = uint32(5000));
end
if tracker.isLocked() || ~isempty(detections)
tracks = tracker(detections, configs, double(time));
end
end
Loop unrolling failed because the number of iterations is unknown.

Respuesta aceptada

Prashant Arora
Prashant Arora el 19 de Mayo de 2023
Hi Lechi,
The tracker defines many of these properties as "nontunable", which means that you cannot change them after C/C++ code is generated. You will need to regenerate code with new set of values.
There are some properties which are possible to make "tunable". For example, BirthRate, DeathRate etc, but they are not as of R2023b. However, some properties control the size, datatype and memory allocation of datatypes in C/C++. For example, it will be difficult to support "MaxNumTracks", "MaxNumSensors" etc. as tunable properties. I will create an enhancement request to support changing some of these properties after code generation.
Regarding SensorConfigurations:
The number and properties of the sensor configurations can be tuned on the fly in a way. You can pre-define the maximum sensors as Nmax. You can construct the tracker with Nmax configurations. However, only n out of those nMax sensors can be active during a run. To do this, you can use configs input to the tracker. By setting the IsValidTime of the sensors "inactive" during this run as false, you can indicate that these trackers only n sensors are being used during a run.
Hope this helps.
Thanks,
Prashant

Más respuestas (0)

Productos


Versión

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by