Flying the Virtual Drone with Code
This page assumes you’ve followed the steps in Environment Setup (Windows) or Environment Setup (Linux)
- Open your AirSim Unreal Engine project
- you can run AirSim’s default project, called Blocks, located in your AirSim folder at
\AirSim\Unreal\Environments\Blocks\Blocks.uproject
- open the uproject directly in unreal; trying to run blocks from the Visual Studio Solution probably won’t work
- if it says that the project was built with a different Unreal version, click “Yes” to rebuild with the version you have
- you can run AirSim’s default project, called Blocks, located in your AirSim folder at
- Open a terminal and navigate to the root of your cloned repository. Then, run
poetry shell
- This will activate a virtual environment outfitted with the necessary dependencies need to interact with the simulation with Python.
- Start the Unreal Engine simulation using the editor’s
Play
button- located above the viewport to the far right
- if not immediately visible, press the double-arrow ($>!!>$) button, then
Play
- Start the PX4 and MavSDK servers by running
\scripts\run-servers.ps1
- if you encounter any issues with PX4 and MavSDK connecting, check out the environment debugging page
- Run your code!
- if you don’t have code of your own, there are example/test scripts you can run in the Simulation 2023 repository under the
\tests\
directorydrone_control.py
gives you rudimentary control via a text prompt. Open the file and read the top comment for the various control commands
- if you don’t have code of your own, there are example/test scripts you can run in the Simulation 2023 repository under the
Whenever you want to rerun code, you must
- stop the Unreal Simulation
- close the PX4 and MavSDK PowerShell instances
- repeat steps 3-5 in the above guide
There might be a better way to do this, but we haven’t discovered it.
When finished running code, run exit
to exit your Poetry virtual environment.