From bcb3bc3da3e351692bb3fa5032fd0b277ab606cb Mon Sep 17 00:00:00 2001 From: Kevin D Date: Tue, 13 Jan 2026 21:17:35 -0800 Subject: [PATCH] lots of cleanup and simplification in test case construction --- @agent/agent.m | 7 +- @agent/initialize.m | 8 +- @agent/partition.m | 2 +- @agent/run.m | 8 +- @agent/updatePlots.m | 10 +- @miSim/constrainMotion.m | 5 + @miSim/initialize.m | 8 +- @miSim/miSim.m | 3 +- @miSim/teardown.m | 13 +++ .../distanceMembership.m | 0 .../initialize.m | 6 +- .../plotParameters.m | 0 .../sensorPerformance.m | 6 +- .../sigmoidSensor.m | 5 +- .../tiltMembership.m | 0 geometries/@rectangularPrism/initialize.m | 9 -- .../@rectangularPrism/rectangularPrism.m | 4 - geometries/@spherical/initialize.m | 5 - geometries/@spherical/spherical.m | 4 - .../r541J80LBY7p-VdF-2cmu2pJyd4p.xml | 2 - .../svhNcplUM7n23Qjwql1uZ5L6c6sd.xml | 2 - .../QQkomTANNGDauE43PAdpZJlxaiQd.xml} | 0 .../QQkomTANNGDauE43PAdpZJlxaiQp.xml | 2 + .../ohKqyO-2hbPx9f-0yqpBSUUQdsgd.xml | 2 - .../ohKqyO-2hbPx9f-0yqpBSUUQdsgp.xml | 2 - .../c0mYkONNU4mIjcCgfDyvbU49RuMd.xml} | 0 .../c0mYkONNU4mIjcCgfDyvbU49RuMp.xml | 2 + .../f0RkSaUnOeV8lDfnKFJ8u9hIZUUp.xml | 2 - .../FSUxhxpU_Dod-AnagxlbCzI9H-gd.xml} | 0 .../FSUxhxpU_Dod-AnagxlbCzI9H-gp.xml} | 0 .../GguIqNeeBWU5xZrynPO-wpFYSAEd.xml} | 0 .../GguIqNeeBWU5xZrynPO-wpFYSAEp.xml} | 0 .../HXew_loNxIfLeyeZuyA5EgMo6NMd.xml} | 0 .../HXew_loNxIfLeyeZuyA5EgMo6NMp.xml} | 0 .../VkGixlI-aRMfBjgCxPv00TxbT_8d.xml} | 0 .../VkGixlI-aRMfBjgCxPv00TxbT_8p.xml} | 0 .../YfPAcafii5LkaqbJJW4iwwCWMlAd.xml} | 0 .../YfPAcafii5LkaqbJJW4iwwCWMlAp.xml} | 0 .../fUKAN5TqAqbLbj64AJ0xGtOkIPQd.xml} | 0 .../fUKAN5TqAqbLbj64AJ0xGtOkIPQp.xml} | 0 .../s62GUzlA81yhDNi9jlY63dGGTVId.xml} | 0 .../s62GUzlA81yhDNi9jlY63dGGTVIp.xml} | 0 .../9ucwbDs2BkA9ZqIHQI_XVIGSH5Ad.xml | 2 - .../9ucwbDs2BkA9ZqIHQI_XVIGSH5Ap.xml | 2 - .../o6vRLbVRBKxltajotIPvuRfoO58d.xml} | 0 .../o6vRLbVRBKxltajotIPvuRfoO58p.xml} | 0 .../KQTHy3u41hZ5fp_zyPTt34VbI4Yp.xml | 2 - .../nQxSe2SDiKQ4IIJQlHCi9SxD7Vsp.xml | 2 - .../peMR3cfX5HUpN7z1gUid-46m5V8d.xml | 2 - .../peMR3cfX5HUpN7z1gUid-46m5V8p.xml | 2 - .../Jdb23yLfHsZsXlb_4WZeit3L6-Ud.xml | 2 - .../Jdb23yLfHsZsXlb_4WZeit3L6-Up.xml | 2 - .../a6WBlPgSaAg9MeMZ9a3VNFUwwHYp.xml | 2 - .../idDvq0mRu533mATDdzl_FG-b-w4d.xml | 6 - .../jU0rMGjmBFOW1Qf0MUFrG_zqjO0d.xml | 6 - .../lA9hUETTjsTN6BFBFM_Djjvh2CId.xml | 6 - .../lA9hUETTjsTN6BFBFM_Djjvh2CIp.xml | 2 - .../fixedCardinalSensor.m | 13 --- .../@fixedCardinalSensor/initialize.m | 10 -- sensorModels/@fixedCardinalSensor/sense.m | 45 -------- .../@fixedCardinalSensor/sensorPerformance.m | 14 --- test/parametricTestSuite.m | 44 ++++--- test/test_miSim.m | 107 +++++++++--------- test/test_sigmoidSensor.m | 14 +-- util/objectiveFunctionWrapper.m | 13 +++ 65 files changed, 150 insertions(+), 265 deletions(-) create mode 100644 @miSim/teardown.m rename {sensorModels/@sigmoidSensor => @sigmoidSensor}/distanceMembership.m (100%) rename {sensorModels/@sigmoidSensor => @sigmoidSensor}/initialize.m (66%) rename {sensorModels/@sigmoidSensor => @sigmoidSensor}/plotParameters.m (100%) rename {sensorModels/@sigmoidSensor => @sigmoidSensor}/sensorPerformance.m (81%) rename {sensorModels/@sigmoidSensor => @sigmoidSensor}/sigmoidSensor.m (76%) rename {sensorModels/@sigmoidSensor => @sigmoidSensor}/tiltMembership.m (100%) delete mode 100644 resources/project/9ucwbDs2BkA9ZqIHQI_XVIGSH5A/r541J80LBY7p-VdF-2cmu2pJyd4p.xml delete mode 100644 resources/project/9ucwbDs2BkA9ZqIHQI_XVIGSH5A/svhNcplUM7n23Qjwql1uZ5L6c6sd.xml rename resources/project/{SIL3u_W39LwE7HHYsarfFmr9gVQ/f0RkSaUnOeV8lDfnKFJ8u9hIZUUd.xml => E2mMq2X73DyjKhlQAouGqrsyLgg/QQkomTANNGDauE43PAdpZJlxaiQd.xml} (100%) create mode 100644 resources/project/E2mMq2X73DyjKhlQAouGqrsyLgg/QQkomTANNGDauE43PAdpZJlxaiQp.xml delete mode 100644 resources/project/EEtUlUb-dLAdf0KpMVivaUlztwA/ohKqyO-2hbPx9f-0yqpBSUUQdsgd.xml delete mode 100644 resources/project/EEtUlUb-dLAdf0KpMVivaUlztwA/ohKqyO-2hbPx9f-0yqpBSUUQdsgp.xml rename resources/project/{r541J80LBY7p-VdF-2cmu2pJyd4/KQTHy3u41hZ5fp_zyPTt34VbI4Yd.xml => SIL3u_W39LwE7HHYsarfFmr9gVQ/c0mYkONNU4mIjcCgfDyvbU49RuMd.xml} (100%) create mode 100644 resources/project/SIL3u_W39LwE7HHYsarfFmr9gVQ/c0mYkONNU4mIjcCgfDyvbU49RuMp.xml delete mode 100644 resources/project/SIL3u_W39LwE7HHYsarfFmr9gVQ/f0RkSaUnOeV8lDfnKFJ8u9hIZUUp.xml rename resources/project/{9ucwbDs2BkA9ZqIHQI_XVIGSH5A/isiBrcsGCu0pq9djBUrtow7oYN8d.xml => o6vRLbVRBKxltajotIPvuRfoO58/FSUxhxpU_Dod-AnagxlbCzI9H-gd.xml} (100%) rename resources/project/{9ucwbDs2BkA9ZqIHQI_XVIGSH5A/isiBrcsGCu0pq9djBUrtow7oYN8p.xml => o6vRLbVRBKxltajotIPvuRfoO58/FSUxhxpU_Dod-AnagxlbCzI9H-gp.xml} (100%) rename resources/project/{r541J80LBY7p-VdF-2cmu2pJyd4/UfNKdoPYwGxvwP_XcBmma4_VkKQd.xml => o6vRLbVRBKxltajotIPvuRfoO58/GguIqNeeBWU5xZrynPO-wpFYSAEd.xml} (100%) rename resources/project/{svhNcplUM7n23Qjwql1uZ5L6c6s/jU0rMGjmBFOW1Qf0MUFrG_zqjO0p.xml => o6vRLbVRBKxltajotIPvuRfoO58/GguIqNeeBWU5xZrynPO-wpFYSAEp.xml} (100%) rename resources/project/{r541J80LBY7p-VdF-2cmu2pJyd4/nQxSe2SDiKQ4IIJQlHCi9SxD7Vsd.xml => o6vRLbVRBKxltajotIPvuRfoO58/HXew_loNxIfLeyeZuyA5EgMo6NMd.xml} (100%) rename resources/project/{r541J80LBY7p-VdF-2cmu2pJyd4/UfNKdoPYwGxvwP_XcBmma4_VkKQp.xml => o6vRLbVRBKxltajotIPvuRfoO58/HXew_loNxIfLeyeZuyA5EgMo6NMp.xml} (100%) rename resources/project/{r541J80LBY7p-VdF-2cmu2pJyd4/tTAT2DJRs7K-aVtU05nDJ6Xog3Ud.xml => o6vRLbVRBKxltajotIPvuRfoO58/VkGixlI-aRMfBjgCxPv00TxbT_8d.xml} (100%) rename resources/project/{svhNcplUM7n23Qjwql1uZ5L6c6s/JlTRUONvUsWw4xzUu6ME_Dv4PB4p.xml => o6vRLbVRBKxltajotIPvuRfoO58/VkGixlI-aRMfBjgCxPv00TxbT_8p.xml} (100%) rename resources/project/{svhNcplUM7n23Qjwql1uZ5L6c6s/Cnje8-nVwXLSBkpqGRNU6YqMjQUd.xml => o6vRLbVRBKxltajotIPvuRfoO58/YfPAcafii5LkaqbJJW4iwwCWMlAd.xml} (100%) rename resources/project/{svhNcplUM7n23Qjwql1uZ5L6c6s/idDvq0mRu533mATDdzl_FG-b-w4p.xml => o6vRLbVRBKxltajotIPvuRfoO58/YfPAcafii5LkaqbJJW4iwwCWMlAp.xml} (100%) rename resources/project/{svhNcplUM7n23Qjwql1uZ5L6c6s/JlTRUONvUsWw4xzUu6ME_Dv4PB4d.xml => o6vRLbVRBKxltajotIPvuRfoO58/fUKAN5TqAqbLbj64AJ0xGtOkIPQd.xml} (100%) rename resources/project/{svhNcplUM7n23Qjwql1uZ5L6c6s/Cnje8-nVwXLSBkpqGRNU6YqMjQUp.xml => o6vRLbVRBKxltajotIPvuRfoO58/fUKAN5TqAqbLbj64AJ0xGtOkIPQp.xml} (100%) rename resources/project/{svhNcplUM7n23Qjwql1uZ5L6c6s/a6WBlPgSaAg9MeMZ9a3VNFUwwHYd.xml => o6vRLbVRBKxltajotIPvuRfoO58/s62GUzlA81yhDNi9jlY63dGGTVId.xml} (100%) rename resources/project/{r541J80LBY7p-VdF-2cmu2pJyd4/tTAT2DJRs7K-aVtU05nDJ6Xog3Up.xml => o6vRLbVRBKxltajotIPvuRfoO58/s62GUzlA81yhDNi9jlY63dGGTVIp.xml} (100%) delete mode 100644 resources/project/qaw0eS1zuuY1ar9TdPn1GMfrjbQ/9ucwbDs2BkA9ZqIHQI_XVIGSH5Ad.xml delete mode 100644 resources/project/qaw0eS1zuuY1ar9TdPn1GMfrjbQ/9ucwbDs2BkA9ZqIHQI_XVIGSH5Ap.xml rename resources/project/{9ucwbDs2BkA9ZqIHQI_XVIGSH5A/r541J80LBY7p-VdF-2cmu2pJyd4d.xml => qaw0eS1zuuY1ar9TdPn1GMfrjbQ/o6vRLbVRBKxltajotIPvuRfoO58d.xml} (100%) rename resources/project/{9ucwbDs2BkA9ZqIHQI_XVIGSH5A/svhNcplUM7n23Qjwql1uZ5L6c6sp.xml => qaw0eS1zuuY1ar9TdPn1GMfrjbQ/o6vRLbVRBKxltajotIPvuRfoO58p.xml} (100%) delete mode 100644 resources/project/r541J80LBY7p-VdF-2cmu2pJyd4/KQTHy3u41hZ5fp_zyPTt34VbI4Yp.xml delete mode 100644 resources/project/r541J80LBY7p-VdF-2cmu2pJyd4/nQxSe2SDiKQ4IIJQlHCi9SxD7Vsp.xml delete mode 100644 resources/project/r541J80LBY7p-VdF-2cmu2pJyd4/peMR3cfX5HUpN7z1gUid-46m5V8d.xml delete mode 100644 resources/project/r541J80LBY7p-VdF-2cmu2pJyd4/peMR3cfX5HUpN7z1gUid-46m5V8p.xml delete mode 100644 resources/project/svhNcplUM7n23Qjwql1uZ5L6c6s/Jdb23yLfHsZsXlb_4WZeit3L6-Ud.xml delete mode 100644 resources/project/svhNcplUM7n23Qjwql1uZ5L6c6s/Jdb23yLfHsZsXlb_4WZeit3L6-Up.xml delete mode 100644 resources/project/svhNcplUM7n23Qjwql1uZ5L6c6s/a6WBlPgSaAg9MeMZ9a3VNFUwwHYp.xml delete mode 100644 resources/project/svhNcplUM7n23Qjwql1uZ5L6c6s/idDvq0mRu533mATDdzl_FG-b-w4d.xml delete mode 100644 resources/project/svhNcplUM7n23Qjwql1uZ5L6c6s/jU0rMGjmBFOW1Qf0MUFrG_zqjO0d.xml delete mode 100644 resources/project/svhNcplUM7n23Qjwql1uZ5L6c6s/lA9hUETTjsTN6BFBFM_Djjvh2CId.xml delete mode 100644 resources/project/svhNcplUM7n23Qjwql1uZ5L6c6s/lA9hUETTjsTN6BFBFM_Djjvh2CIp.xml delete mode 100644 sensorModels/@fixedCardinalSensor/fixedCardinalSensor.m delete mode 100644 sensorModels/@fixedCardinalSensor/initialize.m delete mode 100644 sensorModels/@fixedCardinalSensor/sense.m delete mode 100644 sensorModels/@fixedCardinalSensor/sensorPerformance.m create mode 100644 util/objectiveFunctionWrapper.m diff --git a/@agent/agent.m b/@agent/agent.m index aebca85..3f91e3d 100644 --- a/@agent/agent.m +++ b/@agent/agent.m @@ -9,14 +9,9 @@ classdef agent % State lastPos = NaN(1, 3); % position from previous timestep pos = NaN(1, 3); % current position - vel = NaN(1, 3); % current velocity - pan = NaN; % pan angle - tilt = NaN; % tilt angle % Collision collisionGeometry; - barrierFunction; - dBarrierFunction; % FOV cone fovGeometry; @@ -39,7 +34,7 @@ classdef agent end methods (Access = public) - [obj] = initialize(obj, pos, vel, pan, tilt, collisionGeometry, sensorModel, guidanceModel, comRange, index, label); + [obj] = initialize(obj, pos, pan, tilt, collisionGeometry, sensorModel, guidanceModel, comRange, index, label); [obj] = run(obj, domain, partitioning, t, index, agents); [partitioning] = partition(obj, agents, objective) [obj, f] = plot(obj, ind, f); diff --git a/@agent/initialize.m b/@agent/initialize.m index 5002ab6..2bcff5d 100644 --- a/@agent/initialize.m +++ b/@agent/initialize.m @@ -1,10 +1,7 @@ -function obj = initialize(obj, pos, vel, pan, tilt, collisionGeometry, sensorModel, comRange, maxIter, label, plotCommsGeometry) +function obj = initialize(obj, pos, collisionGeometry, sensorModel, comRange, maxIter, label, plotCommsGeometry) arguments (Input) obj (1, 1) {mustBeA(obj, 'agent')}; pos (1, 3) double; - vel (1, 3) double; - pan (1, 1) double; - tilt (1, 1) double; collisionGeometry (1, 1) {mustBeGeometry}; sensorModel (1, 1) {mustBeSensor}; comRange (1, 1) double; @@ -17,9 +14,6 @@ function obj = initialize(obj, pos, vel, pan, tilt, collisionGeometry, sensorMod end obj.pos = pos; - obj.vel = vel; - obj.pan = pan; - obj.tilt = tilt; obj.collisionGeometry = collisionGeometry; obj.sensorModel = sensorModel; obj.label = label; diff --git a/@agent/partition.m b/@agent/partition.m index 80012ce..8e94c5e 100644 --- a/@agent/partition.m +++ b/@agent/partition.m @@ -10,7 +10,7 @@ function [partitioning] = partition(obj, agents, objective) % Assess sensing performance of each agent at each sample point % in the domain - agentPerformances = cellfun(@(x) reshape(x.sensorModel.sensorPerformance(x.pos, x.pan, x.tilt, [objective.X(:), objective.Y(:), zeros(size(objective.X(:)))]), size(objective.X)), agents, 'UniformOutput', false); + agentPerformances = cellfun(@(x) reshape(x.sensorModel.sensorPerformance(x.pos, [objective.X(:), objective.Y(:), zeros(size(objective.X(:)))]), size(objective.X)), agents, 'UniformOutput', false); agentPerformances{end + 1} = objective.sensorPerformanceMinimum * ones(size(agentPerformances{end})); % add additional layer to represent the threshold that has to be cleared for assignment to any partiton agentPerformances = cat(3, agentPerformances{:}); diff --git a/@agent/run.m b/@agent/run.m index 5e48a0f..7a024cf 100644 --- a/@agent/run.m +++ b/@agent/run.m @@ -13,6 +13,10 @@ function obj = run(obj, domain, partitioning, timestepIndex, index, agents) % Collect objective function values across partition partitionMask = partitioning == index; + if ~unique(partitionMask) + % This agent has no partition, maintain current state + return; + end objectiveValues = domain.objective.values(partitionMask); % f(omega) on W_n % Compute sensor performance on partition @@ -30,7 +34,7 @@ function obj = run(obj, domain, partitioning, timestepIndex, index, agents) % Compute performance values on partition if ii < 5 % Compute sensing performance - sensorValues = obj.sensorModel.sensorPerformance(pos, obj.pan, obj.tilt, [maskedX, maskedY, zeros(size(maskedX))]); % S_n(omega, P_n) on W_n + sensorValues = obj.sensorModel.sensorPerformance(pos, [maskedX, maskedY, zeros(size(maskedX))]); % S_n(omega, P_n) on W_n % Objective performance does not change for 0, +/- X, Y steps. % Those values are computed once before the loop and are only % recomputed when +/- Z steps are applied @@ -45,7 +49,7 @@ function obj = run(obj, domain, partitioning, timestepIndex, index, agents) % Recompute partiton-derived performance values for sensing maskedX = domain.objective.X(partitionMask); maskedY = domain.objective.Y(partitionMask); - sensorValues = obj.sensorModel.sensorPerformance(pos, obj.pan, obj.tilt, [maskedX, maskedY, zeros(size(maskedX))]); % S_n(omega, P_n) on W_n + sensorValues = obj.sensorModel.sensorPerformance(pos, [maskedX, maskedY, zeros(size(maskedX))]); % S_n(omega, P_n) on W_n end % Rearrange data into image arrays diff --git a/@agent/updatePlots.m b/@agent/updatePlots.m index d05a043..6a300c6 100644 --- a/@agent/updatePlots.m +++ b/@agent/updatePlots.m @@ -5,6 +5,13 @@ function updatePlots(obj) arguments (Output) end + % Find change in agent position since last timestep + deltaPos = obj.pos - obj.lastPos; + if all(isnan(deltaPos)) || all(deltaPos == zeros(1, 3)) + % Agent did not move, so nothing has to move on the plots + return; + end + % Scatterplot point positions for ii = 1:size(obj.scatterPoints, 1) obj.scatterPoints(ii).XData = obj.pos(1); @@ -12,9 +19,6 @@ function updatePlots(obj) obj.scatterPoints(ii).ZData = obj.pos(3); end - % Find change in agent position since last timestep - deltaPos = obj.pos - obj.lastPos; - % Collision geometry edges for jj = 1:size(obj.collisionGeometry.lines, 2) % Update plotting diff --git a/@miSim/constrainMotion.m b/@miSim/constrainMotion.m index 4d0a152..d20575e 100644 --- a/@miSim/constrainMotion.m +++ b/@miSim/constrainMotion.m @@ -14,6 +14,11 @@ function [obj] = constrainMotion(obj) agents = [obj.agents{:}]; v = reshape(([agents.pos] - [agents.lastPos])./obj.timestep, 3, size(obj.agents, 1))'; + if all(isnan(v)) || all(v == zeros(1, 3)) + % Agents are not attempting to move, so there is no motion to be + % constrained + return; + end % Initialize QP based on number of agents and obstacles nAOPairs = size(obj.agents, 1) * size(obj.obstacles, 1); % unique agent/obstacle pairs diff --git a/@miSim/initialize.m b/@miSim/initialize.m index fdff6b5..e12cfac 100644 --- a/@miSim/initialize.m +++ b/@miSim/initialize.m @@ -1,8 +1,7 @@ -function obj = initialize(obj, domain, objective, agents, minAlt, timestep, maxIter, obstacles, makePlots, makeVideo) +function obj = initialize(obj, domain, agents, minAlt, timestep, maxIter, obstacles, makePlots, makeVideo) arguments (Input) obj (1, 1) {mustBeA(obj, 'miSim')}; domain (1, 1) {mustBeGeometry}; - objective (1, 1) {mustBeA(objective, 'sensingObjective')}; agents (:, 1) cell; minAlt (1, 1) double = 1; timestep (:, 1) double = 0.05; @@ -44,9 +43,6 @@ function obj = initialize(obj, domain, objective, agents, minAlt, timestep, maxI 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; - % Define agents obj.agents = agents; obj.constraintAdjacencyMatrix = logical(eye(size(agents, 1))); @@ -76,7 +72,7 @@ function obj = initialize(obj, domain, objective, agents, minAlt, timestep, maxI obj.perf = [zeros(size(obj.agents, 1) + 1, 1), NaN(size(obj.agents, 1) + 1, size(obj.partitioningTimes, 1) - 1)]; % Prepare h function data store - obj.h = NaN(size(obj.agents, 1) * (size(obj.agents, 1) - 1) / 2 + size(obj.agents, 1) * size(obj.obstacles, 1) + 6, size(obj.times, 1) - 1); + obj.h = NaN(size(obj.agents, 1) * (size(obj.agents, 1) - 1) / 2 + size(obj.agents, 1) * size(obj.obstacles, 1) + 6, size(obj.times, 1)); % Create initial partitioning obj.partitioning = obj.agents{1}.partition(obj.agents, obj.domain.objective); diff --git a/@miSim/miSim.m b/@miSim/miSim.m index 80ead18..3dce005 100644 --- a/@miSim/miSim.m +++ b/@miSim/miSim.m @@ -55,7 +55,7 @@ classdef miSim end methods (Access = public) - [obj] = initialize(obj, domain, objective, agents, timestep, partitoningFreq, maxIter, obstacles); + [obj] = initialize(obj, domain, agents, timestep, partitoningFreq, maxIter, obstacles); [obj] = run(obj); [obj] = lesserNeighbor(obj); [obj] = constrainMotion(obj); @@ -69,6 +69,7 @@ classdef miSim [obj] = plotH(obj); [obj] = updatePlots(obj); validate(obj); + teardown(obj); end methods (Access = private) [v] = setupVideoWriter(obj); diff --git a/@miSim/teardown.m b/@miSim/teardown.m new file mode 100644 index 0000000..4563b45 --- /dev/null +++ b/@miSim/teardown.m @@ -0,0 +1,13 @@ +function teardown(obj) + arguments (Input) + obj (1, 1) {mustBeA(obj, 'miSim')}; + end + arguments (Output) + end + + % Close plots + close(obj.hf); + close(obj.fPerf); + close(obj.f); + +end \ No newline at end of file diff --git a/sensorModels/@sigmoidSensor/distanceMembership.m b/@sigmoidSensor/distanceMembership.m similarity index 100% rename from sensorModels/@sigmoidSensor/distanceMembership.m rename to @sigmoidSensor/distanceMembership.m diff --git a/sensorModels/@sigmoidSensor/initialize.m b/@sigmoidSensor/initialize.m similarity index 66% rename from sensorModels/@sigmoidSensor/initialize.m rename to @sigmoidSensor/initialize.m index 04cd77b..50ebf4d 100644 --- a/sensorModels/@sigmoidSensor/initialize.m +++ b/@sigmoidSensor/initialize.m @@ -1,10 +1,8 @@ -function obj = initialize(obj, alphaDist, betaDist, alphaPan, betaPan, alphaTilt, betaTilt) +function obj = initialize(obj, alphaDist, betaDist, alphaTilt, betaTilt) arguments (Input) obj (1, 1) {mustBeA(obj, 'sigmoidSensor')} alphaDist (1, 1) double; betaDist (1, 1) double; - alphaPan (1, 1) double; - betaPan (1, 1) double; alphaTilt (1, 1) double; betaTilt (1, 1) double; end @@ -14,8 +12,6 @@ function obj = initialize(obj, alphaDist, betaDist, alphaPan, betaPan, alphaTilt obj.alphaDist = alphaDist; obj.betaDist = betaDist; - obj.alphaPan = alphaPan; - obj.betaPan = betaPan; obj.alphaTilt = alphaTilt; obj.betaTilt = betaTilt; end \ No newline at end of file diff --git a/sensorModels/@sigmoidSensor/plotParameters.m b/@sigmoidSensor/plotParameters.m similarity index 100% rename from sensorModels/@sigmoidSensor/plotParameters.m rename to @sigmoidSensor/plotParameters.m diff --git a/sensorModels/@sigmoidSensor/sensorPerformance.m b/@sigmoidSensor/sensorPerformance.m similarity index 81% rename from sensorModels/@sigmoidSensor/sensorPerformance.m rename to @sigmoidSensor/sensorPerformance.m index 044060f..50e3853 100644 --- a/sensorModels/@sigmoidSensor/sensorPerformance.m +++ b/@sigmoidSensor/sensorPerformance.m @@ -1,9 +1,7 @@ -function value = sensorPerformance(obj, agentPos, agentPan, agentTilt, targetPos) +function value = sensorPerformance(obj, agentPos, targetPos) arguments (Input) obj (1, 1) {mustBeA(obj, 'sigmoidSensor')}; agentPos (1, 3) double; - agentPan (1, 1) double; - agentTilt (1, 1) double; targetPos (:, 3) double; end arguments (Output) @@ -15,7 +13,7 @@ function value = sensorPerformance(obj, agentPos, agentPan, agentTilt, targetPos x = vecnorm(agentPos(1:2) - targetPos(:, 1:2), 2, 2); % distance from sensor nadir to target nadir (i.e. distance ignoring height difference) % compute tilt angle - tiltAngle = (180 - atan2d(x, targetPos(:, 3) - agentPos(3))) - agentTilt; % degrees + tiltAngle = (180 - atan2d(x, targetPos(:, 3) - agentPos(3))); % degrees % Membership functions mu_d = obj.distanceMembership(d); diff --git a/sensorModels/@sigmoidSensor/sigmoidSensor.m b/@sigmoidSensor/sigmoidSensor.m similarity index 76% rename from sensorModels/@sigmoidSensor/sigmoidSensor.m rename to @sigmoidSensor/sigmoidSensor.m index fb5e874..c1a8e28 100644 --- a/sensorModels/@sigmoidSensor/sigmoidSensor.m +++ b/@sigmoidSensor/sigmoidSensor.m @@ -3,15 +3,12 @@ classdef sigmoidSensor % Sensor parameters alphaDist = NaN; betaDist = NaN; - alphaPan = NaN; - betaPan = NaN; alphaTilt = NaN; % degrees betaTilt = NaN; end methods (Access = public) - [obj] = initialize(obj, alphaDist, betaDist, alphaPan, betaPan, alphaTilt, betaTilt); - [values, positions] = sense(obj, agent, sensingObjective, domain, partitioning); + [obj] = initialize(obj, alphaDist, betaDist, alphaTilt, betaTilt); [value] = sensorPerformance(obj, agentPos, agentPan, agentTilt, targetPos); [f] = plotParameters(obj); end diff --git a/sensorModels/@sigmoidSensor/tiltMembership.m b/@sigmoidSensor/tiltMembership.m similarity index 100% rename from sensorModels/@sigmoidSensor/tiltMembership.m rename to @sigmoidSensor/tiltMembership.m diff --git a/geometries/@rectangularPrism/initialize.m b/geometries/@rectangularPrism/initialize.m index 5d3f21a..c945e78 100644 --- a/geometries/@rectangularPrism/initialize.m +++ b/geometries/@rectangularPrism/initialize.m @@ -48,13 +48,4 @@ function obj = initialize(obj, bounds, tag, label, objectiveFunction, discretiza if tag == REGION_TYPE.DOMAIN obj.objective = sensingObjective; end - - % Initialize CBF - % first part evaluates to +/-1 if the point is outside/inside the collision geometry - % Second part determines the distance from the point to the boundary of the collision geometry - obj.barrierFunction = @(x) (1 - 2 * obj.collisionGeometry.contains(x)) * obj.collisionGeometry.distance(x); % x is 1x3 - % gradient of barrier function - obj.dBarrierFunction = @(x) obj.collisionGeometry.distanceGradient(x); % x is 1x3 - % as long as the collisionGeometry object is updated during runtime, - % these functions never have to be updated again end \ No newline at end of file diff --git a/geometries/@rectangularPrism/rectangularPrism.m b/geometries/@rectangularPrism/rectangularPrism.m index 17a4b6f..bb0dd07 100644 --- a/geometries/@rectangularPrism/rectangularPrism.m +++ b/geometries/@rectangularPrism/rectangularPrism.m @@ -20,10 +20,6 @@ classdef rectangularPrism % Plotting lines; - - % collision - barrierFunction; - dBarrierFunction; end properties (SetAccess = public, GetAccess = public) label = ""; diff --git a/geometries/@spherical/initialize.m b/geometries/@spherical/initialize.m index a35418d..7383740 100644 --- a/geometries/@spherical/initialize.m +++ b/geometries/@spherical/initialize.m @@ -18,11 +18,6 @@ function obj = initialize(obj, center, radius, tag, label) obj.radius = radius; obj.diameter = 2 * obj.radius; - % Initialize CBF - obj.barrierFunction = @(x) NaN; - % gradient of barrier function - obj.dBarrierFunction = @(x) NaN; - % fake vertices in a cross pattern obj.vertices = [obj.center + [obj.radius, 0, 0]; ... obj.center - [obj.radius, 0, 0]; ... diff --git a/geometries/@spherical/spherical.m b/geometries/@spherical/spherical.m index d2e9269..8e3b618 100644 --- a/geometries/@spherical/spherical.m +++ b/geometries/@spherical/spherical.m @@ -11,10 +11,6 @@ classdef spherical % Plotting lines; - - % collision - barrierFunction; - dBarrierFunction; end properties (SetAccess = public, GetAccess = public) % Meta diff --git a/resources/project/9ucwbDs2BkA9ZqIHQI_XVIGSH5A/r541J80LBY7p-VdF-2cmu2pJyd4p.xml b/resources/project/9ucwbDs2BkA9ZqIHQI_XVIGSH5A/r541J80LBY7p-VdF-2cmu2pJyd4p.xml deleted file mode 100644 index 2f0264c..0000000 --- a/resources/project/9ucwbDs2BkA9ZqIHQI_XVIGSH5A/r541J80LBY7p-VdF-2cmu2pJyd4p.xml +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/resources/project/9ucwbDs2BkA9ZqIHQI_XVIGSH5A/svhNcplUM7n23Qjwql1uZ5L6c6sd.xml b/resources/project/9ucwbDs2BkA9ZqIHQI_XVIGSH5A/svhNcplUM7n23Qjwql1uZ5L6c6sd.xml deleted file mode 100644 index 4356a6a..0000000 --- a/resources/project/9ucwbDs2BkA9ZqIHQI_XVIGSH5A/svhNcplUM7n23Qjwql1uZ5L6c6sd.xml +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/resources/project/SIL3u_W39LwE7HHYsarfFmr9gVQ/f0RkSaUnOeV8lDfnKFJ8u9hIZUUd.xml b/resources/project/E2mMq2X73DyjKhlQAouGqrsyLgg/QQkomTANNGDauE43PAdpZJlxaiQd.xml similarity index 100% rename from resources/project/SIL3u_W39LwE7HHYsarfFmr9gVQ/f0RkSaUnOeV8lDfnKFJ8u9hIZUUd.xml rename to resources/project/E2mMq2X73DyjKhlQAouGqrsyLgg/QQkomTANNGDauE43PAdpZJlxaiQd.xml diff --git a/resources/project/E2mMq2X73DyjKhlQAouGqrsyLgg/QQkomTANNGDauE43PAdpZJlxaiQp.xml b/resources/project/E2mMq2X73DyjKhlQAouGqrsyLgg/QQkomTANNGDauE43PAdpZJlxaiQp.xml new file mode 100644 index 0000000..7577442 --- /dev/null +++ b/resources/project/E2mMq2X73DyjKhlQAouGqrsyLgg/QQkomTANNGDauE43PAdpZJlxaiQp.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/resources/project/EEtUlUb-dLAdf0KpMVivaUlztwA/ohKqyO-2hbPx9f-0yqpBSUUQdsgd.xml b/resources/project/EEtUlUb-dLAdf0KpMVivaUlztwA/ohKqyO-2hbPx9f-0yqpBSUUQdsgd.xml deleted file mode 100644 index 03feb65..0000000 --- a/resources/project/EEtUlUb-dLAdf0KpMVivaUlztwA/ohKqyO-2hbPx9f-0yqpBSUUQdsgd.xml +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/resources/project/EEtUlUb-dLAdf0KpMVivaUlztwA/ohKqyO-2hbPx9f-0yqpBSUUQdsgp.xml b/resources/project/EEtUlUb-dLAdf0KpMVivaUlztwA/ohKqyO-2hbPx9f-0yqpBSUUQdsgp.xml deleted file mode 100644 index 249cad0..0000000 --- a/resources/project/EEtUlUb-dLAdf0KpMVivaUlztwA/ohKqyO-2hbPx9f-0yqpBSUUQdsgp.xml +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/resources/project/r541J80LBY7p-VdF-2cmu2pJyd4/KQTHy3u41hZ5fp_zyPTt34VbI4Yd.xml b/resources/project/SIL3u_W39LwE7HHYsarfFmr9gVQ/c0mYkONNU4mIjcCgfDyvbU49RuMd.xml similarity index 100% rename from resources/project/r541J80LBY7p-VdF-2cmu2pJyd4/KQTHy3u41hZ5fp_zyPTt34VbI4Yd.xml rename to resources/project/SIL3u_W39LwE7HHYsarfFmr9gVQ/c0mYkONNU4mIjcCgfDyvbU49RuMd.xml diff --git a/resources/project/SIL3u_W39LwE7HHYsarfFmr9gVQ/c0mYkONNU4mIjcCgfDyvbU49RuMp.xml b/resources/project/SIL3u_W39LwE7HHYsarfFmr9gVQ/c0mYkONNU4mIjcCgfDyvbU49RuMp.xml new file mode 100644 index 0000000..6b53f27 --- /dev/null +++ b/resources/project/SIL3u_W39LwE7HHYsarfFmr9gVQ/c0mYkONNU4mIjcCgfDyvbU49RuMp.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/resources/project/SIL3u_W39LwE7HHYsarfFmr9gVQ/f0RkSaUnOeV8lDfnKFJ8u9hIZUUp.xml b/resources/project/SIL3u_W39LwE7HHYsarfFmr9gVQ/f0RkSaUnOeV8lDfnKFJ8u9hIZUUp.xml deleted file mode 100644 index 7c8e137..0000000 --- a/resources/project/SIL3u_W39LwE7HHYsarfFmr9gVQ/f0RkSaUnOeV8lDfnKFJ8u9hIZUUp.xml +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/resources/project/9ucwbDs2BkA9ZqIHQI_XVIGSH5A/isiBrcsGCu0pq9djBUrtow7oYN8d.xml b/resources/project/o6vRLbVRBKxltajotIPvuRfoO58/FSUxhxpU_Dod-AnagxlbCzI9H-gd.xml similarity index 100% rename from resources/project/9ucwbDs2BkA9ZqIHQI_XVIGSH5A/isiBrcsGCu0pq9djBUrtow7oYN8d.xml rename to resources/project/o6vRLbVRBKxltajotIPvuRfoO58/FSUxhxpU_Dod-AnagxlbCzI9H-gd.xml diff --git a/resources/project/9ucwbDs2BkA9ZqIHQI_XVIGSH5A/isiBrcsGCu0pq9djBUrtow7oYN8p.xml b/resources/project/o6vRLbVRBKxltajotIPvuRfoO58/FSUxhxpU_Dod-AnagxlbCzI9H-gp.xml similarity index 100% rename from resources/project/9ucwbDs2BkA9ZqIHQI_XVIGSH5A/isiBrcsGCu0pq9djBUrtow7oYN8p.xml rename to resources/project/o6vRLbVRBKxltajotIPvuRfoO58/FSUxhxpU_Dod-AnagxlbCzI9H-gp.xml diff --git a/resources/project/r541J80LBY7p-VdF-2cmu2pJyd4/UfNKdoPYwGxvwP_XcBmma4_VkKQd.xml b/resources/project/o6vRLbVRBKxltajotIPvuRfoO58/GguIqNeeBWU5xZrynPO-wpFYSAEd.xml similarity index 100% rename from resources/project/r541J80LBY7p-VdF-2cmu2pJyd4/UfNKdoPYwGxvwP_XcBmma4_VkKQd.xml rename to resources/project/o6vRLbVRBKxltajotIPvuRfoO58/GguIqNeeBWU5xZrynPO-wpFYSAEd.xml diff --git a/resources/project/svhNcplUM7n23Qjwql1uZ5L6c6s/jU0rMGjmBFOW1Qf0MUFrG_zqjO0p.xml b/resources/project/o6vRLbVRBKxltajotIPvuRfoO58/GguIqNeeBWU5xZrynPO-wpFYSAEp.xml similarity index 100% rename from resources/project/svhNcplUM7n23Qjwql1uZ5L6c6s/jU0rMGjmBFOW1Qf0MUFrG_zqjO0p.xml rename to resources/project/o6vRLbVRBKxltajotIPvuRfoO58/GguIqNeeBWU5xZrynPO-wpFYSAEp.xml diff --git a/resources/project/r541J80LBY7p-VdF-2cmu2pJyd4/nQxSe2SDiKQ4IIJQlHCi9SxD7Vsd.xml b/resources/project/o6vRLbVRBKxltajotIPvuRfoO58/HXew_loNxIfLeyeZuyA5EgMo6NMd.xml similarity index 100% rename from resources/project/r541J80LBY7p-VdF-2cmu2pJyd4/nQxSe2SDiKQ4IIJQlHCi9SxD7Vsd.xml rename to resources/project/o6vRLbVRBKxltajotIPvuRfoO58/HXew_loNxIfLeyeZuyA5EgMo6NMd.xml diff --git a/resources/project/r541J80LBY7p-VdF-2cmu2pJyd4/UfNKdoPYwGxvwP_XcBmma4_VkKQp.xml b/resources/project/o6vRLbVRBKxltajotIPvuRfoO58/HXew_loNxIfLeyeZuyA5EgMo6NMp.xml similarity index 100% rename from resources/project/r541J80LBY7p-VdF-2cmu2pJyd4/UfNKdoPYwGxvwP_XcBmma4_VkKQp.xml rename to resources/project/o6vRLbVRBKxltajotIPvuRfoO58/HXew_loNxIfLeyeZuyA5EgMo6NMp.xml diff --git a/resources/project/r541J80LBY7p-VdF-2cmu2pJyd4/tTAT2DJRs7K-aVtU05nDJ6Xog3Ud.xml b/resources/project/o6vRLbVRBKxltajotIPvuRfoO58/VkGixlI-aRMfBjgCxPv00TxbT_8d.xml similarity index 100% rename from resources/project/r541J80LBY7p-VdF-2cmu2pJyd4/tTAT2DJRs7K-aVtU05nDJ6Xog3Ud.xml rename to resources/project/o6vRLbVRBKxltajotIPvuRfoO58/VkGixlI-aRMfBjgCxPv00TxbT_8d.xml diff --git a/resources/project/svhNcplUM7n23Qjwql1uZ5L6c6s/JlTRUONvUsWw4xzUu6ME_Dv4PB4p.xml b/resources/project/o6vRLbVRBKxltajotIPvuRfoO58/VkGixlI-aRMfBjgCxPv00TxbT_8p.xml similarity index 100% rename from resources/project/svhNcplUM7n23Qjwql1uZ5L6c6s/JlTRUONvUsWw4xzUu6ME_Dv4PB4p.xml rename to resources/project/o6vRLbVRBKxltajotIPvuRfoO58/VkGixlI-aRMfBjgCxPv00TxbT_8p.xml diff --git a/resources/project/svhNcplUM7n23Qjwql1uZ5L6c6s/Cnje8-nVwXLSBkpqGRNU6YqMjQUd.xml b/resources/project/o6vRLbVRBKxltajotIPvuRfoO58/YfPAcafii5LkaqbJJW4iwwCWMlAd.xml similarity index 100% rename from resources/project/svhNcplUM7n23Qjwql1uZ5L6c6s/Cnje8-nVwXLSBkpqGRNU6YqMjQUd.xml rename to resources/project/o6vRLbVRBKxltajotIPvuRfoO58/YfPAcafii5LkaqbJJW4iwwCWMlAd.xml diff --git a/resources/project/svhNcplUM7n23Qjwql1uZ5L6c6s/idDvq0mRu533mATDdzl_FG-b-w4p.xml b/resources/project/o6vRLbVRBKxltajotIPvuRfoO58/YfPAcafii5LkaqbJJW4iwwCWMlAp.xml similarity index 100% rename from resources/project/svhNcplUM7n23Qjwql1uZ5L6c6s/idDvq0mRu533mATDdzl_FG-b-w4p.xml rename to resources/project/o6vRLbVRBKxltajotIPvuRfoO58/YfPAcafii5LkaqbJJW4iwwCWMlAp.xml diff --git a/resources/project/svhNcplUM7n23Qjwql1uZ5L6c6s/JlTRUONvUsWw4xzUu6ME_Dv4PB4d.xml b/resources/project/o6vRLbVRBKxltajotIPvuRfoO58/fUKAN5TqAqbLbj64AJ0xGtOkIPQd.xml similarity index 100% rename from resources/project/svhNcplUM7n23Qjwql1uZ5L6c6s/JlTRUONvUsWw4xzUu6ME_Dv4PB4d.xml rename to resources/project/o6vRLbVRBKxltajotIPvuRfoO58/fUKAN5TqAqbLbj64AJ0xGtOkIPQd.xml diff --git a/resources/project/svhNcplUM7n23Qjwql1uZ5L6c6s/Cnje8-nVwXLSBkpqGRNU6YqMjQUp.xml b/resources/project/o6vRLbVRBKxltajotIPvuRfoO58/fUKAN5TqAqbLbj64AJ0xGtOkIPQp.xml similarity index 100% rename from resources/project/svhNcplUM7n23Qjwql1uZ5L6c6s/Cnje8-nVwXLSBkpqGRNU6YqMjQUp.xml rename to resources/project/o6vRLbVRBKxltajotIPvuRfoO58/fUKAN5TqAqbLbj64AJ0xGtOkIPQp.xml diff --git a/resources/project/svhNcplUM7n23Qjwql1uZ5L6c6s/a6WBlPgSaAg9MeMZ9a3VNFUwwHYd.xml b/resources/project/o6vRLbVRBKxltajotIPvuRfoO58/s62GUzlA81yhDNi9jlY63dGGTVId.xml similarity index 100% rename from resources/project/svhNcplUM7n23Qjwql1uZ5L6c6s/a6WBlPgSaAg9MeMZ9a3VNFUwwHYd.xml rename to resources/project/o6vRLbVRBKxltajotIPvuRfoO58/s62GUzlA81yhDNi9jlY63dGGTVId.xml diff --git a/resources/project/r541J80LBY7p-VdF-2cmu2pJyd4/tTAT2DJRs7K-aVtU05nDJ6Xog3Up.xml b/resources/project/o6vRLbVRBKxltajotIPvuRfoO58/s62GUzlA81yhDNi9jlY63dGGTVIp.xml similarity index 100% rename from resources/project/r541J80LBY7p-VdF-2cmu2pJyd4/tTAT2DJRs7K-aVtU05nDJ6Xog3Up.xml rename to resources/project/o6vRLbVRBKxltajotIPvuRfoO58/s62GUzlA81yhDNi9jlY63dGGTVIp.xml diff --git a/resources/project/qaw0eS1zuuY1ar9TdPn1GMfrjbQ/9ucwbDs2BkA9ZqIHQI_XVIGSH5Ad.xml b/resources/project/qaw0eS1zuuY1ar9TdPn1GMfrjbQ/9ucwbDs2BkA9ZqIHQI_XVIGSH5Ad.xml deleted file mode 100644 index 4356a6a..0000000 --- a/resources/project/qaw0eS1zuuY1ar9TdPn1GMfrjbQ/9ucwbDs2BkA9ZqIHQI_XVIGSH5Ad.xml +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/resources/project/qaw0eS1zuuY1ar9TdPn1GMfrjbQ/9ucwbDs2BkA9ZqIHQI_XVIGSH5Ap.xml b/resources/project/qaw0eS1zuuY1ar9TdPn1GMfrjbQ/9ucwbDs2BkA9ZqIHQI_XVIGSH5Ap.xml deleted file mode 100644 index 2921191..0000000 --- a/resources/project/qaw0eS1zuuY1ar9TdPn1GMfrjbQ/9ucwbDs2BkA9ZqIHQI_XVIGSH5Ap.xml +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/resources/project/9ucwbDs2BkA9ZqIHQI_XVIGSH5A/r541J80LBY7p-VdF-2cmu2pJyd4d.xml b/resources/project/qaw0eS1zuuY1ar9TdPn1GMfrjbQ/o6vRLbVRBKxltajotIPvuRfoO58d.xml similarity index 100% rename from resources/project/9ucwbDs2BkA9ZqIHQI_XVIGSH5A/r541J80LBY7p-VdF-2cmu2pJyd4d.xml rename to resources/project/qaw0eS1zuuY1ar9TdPn1GMfrjbQ/o6vRLbVRBKxltajotIPvuRfoO58d.xml diff --git a/resources/project/9ucwbDs2BkA9ZqIHQI_XVIGSH5A/svhNcplUM7n23Qjwql1uZ5L6c6sp.xml b/resources/project/qaw0eS1zuuY1ar9TdPn1GMfrjbQ/o6vRLbVRBKxltajotIPvuRfoO58p.xml similarity index 100% rename from resources/project/9ucwbDs2BkA9ZqIHQI_XVIGSH5A/svhNcplUM7n23Qjwql1uZ5L6c6sp.xml rename to resources/project/qaw0eS1zuuY1ar9TdPn1GMfrjbQ/o6vRLbVRBKxltajotIPvuRfoO58p.xml diff --git a/resources/project/r541J80LBY7p-VdF-2cmu2pJyd4/KQTHy3u41hZ5fp_zyPTt34VbI4Yp.xml b/resources/project/r541J80LBY7p-VdF-2cmu2pJyd4/KQTHy3u41hZ5fp_zyPTt34VbI4Yp.xml deleted file mode 100644 index e09fee5..0000000 --- a/resources/project/r541J80LBY7p-VdF-2cmu2pJyd4/KQTHy3u41hZ5fp_zyPTt34VbI4Yp.xml +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/resources/project/r541J80LBY7p-VdF-2cmu2pJyd4/nQxSe2SDiKQ4IIJQlHCi9SxD7Vsp.xml b/resources/project/r541J80LBY7p-VdF-2cmu2pJyd4/nQxSe2SDiKQ4IIJQlHCi9SxD7Vsp.xml deleted file mode 100644 index 1b3fd95..0000000 --- a/resources/project/r541J80LBY7p-VdF-2cmu2pJyd4/nQxSe2SDiKQ4IIJQlHCi9SxD7Vsp.xml +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/resources/project/r541J80LBY7p-VdF-2cmu2pJyd4/peMR3cfX5HUpN7z1gUid-46m5V8d.xml b/resources/project/r541J80LBY7p-VdF-2cmu2pJyd4/peMR3cfX5HUpN7z1gUid-46m5V8d.xml deleted file mode 100644 index 4356a6a..0000000 --- a/resources/project/r541J80LBY7p-VdF-2cmu2pJyd4/peMR3cfX5HUpN7z1gUid-46m5V8d.xml +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/resources/project/r541J80LBY7p-VdF-2cmu2pJyd4/peMR3cfX5HUpN7z1gUid-46m5V8p.xml b/resources/project/r541J80LBY7p-VdF-2cmu2pJyd4/peMR3cfX5HUpN7z1gUid-46m5V8p.xml deleted file mode 100644 index 01cb34e..0000000 --- a/resources/project/r541J80LBY7p-VdF-2cmu2pJyd4/peMR3cfX5HUpN7z1gUid-46m5V8p.xml +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/resources/project/svhNcplUM7n23Qjwql1uZ5L6c6s/Jdb23yLfHsZsXlb_4WZeit3L6-Ud.xml b/resources/project/svhNcplUM7n23Qjwql1uZ5L6c6s/Jdb23yLfHsZsXlb_4WZeit3L6-Ud.xml deleted file mode 100644 index 4356a6a..0000000 --- a/resources/project/svhNcplUM7n23Qjwql1uZ5L6c6s/Jdb23yLfHsZsXlb_4WZeit3L6-Ud.xml +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/resources/project/svhNcplUM7n23Qjwql1uZ5L6c6s/Jdb23yLfHsZsXlb_4WZeit3L6-Up.xml b/resources/project/svhNcplUM7n23Qjwql1uZ5L6c6s/Jdb23yLfHsZsXlb_4WZeit3L6-Up.xml deleted file mode 100644 index 01cb34e..0000000 --- a/resources/project/svhNcplUM7n23Qjwql1uZ5L6c6s/Jdb23yLfHsZsXlb_4WZeit3L6-Up.xml +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/resources/project/svhNcplUM7n23Qjwql1uZ5L6c6s/a6WBlPgSaAg9MeMZ9a3VNFUwwHYp.xml b/resources/project/svhNcplUM7n23Qjwql1uZ5L6c6s/a6WBlPgSaAg9MeMZ9a3VNFUwwHYp.xml deleted file mode 100644 index 919c37e..0000000 --- a/resources/project/svhNcplUM7n23Qjwql1uZ5L6c6s/a6WBlPgSaAg9MeMZ9a3VNFUwwHYp.xml +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/resources/project/svhNcplUM7n23Qjwql1uZ5L6c6s/idDvq0mRu533mATDdzl_FG-b-w4d.xml b/resources/project/svhNcplUM7n23Qjwql1uZ5L6c6s/idDvq0mRu533mATDdzl_FG-b-w4d.xml deleted file mode 100644 index 99772b4..0000000 --- a/resources/project/svhNcplUM7n23Qjwql1uZ5L6c6s/idDvq0mRu533mATDdzl_FG-b-w4d.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - \ No newline at end of file diff --git a/resources/project/svhNcplUM7n23Qjwql1uZ5L6c6s/jU0rMGjmBFOW1Qf0MUFrG_zqjO0d.xml b/resources/project/svhNcplUM7n23Qjwql1uZ5L6c6s/jU0rMGjmBFOW1Qf0MUFrG_zqjO0d.xml deleted file mode 100644 index 99772b4..0000000 --- a/resources/project/svhNcplUM7n23Qjwql1uZ5L6c6s/jU0rMGjmBFOW1Qf0MUFrG_zqjO0d.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - \ No newline at end of file diff --git a/resources/project/svhNcplUM7n23Qjwql1uZ5L6c6s/lA9hUETTjsTN6BFBFM_Djjvh2CId.xml b/resources/project/svhNcplUM7n23Qjwql1uZ5L6c6s/lA9hUETTjsTN6BFBFM_Djjvh2CId.xml deleted file mode 100644 index 99772b4..0000000 --- a/resources/project/svhNcplUM7n23Qjwql1uZ5L6c6s/lA9hUETTjsTN6BFBFM_Djjvh2CId.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - \ No newline at end of file diff --git a/resources/project/svhNcplUM7n23Qjwql1uZ5L6c6s/lA9hUETTjsTN6BFBFM_Djjvh2CIp.xml b/resources/project/svhNcplUM7n23Qjwql1uZ5L6c6s/lA9hUETTjsTN6BFBFM_Djjvh2CIp.xml deleted file mode 100644 index 844d632..0000000 --- a/resources/project/svhNcplUM7n23Qjwql1uZ5L6c6s/lA9hUETTjsTN6BFBFM_Djjvh2CIp.xml +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/sensorModels/@fixedCardinalSensor/fixedCardinalSensor.m b/sensorModels/@fixedCardinalSensor/fixedCardinalSensor.m deleted file mode 100644 index 374d38a..0000000 --- a/sensorModels/@fixedCardinalSensor/fixedCardinalSensor.m +++ /dev/null @@ -1,13 +0,0 @@ -classdef fixedCardinalSensor - % Senses in the +/-x, +/- y directions at some specified fixed length - properties - alphaTilt = NaN; - r = 0.1; % fixed sensing length - end - - methods (Access = public) - [obj] = initialize(obj, r); - [neighborValues, neighborPos] = sense(obj, agent, sensingObjective, domain, partitioning); - [value] = sensorPerformance(obj, agentPos, agentPan, agentTilt, targetPos); - end -end \ No newline at end of file diff --git a/sensorModels/@fixedCardinalSensor/initialize.m b/sensorModels/@fixedCardinalSensor/initialize.m deleted file mode 100644 index c65b583..0000000 --- a/sensorModels/@fixedCardinalSensor/initialize.m +++ /dev/null @@ -1,10 +0,0 @@ -function obj = initialize(obj, r) - arguments(Input) - obj (1, 1) {mustBeA(obj, 'fixedCardinalSensor')}; - r (1, 1) double; - end - arguments(Output) - obj (1, 1) {mustBeA(obj, 'fixedCardinalSensor')}; - end - obj.r = r; -end \ No newline at end of file diff --git a/sensorModels/@fixedCardinalSensor/sense.m b/sensorModels/@fixedCardinalSensor/sense.m deleted file mode 100644 index 5369a22..0000000 --- a/sensorModels/@fixedCardinalSensor/sense.m +++ /dev/null @@ -1,45 +0,0 @@ -function [neighborValues, neighborPos] = sense(obj, agent, sensingObjective, domain, partitioning) - arguments (Input) - obj (1, 1) {mustBeA(obj, 'fixedCardinalSensor')}; - agent (1, 1) {mustBeA(agent, 'agent')}; - sensingObjective (1, 1) {mustBeA(sensingObjective, 'sensingObjective')}; - domain (1, 1) {mustBeGeometry}; - partitioning (:, :) double = NaN; - end - arguments (Output) - neighborValues (4, 1) double; - neighborPos (4, 3) double; - end - - % Set alphaTilt to produce an FOV cone with radius 'r' on the ground - obj.alphaTilt = atan2(obj.r, agent.pos(3)); - - % Evaluate objective at position offsets +/-[r, 0, 0] and +/-[0, r, 0] - currentPos = agent.pos(1:2); - neighborPos = [currentPos(1) + obj.r, currentPos(2); ... % (+x) - currentPos(1), currentPos(2) + obj.r; ... % (+y) - currentPos(1) - obj.r, currentPos(2); ... % (-x) - currentPos(1), currentPos(2) - obj.r; ... % (-y) - ]; - - % Check for neighbor positions that fall outside of the domain - outOfBounds = false(size(neighborPos, 1), 1); - for ii = 1:size(neighborPos, 1) - if ~domain.contains([neighborPos(ii, :), 0]) - outOfBounds(ii) = true; - end - end - - % Replace out of bounds positions with inoffensive in-bounds positions - neighborPos(outOfBounds, 1:3) = repmat(agent.pos, sum(outOfBounds), 1); - - % Sense values at selected positions - neighborValues = [sensingObjective.objectiveFunction(neighborPos(1, 1), neighborPos(1, 2)), ... % (+x) - sensingObjective.objectiveFunction(neighborPos(2, 1), neighborPos(2, 2)), ... % (+y) - sensingObjective.objectiveFunction(neighborPos(3, 1), neighborPos(3, 2)), ... % (-x) - sensingObjective.objectiveFunction(neighborPos(4, 1), neighborPos(4, 2)), ... % (-y) - ]; - - % Prevent out of bounds locations from ever possibly being selected - neighborValues(outOfBounds) = 0; -end \ No newline at end of file diff --git a/sensorModels/@fixedCardinalSensor/sensorPerformance.m b/sensorModels/@fixedCardinalSensor/sensorPerformance.m deleted file mode 100644 index 2c2a294..0000000 --- a/sensorModels/@fixedCardinalSensor/sensorPerformance.m +++ /dev/null @@ -1,14 +0,0 @@ -function value = sensorPerformance(obj, agentPos, agentPan, agentTilt, targetPos) - arguments (Input) - obj (1, 1) {mustBeA(obj, 'fixedCardinalSensor')}; - agentPos (1, 3) double; - agentPan (1, 1) double; - agentTilt (1, 1) double; - targetPos (:, 3) double; - end - arguments (Output) - value (:, 1) double; - end - - value = 0.5 * ones(size(targetPos, 1), 1); -end \ No newline at end of file diff --git a/test/parametricTestSuite.m b/test/parametricTestSuite.m index bc56f58..14df5bb 100644 --- a/test/parametricTestSuite.m +++ b/test/parametricTestSuite.m @@ -3,7 +3,6 @@ classdef parametricTestSuite < matlab.unittest.TestCase % System under test testClass = miSim; domain = rectangularPrism; - objective = sensingObjective; obstacles = cell(1, 0); %% Diagnostic Parameters @@ -16,33 +15,52 @@ classdef parametricTestSuite < matlab.unittest.TestCase end properties (TestParameter) %% Simulation Parameters - maxIter = num2cell([200, 400]); % number of timesteps to run + maxIter = num2cell([25]); % number of timesteps to run % Domain parameters - minAlt = num2cell([1, 3]); % minimum allowed agent altitude, make sure test cases don't conflict with this + minAlt = num2cell([1]); % minimum allowed agent altitude, make sure test cases don't conflict with this % Sensing Objective Parameters - discretizationStep = num2cell([0.01, 0.05]); + discretizationStep = num2cell([0.01]); % Agent Parameters - collisionRange = num2cell([0.1, 0.5]); + collisionRadius = num2cell([0.1]); % Sensor Model Parameters - betaDist = num2cell(3:6:15); - betaTilt = num2cell(3:6:15); alphaDist = num2cell([2.5, 5]); - alphaTilt = num2cell([15, 30]); % (degrees) + betaDist = num2cell([3, 15]); + alphaTilt = num2cell([15, 30]); % (degrees)methods + betaTilt = num2cell([3, 15]); % Communications Parameters - comRange = num2cell(1:2:5); + comRange = num2cell([3]); end methods (Test, ParameterCombination = "exhaustive") - % Test methods + % Test cases + function single_agent_gradient_ascent(tc, maxIter, minAlt, discretizationStep, collisionRadius, alphaDist, betaDist, alphaTilt, betaTilt, comRange) + % Set up square domain + l = 10; + tc.domain = tc.domain.initialize([zeros(1, 3); l * ones(1, 3)], REGION_TYPE.DOMAIN, "Domain"); + tc.domain.objective = tc.domain.objective.initialize(objectiveFunctionWrapper([.75 * l, 0.75 * l]), tc.domain, discretizationStep, tc.protectedRange); + + % Set up agent + sensorModel = sigmoidSensor; + sensorModel = sensorModel.initialize(alphaDist, betaDist, alphaTilt, betaTilt); + agentPos = [l/4, l/4, 3*l/4]; + collisionGeometry = spherical; + collisionGeometry = collisionGeometry.initialize(agentPos, collisionRadius, REGION_TYPE.COLLISION, "Agent 1 Collision Region"); + agents = {agent}; + agents{1} = agents{1}.initialize(agentPos, collisionGeometry, sensorModel, comRange, maxIter, "Agent 1", tc.plotCommsGeometry); - function single_agent_gradient_ascent(tc, maxIter, minAlt, discretizationStep, collisionRange, alphaDist, alphaTilt, betaDist, betaTilt, comRange) - 1; + % Set up simulation + tc.testClass = tc.testClass.initialize(tc.domain, agents, minAlt, tc.timestep, maxIter, tc.obstacles, tc.makePlots, tc.makeVideo); + + % Run + tc.testClass = tc.testClass.run(); + + % Cleanup + tc.testClass.teardown(); end end - end \ No newline at end of file diff --git a/test/test_miSim.m b/test/test_miSim.m index ac00406..5174013 100644 --- a/test/test_miSim.m +++ b/test/test_miSim.m @@ -157,10 +157,10 @@ classdef test_miSim < matlab.unittest.TestCase % Initialize candidate agent sensor model sensor = sigmoidSensor; - sensor = sensor.initialize(tc.alphaDistMin + rand * (tc.alphaDistMax - tc.alphaDistMin), tc.betaDistMin + rand * (tc.betaDistMax - tc.betaDistMin), NaN, NaN, tc.alphaTiltMin + rand * (tc.alphaTiltMax - tc.alphaTiltMin), tc.betaTiltMin + rand * (tc.betaTiltMax - tc.betaTiltMin)); + sensor = sensor.initialize(tc.alphaDistMin + rand * (tc.alphaDistMax - tc.alphaDistMin), tc.betaDistMin + rand * (tc.betaDistMax - tc.betaDistMin), tc.alphaTiltMin + rand * (tc.alphaTiltMax - tc.alphaTiltMin), tc.betaTiltMin + rand * (tc.betaTiltMax - tc.betaTiltMin)); % Initialize candidate agent - newAgent = tc.agents{ii}.initialize(candidatePos, zeros(1,3), 0, 0, candidateGeometry, sensor, tc.comRange, tc.maxIter); + newAgent = tc.agents{ii}.initialize(candidatePos, candidateGeometry, sensor, tc.comRange, tc.maxIter); % Make sure candidate agent doesn't collide with % domain @@ -208,7 +208,7 @@ classdef test_miSim < matlab.unittest.TestCase end % Initialize the simulation - tc.testClass = tc.testClass.initialize(tc.domain, tc.domain.objective, tc.agents, tc.minAlt, tc.timestep, tc.maxIter, tc.obstacles, tc.makeVideo); + tc.testClass = tc.testClass.initialize(tc.domain, tc.agents, tc.minAlt, tc.timestep, tc.maxIter, tc.obstacles, tc.makeVideo); end function misim_run(tc) % randomly create obstacles @@ -291,10 +291,10 @@ classdef test_miSim < matlab.unittest.TestCase % Initialize candidate agent sensor model sensor = sigmoidSensor; - sensor = sensor.initialize(tc.alphaDistMin + rand * (tc.alphaDistMax - tc.alphaDistMin), tc.betaDistMin + rand * (tc.betaDistMax - tc.betaDistMin), NaN, NaN, tc.alphaTiltMin + rand * (tc.alphaTiltMax - tc.alphaTiltMin), tc.betaTiltMin + rand * (tc.betaTiltMax - tc.betaTiltMin)); + sensor = sensor.initialize(tc.alphaDistMin + rand * (tc.alphaDistMax - tc.alphaDistMin), tc.betaDistMin + rand * (tc.betaDistMax - tc.betaDistMin), tc.alphaTiltMin + rand * (tc.alphaTiltMax - tc.alphaTiltMin), tc.betaTiltMin + rand * (tc.betaTiltMax - tc.betaTiltMin)); % Initialize candidate agent - newAgent = tc.agents{ii}.initialize(candidatePos, zeros(1,3), 0, 0, candidateGeometry, sensor, tc.comRange, tc.maxIter); + newAgent = tc.agents{ii}.initialize(candidatePos, candidateGeometry, sensor, tc.comRange, tc.maxIter); % Make sure candidate agent doesn't collide with % domain @@ -342,7 +342,7 @@ classdef test_miSim < matlab.unittest.TestCase end % Initialize the simulation - tc.testClass = tc.testClass.initialize(tc.domain, tc.domain.objective, tc.agents, tc.minAlt, tc.timestep, tc.maxIter, tc.obstacles, tc.makeVideo); + tc.testClass = tc.testClass.initialize(tc.domain, tc.agents, tc.minAlt, tc.timestep, tc.maxIter, tc.obstacles, tc.makeVideo); % Run simulation loop tc.testClass = tc.testClass.run(); @@ -367,26 +367,26 @@ classdef test_miSim < matlab.unittest.TestCase % Initialize agent sensor model sensor = sigmoidSensor; % Homogeneous sensor model parameters - sensor = sensor.initialize(2.75, 9, NaN, NaN, 22.5, 9); + sensor = sensor.initialize(2.75, 9, 22.5, 9); % Heterogeneous sensor model parameters - % sensor = sensor.initialize(tc.alphaDistMin + rand * (tc.alphaDistMax - tc.alphaDistMin), tc.betaDistMin + rand * (tc.betaDistMax - tc.betaDistMin), NaN, NaN, tc.alphaTiltMin + rand * (tc.alphaTiltMax - tc.alphaTiltMin), tc.betaTiltMin + rand * (tc.betaTiltMax - tc.betaTiltMin)); + % sensor = sensor.initialize(tc.alphaDistMin + rand * (tc.alphaDistMax - tc.alphaDistMin), tc.betaDistMin + rand * (tc.betaDistMax - tc.betaDistMin), tc.alphaTiltMin + rand * (tc.alphaTiltMax - tc.alphaTiltMin), tc.betaTiltMin + rand * (tc.betaTiltMax - tc.betaTiltMin)); % Plot sensor parameters (optional) % f = sensor.plotParameters(); % Initialize agents tc.agents = {agent; agent}; - tc.agents{1} = tc.agents{1}.initialize(tc.domain.center + dh + [d, 0, 0], zeros(1,3), 0, 0, geometry1, sensor, 3*d, tc.maxIter); - tc.agents{2} = tc.agents{2}.initialize(tc.domain.center + dh - [d, 0, 0], zeros(1,3), 0, 0, geometry2, sensor, 3*d, tc.maxIter); + tc.agents{1} = tc.agents{1}.initialize(tc.domain.center + dh + [d, 0, 0], geometry1, sensor, 3*d, tc.maxIter); + tc.agents{2} = tc.agents{2}.initialize(tc.domain.center + dh - [d, 0, 0], geometry2, sensor, 3*d, tc.maxIter); % Optional third agent along the +Y axis geometry3 = rectangularPrism; geometry3 = geometry3.initialize([tc.domain.center + dh - [0, d, 0] - tc.collisionRanges(1) * ones(1, 3); tc.domain.center + dh - [0, d, 0] + tc.collisionRanges(1) * ones(1, 3)], REGION_TYPE.COLLISION); tc.agents{3} = agent; - tc.agents{3} = tc.agents{3}.initialize(tc.domain.center + dh - [0, d, 0], zeros(1, 3), 0, 0, geometry3, sensor, 3*d, tc.maxIter); + tc.agents{3} = tc.agents{3}.initialize(tc.domain.center + dh - [0, d, 0], geometry3, sensor, 3*d, tc.maxIter); % Initialize the simulation - tc.testClass = tc.testClass.initialize(tc.domain, tc.domain.objective, tc.agents, tc.minAlt, tc.timestep, tc.maxIter, cell(0, 1), false, false); + tc.testClass = tc.testClass.initialize(tc.domain, tc.agents, tc.minAlt, tc.timestep, tc.maxIter, cell(0, 1), false, false); tc.verifyEqual(tc.testClass.partitioning(500, 500:502), [2, 3, 1]); % all three near center tc.verifyLessThan(sum(tc.testClass.partitioning == 1, 'all'), sum(tc.testClass.partitioning == 0, 'all')); % more non-assignments than partition 1 assignments @@ -409,19 +409,19 @@ classdef test_miSim < matlab.unittest.TestCase % Initialize agent sensor model sensor = sigmoidSensor; % Homogeneous sensor model parameters - % sensor = sensor.initialize(2.5666, 5.0807, NaN, NaN, 20.8614, 13); % 13 + % sensor = sensor.initialize(2.5666, 5.0807, 20.8614, 13); % 13 alphaDist = l/2; % half of domain length/width - sensor = sensor.initialize(alphaDist, 3, NaN, NaN, 20, 3); + sensor = sensor.initialize(alphaDist, 3, 20, 3); % Plot sensor parameters (optional) % f = sensor.plotParameters(); % Initialize agents tc.agents = {agent}; - tc.agents{1} = tc.agents{1}.initialize([tc.domain.center(1:2), 3], zeros(1,3), 0, 0, geometry1, sensor, 3, tc.maxIter); + tc.agents{1} = tc.agents{1}.initialize([tc.domain.center(1:2), 3], geometry1, sensor, 3, tc.maxIter); % Initialize the simulation - tc.testClass = tc.testClass.initialize(tc.domain, tc.domain.objective, tc.agents, tc.minAlt, tc.timestep, tc.maxIter, cell(0, 1), false, false); + tc.testClass = tc.testClass.initialize(tc.domain, tc.agents, tc.minAlt, tc.timestep, tc.maxIter, cell(0, 1), false, false); close(tc.testClass.fPerf); tc.verifyEqual(unique(tc.testClass.partitioning), [0; 1]); @@ -442,9 +442,9 @@ classdef test_miSim < matlab.unittest.TestCase % Initialize agent sensor model sensor = sigmoidSensor; % Homogeneous sensor model parameters - % sensor = sensor.initialize(2.5666, 5.0807, NaN, NaN, 20.8614, 13); % 13 + % sensor = sensor.initialize(2.5666, 5.0807, 20.8614, 13); % 13 alphaDist = l/2; % half of domain length/width - sensor = sensor.initialize(alphaDist, 3, NaN, NaN, 20, 3); + sensor = sensor.initialize(alphaDist, 3, 20, 3); % Plot sensor parameters (optional) % f = sensor.plotParameters(); @@ -452,10 +452,10 @@ classdef test_miSim < matlab.unittest.TestCase % Initialize agents nIter = 100; tc.agents = {agent}; - tc.agents{1} = tc.agents{1}.initialize([tc.domain.center(1:2)-tc.domain.dimensions(1)/4, 3], zeros(1,3), 0, 0, geometry1, sensor, 3, nIter); + tc.agents{1} = tc.agents{1}.initialize([tc.domain.center(1:2)-tc.domain.dimensions(1)/4, 3], geometry1, sensor, 3, nIter); % Initialize the simulation - tc.testClass = tc.testClass.initialize(tc.domain, tc.domain.objective, tc.agents, tc.minAlt, tc.timestep, nIter, cell(0, 1)); + tc.testClass = tc.testClass.initialize(tc.domain, tc.agents, tc.minAlt, tc.timestep, nIter, cell(0, 1)); % Run the simulation tc.testClass = tc.testClass.run(); @@ -484,18 +484,18 @@ classdef test_miSim < matlab.unittest.TestCase % Initialize agent sensor model sensor = sigmoidSensor; % Homogeneous sensor model parameters - % sensor = sensor.initialize(2.5666, 5.0807, NaN, NaN, 20.8614, 13); % 13 + % sensor = sensor.initialize(2.5666, 5.0807, 20.8614, 13); % 13 alphaDist = l/2; % half of domain length/width - sensor = sensor.initialize(alphaDist, 3, NaN, NaN, 15, 3); + sensor = sensor.initialize(alphaDist, 3, 15, 3); % Initialize agents nIter = 50; tc.agents = {agent; agent}; - tc.agents{1} = tc.agents{1}.initialize(tc.domain.center + d, zeros(1,3), 0, 0, geometry1, sensor, 5, nIter); - tc.agents{2} = tc.agents{2}.initialize(tc.domain.center - d, zeros(1,3), 0, 0, geometry2, sensor, 5, nIter); + tc.agents{1} = tc.agents{1}.initialize(tc.domain.center + d, geometry1, sensor, 5, nIter); + tc.agents{2} = tc.agents{2}.initialize(tc.domain.center - d, geometry2, sensor, 5, nIter); % Initialize the simulation - tc.testClass = tc.testClass.initialize(tc.domain, tc.domain.objective, tc.agents, tc.minAlt, tc.timestep, nIter, cell(0, 1), tc.makeVideo, tc.makePlots); + tc.testClass = tc.testClass.initialize(tc.domain, tc.agents, tc.minAlt, tc.timestep, nIter, cell(0, 1), tc.makeVideo, tc.makePlots); % Run the simulation tc.testClass.run(); @@ -529,7 +529,7 @@ classdef test_miSim < matlab.unittest.TestCase % Initialize agent sensor model sensor = sigmoidSensor; alphaDist = l/2; % half of domain length/width - sensor = sensor.initialize(alphaDist, 3, NaN, NaN, 15, 3); + sensor = sensor.initialize(alphaDist, 3, 15, 3); % Initialize obstacles obstacleLength = 1; @@ -539,11 +539,10 @@ classdef test_miSim < matlab.unittest.TestCase % Initialize agents commsRadius = (2*radius + obstacleLength) * 0.9; % defined such that they cannot go around the obstacle on both sides tc.agents = {agent; agent;}; - tc.agents{1} = tc.agents{1}.initialize(tc.domain.center - d + [0, radius * 1.1 - yOffset, 0], zeros(1,3), 0, 0, geometry1, sensor, commsRadius, tc.maxIter); - tc.agents{2} = tc.agents{2}.initialize(tc.domain.center - d - [0, radius *1.1 + yOffset, 0], zeros(1,3), 0, 0, geometry2, sensor, commsRadius, tc.maxIter); - + tc.agents{1} = tc.agents{1}.initialize(tc.domain.center - d + [0, radius * 1.1 - yOffset, 0], geometry1, sensor, commsRadius, tc.maxIter); + tc.agents{2} = tc.agents{2}.initialize(tc.domain.center - d - [0, radius *1.1 + yOffset, 0], geometry2, sensor, commsRadius, tc.maxIter); % Initialize the simulation - tc.testClass = tc.testClass.initialize(tc.domain, tc.domain.objective, tc.agents, tc.minAlt, tc.timestep, tc.maxIter, tc.obstacles, tc.makeVideo); + tc.testClass = tc.testClass.initialize(tc.domain, tc.agents, tc.minAlt, tc.timestep, tc.maxIter, tc.obstacles, tc.makeVideo); % Run the simulation tc.testClass.run(); @@ -571,7 +570,7 @@ classdef test_miSim < matlab.unittest.TestCase % Initialize agent sensor model sensor = sigmoidSensor; alphaDist = l/2; % half of domain length/width - sensor = sensor.initialize(alphaDist, 3, NaN, NaN, 15, 3); + sensor = sensor.initialize(alphaDist, 3, 15, 3); % Initialize obstacles tc.obstacles = {}; @@ -580,11 +579,11 @@ classdef test_miSim < matlab.unittest.TestCase nIter = 75; commsRadius = 4; % defined such that they cannot reach their objective without breaking connectivity tc.agents = {agent; agent;}; - tc.agents{1} = tc.agents{1}.initialize(dom.center + d, zeros(1,3), 0, 0, geometry1, sensor, commsRadius, nIter); - tc.agents{2} = tc.agents{2}.initialize(dom.center - d, zeros(1,3), 0, 0, geometry2, sensor, commsRadius, nIter); + tc.agents{1} = tc.agents{1}.initialize(dom.center + d, geometry1, sensor, commsRadius, nIter); + tc.agents{2} = tc.agents{2}.initialize(dom.center - d, geometry2, sensor, commsRadius, nIter); % Initialize the simulation - tc.testClass = tc.testClass.initialize(dom, dom.objective, tc.agents, tc.minAlt, tc.timestep, nIter, tc.obstacles, true, false); + tc.testClass = tc.testClass.initialize(dom, tc.agents, tc.minAlt, tc.timestep, nIter, tc.obstacles, true, false); % Run the simulation tc.testClass = tc.testClass.run(); @@ -611,14 +610,14 @@ classdef test_miSim < matlab.unittest.TestCase % Initialize agent sensor model sensor = sigmoidSensor; alphaDist = l/2; % half of domain length/width - sensor = sensor.initialize(alphaDist, 3, NaN, NaN, 15, 3); + sensor = sensor.initialize(alphaDist, 3, 15, 3); % Initialize agents nIter = 125; commsRadius = 5; tc.agents = {agent; agent;}; - tc.agents{1} = tc.agents{1}.initialize(tc.domain.center - [d, 0, 0], zeros(1,3), 0, 0, geometry1, sensor, commsRadius, nIter); - tc.agents{2} = tc.agents{2}.initialize(tc.domain.center - [0, d, 0], zeros(1,3), 0, 0, geometry2, sensor, commsRadius, nIter); + tc.agents{1} = tc.agents{1}.initialize(tc.domain.center - [d, 0, 0], geometry1, sensor, commsRadius, nIter); + tc.agents{2} = tc.agents{2}.initialize(tc.domain.center - [0, d, 0], geometry2, sensor, commsRadius, nIter); % Initialize obstacles obstacleLength = 1.5; @@ -626,7 +625,7 @@ classdef test_miSim < matlab.unittest.TestCase tc.obstacles{1} = tc.obstacles{1}.initialize([tc.domain.center(1:2) - obstacleLength, 0; tc.domain.center(1:2) + obstacleLength, tc.domain.maxCorner(3)], REGION_TYPE.OBSTACLE, "Obstacle 1"); % Initialize the simulation - tc.testClass = tc.testClass.initialize(tc.domain, tc.domain.objective, tc.agents, 0, tc.timestep, nIter, tc.obstacles, false, false); + tc.testClass = tc.testClass.initialize(tc.domain, tc.agents, 0, tc.timestep, nIter, tc.obstacles, false, false); % No communications link should be established tc.assertEqual(tc.testClass.adjacency, logical(true(2))); @@ -657,20 +656,20 @@ classdef test_miSim < matlab.unittest.TestCase % Initialize agent sensor model sensor = sigmoidSensor; alphaDist = l/2; % half of domain length/width - sensor = sensor.initialize(alphaDist, 3, NaN, NaN, 15, 3); + sensor = sensor.initialize(alphaDist, 3, 15, 3); % Initialize agents nIter = 125; commsRadius = d; tc.agents = {agent; agent; agent; agent; agent;}; - tc.agents{1} = tc.agents{1}.initialize(tc.domain.center + [d, 0, 0], zeros(1,3), 0, 0, geometry1, sensor, commsRadius, nIter); - tc.agents{2} = tc.agents{2}.initialize(tc.domain.center, zeros(1,3), 0, 0, geometry2, sensor, commsRadius, nIter); - tc.agents{3} = tc.agents{3}.initialize(tc.domain.center + [-d, d, 0], zeros(1,3), 0, 0, geometry3, sensor, commsRadius, nIter); - tc.agents{4} = tc.agents{4}.initialize(tc.domain.center + [-2*d, d, 0], zeros(1,3), 0, 0, geometry4, sensor, commsRadius, nIter); - tc.agents{5} = tc.agents{5}.initialize(tc.domain.center + [0, d, 0], zeros(1,3), 0, 0, geometry5, sensor, commsRadius, nIter); + tc.agents{1} = tc.agents{1}.initialize(tc.domain.center + [d, 0, 0], geometry1, sensor, commsRadius, nIter); + tc.agents{2} = tc.agents{2}.initialize(tc.domain.center, 0, 0, geometry2, sensor, commsRadius, nIter); + tc.agents{3} = tc.agents{3}.initialize(tc.domain.center + [-d, d, 0], geometry3, sensor, commsRadius, nIter); + tc.agents{4} = tc.agents{4}.initialize(tc.domain.center + [-2*d, d, 0], geometry4, sensor, commsRadius, nIter); + tc.agents{5} = tc.agents{5}.initialize(tc.domain.center + [0, d, 0], geometry5, sensor, commsRadius, nIter); % Initialize the simulation - tc.testClass = tc.testClass.initialize(tc.domain, tc.domain.objective, tc.agents, 0, tc.timestep, nIter, tc.obstacles, false, false); + tc.testClass = tc.testClass.initialize(tc.domain, tc.agents, 0, tc.timestep, nIter, tc.obstacles, false, false); % Constraint adjacency matrix defined by LNA should be as follows tc.assertEqual(tc.testClass.constraintAdjacencyMatrix, logical( ... @@ -708,22 +707,22 @@ classdef test_miSim < matlab.unittest.TestCase % Initialize agent sensor model sensor = sigmoidSensor; alphaDist = l/2; % half of domain length/width - sensor = sensor.initialize(alphaDist, 3, NaN, NaN, 15, 3); + sensor = sensor.initialize(alphaDist, 3, 15, 3); % Initialize agents nIter = 125; commsRadius = d; tc.agents = {agent; agent; agent; agent; agent; agent; agent;}; - tc.agents{1} = tc.agents{1}.initialize(tc.domain.center + [-0.9 * d/sqrt(2), 0.9 * d/sqrt(2), 0], zeros(1,3), 0, 0, geometry1, sensor, commsRadius, nIter); - tc.agents{2} = tc.agents{2}.initialize(tc.domain.center + [-0.5 * d, 0.25 * d, 0], zeros(1,3), 0, 0, geometry2, sensor, commsRadius, nIter); - tc.agents{3} = tc.agents{3}.initialize(tc.domain.center + [0.9 * d, 0, 0], zeros(1,3), 0, 0, geometry3, sensor, commsRadius, nIter); - tc.agents{4} = tc.agents{4}.initialize(tc.domain.center + [0.9 * d/sqrt(2), -0.9 * d/sqrt(2), 0], zeros(1,3), 0, 0, geometry4, sensor, commsRadius, nIter); - tc.agents{5} = tc.agents{5}.initialize(tc.domain.center + [0, 0.9 * d, 0], zeros(1,3), 0, 0, geometry5, sensor, commsRadius, nIter); - tc.agents{6} = tc.agents{6}.initialize(tc.domain.center, zeros(1,3), 0, 0, geometry6, sensor, commsRadius, nIter); - tc.agents{7} = tc.agents{7}.initialize(tc.domain.center + [d/2, d/2, 0], zeros(1,3), 0, 0, geometry7, sensor, commsRadius, nIter); + tc.agents{1} = tc.agents{1}.initialize(tc.domain.center + [-0.9 * d/sqrt(2), 0.9 * d/sqrt(2), 0], geometry1, sensor, commsRadius, nIter); + tc.agents{2} = tc.agents{2}.initialize(tc.domain.center + [-0.5 * d, 0.25 * d, 0], geometry2, sensor, commsRadius, nIter); + tc.agents{3} = tc.agents{3}.initialize(tc.domain.center + [0.9 * d, 0, 0], geometry3, sensor, commsRadius, nIter); + tc.agents{4} = tc.agents{4}.initialize(tc.domain.center + [0.9 * d/sqrt(2), -0.9 * d/sqrt(2), 0], geometry4, sensor, commsRadius, nIter); + tc.agents{5} = tc.agents{5}.initialize(tc.domain.center + [0, 0.9 * d, 0], geometry5, sensor, commsRadius, nIter); + tc.agents{6} = tc.agents{6}.initialize(tc.domain.center, geometry6, sensor, commsRadius, nIter); + tc.agents{7} = tc.agents{7}.initialize(tc.domain.center + [d/2, d/2, 0], geometry7, sensor, commsRadius, nIter); % Initialize the simulation - tc.testClass = tc.testClass.initialize(tc.domain, tc.domain.objective, tc.agents, 0, tc.timestep, nIter, tc.obstacles, false, false); + tc.testClass = tc.testClass.initialize(tc.domain, tc.agents, 0, tc.timestep, nIter, tc.obstacles, false, false); % Constraint adjacency matrix defined by LNA should be as follows tc.assertEqual(tc.testClass.constraintAdjacencyMatrix, logical( ... diff --git a/test/test_sigmoidSensor.m b/test/test_sigmoidSensor.m index 007932d..2980c35 100644 --- a/test/test_sigmoidSensor.m +++ b/test/test_sigmoidSensor.m @@ -21,7 +21,7 @@ classdef test_sigmoidSensor < matlab.unittest.TestCase function tc = setup(tc) % Reinitialize sensor with random parameters tc.testClass = sigmoidSensor; - tc.testClass = tc.testClass.initialize(tc.alphaDistMin + rand * (tc.alphaDistMax - tc.alphaDistMin), tc.betaDistMin + rand * (tc.betaDistMax - tc.betaDistMin), NaN, NaN, tc.alphaTiltMin + rand * (tc.alphaTiltMax - tc.alphaTiltMin), tc.betaTiltMin + rand * (tc.betaTiltMax - tc.betaTiltMin)); + tc.testClass = tc.testClass.initialize(tc.alphaDistMin + rand * (tc.alphaDistMax - tc.alphaDistMin), tc.betaDistMin + rand * (tc.betaDistMax - tc.betaDistMin), tc.alphaTiltMin + rand * (tc.alphaTiltMax - tc.alphaTiltMin), tc.betaTiltMin + rand * (tc.betaTiltMax - tc.betaTiltMin)); end end @@ -34,28 +34,28 @@ classdef test_sigmoidSensor < matlab.unittest.TestCase alphaTilt = 15; % degrees betaTilt = 3; h = 1e-6; - tc.testClass = tc.testClass.initialize(alphaDist, betaDist, NaN, NaN, alphaTilt, betaTilt); + tc.testClass = tc.testClass.initialize(alphaDist, betaDist, alphaTilt, betaTilt); % Plot (optional) % tc.testClass.plotParameters(); % Anticipate perfect performance for a point directly below and % extremely close - tc.verifyEqual(tc.testClass.sensorPerformance([0, 0, h], NaN, 0, [0, 0, 0]), 1, 'RelTol', 1e-3); + tc.verifyEqual(tc.testClass.sensorPerformance([0, 0, h], 0, [0, 0, 0]), 1, 'RelTol', 1e-3); % It looks like mu_t can max out at really low values like 0.37 % when alphaTilt and betaTilt are small, which seems wrong % Performance at nadir point, distance alphaDist should be 1/2 exactly - tc.verifyEqual(tc.testClass.sensorPerformance([0, 0, alphaDist], NaN, 0, [0, 0, 0]), 1/2); + tc.verifyEqual(tc.testClass.sensorPerformance([0, 0, alphaDist], 0, [0, 0, 0]), 1/2); % Performance at (almost) 0 distance, alphaTilt should be 1/2 - tc.verifyEqual(tc.testClass.sensorPerformance([0, 0, h], NaN, 0, [tand(alphaTilt)*h, 0, 0]), 1/2, 'RelTol', 1e-3); + tc.verifyEqual(tc.testClass.sensorPerformance([0, 0, h], 0, [tand(alphaTilt)*h, 0, 0]), 1/2, 'RelTol', 1e-3); % Performance at great distance should be 0 - tc.verifyEqual(tc.testClass.sensorPerformance([0, 0, 10], NaN, 0, [0, 0, 0]), 0, 'AbsTol', 1e-9); + tc.verifyEqual(tc.testClass.sensorPerformance([0, 0, 10], 0, [0, 0, 0]), 0, 'AbsTol', 1e-9); % Performance at great tilt should be 0 - tc.verifyEqual(tc.testClass.sensorPerformance([0, 0, h], NaN, 0, [5, 5, 0]), 0, 'AbsTol', 1e-9); + tc.verifyEqual(tc.testClass.sensorPerformance([0, 0, h], 0, [5, 5, 0]), 0, 'AbsTol', 1e-9); end end diff --git a/util/objectiveFunctionWrapper.m b/util/objectiveFunctionWrapper.m new file mode 100644 index 0000000..631ef20 --- /dev/null +++ b/util/objectiveFunctionWrapper.m @@ -0,0 +1,13 @@ +function f = objectiveFunctionWrapper(center) + % Convenience function to generate MVNPDFs at a point + % Makes it look a lot neater to instantiate and sum these to make + % composite objectives in particular + arguments (Input) + center (1, 2) double; + end + arguments (Output) + f (1, 1) {mustBeA(f, 'function_handle')}; + end + + f = @(x, y) mvnpdf([x(:), y(:)], center); +end \ No newline at end of file