cleaned up obstacle generation

This commit is contained in:
2025-11-16 10:21:58 -08:00
parent c9ac9d7725
commit 12dbde7a02
6 changed files with 51 additions and 78 deletions

View File

@@ -1,15 +1,17 @@
function obj = initialize(obj, objectiveFunction, domain, discretizationStep)
function obj = initialize(obj, objectiveFunction, domain, discretizationStep, protectedRange)
arguments (Input)
obj (1,1) {mustBeA(obj, 'sensingObjective')};
objectiveFunction (1, 1) {mustBeA(objectiveFunction, 'function_handle')};
domain (1, 1) {mustBeGeometry};
discretizationStep (1, 1) double = 1;
protectedRange (1, 1) double = 1;
end
arguments (Output)
obj (1,1) {mustBeA(obj, 'sensingObjective')};
end
obj.groundAlt = domain.minCorner(3);
obj.protectedRange = protectedRange;
% Extract footprint limits
xMin = min(domain.footprint(:, 1));
@@ -30,4 +32,6 @@ function obj = initialize(obj, objectiveFunction, domain, discretizationStep)
% store ground position
idx = obj.values == max(obj.values, [], "all");
obj.groundPos = [obj.X(idx), obj.Y(idx)];
assert(domain.distance([obj.groundPos, domain.center(3)]) > protectedRange, "Domain is crowding the sensing objective")
end

View File

@@ -1,9 +1,9 @@
function obj = initializeRandomMvnpdf(obj, domain, protectedRange, discretizationStep)
function obj = initializeRandomMvnpdf(obj, domain, discretizationStep, protectedRange)
arguments (Input)
obj (1, 1) {mustBeA(obj, 'sensingObjective')};
domain (1, 1) {mustBeGeometry};
protectedRange (1, 1) double = 1;
discretizationStep (1, 1) double = 1;
protectedRange (1, 1) double = 1;
end
arguments (Output)
obj (1, 1) {mustBeA(obj, 'sensingObjective')};
@@ -23,5 +23,5 @@ function obj = initializeRandomMvnpdf(obj, domain, protectedRange, discretizatio
objectiveFunction = @(x, y) mvnpdf([x(:), y(:)], mu, sig);
% Regular initialization
obj = obj.initialize(objectiveFunction, domain, discretizationStep);
obj = obj.initialize(objectiveFunction, domain, discretizationStep, protectedRange);
end

View File

@@ -9,11 +9,12 @@ classdef sensingObjective
X = [];
Y = [];
values = [];
protectedRange = 1; % keep obstacles from crowding objective
end
methods (Access = public)
[obj] = initialize(obj, objectiveFunction, domain, discretizationStep);
[obj] = initializeRandomMvnpdf(obj, domain, protectedRange, discretizationStep);
[obj] = initialize(obj, objectiveFunction, domain, discretizationStep, protectedRange);
[obj] = initializeRandomMvnpdf(obj, domain, protectedRange, discretizationStep, protectedRange);
[f ] = plot(obj, ind, f);
end
end