I cant upload my function to jetson nano because it's not supported, how to fix it ? note : that the problem in the function is in (inputParser).
1 次查看(过去 30 天)
显示 更早的评论
function scan = pc2scannn(ptCloudIn, varargin)
narginchk(1, 10);
% Validate inputs
[tform, scanAngleLimits, scanRangeLimits, elevationAngleTolerance, ...
scanAngleResolution] = parseAndValidateInputs(ptCloudIn, varargin{:});
% Remove invalid points from the point cloud
ptCloudIn = removeInvalidPoints(ptCloudIn);
if ~isequal(tform.T, eye(4, 'like', tform.T))
% Transform the point cloud to 2-D lidar sensor coordinate system in
% case of non-identity transform
ptCloudIn = pctransform(ptCloudIn, invert(tform));
end
% Convert the point cloud to lidar scan
scan = pointCloudToScan(ptCloudIn, scanAngleLimits, scanRangeLimits, ...
elevationAngleTolerance, scanAngleResolution);
end
%--------------------------------------------------------------------------
function [tform, scanAngleLimits, scanRangeLimits, elevationAngleTolerance, ...
scanAngleResolution] = parseAndValidateInputs(ptCloudIn, varargin)
validateattributes(ptCloudIn, {'pointCloud'}, {'scalar'}, mfilename, ...
'ptCloudIn', 1);
p = inputParser;
% Set default values
defaultValues = getDefaultOptionalInputs();
addOptional(p, 'tform', defaultValues.Tform, @checkTform);
addParameter(p, 'ElevationAngleTolerance', ...
defaultValues.ElevationAngleTolerance, @checkElevationAngleTolerance);
addParameter(p, 'ScanAngleResolution', ...
defaultValues.ScanAngleResolution, @checkScanAngleResolution);
addParameter(p, 'ScanAngleLimits', ...
defaultValues.ScanAngleLimits, @checkScanAngleLimits);
addParameter(p, 'ScanRangeLimits', ...
defaultValues.ScanRangeLimits, @checkScanRangeLimits);
% Parse input
parse(p, varargin{:});
tform = p.Results.tform;
elevationAngleTolerance = cast(p.Results.ElevationAngleTolerance, ...
'like', ptCloudIn.Location);
scanAngleResolution = cast(p.Results.ScanAngleResolution, ...
'like', ptCloudIn.Location);
scanAngleLimits = cast(p.Results.ScanAngleLimits, ...
'like', ptCloudIn.Location);
scanRangeLimits = cast(p.Results.ScanRangeLimits, ...
'like', ptCloudIn.Location);
if diff(scanAngleLimits) < scanAngleResolution
error(message('lidar:pc2scan:invalidInput'));
end
if isscalar(elevationAngleTolerance)
elevationAngleTolerance = [-elevationAngleTolerance elevationAngleTolerance];
end
end
0 个评论
回答(1 个)
Vinayak
2024-1-5
Hi Aly,
Code generation is not supported for the “inputParser” in MATLAB Coder or GPU Coder. You may consider creating your own parser. As you are already having check functions, you can call them in a switch-case or if-else before other checks.
The sample code that can achieve something similar is:
for i = 1:2:length(varargin)
paramName = varargin{i};
paramValue = varargin{i+1};
switch lower(paramName)
case 'tform'
checkTform(paramValue);
tform = paramValue;
case 'elevationangletolerance'
checkElevationAngleTolerance(paramValue);
elevationAngleTolerance = cast(paramValue, 'like', ptCloudIn.Location);
case 'scanangleresolution'
checkScanAngleResolution(paramValue);
scanAngleResolution = cast(paramValue, 'like', ptCloudIn.Location);
case 'scananglelimits'
checkScanAngleLimits(paramValue);
scanAngleLimits = cast(paramValue, 'like', ptCloudIn.Location);
case 'scanrangelimits'
checkScanRangeLimits(paramValue);
scanRangeLimits = cast(paramValue, 'like', ptCloudIn.Location);
otherwise
error('Unknown parameter name: %s', paramName);
end
end
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Convert Image Type 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!