The aim of the project is to implement a Reinforcement Learning Architecture able to control aerial quadricopters, even in commercial drones. The scenario concerns the advanced stabilization of a drone in critical situations such as high-speed wind, recovery due to a free fall, a propeller failure and any kind of features that could ensure safety during a flight in densely populated areas.
First of all we developed the project in a virtual environment, using the AirSim simulator, based on Unreal Engine, which was created precisely for the purpose of supporting the development of reinforcement learning applications for vehicles and quadcopters.
The idea was to initially simulate it in a virtual environment, to train the agent through deep RL, developing an MLP that runs with low latency. In the future it would be interesting to try to deploy, safely, on a physical drone.
-
Install Unreal Engine (4.27 suggested) from Epic Games Launcher.
-
Install Visual Studio 2019
-
Install C++ dev
-
Install Python
-
Download AirSim prebuilt source code and the environment of your choice.
-
Place the Environment in AirSim/Unreal/Environment
-
Use Visual Studio 2019 Developer Command Prompt with Admin privileges to run AirSim-1.7.0-windows/build.cmd
-
Follow the tutorial in order to setup Blocks Environment for AirSim
-
Install .net framework 4.6.2 Developer (SDK), desktop runtime 3.1.24
-
Run AirSim-1.7.0-windows/Unreal/Environments/Blocks/update_from_git.bat
-
Add settings.json inside airsim folder (settings.json is a file containing all the quadricopter settings)
-
Open .sln with Visual Studio 2022 (or 2019 if the only installed), as suggested in this link set Blocks as default Project, DebugGame Editor & Win64. Finally press F5
-
Once Unreal is open with the project, click "Play" and use the keyboard to move the drone.
-
Take AirSim-1.7.0-windows/PythonClient/multirotor/hello_drone.py
-
Delete first line of import.
-
Create an Anaconda environment.
-
Install the following libraries
pip install numpy pip install opencv-python pip install msgpack-rpc-python pip install airsim
-
Install Visual Studio & recommended python extensions (optional)
-
Unreal might lag if there is another window on top.To avoid this go in Unreal Engine settings: Edit->Editor preferences->search Performance->disable "Use less CPU when in background"
-
Clone the repository
git clone https://github.com/lap98/RL-Drone-Stabilization.git
-
Open the environment in Unreal Engine
-
Run first.py in order to control the drone
In order to use TF-Agents library:
conda install -c conda-forge cudatoolkit=11.2 cudnn=8.1.0
pip install tensorflow==2.9
pip install tf-agents==0.13.0