Skip to content

5. Installation Instructions

Ethan Bond edited this page Jun 18, 2020 · 2 revisions

Getting Started -Installation

Setting up the Scene

First you must create two tags and three layers, these are added under the inspector on any GameObject. The Layers and tags required are listed below:

Tags:

  • RedDrone
  • GreenDrone
  • Target

Layers:

  • 8, Drones
  • 15, Disabled
  • 16, Target

*note for the layers the layer number must be the one stated above.

Once the layers have been created the collisions for the disabled layer must be turned off. This is done by navigating to, Edit -> Project Settings -> Physics, and then deselecting all the check boxes in the Layer Collision Matrix which involve the "Disabled" layer.

A further requirement of the scene is that no objects reside under -90 in the Y axis, as -100 is used as a "garbage pile" for disabled drones, and targets.

Setting up the Advanced Drone prefab

The next setup phase is to open the Drone Prefab in the Prefab editor mode and change the folder path for the propeller database.

  1. Double click "Drone" prefab in the project explorer window, this will open the prefab.
  2. Navigate to the Inspector Panel
  3. Expand the Inspector for "Prop Data SQ Lite"
  4. Select show original Inspector
  5. Type in the folder path (not filepath) of the prop database included in the download
  6. Close the prefab by selecting the horizontal arrow in the top left.

*Tip, place the PropDatabase.sqlite on the fastest disk you have, it will be accessed frequently.

The prefab can now be dragged into any scene and will begin working straight away providing it has been tagged as a "RedDrone" or "GreenDrone". A "GreenDrone" will aim to collide with a "RedDrone", and Aa "RedDrone" will heads towards the closest GameObject tagged "Target", the target can be moving or stationary. These configurations are selected by Tagging the drone shown below:

In its default configuration the prefab acts as a "Red Drone".

Setting a target

Figure 2 Setting the "Tag" of a GameObject to Target

Setting a target is conducted by tagging any GameObject with the "Target" tag. On run the guidance component in the advanced drone will perform a "FindGameObjectByTag" command and will sort the response by distance from itself. The advanced drone will then check to see if the drone is not in the disabled layer (layer 15) and if not will target it. If the target is disabled, the advanced drone will move to check the next closest target and so on until the list is exhausted. If the list is exhausted the drone will give a warning in the console.

Alternatively a second prefab named Target.prefab is provided, this prefab contains a cube, with a class file attached which automatically sets the Tag to Target, and on collision will go to the "garbage pile" and change its layer to "Disabled" so it is no longer targeted.

Changing settings

All the variables with the exception of the propeller used are set in the Drone_Configuration Inspector. In the Architecture section you will find a "Variable table" for every component. In the variable table you will find a description for what each variables is, as well as units, and what component generates them. All the variables marked user input must be filled in for the component to work and are the only variables which can be changed by the user. There is also an explanation on how to disable an unwanted module, and which outputs from that module become fixed user inputs after doing so

Depending on the use case components can be disabled or enabled. When disabling a component, the outputs used by other components will remain at their fixed initial values contained within the "Drone_Configuration" component. The user may modify these values in the inspector. An explanation of which values need to be set when disabling a component is given in the relevant component subsections. An example of disabling the Battery Component is given below:

Use case example

In the following use case, an experiment looking into the effect of increasing drag factor on time to travel to target will be setup. A system architecture diagram of the entire scene is provided below. 5 modules make up the scene:

  1. Simulation Manager
  2. Sub-manager
  3. SaveData
  4. Advanced Drone Prefab
  5. Target Prefab

The simulation manager sits at the top of the management system hierarchy and is responsible for controlling the simulation, instantiating workers, and incrementing variables.

The Sub-manger manages the simulation on a local level and is used to determine when the simulation run is complete, i.e. the drone has become disabled or the target has been reached. When the simulation is complete it will then trigger "SaveData".

SaveData is a CUEDOS asset which records variable values of the GameObject it is on to a tab-delimited text file.

The Target Prefab is a GameObject which on collision changes its tag to disabled.

Setup

Firstly the Advanced Drone Prefab must setup and added to the scene using the installation and setup guide in this guide.

Once the Prefab is setup, add in the Target prefab and move it to any location approximately 100m away from the drone prefab.

Next create an empty GameObject, rename it "Sub_Manager", and attach the "Sub_Manager_Example_Script". The expectation is for every experiment you will want to write a custom "Sub_manager" and "Simulation_manager" class.

Next attach the SaveData script to the Sub_manager following the SaveData UserGuide to set it up. The script/instance should be set to "Sub_Manager", and the fields to save "Time_Elapsed" and "Drone_DF".

Finally, you will need to create a simulation manager, create an empty GameObject, rename it "Simulation_Manager" and add the "Simulation_Manager_Example" script to it. In the inspector of the simulation manager you can now select a maximum and minimum and drag factor value and a resolution, the resolution is the number of values it try between the min and max including the min and max. Set these value to whatever you want and then press run.

A text file will now have been generated in the path selected in savedata.

To speed up the simulator you can go file -> project settings -> time -> timescale and then set it to 100. Unity has a maximum timescale of 100 meaning it can only run at 100 times real time. For a lot of large simulations this is not feasible thus parallel runs is the way forward.

To modify your simulation to run in parallel you will need to assemble everything as prefab and then have instantiate copies using the simulation manager.

Begin by create an empty gameobject and calling is Simulation_Prefab, drag the Simulation Prefab into the explorer and then delete all the files in the hierarchy so it looks like the following.

Next open the simulation_manager script and add in the following code.

Then save the script and open the inspector for the simulation_manager, drag the simulation_prefab you just created and place it in the simulation_prefab. While in the inspector you can select the number of worker to instantiate. Set this to 10 then start the simulation. The simulation should complete faster and the data appended to the end of the first SaveData file. If the simulation does not complete significantly faster it is likely your PCs performance was being maxed out already.