0% found this document useful (0 votes)
314 views7 pages

Air Sim

The document provides instructions for setting up the AirSim plugin in an Unreal Engine project to enable the use of the AirSim simulation API. It involves downloading Unreal Engine and Visual Studio, cloning the AirSim GitHub repository, building the AirSim plugin files, copying them to the Unreal project plugins folder, and configuring the project settings to use the AirSim plugin for simulation and API access. Additionally, it describes how to set up a separate C++ project in Visual Studio to access the AirSim API and control the simulation from a client application.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
314 views7 pages

Air Sim

The document provides instructions for setting up the AirSim plugin in an Unreal Engine project to enable the use of the AirSim simulation API. It involves downloading Unreal Engine and Visual Studio, cloning the AirSim GitHub repository, building the AirSim plugin files, copying them to the Unreal project plugins folder, and configuring the project settings to use the AirSim plugin for simulation and API access. Additionally, it describes how to set up a separate C++ project in Visual Studio to access the AirSim API and control the simulation from a client application.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

How to Setup AirSim Plugin in Unreal

Engine Project
1. Go to the Unreal Engine website and download the Unreal Engine installer. Note: it is
also possible to download Unreal Engine installer through Visual Studio installer.
https://www.unrealengine.com/en-US/eulacheck?state=https%3A%2F
%2Fwww.unrealengine.com%2Fen-US%2Fblog%2Funreal-engine-4-21-
released&studio=false
2. Open the installer and instal the Epic Games launcher.
3. In the launcher go ahead and install latest Unreal Engine. At the time of writing this it
was 4.12.2.
4. Go to Visual Studio website and download Visual Studio Community IDE.
https://visualstudio.microsoft.com/
5. Open the installer and choose Game development with C++ also make sure that VC+
+ and Windows SDK 8.1 are selected while installing VS 2017.
6. Start x64 Native Tools Command Prompt for VS 2017
7. Position yourself in the folder you wish to download AirSim, note it can get pretty
large.
8. Clone the repo: git clone https://github.com/Microsoft/AirSim.git
9. Go to the AirSim directory by cd AirSim
10. Run build.cmd from the command line. his will create ready to use plugin bits in the
Unreal\Plugins folder that can be dropped into any Unreal project.
11. Open Unreal Engine and select New Project.
12. Choose what type of project you want, but with AirSim the best choice would be any
C++ project. I selected Basic Code with Starter Content so I could place pre-made
objects in the scene, name the project and click create.
13. This will generate basic Unreal Project with few .cpp files and some sort of scene
depending what you chose.
14. Now close the Unreal Engine along the Visual Studio and go in the AirSim folder, the
same folder as in the step 9. Go in to Unreal folder and copy whole Plugins folder in
to your root project directory which can be found at
C:\Users\”YourUsername”\Documents\Unreal Projects\
15. In order so the Unreal Engine can find the plugin you have to edit .uproject that you
find in your root project directory. Right click > Open with > Notepad
Modules part should look like this:
"Modules": [
{
"Name": "ProjectName",
"Type": "Runtime",
"LoadingPhase": "Default",
"AdditionalDependencies": [
"AirSim"
]
}
]
And there needs to be added Plugins part after Modules:
,
"Plugins": [
{
"Name": "AirSim",
"Enabled": true
}
]

My example looks like this:


{
"FileVersion": 3,
"EngineAssociation": "4.21",
"Category": "Samples",
"Description": "",
"Modules": [
{
"Name": "LandscapeMountains",
"Type": "Runtime",
"LoadingPhase": "Default",
"AdditionalDependencies": [
"AirSim"
]
}
],
"TargetPlatforms": [
"MacNoEditor",
"WindowsNoEditor"
],
"Plugins": [
{
"Name": "AirSim",
"Enabled": true
}
]
}

16. Now right click on the .uproject file and select Generate. This step detects all plugins
and source files in your Unreal project and generates .sln file for Visual Studio.
17. Reopen .sln file in Visual Studio, and make sure "DebugGame Editor" and "Win64"
build configuration is the active build configuration.
18. Press F5 to run. This will start the Unreal Editor. The Unreal Editor allows you to edit
the environment, assets and other game related settings.
But there are two errors that keep you from building: IncrementFlushOnDraw and
DecrementFlushOnDraw.
You can safely remove or comment the lines 126-127 and 133-134 in
AirBlueprintLib.cpp that are causing the issues. And try F5 again.
19. After the Unreal Editor opens you will see error message about M_radial_ramp
cannot find file of asset. Click on the first link where it says M_radial_ramp and it will
be highlighted in the Content Browser so you can safely dismiss the Message Log.
20. Open M_radial_ramp and delete Unspecified function node. Right click and type in
Radial, and choose RadialGradientExponential from the list. Connect that node to the
Base of the Power(X,4) node. Apply and Save.
21. First thing you want to do in your environment is set up PlayerStart object. If it doesn’t
exist in the scene you can add one by looking at modes section and going to Basic
tab where you will find PlayerStart. This is where AirSim plugin will create and place
the vehicle. If its too high up then vehicle will fall down as soon as you press play
giving potentially random behavior.
22. Go to Window > World Settings, it will open in the lower right corner next to Details
pane. Here you need to set the GameMode Override to AirSimGameMode.
23. To ensure game runs even if the editor is not in focus, i.e. in the background, go to
Edit > Editor Preferences. In the Search box type CPU and ensure that the 'Use Less
CPU when in Background' is unchecked. If you don't do this then UE will be slowed
down dramatically when UE window loses focus.
24. Be sure to Save these edits. Hit the Play button in the Unreal Editor.
How to Setup AirSim API in Unreal
Project in Visual Studio
1. To be able to use API we need to set up Visual Studio to know where the library and
the dependancies are. They are located inside of the AirSim plugin folder in the
Source\AirLib folder.
2. Usually when we want to link libraries to the Visual Studio we right click on the project
name and then choose Properties. In this window, we then are presented with
Linker and C/C++ settings. But the Unreal Engine doesn’t support linking
libraries through Visual Studio so these options are not available. What you actually
need is to link the libraries through UnrealBuildTool (UBT) system.
3. Although it is best recommended to create another C++ project to handle client-side
communication since the Unreal Engine project is the server side, I will show you how
to include libraries using UBT in Unreal Project we opened above but will then focus
on actually creating a new project for client-side communication and control.
4. To include libraries in Unreal Project we created we need to add lines in
“ProjectName”.build.cs file which can be found under Source > “ProjectName”.
The lines need to be added under SetupProject method inside SetupProject class:

