fixed comms LOS obstruction by obstacles
This commit is contained in:
@@ -32,8 +32,10 @@ function obj = initialize(obj, domain, objective, agents, minAlt, timestep, part
|
||||
% Add an additional obstacle spanning the domain's footprint to
|
||||
% represent the minimum allowable altitude
|
||||
obj.minAlt = minAlt;
|
||||
obj.obstacles{end + 1, 1} = rectangularPrism;
|
||||
obj.obstacles{end, 1} = obj.obstacles{end, 1}.initialize([obj.domain.minCorner; obj.domain.maxCorner(1:2), obj.minAlt], "OBSTACLE", "Minimum Altitude Domain Constraint");
|
||||
if obj.minAlt > 0
|
||||
obj.obstacles{end + 1, 1} = rectangularPrism;
|
||||
obj.obstacles{end, 1} = obj.obstacles{end, 1}.initialize([obj.domain.minCorner; obj.domain.maxCorner(1:2), obj.minAlt], "OBSTACLE", "Minimum Altitude Domain Constraint");
|
||||
end
|
||||
|
||||
% Define objective
|
||||
obj.objective = objective;
|
||||
|
||||
@@ -7,26 +7,41 @@ function obj = updateAdjacency(obj)
|
||||
end
|
||||
|
||||
% Initialize assuming only self-connections
|
||||
A = logical(eye(size(obj.agents, 1)));
|
||||
A = true(size(obj.agents, 1));
|
||||
|
||||
% Check lower triangle off-diagonal connections
|
||||
for ii = 2:size(A, 1)
|
||||
for jj = 1:(ii - 1)
|
||||
if norm(obj.agents{ii}.pos - obj.agents{jj}.pos) <= min([obj.agents{ii}.comRange, obj.agents{jj}.comRange])
|
||||
% Make sure that obstacles don't obstruct the line
|
||||
% of sight, breaking the connection
|
||||
for kk = 1:size(obj.obstacles, 1)
|
||||
if ~obj.obstacles{kk}.containsLine(obj.agents{ii}.pos, obj.agents{jj}.pos)
|
||||
A(ii, jj) = true;
|
||||
end
|
||||
end
|
||||
% need extra handling for cases with no obstacles
|
||||
if isempty(obj.obstacles)
|
||||
A(ii, jj) = true;
|
||||
% Check that agents are not out of range
|
||||
if norm(obj.agents{ii}.pos - obj.agents{jj}.pos) > min([obj.agents{ii}.comRange, obj.agents{jj}.comRange]);
|
||||
A(ii, jj) = false; % comm range violation
|
||||
continue;
|
||||
end
|
||||
|
||||
% Check that agents do not have their line of sight obstructed
|
||||
for kk = 1:size(obj.obstacles, 1)
|
||||
if obj.obstacles{kk}.containsLine(obj.agents{jj}.pos, obj.agents{ii}.pos)
|
||||
A(ii, jj) = false;
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
% if norm(obj.agents{ii}.pos - obj.agents{jj}.pos) <= min([obj.agents{ii}.comRange, obj.agents{jj}.comRange])
|
||||
% % Make sure that obstacles don't obstruct the line
|
||||
% % of sight, breaking the connection
|
||||
% for kk = 1:size(obj.obstacles, 1)
|
||||
% if A(ii, jj) && obj.obstacles{kk}.containsLine(obj.agents{ii}.pos, obj.agents{jj}.pos)
|
||||
% A(ii, jj) = false;
|
||||
% end
|
||||
% end
|
||||
% % need extra handling for cases with no obstacles
|
||||
% if isempty(obj.obstacles)
|
||||
% A(ii, jj) = true;
|
||||
% end
|
||||
% end
|
||||
end
|
||||
end
|
||||
|
||||
obj.adjacency = A | A';
|
||||
obj.adjacency = A & A';
|
||||
end
|
||||
Reference in New Issue
Block a user