fixed cone plotting all the way to ground

This commit is contained in:
2026-01-11 18:43:44 -08:00
parent 40df9059e7
commit 7ba21fbaa7
11 changed files with 33 additions and 12 deletions

View File

@@ -33,5 +33,5 @@ function obj = initialize(obj, pos, vel, pan, tilt, collisionGeometry, sensorMod
% Initialize FOV cone
obj.fovGeometry = cone;
obj.fovGeometry = obj.fovGeometry.initialize([obj.pos(1:2), 0], tand(obj.sensorModel.alphaTilt) * obj.pos(3), obj.pos(3), REGION_TYPE.FOV, sprintf("%s FOV", obj.label));
obj.fovGeometry = obj.fovGeometry.initialize([obj.pos(1:3)], tand(obj.sensorModel.alphaTilt) * obj.pos(3), obj.pos(3), REGION_TYPE.FOV, sprintf("%s FOV", obj.label));
end

View File

@@ -36,5 +36,6 @@ function [obj, f] = plot(obj, ind, f)
end
% Plot FOV geometry
[obj.fovGeometry, f] = obj.fovGeometry.plot(ind, f);
maxAlt = f.Children(1).Children(end).ZLim(2); % to avoid scaling the FOV geometry as the sim runs, let's just make it really big and hide the excess under the floor of the domain. Check the domain altitude to figure out how big it needs to be to achieve this deception.
[obj.fovGeometry, f] = obj.fovGeometry.plot(ind, f, maxAlt);
end

View File

@@ -39,6 +39,7 @@ function updatePlots(obj)
% Update FOV geometry surfaces
for jj = 1:size(obj.fovGeometry.surface, 2)
% Update each plot
% obj.fovGeometry = obj.fovGeometry.plot(obj.spatialPlotIndices)
obj.fovGeometry.surface(jj).XData = obj.fovGeometry.surface(jj).XData + deltaPos(1);
obj.fovGeometry.surface(jj).YData = obj.fovGeometry.surface(jj).YData + deltaPos(2);
obj.fovGeometry.surface(jj).ZData = obj.fovGeometry.surface(jj).ZData + deltaPos(3);

View File

@@ -17,6 +17,6 @@ classdef cone
methods (Access = public)
[obj ] = initialize(obj, center, radius, height, tag, label);
[obj, f] = plot(obj, ind, f);
[obj, f] = plot(obj, ind, f, maxAlt);
end
end

View File

@@ -1,8 +1,9 @@
function [obj, f] = plot(obj, ind, f)
function [obj, f] = plot(obj, ind, f, maxAlt)
arguments (Input)
obj (1, 1) {mustBeA(obj, 'cone')};
ind (1, :) double = NaN;
f (1, 1) {mustBeA(f, 'matlab.ui.Figure')} = figure;
maxAlt (1, 1) = 10;
end
arguments (Output)
obj (1, 1) {mustBeA(obj, 'cone')};
@@ -12,16 +13,18 @@ function [obj, f] = plot(obj, ind, f)
% Create axes if they don't already exist
f = firstPlotSetup(f);
scalingFactor = (maxAlt / obj.height);
% Plot cone
[X, Y, Z] = cylinder([obj.radius, 0], obj.n);
[X, Y, Z] = cylinder([scalingFactor * obj.radius, 0], obj.n);
% Scale to match height
Z = Z * obj.height;
Z = Z * maxAlt;
% Move to center location
X = X + obj.center(1);
Y = Y + obj.center(2);
Z = Z + obj.center(3);
Z = Z + obj.center(3) - maxAlt;
% Plot
if isnan(ind)

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Info>
<Category UUID="FileClassCategory">
<Label UUID="design"/>
</Category>
</Info>

View File

@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<Info location="validate.m" type="File"/>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Info>
<Category UUID="FileClassCategory">
<Label UUID="design"/>
</Category>
</Info>

View File

@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<Info location="plotH.m" type="File"/>

View File

@@ -31,8 +31,8 @@ classdef test_miSim < matlab.unittest.TestCase
objective = sensingObjective;
% Agents
minAgents = 2; % Minimum number of agents to be randomly generated
maxAgents = 2; % Maximum number of agents to be randomly generated
minAgents = 3; % Minimum number of agents to be randomly generated
maxAgents = 4; % Maximum number of agents to be randomly generated
sensingLength = 0.05; % length parameter used by sensing function
agents = cell(0, 1);
@@ -591,7 +591,7 @@ classdef test_miSim < matlab.unittest.TestCase
% Run the simulation
tc.testClass = tc.testClass.run();
end
function test_obstacle_blocks_comms_LOS(tc)
function test_obstacle_permits_comms_LOS(tc)
% Fixed single obstacle
% Fixed two agents initial conditions
% Exaggerated large communications radius
@@ -631,7 +631,7 @@ classdef test_miSim < matlab.unittest.TestCase
tc.testClass = tc.testClass.initialize(tc.domain, tc.domain.objective, tc.agents, 0, tc.timestep, tc.partitoningFreq, nIter, tc.obstacles, false, false);
% No communications link should be established
tc.assertEqual(tc.testClass.adjacency, logical(eye(2)));
tc.assertEqual(tc.testClass.adjacency, logical(true(2)));
end
function test_LNA_case_1(tc)
% based on example in meeting