finalized plotting utility
This commit is contained in:
@@ -19,6 +19,7 @@ classdef miSim
|
|||||||
barrierExponent = NaN; % CBF exponent parameter
|
barrierExponent = NaN; % CBF exponent parameter
|
||||||
minAlt = 0; % minimum allowable altitude (m)
|
minAlt = 0; % minimum allowable altitude (m)
|
||||||
artifactName = "";
|
artifactName = "";
|
||||||
|
f; % main plotting tiled layout figure
|
||||||
fPerf; % performance plot figure
|
fPerf; % performance plot figure
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -31,7 +32,6 @@ classdef miSim
|
|||||||
% Plot objects
|
% Plot objects
|
||||||
makePlots = true; % enable/disable simulation plotting (performance implications)
|
makePlots = true; % enable/disable simulation plotting (performance implications)
|
||||||
makeVideo = true; % enable/disable VideoWriter (performance implications)
|
makeVideo = true; % enable/disable VideoWriter (performance implications)
|
||||||
f; % main plotting tiled layout figure
|
|
||||||
connectionsPlot; % objects for lines connecting agents in spatial plots
|
connectionsPlot; % objects for lines connecting agents in spatial plots
|
||||||
graphPlot; % objects for abstract network graph plot
|
graphPlot; % objects for abstract network graph plot
|
||||||
partitionPlot; % objects for partition plot
|
partitionPlot; % objects for partition plot
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
function f = plotGpsLogs(logDirs)
|
function [f, G] = plotGpsLogs(logDirs, seaToGroundLevel)
|
||||||
arguments (Input)
|
arguments (Input)
|
||||||
logDirs (1, 1) string;
|
logDirs (1, 1) string;
|
||||||
|
seaToGroundLevel (1, 1) double = 110; % measured approximately from USGS national map viewer for the AERPAW test field
|
||||||
end
|
end
|
||||||
arguments (Output)
|
arguments (Output)
|
||||||
f (1, 1) matlab.ui.Figure;
|
f (1, 1) matlab.ui.Figure;
|
||||||
|
G cell;
|
||||||
end
|
end
|
||||||
% Plot setup
|
% Plot setup
|
||||||
f = uifigure;
|
f = uifigure;
|
||||||
@@ -17,9 +19,6 @@ function f = plotGpsLogs(logDirs)
|
|||||||
% configured data
|
% configured data
|
||||||
params = readScenarioCsv(scenarioCsv);
|
params = readScenarioCsv(scenarioCsv);
|
||||||
|
|
||||||
% coordinate system constants
|
|
||||||
seaToGroundLevel = 110; % meters, measured approximately from USGS national map viewer
|
|
||||||
|
|
||||||
fID = fopen(fullfile(matlab.project.rootProject().RootFolder, "aerpaw", "config", "client1.yaml"), 'r');
|
fID = fopen(fullfile(matlab.project.rootProject().RootFolder, "aerpaw", "config", "client1.yaml"), 'r');
|
||||||
yaml = fscanf(fID, '%s');
|
yaml = fscanf(fID, '%s');
|
||||||
fclose(fID);
|
fclose(fID);
|
||||||
@@ -45,12 +44,19 @@ function f = plotGpsLogs(logDirs)
|
|||||||
|
|
||||||
% Automatically detect start/stop of algorithm flight (ignore takeoff, setup, return to liftoff, landing segments of flight)
|
% Automatically detect start/stop of algorithm flight (ignore takeoff, setup, return to liftoff, landing segments of flight)
|
||||||
pctThreshold = 60; % pctThreshold may need adjusting depending on your flight
|
pctThreshold = 60; % pctThreshold may need adjusting depending on your flight
|
||||||
startIdx = find(verticalSpeed <= prctile(verticalSpeed, pctThreshold), 1, 'first');
|
startIdx = find(verticalSpeed <= prctile(verticalSpeed, pctThreshold), 1, "first");
|
||||||
stopIdx = find(verticalSpeed <= prctile(verticalSpeed, pctThreshold), 1, 'last');
|
stopIdx = find(verticalSpeed <= prctile(verticalSpeed, pctThreshold), 1, "last");
|
||||||
|
|
||||||
% % Plot whole flight, including setup/cleanup
|
% % Plot whole flight, including setup/cleanup
|
||||||
% startIdx = 1;
|
% startIdx = 1;
|
||||||
% stopIdx = length(verticalSpeed);
|
% stopIdx = length(verticalSpeed);
|
||||||
|
|
||||||
|
% Convert LLA trajectory data to ENU for external analysis
|
||||||
|
% NaN out entries outside the algorithm flight range so they don't plot
|
||||||
|
enu = NaN(height(G{ii}), 3);
|
||||||
|
enu(startIdx:stopIdx, :) = lla2enu([G{ii}.Latitude(startIdx:stopIdx), G{ii}.Longitude(startIdx:stopIdx), G{ii}.Altitude(startIdx:stopIdx)], lla0, "flat");
|
||||||
|
enu = array2table(enu, 'VariableNames', ["East", "North", "Up"]);
|
||||||
|
G{ii} = [G{ii}, enu];
|
||||||
|
|
||||||
% Plot recorded trajectory over specified range of indices
|
% Plot recorded trajectory over specified range of indices
|
||||||
geoplot3(gf, G{ii}.Latitude(startIdx:stopIdx), G{ii}.Longitude(startIdx:stopIdx), G{ii}.Altitude(startIdx:stopIdx) + seaToGroundLevel, c(mod(ii, length(c))), 'LineWidth', 2, "MarkerSize", 5);
|
geoplot3(gf, G{ii}.Latitude(startIdx:stopIdx), G{ii}.Longitude(startIdx:stopIdx), G{ii}.Altitude(startIdx:stopIdx) + seaToGroundLevel, c(mod(ii, length(c))), 'LineWidth', 2, "MarkerSize", 5);
|
||||||
@@ -58,7 +64,7 @@ function f = plotGpsLogs(logDirs)
|
|||||||
|
|
||||||
% Plot domain
|
% Plot domain
|
||||||
altOffset = 1; % to avoid clipping into the ground when displayed
|
altOffset = 1; % to avoid clipping into the ground when displayed
|
||||||
domain = [lla0; enu2lla(params.domainMax, lla0, 'flat')];
|
domain = [lla0; enu2lla(params.domainMax, lla0, "flat")];
|
||||||
geoplot3(gf, [domain(1, 1), domain(2, 1), domain(2, 1), domain(1, 1), domain(1, 1)], [domain(1, 2), domain(1, 2), domain(2, 2), domain(2, 2), domain(1, 2)], repmat(domain(1, 3) + altOffset, 1, 5), 'LineWidth', 3, 'Color', 'k');
|
geoplot3(gf, [domain(1, 1), domain(2, 1), domain(2, 1), domain(1, 1), domain(1, 1)], [domain(1, 2), domain(1, 2), domain(2, 2), domain(2, 2), domain(1, 2)], repmat(domain(1, 3) + altOffset, 1, 5), 'LineWidth', 3, 'Color', 'k');
|
||||||
geoplot3(gf, [domain(1, 1), domain(2, 1), domain(2, 1), domain(1, 1), domain(1, 1)], [domain(1, 2), domain(1, 2), domain(2, 2), domain(2, 2), domain(1, 2)], repmat(domain(2, 3) + altOffset, 1, 5), 'LineWidth', 3, 'Color', 'k');
|
geoplot3(gf, [domain(1, 1), domain(2, 1), domain(2, 1), domain(1, 1), domain(1, 1)], [domain(1, 2), domain(1, 2), domain(2, 2), domain(2, 2), domain(1, 2)], repmat(domain(2, 3) + altOffset, 1, 5), 'LineWidth', 3, 'Color', 'k');
|
||||||
geoplot3(gf, [domain(1, 1), domain(1, 1)], [domain(1, 2), domain(1, 2)], domain(:, 3) + altOffset, 'LineWidth', 3, 'Color', 'k');
|
geoplot3(gf, [domain(1, 1), domain(1, 1)], [domain(1, 2), domain(1, 2)], domain(:, 3) + altOffset, 'LineWidth', 3, 'Color', 'k');
|
||||||
@@ -72,12 +78,12 @@ function f = plotGpsLogs(logDirs)
|
|||||||
|
|
||||||
% Plot objective
|
% Plot objective
|
||||||
objectivePos = [params.objectivePos, 0];
|
objectivePos = [params.objectivePos, 0];
|
||||||
llaObj = enu2lla(objectivePos, lla0, 'flat');
|
llaObj = enu2lla(objectivePos, lla0, "flat");
|
||||||
geoplot3(gf, [llaObj(1), llaObj(1)], [llaObj(2), llaObj(2)], [llaObj(3), domain(2, 3)], 'LineWidth', 3, "Color", 'y');
|
geoplot3(gf, [llaObj(1), llaObj(1)], [llaObj(2), llaObj(2)], [llaObj(3), domain(2, 3)], 'LineWidth', 3, "Color", 'y');
|
||||||
|
|
||||||
% Plot obstacles
|
% Plot obstacles
|
||||||
for ii = 1:params.numObstacles
|
for ii = 1:params.numObstacles
|
||||||
obstacle = enu2lla([params.obstacleMin((1 + (ii - 1) * 3):(ii * 3)); params.obstacleMax((1 + (ii - 1) * 3):(ii * 3))], lla0, 'flat');
|
obstacle = enu2lla([params.obstacleMin((1 + (ii - 1) * 3):(ii * 3)); params.obstacleMax((1 + (ii - 1) * 3):(ii * 3))], lla0, "flat");
|
||||||
geoplot3(gf, [obstacle(1, 1), obstacle(2, 1), obstacle(2, 1), obstacle(1, 1), obstacle(1, 1)], [obstacle(1, 2), obstacle(1, 2), obstacle(2, 2), obstacle(2, 2), obstacle(1, 2)], repmat(obstacle(1, 3) + altOffset, 1, 5), 'LineWidth', 3, 'Color', 'r');
|
geoplot3(gf, [obstacle(1, 1), obstacle(2, 1), obstacle(2, 1), obstacle(1, 1), obstacle(1, 1)], [obstacle(1, 2), obstacle(1, 2), obstacle(2, 2), obstacle(2, 2), obstacle(1, 2)], repmat(obstacle(1, 3) + altOffset, 1, 5), 'LineWidth', 3, 'Color', 'r');
|
||||||
geoplot3(gf, [obstacle(1, 1), obstacle(2, 1), obstacle(2, 1), obstacle(1, 1), obstacle(1, 1)], [obstacle(1, 2), obstacle(1, 2), obstacle(2, 2), obstacle(2, 2), obstacle(1, 2)], repmat(obstacle(2, 3) + altOffset, 1, 5), 'LineWidth', 3, 'Color', 'r');
|
geoplot3(gf, [obstacle(1, 1), obstacle(2, 1), obstacle(2, 1), obstacle(1, 1), obstacle(1, 1)], [obstacle(1, 2), obstacle(1, 2), obstacle(2, 2), obstacle(2, 2), obstacle(1, 2)], repmat(obstacle(2, 3) + altOffset, 1, 5), 'LineWidth', 3, 'Color', 'r');
|
||||||
geoplot3(gf, [obstacle(1, 1), obstacle(1, 1)], [obstacle(1, 2), obstacle(1, 2)], obstacle(:, 3) + altOffset, 'LineWidth', 3, 'Color', 'r');
|
geoplot3(gf, [obstacle(1, 1), obstacle(1, 1)], [obstacle(1, 2), obstacle(1, 2)], obstacle(:, 3) + altOffset, 'LineWidth', 3, 'Color', 'r');
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
function f = plotRadioLogs(resultsPath)
|
function [f, R] = plotRadioLogs(resultsPath)
|
||||||
arguments (Input)
|
arguments (Input)
|
||||||
resultsPath (1, 1) string;
|
resultsPath (1, 1) string;
|
||||||
end
|
end
|
||||||
|
|
||||||
arguments (Output)
|
arguments (Output)
|
||||||
f (1, 1) matlab.ui.Figure;
|
f (1, 1) matlab.ui.Figure;
|
||||||
|
R cell;
|
||||||
end
|
end
|
||||||
|
|
||||||
logDirs = dir(resultsPath);
|
logDirs = dir(resultsPath);
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
%% Plot AERPAW logs (trajectory, radio)
|
|
||||||
resultsPath = fullfile(matlab.project.rootProject().RootFolder, "sandbox", "t1"); % Define path to results copied from AERPAW platform
|
|
||||||
|
|
||||||
% Plot GPS logged data and scenario information (domain, objective, obstacles)
|
|
||||||
fGlobe = plotGpsLogs(resultsPath);
|
|
||||||
|
|
||||||
% Plot radio statistics
|
|
||||||
fRadio = plotRadioLogs(resultsPath);
|
|
||||||
|
|
||||||
%% Run simulation
|
|
||||||
% Run miSim using same AERPAW scenario definition CSV
|
|
||||||
|
|
||||||
|
|
||||||
%% Plot AERPAW trajectory logs onto simulated result for comparison
|
|
||||||
66
aerpaw/results/resultsAnalysis.m
Normal file
66
aerpaw/results/resultsAnalysis.m
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
%% Plot AERPAW logs (trajectory, radio)
|
||||||
|
resultsPath = fullfile(matlab.project.rootProject().RootFolder, "sandbox", "t1"); % Define path to results copied from AERPAW platform
|
||||||
|
|
||||||
|
% Plot GPS logged data and scenario information (domain, objective, obstacles)
|
||||||
|
seaToGroundLevel = 110; % measured approximately from USGS national map viewer
|
||||||
|
[fGlobe, G] = plotGpsLogs(resultsPath, seaToGroundLevel);
|
||||||
|
|
||||||
|
% Plot radio statistics
|
||||||
|
[fRadio, R] = plotRadioLogs(resultsPath);
|
||||||
|
|
||||||
|
%% Run simulation
|
||||||
|
% Run miSim using same AERPAW scenario definition CSV
|
||||||
|
csvPath = fullfile(matlab.project.rootProject().RootFolder, "aerpaw", "config", "scenario.csv");
|
||||||
|
params = readScenarioCsv(csvPath);
|
||||||
|
|
||||||
|
% Visualization settings
|
||||||
|
plotCommsGeometry = false;
|
||||||
|
makePlots = true;
|
||||||
|
makeVideo = true;
|
||||||
|
|
||||||
|
% Define scenario according to CSV specification
|
||||||
|
domain = rectangularPrism;
|
||||||
|
domain = domain.initialize([params.domainMin; params.domainMax], REGION_TYPE.DOMAIN, "Domain");
|
||||||
|
domain.objective = domain.objective.initialize(objectiveFunctionWrapper(params.objectivePos, reshape(params.objectiveVar, [2 2])), domain, params.discretizationStep, params.protectedRange, params.sensorPerformanceMinimum);
|
||||||
|
|
||||||
|
agents = cell(size(params.initialPositions, 2) / 3, 1);
|
||||||
|
for ii = 1:size(agents, 1)
|
||||||
|
agents{ii} = agent;
|
||||||
|
|
||||||
|
sensorModel = sigmoidSensor;
|
||||||
|
sensorModel = sensorModel.initialize(params.alphaDist(ii), params.betaDist(ii), params.alphaTilt(ii), params.betaTilt(ii));
|
||||||
|
|
||||||
|
collisionGeometry = spherical;
|
||||||
|
collisionGeometry = collisionGeometry.initialize(params.initialPositions((((ii - 1) * 3) + 1):(ii * 3)), params.collisionRadius(ii), REGION_TYPE.COLLISION, sprintf("Agent %d collision geometry", ii));
|
||||||
|
|
||||||
|
agents{ii} = agents{ii}.initialize(params.initialPositions((((ii - 1) * 3) + 1):(ii * 3)), collisionGeometry, sensorModel, params.comRange(ii), params.maxIter, params.initialStepSize, sprintf("Agent %d", ii), plotCommsGeometry);
|
||||||
|
end
|
||||||
|
|
||||||
|
% Create obstacles
|
||||||
|
obstacles = cell(params.numObstacles, 1);
|
||||||
|
for ii = 1:size(obstacles, 1)
|
||||||
|
obstacles{ii} = rectangularPrism;
|
||||||
|
obstacles{ii} = obstacles{ii}.initialize([params.obstacleMin((((ii - 1) * 3) + 1):(ii * 3)); params.obstacleMax((((ii - 1) * 3) + 1):(ii * 3))], "OBSTACLE", sprintf("Obstacle %d", ii));
|
||||||
|
end
|
||||||
|
|
||||||
|
% Set up simulation
|
||||||
|
sim = miSim;
|
||||||
|
sim = sim.initialize(domain, agents, params.barrierGain, params.barrierExponent, params.minAlt, params.timestep, params.maxIter, obstacles, makePlots, makeVideo);
|
||||||
|
|
||||||
|
% Save simulation parameters to output file
|
||||||
|
sim.writeInits();
|
||||||
|
|
||||||
|
% Run
|
||||||
|
sim = sim.run();
|
||||||
|
|
||||||
|
%% Plot AERPAW trajectory logs onto simulated result for comparison
|
||||||
|
% Duplicate plot to overlay with logged trajectories
|
||||||
|
comparison = figure;
|
||||||
|
copyobj(sim.f.Children, comparison);
|
||||||
|
|
||||||
|
% Plot trajectories on top
|
||||||
|
hold(comparison.Children.Children(end), "on");
|
||||||
|
for ii = 1:size(G, 1)
|
||||||
|
plot3(comparison.Children(1).Children(end), G{ii}.East, G{ii}.North, G{ii}.Up + seaToGroundLevel, 'Color', 'r', 'LineWidth', 1);
|
||||||
|
end
|
||||||
|
hold(comparison.Children.Children(end), "off");
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<Info location="plotResults.m" type="File"/>
|
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Info location="resultsAnalysis.m" type="File"/>
|
||||||
Reference in New Issue
Block a user