|
|
|
|
@@ -162,7 +162,7 @@ classdef test_miSim < matlab.unittest.TestCase
|
|
|
|
|
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));
|
|
|
|
|
|
|
|
|
|
% Initialize candidate agent
|
|
|
|
|
newAgent = tc.agents{ii}.initialize(candidatePos, zeros(1,3), 0, 0, candidateGeometry, sensor, @gradientAscent, tc.comRange, ii, sprintf("Agent %d", ii));
|
|
|
|
|
newAgent = tc.agents{ii}.initialize(candidatePos, zeros(1,3), 0, 0, candidateGeometry, sensor, @gradientAscent, tc.comRange, sprintf("Agent %d", ii));
|
|
|
|
|
|
|
|
|
|
% Make sure candidate agent doesn't collide with
|
|
|
|
|
% domain
|
|
|
|
|
@@ -296,7 +296,7 @@ classdef test_miSim < matlab.unittest.TestCase
|
|
|
|
|
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));
|
|
|
|
|
|
|
|
|
|
% Initialize candidate agent
|
|
|
|
|
newAgent = tc.agents{ii}.initialize(candidatePos, zeros(1,3), 0, 0, candidateGeometry, sensor, @gradientAscent, tc.comRange, ii, sprintf("Agent %d", ii), false, false);
|
|
|
|
|
newAgent = tc.agents{ii}.initialize(candidatePos, zeros(1,3), 0, 0, candidateGeometry, sensor, @gradientAscent, tc.comRange, sprintf("Agent %d", ii), false, false);
|
|
|
|
|
|
|
|
|
|
% Make sure candidate agent doesn't collide with
|
|
|
|
|
% domain
|
|
|
|
|
@@ -378,14 +378,14 @@ classdef test_miSim < matlab.unittest.TestCase
|
|
|
|
|
|
|
|
|
|
% 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, @gradientAscent, 3*d, 1, sprintf("Agent %d", 1));
|
|
|
|
|
tc.agents{2} = tc.agents{2}.initialize(tc.domain.center + dh - [d, 0, 0], zeros(1,3), 0, 0, geometry2, sensor, @gradientAscent, 3*d, 2, sprintf("Agent %d", 2));
|
|
|
|
|
tc.agents{1} = tc.agents{1}.initialize(tc.domain.center + dh + [d, 0, 0], zeros(1,3), 0, 0, geometry1, sensor, @gradientAscent, 3*d, sprintf("Agent %d", 1));
|
|
|
|
|
tc.agents{2} = tc.agents{2}.initialize(tc.domain.center + dh - [d, 0, 0], zeros(1,3), 0, 0, geometry2, sensor, @gradientAscent, 3*d, sprintf("Agent %d", 2));
|
|
|
|
|
|
|
|
|
|
% 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, sprintf("Agent %d collision volume", 3));
|
|
|
|
|
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, @gradientAscent, 3*d, 3, sprintf("Agent %d", 3));
|
|
|
|
|
tc.agents{3} = tc.agents{3}.initialize(tc.domain.center + dh - [0, d, 0], zeros(1, 3), 0, 0, geometry3, sensor, @gradientAscent, 3*d, sprintf("Agent %d", 3));
|
|
|
|
|
|
|
|
|
|
% Initialize the simulation
|
|
|
|
|
tc.testClass = tc.testClass.initialize(tc.domain, tc.domain.objective, tc.agents, tc.minAlt, tc.timestep, tc.partitoningFreq, tc.maxIter, cell(0, 1), tc.makeVideo);
|
|
|
|
|
@@ -415,7 +415,7 @@ classdef test_miSim < matlab.unittest.TestCase
|
|
|
|
|
|
|
|
|
|
% 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, @gradientAscent, 3, 1, sprintf("Agent %d", 1));
|
|
|
|
|
tc.agents{1} = tc.agents{1}.initialize([tc.domain.center(1:2), 3], zeros(1,3), 0, 0, geometry1, sensor, @gradientAscent, 3, sprintf("Agent %d", 1));
|
|
|
|
|
|
|
|
|
|
% Initialize the simulation
|
|
|
|
|
tc.testClass = tc.testClass.initialize(tc.domain, tc.domain.objective, tc.agents, tc.minAlt, tc.timestep, tc.partitoningFreq, tc.maxIter, cell(0, 1), tc.makeVideo);
|
|
|
|
|
@@ -445,7 +445,7 @@ classdef test_miSim < matlab.unittest.TestCase
|
|
|
|
|
|
|
|
|
|
% Initialize agents
|
|
|
|
|
tc.agents = {agent};
|
|
|
|
|
tc.agents{1} = tc.agents{1}.initialize([tc.domain.center(1:2)-tc.domain.dimensions(1)/3, 3], zeros(1,3), 0, 0, geometry1, sensor, @gradientAscent, 3, 1, sprintf("Agent %d", 1), true);
|
|
|
|
|
tc.agents{1} = tc.agents{1}.initialize([tc.domain.center(1:2)-tc.domain.dimensions(1)/3, 3], zeros(1,3), 0, 0, geometry1, sensor, @gradientAscent, 3, sprintf("Agent %d", 1), true);
|
|
|
|
|
|
|
|
|
|
% Initialize the simulation
|
|
|
|
|
tc.testClass = tc.testClass.initialize(tc.domain, tc.domain.objective, tc.agents, tc.minAlt, tc.timestep, tc.partitoningFreq, tc.maxIter, cell(0, 1), tc.makeVideo);
|
|
|
|
|
@@ -481,8 +481,8 @@ classdef test_miSim < matlab.unittest.TestCase
|
|
|
|
|
|
|
|
|
|
% Initialize agents
|
|
|
|
|
tc.agents = {agent; agent};
|
|
|
|
|
tc.agents{1} = tc.agents{1}.initialize(tc.domain.center + d, zeros(1,3), 0, 0, geometry1, sensor, @gradientAscent, 3, 1, sprintf("Agent %d", 1), false);
|
|
|
|
|
tc.agents{2} = tc.agents{2}.initialize(tc.domain.center - d, zeros(1,3), 0, 0, geometry2, sensor, @gradientAscent, 3, 2, sprintf("Agent %d", 2), false);
|
|
|
|
|
tc.agents{1} = tc.agents{1}.initialize(tc.domain.center + d, zeros(1,3), 0, 0, geometry1, sensor, @gradientAscent, 3, sprintf("Agent %d", 1), false);
|
|
|
|
|
tc.agents{2} = tc.agents{2}.initialize(tc.domain.center - d, zeros(1,3), 0, 0, geometry2, sensor, @gradientAscent, 3, sprintf("Agent %d", 2), false);
|
|
|
|
|
|
|
|
|
|
% Initialize the simulation
|
|
|
|
|
tc.testClass = tc.testClass.initialize(tc.domain, tc.domain.objective, tc.agents, tc.minAlt, tc.timestep, tc.partitoningFreq, tc.maxIter, cell(0, 1), tc.makeVideo, tc.makePlots);
|
|
|
|
|
@@ -516,8 +516,8 @@ classdef test_miSim < matlab.unittest.TestCase
|
|
|
|
|
|
|
|
|
|
% Initialize agents
|
|
|
|
|
tc.agents = {agent; agent;};
|
|
|
|
|
tc.agents{1} = tc.agents{1}.initialize(tc.domain.center - d + [0, radius * 1.5, 0], zeros(1,3), 0, 0, geometry1, sensor, @gradientAscent, 10, 1, sprintf("Agent %d", 1), false, false);
|
|
|
|
|
tc.agents{2} = tc.agents{2}.initialize(tc.domain.center - d - [0, radius * 1.5, 0], zeros(1,3), 0, 0, geometry2, sensor, @gradientAscent, 10, 2, sprintf("Agent %d", 2), false, false);
|
|
|
|
|
tc.agents{1} = tc.agents{1}.initialize(tc.domain.center - d + [0, radius * 1.5, 0], zeros(1,3), 0, 0, geometry1, sensor, @gradientAscent, 10, sprintf("Agent %d", 1), false, false);
|
|
|
|
|
tc.agents{2} = tc.agents{2}.initialize(tc.domain.center - d - [0, radius * 1.5, 0], zeros(1,3), 0, 0, geometry2, sensor, @gradientAscent, 10, sprintf("Agent %d", 2), false, false);
|
|
|
|
|
|
|
|
|
|
% Initialize obstacles
|
|
|
|
|
obstacleLength = 1;
|
|
|
|
|
@@ -557,8 +557,8 @@ classdef test_miSim < matlab.unittest.TestCase
|
|
|
|
|
% Initialize agents
|
|
|
|
|
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, @gradientAscent, commsRadius, 1, sprintf("Agent %d", 1), false);
|
|
|
|
|
tc.agents{2} = tc.agents{2}.initialize(tc.domain.center - [0, d, 0], zeros(1,3), 0, 0, geometry2, sensor, @gradientAscent, commsRadius, 2, sprintf("Agent %d", 2), false);
|
|
|
|
|
tc.agents{1} = tc.agents{1}.initialize(tc.domain.center - [d, 0, 0], zeros(1,3), 0, 0, geometry1, sensor, @gradientAscent, commsRadius, sprintf("Agent %d", 1), false);
|
|
|
|
|
tc.agents{2} = tc.agents{2}.initialize(tc.domain.center - [0, d, 0], zeros(1,3), 0, 0, geometry2, sensor, @gradientAscent, commsRadius, sprintf("Agent %d", 2), false);
|
|
|
|
|
|
|
|
|
|
% Initialize obstacles
|
|
|
|
|
obstacleLength = 1.5;
|
|
|
|
|
@@ -571,7 +571,6 @@ classdef test_miSim < matlab.unittest.TestCase
|
|
|
|
|
% No communications link should be established
|
|
|
|
|
tc.assertEqual(tc.testClass.adjacency, logical(eye(2)));
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function test_LNA_example_case(tc)
|
|
|
|
|
% No obstacles
|
|
|
|
|
% Fixed 5 agents initial conditions
|
|
|
|
|
@@ -606,16 +605,17 @@ classdef test_miSim < matlab.unittest.TestCase
|
|
|
|
|
% Initialize agents
|
|
|
|
|
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, @gradientAscent, commsRadius, 1, sprintf("Agent %d", 1), false);
|
|
|
|
|
tc.agents{2} = tc.agents{2}.initialize(tc.domain.center, zeros(1,3), 0, 0, geometry2, sensor, @gradientAscent, commsRadius, 2, sprintf("Agent %d", 2), false);
|
|
|
|
|
tc.agents{3} = tc.agents{3}.initialize(tc.domain.center + [-d, d, 0], zeros(1,3), 0, 0, geometry3, sensor, @gradientAscent, commsRadius, 3, sprintf("Agent %d", 3), false);
|
|
|
|
|
tc.agents{4} = tc.agents{4}.initialize(tc.domain.center + [-2*d, d, 0], zeros(1,3), 0, 0, geometry4, sensor, @gradientAscent, commsRadius, 4, sprintf("Agent %d", 4), false);
|
|
|
|
|
tc.agents{5} = tc.agents{5}.initialize(tc.domain.center + [0, d, 0], zeros(1,3), 0, 0, geometry5, sensor, @gradientAscent, commsRadius, 5, sprintf("Agent %d", 5), false);
|
|
|
|
|
tc.agents{1} = tc.agents{1}.initialize(tc.domain.center + [d, 0, 0], zeros(1,3), 0, 0, geometry1, sensor, @gradientAscent, commsRadius, sprintf("Agent %d", 1), false);
|
|
|
|
|
tc.agents{2} = tc.agents{2}.initialize(tc.domain.center, zeros(1,3), 0, 0, geometry2, sensor, @gradientAscent, commsRadius, sprintf("Agent %d", 2), false);
|
|
|
|
|
tc.agents{3} = tc.agents{3}.initialize(tc.domain.center + [-d, d, 0], zeros(1,3), 0, 0, geometry3, sensor, @gradientAscent, commsRadius, sprintf("Agent %d", 3), false);
|
|
|
|
|
tc.agents{4} = tc.agents{4}.initialize(tc.domain.center + [-2*d, d, 0], zeros(1,3), 0, 0, geometry4, sensor, @gradientAscent, commsRadius, sprintf("Agent %d", 4), false);
|
|
|
|
|
tc.agents{5} = tc.agents{5}.initialize(tc.domain.center + [0, d, 0], zeros(1,3), 0, 0, geometry5, sensor, @gradientAscent, commsRadius, sprintf("Agent %d", 5), false);
|
|
|
|
|
|
|
|
|
|
% TODO
|
|
|
|
|
% make agent label and ID optional, they can be derived from index
|
|
|
|
|
% Consider how to do the same for collision geometry label
|
|
|
|
|
% make @gradientAscent always the choice
|
|
|
|
|
% Build collision geometry initialization into agent initialization?
|
|
|
|
|
|
|
|
|
|
% Initialize the simulation
|
|
|
|
|
tc.testClass = tc.testClass.initialize(tc.domain, tc.domain.objective, tc.agents, 0, tc.timestep, tc.partitoningFreq, 125, tc.obstacles, false, false);
|
|
|
|
|
|