Skip to content

Unreal Simulation Setup

Devon Ash edited this page Feb 6, 2019 · 19 revisions

Prerequisites

Install Unreal and Simbotic

Automated Option:

While inside your cloned GAMS repo, simply call:

./scripts/linux/base_build.sh prereqs unreal

Which will pull UnrealEngine to $GAMS_ROOT/UnrealEngine and AirSim to $GAMS_ROOT/AirSim if they are not already there.

Manual Option:

Unreal

git clone -b 4.18 git@github.com:EpicGames/UnrealEngine.git
cd UnrealEngine
./Setup.sh
./GenerateProjectFiles.sh
make

(Option 1) Using Simbotic instead of AirSim

git clone --recursive git@github.com:VertexStudio/Simbotic.git

Environment variables:

export SIMBOTIC_UE4=/path/to/UE4_21
export SIMBOTIC_ROOT=/path/to/Simbotic

Generate project files and build:

cd $SIMBOTIC_ROOT
./generate.sh
./build_airsim.sh
./build.sh

Run sim:

./run.sh

Important: After launching Simbotic by calling run.sh you have to press play inside the running Unreal editor.

(Option 2) Using AirSim directly (instructions found here from https://microsoft.github.io/AirSim/docs/build_linux/)

Important: If you are using the most recent gpc-unreal branch (as per the clone above), your "using_airlib.mpb" file will be pointing to $(AIRSIM_ROOT) rather than $(SIMBOTIC_ROOT). If you wish to use Simbotic (in development) please see the above instructions. (AirSim is default in gpc-unreal as of Monday, Feb 4th, 2019, but we are pending a change over to use Simbotic when it is more feature complete)

Clone AirSim and build it: bash

   # go to the folder where you clone GitHub projects
   git clone https://github.com/Microsoft/AirSim.git
   cd AirSim
   ./setup.sh
   ./build.sh

Set your $(AIRSIM_ROOT) to be wherever you installed AirSim.

Once AirSim is set up by following above steps, you can,

  1. Go to UnrealEngine folder and start Unreal by running UnrealEngine/Engine/Binaries/Linux/UE4Editor. When Unreal Engine prompts for opening or creating project, select Browse and choose 2. AirSim/Unreal/Environments/Blocks (or your custom Unreal project).
  2. If you get prompts to convert project, look for More Options or Convert-In-Place option. If you get prompted to build, chose Yes. If you get prompted to disable AirSim plugin, choose No.
  3. After Unreal Editor loads, press Play button. Tip: go to 'Edit->Editor Preferences', in the 'Search' box type 'CPU' and ensure that the 'Use Less CPU when in Background' is unchecked.

MADARA and GAMS

git clone -b gpc-unreal git@github.com:jredmondson/gams.git
export UNREAL_ROOT=/path/to/unreal
export SIMBOTIC_ROOT=/path/to/Simbotic
export SIMBOTIC_UE4=/path/to/unreal

Build

./scripts/linux/base_build.sh madara gams airlib clang

Important: Add the environment variables which are printed by the base_build script to your .bashrc or activation script.

Run a Waypoint Demo

Launch Simbotic and press play inside the Unreal Editor.

$GAMS_ROOT/scripts/simulation/waypoints/waypoints.pl

Configuring The Waypoints Demo Manually (not recommended)

If you are using Option 1 (AirSim directly) you may wish to try other demos out. These are all experimental at the moment and are currently pending bug fixes and on-going development. However, you may:

1. Modify your ~/Documents/AirSim/settings.json file to add more or remove agents. The file looks like this:

{
  "SettingsVersion": 1.2,
  "SimMode": "Multirotor",
  "Vehicles": 
  { 
  "agent.0": 
        {
          "VehicleType": "SimpleFlight",
          "X": 0,
          "Y": 0,
          "Z": -2,
          "Yaw": -180
        }
   }
}

Adding more statements of agents with the vehicle name following the pattern of agent.XX (agent.1,... agent.2 etc) will tell AirSim to load in more agents with that vehicle name. These vehicle names are important as that is what the AirLib compiled GAMS controller will use to associate what commands to the respective robot over AirLib's RPC API.

2. Modify the MADARA files (*.mf) inside of $GAMS_ROOT/scripts/simulation/

After adding more agents to the above .json, we must now configure the simulation files to reflect that there are more agents. In this example, we will add more agents to the waypoints.pl scripts.

Update this line inside of $GAMS_ROOT/scripts/simulation/waypoints/waypoints.pl

$num = 20;

To the number of agents matching the number of agents that you have added in your settings.json

For every agent you have, create a "madara_init_X.mf" file where X is the ID of the agent (if you have 20 agents, you'll use the numbers 0-19 to name your files).

Here is an example file contents, which you can see by going to your $GAMS_ROOT/scripts/simulation/waypoints directory:

.vrep_port=19906;

.initial_lat=40.443222;
.initial_lon=-79.940334;
.initial_alt=4;

agent.0.algorithm="waypoints";

agent.0.algorithm.args.locations.size=4;
agent.0.algorithm.args.locations.0=[40.443237,-79.940570,2];
agent.0.algorithm.args.locations.1=[40.443387,-79.940270,2];
agent.0.algorithm.args.locations.2=[40.443187,-79.940098,2];
agent.0.algorithm.args.locations.3=[40.443077,-79.940398,2];
agent.0.algorithm.args.repeat=3;

By adding locations to your agent.0.algorithm.args.locations.X you may add more spots the bot is to move to during simulation. In addition, repeat is how many times the demo will repeat. Size=4 is the total number of waypoints. If you add more waypoints you will have to increase size as it will only go to that number of waypoints as a maximum.

To run this, simply do the same as above. That is, run Unreal and load in the AirSim Blocks.uproject and then press play, and then call $GAMS_ROOT/scripts/simulation/waypoints/waypoints.pl

Configuring demos with gpc.pl (GAMS Project Creator) (Recommended)

To create a project, head over to your $GAMS_ROOT and then:

./scripts/projects/gpc.pl --path ~/unreal_demo --platform unreal-quad --algorithm waypoints --agents 1

If that command completes successfully,

cd ~/unreal_demo

If your unreal + airsim plugin is loaded in and started, and play is pressed, then:

./action.sh run

You should then see the quadrotor move around

Increasing the number of agents in simulation via the gpc.pl script:

Clone this wiki locally