Skip to content

Commit

Permalink
Merge branch 'preparation_for_final_submission' into 'master'
Browse files Browse the repository at this point in the history
code for the final submission

See merge request ICS/ics-private/phd-students/papers/2023-code-acc-distributed-model-predictive-flocking-with-obstacle-avoidance-and-asymmetric-interaction-forces!1
  • Loading branch information
PhilippHastedt committed Mar 6, 2023
2 parents 5fc5534 + 2b42e3b commit 424a23a
Show file tree
Hide file tree
Showing 19 changed files with 101 additions and 258 deletions.
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
# 2023-code-ACC-Distributed Model Predictive Flocking with Obstacle Avoidance and Asymmetric Interaction Forces

[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.7139904.svg)](https://doi.org/10.5281/zenodo.7139904)
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.7139904.svg)](https://doi.org/10.5281/zenodo.7139903)

## General

This repository contains an implementation of the algorithms and simulations described in
This repository contains an implementation of the algorithms and simulations presented in

> P.Hastedt and H. Werner, "Distributed Model Predictive Flocking with Obstacle Avoidance and Asymmetric Interaction Forces"
submitted to ACC, 2023.

It may be used to recreate and validate the simulation results and figures from the paper. To do so, run either of the two scripts `simulation.m` and `evaluation.m`.

Additionally, videos for the scenarios described in the paper are provided in the `videos` directory.
Expand All @@ -26,7 +24,7 @@ At the top of `simulation.m`, the algorithm and scenario to be simulated can be

## Evaluation

At the top of `evaluation.m`, the scenarios to be compared can be selected by adding the corresponding data index to the `dataSelection` array. To evaluate additional data generated by the simulation, copy the `.mat` files from the `simulation/out` directory to the `data` directory and add the name of the data file to the `simData` array at the top of `evaluation.m`.
At the top of `evaluation.m`, the scenarios to be compared can be selected by changing the `scenarioIndex` variable. To evaluate additional data generated by the simulation, copy the `.mat` files from the `simulation/out` directory to the `data` directory and add the name of the data file to the `simData` array at the top of `evaluation.m`.

## Prerequisites

Expand Down
Binary file modified data/hastedt_scenario_1.mat
Binary file not shown.
Binary file modified data/hastedt_scenario_2.mat
Binary file not shown.
Binary file modified data/huang_scenario_1.mat
Binary file not shown.
Binary file modified data/huang_scenario_2.mat
Binary file not shown.
Binary file modified data/olfati-saber_scenario_1.mat
Binary file not shown.
Binary file modified data/olfati-saber_scenario_2.mat
Binary file not shown.
72 changes: 43 additions & 29 deletions evaluation.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,29 @@

% Available Data
simData = [
"hastedt_scenario_1" % 1
"hastedt_scenario_2" % 2
"huang_scenario_1" % 3
"huang_scenario_2" % 4
"olfati-saber_scenario_1" % 5
"olfati-saber_scenario_2" % 6
"hastedt_scenario_1" % 1
"hastedt_scenario_2" % 2
"huang_scenario_1" % 3
"huang_scenario_2" % 4
"olfati-saber_scenario_1" % 5
"olfati-saber_scenario_2" % 6
];

% Select Data to compare by adding the indices from the simData array
dataSelection = [1,3,5]; % scenario 1 comparison
% dataSelection = [2,4,6]; % scenario 2 comparison
% Select the scenario to evaluate by setting the scenarioIndex. More data
% can be added to the comparison by changing the dataSelection arrays.

% Scenarios
% 1: Large obstacle
% 2: Field of small Obstacles

scenarioIndex = 1;

switch (scenarioIndex)
case (1)
dataSelection = [1,3,5];
case (2)
dataSelection = [2,4,6];
end
%% Comparison/Evaluation
% Minimum distance variable initialization
t_distN = {};
Expand All @@ -49,28 +60,46 @@
for j=1:length(dataSelection)
figure()
load(dataPath+simData(dataSelection(j)));
viscircles(param.obstacles(1:2,:)',param.obstacles(3,:),'Color','black', 'LineWidth', 1); hold on;
if ~isempty(param.obstacles)
viscircles(param.obstacles(1:2,:)',param.obstacles(3,:),'Color','black', 'LineWidth', 1); hold on;
end
for i = 1:size(out.data.position,3)
plot(out.data.position(:,1,i),out.data.position(:,2,i),'b'); hold on;
end

plot(squeeze(out.data.position(1,1,:)),squeeze(out.data.position(1,2,:)),'kx','MarkerSize',10,'LineWidth',1); hold on;
plot(squeeze(out.data.position(end,1,:)),squeeze(out.data.position(end,2,:)),'kx','MarkerSize',10,'LineWidth',1); hold on;
title("Agent Trajectories "+ replace(erase(simData(dataSelection(j)),".mat"),"_","\_"));
xlabel('x');
ylabel('y');
xlim([-5 100]);
ylim([-5 100]);
if (scenarioIndex ~=3)
xlim([-5 100]);
ylim([-5 100]);
end
end

%% Input Comparison
names = {};
for i = 1:length(dataSelection)
load(dataPath+simData(dataSelection(i)));
u_rms(i) = calculateTotalInputUsed(out);
names{i} = replace(erase(simData(dataSelection(i)),".mat"),"_","\_");
end
figure()
bar(1:i,u_rms);
set(gca, 'XTick', 1:length(names),'XTickLabel',names);
title('RMS Input Values')

%% Minimum distances
figure()
for i = 1:size(distN,2)
tmax = t_distN{i}(end);
plot(t_distN{i},distN{i}, 'DisplayName',replace(erase(simData(dataSelection(i)),".mat"),"_","\_")+" q_{ij}");
hold on;
plot(t_distO{i},distO{i}, '--','DisplayName',replace(erase(simData(dataSelection(i)),".mat"),"_","\_")+" q_{io}");
hold on;
end
xlim([0,400])
xlim([0,tmax])
ylim([0,8.4])
grid on;
title('Minimum inter-agent and agent-obstacle distances')
Expand All @@ -79,18 +108,6 @@
legend show;
legend('Location','southeast');

%% Input Comparison
names = {};
for i = 1:length(dataSelection)
load(dataPath+simData(dataSelection(i)));
u_rms(i) = calculateTotalInputUsed(out);
names{i} = replace(erase(simData(dataSelection(i)),".mat"),"_","\_");
end
figure()
bar(1:i,u_rms);
set(gca, 'XTick', 1:length(names),'XTickLabel',names);
title('RMS Input Values')

%% Minimum Obstacle Distance Comparison
names = {};
for i = 1:length(dataSelection)
Expand Down Expand Up @@ -126,7 +143,4 @@
figure()
bar(1:i,clearanceTime);
set(gca, 'XTick', 1:length(names),'XTickLabel',names);
title('Obstacle Clearance Time')

%% Potential Comparison
plotPotentials()
title('Obstacle Clearance Time')
63 changes: 0 additions & 63 deletions evaluation/functions/calculatePerformanceIndices.m

This file was deleted.

57 changes: 0 additions & 57 deletions evaluation/functions/plotPotentials.m

This file was deleted.

Loading

0 comments on commit 424a23a

Please sign in to comment.