This project is about training and implementing self-driving algorithm for Formula Student Driverless competitions
. In such competitions, a formula race car, designed and built by students, is challenged to drive through previously unseen tracks that are marked by traffic cones.
We present a simulator for formula student car and the environment of a driverless competition. The simulator is based on AirSim.
Figure 1. The Technion Formula Student car. Actual car (left), simulated car (right)
The model of the Formula Student Technion car is provided by Ryan Pourati.
The environment scene is provided by PolyPixel.
Figure 2. Driving in real-world using trained imitation learning model, based on AirSim data only
- Operating system: Windows 10
- GPU: Nvidia GTX 1080 or higher (recommended)
- Software: Unreal Engine 4.18 and Visual Studio 2017 (see upgrade instructions)
- Simulator: AirSim 1.2
- You will need Visual Studio 2017 (make sure to install
VC++
andWindows 8.1 SDK
). - Start
x64 Native Tools Command Prompt for VS 2017
. Create a folder for the repo and rungit clone https://github.com/Microsoft/AirSim.git
. - Run
build.cmd
from the command line. This will create ready to use plugin bits in theUnreal\Plugins
folder that can be dropped into any Unreal project.
Finally, you will need an Unreal Project
that hosts
the environment
for your vehicles. Follow the list below to create an environment that simulates the FSD competitions.
-
Make sure
AirSim
is built andUnreal 4.18
is installed as described above. -
Open
Unreal Editor
and chooseNew Project
. ChooseBlank
withno starter content
. Select your project's location, define it's name (ProjectName
for example) and presscreate project
.
Figure 3. Create Unreal Project
-
After the project is loaded to the editor, from the
File
menu selectNew C++ class
, leave default None on the type of class, clickNext
, leave default name MyClass, and clickCreate Class
. We need to do this because Unreal requires at least one source file in project. It should trigger compile andopen up Visual Studio
solutionProjectName.sln
. -
Close and save
ProjectName.sln
. Also, close the UE editor. -
Go to your folder for
AirSim
repo and copyUnreal\Plugins
folder into yourProjectName
folder. This way now your own Unreal project has AirSim plugin. -
Download the environment assets of FSD racecourse. Extract the zip into
ProjectName\Content
(see folders tree at the end of this doc). -
Download the formula Technion car assets. Extract the zip into
ProjectName\Plugins\AirSim\Content\VehicleAdv\SUV
and selectreplace
when asked forSuvCarPawn.uasset
(the original file will be saved into a backup folder). -
Edit
theProjectName.uproject
so that it looks like this:
{
"FileVersion": 3,
"EngineAssociation": "4.18",
"Category": "Samples",
"Description": "",
"Modules": [
{
"Name": "ProjectName",
"Type": "Runtime",
"LoadingPhase": "Default",
"AdditionalDependencies": [
"AirSim"
]
}
],
"TargetPlatforms": [
"MacNoEditor",
"WindowsNoEditor"
],
"Plugins": [
{
"Name": "AirSim",
"Enabled": true
}
]
}
- Right click the
ProjectName.uproject
in Windows Explorer and selectGenerate Visual Studio project files
. This step detects all plugins and source files in your Unreal project and generates.sln
file for Visual Studio.
Figure 4. Generate Visual Studio project files
- Reopen
ProjectName.sln
in Visual Studio, and make sureDebugGame Editor
andWin64
build configuration is the active build configuration.
Figure 5. Build configurations
-
Press
F5
todebug
. This will start the Unreal Editor. The Unreal Editor allows you to edit the environment, assets and other game related settings. -
First thing,
load
amap
to set your environment. The maps are underContent\RaceCourse\Maps
. To choose one of the maps double-click on it. -
In
Window/World Settings
as shown below, set theGameMode Override
toAirSimGameMode
:
- Next,
if
you want tochange
the location ofPlayerStart
object in your environment(PlayerStart
object already exist) you can find and fix it in theWorld Outliner
. 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.
Figure 7. PlayerStart position
- Be sure to
Save
these edits. Hit the Play button in the Unreal Editor. See how to use AirSim.
Ready... Set... GO!!! You are now running AirSim in your FSD Unreal environment.
By default AirSim will prompt you for choosing Car or Multirotor mode. You can use SimMode setting to specify the default vehicle to car (Formula Technion Student car).
If you have a steering wheel (Logitech G920) as shown below, you can manually control the car in the simulator. Also, you can use arrow keys to drive manually.
Using imitation learning, we trained a deep learning model to steer a Formula Student car with an input of only one camera. Our code files for the training procedure are available here and are based on AirSim cookbook.
We added a few graphic features to ease the procedure of recording data. You can change the positions of the cameras using this tutorial.
There are two ways you can generate training data from AirSim for deep learning. The easiest way is to simply press the record button on the lower right corner. This will start writing pose and images for each frame. The data logging code is pretty simple and you can modify it to your heart's desire.
Figure 9. Gathering training data
This section is about training a model to steer our Formula car using imitation learning.
Imitation learning includes the usage of labeled data as input to a training algorithm with the purpose of having the algorithm imitate the actions of people who recorded the data.
Figure 10. Imiation Learning diagram
cook_data.py
is responsible for preparing .h5
dataset files for the training procedure.
The code rely on having two adjacent folders:
raw_data
- contains folders of recorded data by airsim's recording method.
cooked_data
- empty folder to store the .h5 files.
The flag "COOK_ALL_DATA" gives the option to choose all subfolders, or exclude some of them.
train_model.py
is responsible to train a model using the .h5 dataset files.
The code rely on having two adjacent folders:
cooked_data
- contains the .h5 dataset files.
models
- empty folder to store the generated models.
The file will preprocess the data, add augmentations and create a neural network model that predicts the next steering angle.
drive_model.py
connects to the simulation in order to upload a trained model and drive using it.
By using the predicted steering value, the code calculates related control parameters and maintain driving with steady velocities.
I recommend on using augmentation and recording techniques:
- CycleLight - Animation of a day light cycle in a changeable, potentially very short period of time.
- Shifted images - Altering the camera’s position to the right or the left of the car, so that it can record images in extreme conditions. To simulate driving back to the center from those extreme situations, post-process the recorded angle of the steering accordingly (manually).