Repository navigation
Expand file tree
/
Copy pathsetup_example.m
More file actions
106 lines (87 loc) · 4.78 KB
/
Copy pathsetup_example.m
File metadata and controls
106 lines (87 loc) · 4.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
%% EXAMPLE SETUP (setup_example.m) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This script is designed as an example of how to simulate a multiple agent
% collision scenario using the Open Multi-Agent Simulation (OpenMAS) suite.
% For the agent and object interface see:
% examples/agents.md
% For the simulation interface see:
% examples/README.md
% Author: James A. Douthwaite 23/11/2018
clear all; close all;
%% ADD ADDITIONAL THE PROGRAM PATHS
addpath('core');
addpath(genpath('objects'));
addpath('scenarios');
%% DEFINE SIMULATION PARAMETERS
[~, userdir] = system('echo %USERPROFILE%'); % Get desktop path
sim_outputPath = strcat(userdir,'\desktop\OpenMAS_data'); % Set it as output path
sim_vebosity = 1;
sim_warningDistance = 2;
sim_maxDuration = 10;
sim_timeStep = 0.1;
% sim_figureSet = {'collisions'}; % SEE 'OMAS_figureGenerator.m' for options
sim_figureSet = {'events','plan','gif'};
%% SCENARIO PARAMETERS
sim_agentNumber = 2; % TOTAL NUMBER OF AGENTS
sim_agentOrbit = 5;
sim_waypointOrbit = 10;
sim_offsetAngle = 0;
sim_agentVelocity = 0;
sim_obstacleNumber = 4;
sim_noiseSigma = 0.2;
sim_plotScenario = logical(true);
%% GENERATE SCENARIO/OBSTACLE SET
fprintf('|| Assigning agent definitions:\n');
for index = 1:sim_agentNumber
% agentIndex{index} = agent();
% agentIndex{index} = agent_2D();
% agentIndex{index} = agent_test();
agentIndex{index} = agent_example();
% 3D COLLISION AVOIDANCE
% agentIndex{index} = agent_VO();
% agentIndex{index} = agent_RVO();
% agentIndex{index} = agent_HRVO();
% agentIndex{index} = agent_vectorSharing();
% 2D COLLISION AVOIDANCE
% agentIndex{index} = agent_2D_VO();
% agentIndex{index} = agent_2D_RVO();
% agentIndex{index} = agent_2D_HRVO();
% agentIndex{index} = agent_2D_vectorSharing();
% DYNAMICAL EXAMPLES
% agentIndex{index} = ARdrone_LQR();
% agentIndex{index} = quadcopter();
end
%% PLACE AGENT OBJECTS IN PRE-DEFINED SCENARIO
% OBSTACLE TESTS
% [ objectIndex ] = scenario_four_cuboid_obstacles('agents',agentIndex,'plot',sim_plotScenario);
% [ objectIndex ] = scenario_obstacle_track('agents',agentIndex,'plot',sim_plotScenario);
% % AGENT TESTS
% [ objectIndex ] = scenario_two_lines('agents',agentIndex,'agentVelocity',sim_agentVelocity,'padding',2,'plot',sim_plotScenario);
[ objectIndex ] = scenario_concentric_ring('agents',agentIndex,'agentOrbit',sim_agentOrbit,'agentVelocity',sim_agentVelocity,'waypointOrbit',sim_waypointOrbit,'offsetAngle',sim_offsetAngle,'plot',sim_plotScenario,'noiseFactor',sim_noiseSigma);
% [ objectIndex ] = scenario_concentric_ring('agents',agentIndex,'agentOrbit',sim_agentOrbit,'agentVelocity',sim_agentVelocity,'waypointOrbit',sim_waypointOrbit,'offsetAngle',pi/2,'plot',sim_plotScenario,'noiseFactor',sim_noiseSigma);
% [ objectIndex ] = scenario_concentric_sphere('agents',agentIndex,'agentOrbit',sim_agentOrbit,'agentVelocity',sim_agentVelocity,'waypointOrbit',sim_waypointOrbit,'plot',sim_plotScenario);
% [ objectIndex ] = scenario_concentric_angle('agents',agentIndex,'agentOrbit',sim_agentOrbit,'agentVelocity',sim_agentVelocity,'waypointOrbit',sim_waypointOrbit,'angle',pi/4,'plot',sim_plotScenario);
% RANDOM TESTS
% [ objectIndex ] = scenario_random('objects',agentIndex,'plot',sim_plotScenario);
% [ objectIndex ] = scenario_random_normal('objects',agentIndex,'plot',sim_plotScenario);
% [ objectIndex ] = scenario_random_uniform('objects',agentIndex,'plot',sim_plotScenario);
% WAYPOINT TESTS
% [ objectIndex ] = scenario_waypoint_curve('agents',agentIndex,'agentVelocity',sim_agentVelocity,'plot',sim_plotScenario);
% [ objectIndex ] = scenario_waypoint_90_degrees('agents',agentIndex,'agentVelocity',sim_agentVelocity,'plot',sim_plotScenario);
% RL TESTS
% [ objectIndex ] = scenario_earth_orbit('plot',sim_plotScenario);
%% %%%%%% INITIALISE THE SIMULATION WITH THE OBJECT INDEX %%%%%%%%%%%%%%%%%
[DATA,META] = OMAS_initialise('objects',objectIndex,...
'duration',sim_maxDuration,...
'dt',sim_timeStep,...
'figures',sim_figureSet,...
'warningDistance',sim_warningDistance,...
'verbosity',sim_vebosity,...
'outputPath',sim_outputPath);
clearvars -except DATA META
% /////////////////////////////////////////////////////////////////////////
% Upon completion of the simulation all the trajectory, figures and
% statistics will be pushed to the output directory, or held in 'DATA'.
% IMPORT DATA (from 'outputPath')
load(strcat(META.outputPath,'META.mat'));
load(strcat(META.outputPath,'EVENTS.mat'));
fprintf('Complete...\n');