added static network option
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
function [obj] = initialize(obj, domain, agents, barrierGain, barrierExponent, minAlt, timestep, maxIter, obstacles, makePlots, makeVideo, useDoubleIntegrator, dampingCoeff)
|
||||
function [obj] = initialize(obj, domain, agents, barrierGain, barrierExponent, minAlt, timestep, maxIter, obstacles, makePlots, makeVideo, useDoubleIntegrator, dampingCoeff, useFixedTopology)
|
||||
arguments (Input)
|
||||
obj (1, 1) {mustBeA(obj, "miSim")};
|
||||
domain (1, 1) {mustBeGeometry};
|
||||
@@ -13,6 +13,7 @@ function [obj] = initialize(obj, domain, agents, barrierGain, barrierExponent, m
|
||||
makeVideo (1, 1) logical = true;
|
||||
useDoubleIntegrator (1, 1) logical = false;
|
||||
dampingCoeff (1, 1) double = 2.0;
|
||||
useFixedTopology (1, 1) logical = false;
|
||||
end
|
||||
arguments (Output)
|
||||
obj (1, 1) {mustBeA(obj, "miSim")};
|
||||
@@ -91,10 +92,15 @@ function [obj] = initialize(obj, domain, agents, barrierGain, barrierExponent, m
|
||||
% Set dynamics model
|
||||
obj.useDoubleIntegrator = useDoubleIntegrator;
|
||||
obj.dampingCoeff = dampingCoeff;
|
||||
obj.useFixedTopology = useFixedTopology;
|
||||
|
||||
% Compute adjacency matrix and lesser neighbors
|
||||
% Compute adjacency matrix and network topology
|
||||
obj = obj.updateAdjacency();
|
||||
obj = obj.lesserNeighbor();
|
||||
if obj.useFixedTopology
|
||||
obj.constraintAdjacencyMatrix = obj.adjacency;
|
||||
else
|
||||
obj = obj.lesserNeighbor();
|
||||
end
|
||||
|
||||
% Set up times to iterate over
|
||||
obj.times = linspace(0, obj.timestep * obj.maxIter, obj.maxIter+1)';
|
||||
|
||||
@@ -90,6 +90,11 @@ if isfield(scenario, 'dampingCoeff')
|
||||
else
|
||||
DAMPING_COEFF = 2.0;
|
||||
end
|
||||
if isfield(scenario, 'useFixedTopology')
|
||||
USE_FIXED_TOPOLOGY = logical(scenario.useFixedTopology);
|
||||
else
|
||||
USE_FIXED_TOPOLOGY = false;
|
||||
end
|
||||
|
||||
% ---- Build domain --------------------------------------------------------
|
||||
dom = rectangularPrism;
|
||||
@@ -137,6 +142,6 @@ end
|
||||
% ---- Initialise simulation (plots and video disabled) --------------------
|
||||
obj = obj.initialize(dom, agentList, BARRIER_GAIN, BARRIER_EXPONENT, ...
|
||||
MIN_ALT, TIMESTEP, MAX_ITER, obstacleList, false, false, ...
|
||||
USE_DOUBLE_INTEGRATOR, DAMPING_COEFF);
|
||||
USE_DOUBLE_INTEGRATOR, DAMPING_COEFF, USE_FIXED_TOPOLOGY);
|
||||
|
||||
end
|
||||
|
||||
@@ -20,6 +20,7 @@ classdef miSim
|
||||
minAlt = 0; % minimum allowable altitude (m)
|
||||
useDoubleIntegrator = false; % false = single-integrator, true = double-integrator dynamics
|
||||
dampingCoeff = 2.0; % velocity-proportional damping for double-integrator mode
|
||||
useFixedTopology = false; % false = lesser neighbor (dynamic), true = fixed initial topology
|
||||
artifactName = "";
|
||||
f; % main plotting tiled layout figure
|
||||
fPerf; % performance plot figure
|
||||
|
||||
@@ -30,7 +30,9 @@ function [obj] = run(obj)
|
||||
obj.partitioning = obj.agents{1}.partition(obj.agents, obj.domain.objective);
|
||||
|
||||
% Determine desired communications links
|
||||
obj = obj.lesserNeighbor();
|
||||
if ~obj.useFixedTopology
|
||||
obj = obj.lesserNeighbor();
|
||||
end
|
||||
|
||||
% Moving
|
||||
% Iterate over agents to simulate their unconstrained motion
|
||||
|
||||
@@ -13,12 +13,13 @@ function obj = teardown(obj)
|
||||
|
||||
% Log results into matfile
|
||||
histPath = fullfile(matlab.project.rootProject().RootFolder, "sandbox", strcat(obj.artifactName, "_miSimHist.mat"));
|
||||
out = struct("agent", repmat(struct("pos", [], "vel", [], "perf", [], "sensor", struct("alphaDist", [], "betaDist", [], "alphaTilt", [], "betaTilt", []), "collisionRadius", [], "commsRadius", []), size(obj.agents)), "perf", [], "barriers", [], "useDoubleIntegrator", [], "dampingCoeff", []);
|
||||
out = struct("agent", repmat(struct("pos", [], "vel", [], "perf", [], "sensor", struct("alphaDist", [], "betaDist", [], "alphaTilt", [], "betaTilt", []), "collisionRadius", [], "commsRadius", []), size(obj.agents)), "perf", [], "barriers", [], "useDoubleIntegrator", [], "dampingCoeff", [], "useFixedTopology", []);
|
||||
|
||||
out.perf = obj.performance(1:(end - 1));
|
||||
out.barriers = [zeros(size(obj.barriers(1:end, 1), 1), 1), obj.barriers(1:end, 1:(end - 1))];
|
||||
out.dampingCoeff = obj.dampingCoeff;
|
||||
out.useDoubleIntegrator = obj.useDoubleIntegrator;
|
||||
out.useFixedTopology = obj.useFixedTopology;
|
||||
for ii = 1:size(obj.agents, 1)
|
||||
out.agent(ii).pos = squeeze(obj.posHist(ii, 1:(end - 1), 1:3));
|
||||
out.agent(ii).vel = squeeze(obj.velHist(ii, 1:(end - 1), 1:3));
|
||||
@@ -49,6 +50,7 @@ function obj = teardown(obj)
|
||||
obj.barrierExponent = NaN;
|
||||
obj.useDoubleIntegrator = false;
|
||||
obj.dampingCoeff = 2.0;
|
||||
obj.useFixedTopology = false;
|
||||
obj.artifactName = "";
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user