PublicIncludePaths.Add(Path.Combine(ModuleDirectory,
"../../Plugins/AirSim/Source/AirLib/include"));

PublicIncludePaths.Add(Path.Combine(ModuleDirectory,
"../../Plugins/AirSim/Source/AirLib/deps/eigen3"));

PublicIncludePaths.Add(Path.Combine(ModuleDirectory,
"../../Plugins/AirSim/Source/AirLib/deps/MavLinkCom/include"));

PublicIncludePaths.Add(Path.Combine(ModuleDirectory,
"../../Plugins/AirSim/Source/AirLib/deps/rpclib/include"));

PublicAdditionalLibraries.Add(Path.Combine(ModuleDirectory,
"../../Plugins/AirSim/Source/AirLib/lib/x64/Release/AirLib.lib"));

PublicAdditionalLibraries.Add(Path.Combine(ModuleDirectory,
"../../Plugins/AirSim/Source/AirLib/deps/rpclib/lib/x64/Release/rpc.lib"));

PublicAdditionalLibraries.Add(Path.Combine(ModuleDirectory,
"../../Plugins/AirSim/Source/AirLib/deps/MavLinkCom/lib/x64/Release/MavLinkCom.lib
"));
5. After including these lines you should be able to build the Unreal project and have
access to AirSim API. Note that if you have several projects in solution you need to
set the correct one as startup by right clicking on that project and choosing Set as
Startup Project.
6. You can test by copying HelloCar’s main.cpp into your project and trying to compile
and run with F5, although it won’t work because it is not the way they designed the
API to work. As previously stated, API is supposed to be run in different C++ project
on client-side.
How to Setup AirSim API in Client App
in Visual Studio
1. First we need to create new C++ project inside Visual Studio by going File > New >
Project and then we choose Windows Console Application.
2. To be able to use API we need to set up Visual Studio to know where the library and
the dependencies are. They are located inside of the AirSim plugin folder in the
Source\AirLib folder.
3. We need to copy the whole AirLib folder in to the root folder of our new project. You
can easily find the root project by right clicking on solution name in the Solution
Explorer on the right hand side and choosing Open Folder in File Explorer.
4. Now that the AirLib folder is under root directory we can link up our project by right
clicking on project and choosing Properties.
5. Under C/C++ > General we need to add this line to Additional Include Directories:
$(ProjectDir)..\AirLib\deps\rpclib\include;include;$
(ProjectDir)..\AirLib\deps\eigen3;$(ProjectDir)..\AirLib\include
Make sure that Platform is set to All Platforms!
6. Under Linker > General we need to add this line to Additional Library Directories:
$(ProjectDir)\..\AirLib\deps\MavLinkCom\lib\$(Platform)\$
(Configuration);$(ProjectDir)\..\AirLib\deps\rpclib\lib\$(Platform)\$
(Configuration);$(ProjectDir)\..\AirLib\lib\$(Platform)\$
(Configuration);%(AdditionalLibraryDirectories)
Make sure that Platform is set to All Platforms!
7. Under Linker > Input we need to add this line to the Additional Dependencies
AirLib.lib;rpc.lib;%(AdditionalDependencies)
If there exist other dependencies then just add (AirLib.lib;rpc.lib;), and skip
adding %(AdditionalDependencies). Make sure that Platform is set to All Platforms!
8. After you included the libraries make sure you have set the correct project as the
startup project by right-clicking on the project in the Solution Explorer and choosing
Set as Startup Project.
9. Also, the rpc.lib library is built for x64 platform, so if you try building as default x86 it is
not going to compile. So we need to change platform to x64 in the dropdown menu
next to Local Windows Debugger.
10. Now you can build the project.
11. You can test their example by copying HelloCar’s main.cpp into your project. Before
testing though you need to change AirSim settings which can be found: Windows:
Documents\AirSim Linux: ~/Documents/AirSim and the file is called
settings.json.
12. We need to change the settings to say:
{
"SettingsVersion": 1.2,
"SimMode": "Car"
}
So that our projects starts automatically with car as a default choice.
13. In order for it to work properly, you also need to fire up your previously created Unreal
Project so the client side can find the server.
14. Now you can compile and run using F5.

You might also like