Directions for running Ubuntu 22.04 AirSim Docker Container#
Prerequisites#
- Python >=3.5
- Docker
- Drivers for your GPU (e.g.
sudo apt install nvidia-driver-535 nvidia-container-toolkit
)
Steps#
- Clone AirSimExtensions locally:
git clone https://github.com/microsoft/AirSimExtensions.git
- Navigate to AirSimExtensions/docker:
cd AirSimExtensions/docker
- Copy your AirSim environment package (e.g. AirSimNH) (Link to releases) to the same directory as AirSimExtensions:
cp -R $PATH_TO_AIRSIM_PACKAGE/Linux $PATH_TO_AIRSIMEXTENSIONS/../AirSimNH
- Run python docker build script:
python3 build_airsim_image.py --base_image=adamrehn/ue4-runtime:22.04-cudagl11-x11 --target_image=airsim_binary:22.04-cudagl11-x11
- Enable xhost for the docker container:
xhost +local:root
-
Now that the image is built, we can run the container. First:
Then...docker network create ros_network
- If running on Linux:
docker network create ros_network docker run --network ros_network -p 41451:41451 --gpus=all -v "/tmp/.X11-unix:/tmp/.X11-unix:rw" -e DISPLAY airsim_binary:22.04-cudagl11-x11
- If running on Linux in headless mode:
docker run --network ros_network -p 41451:41451 --gpus=all -v "/tmp/.X11-unix:/tmp/.X11-unix:rw" -it airsim_binary:22.04-cudagl11-x11 ./airsim_ros_entry.sh -RenderOffscreen
-
If running on Windows:
Once the container is running, it will automatically start an AirSim environment. 1. [This step can be skipped; it confirms that the AirSim server is running on the container and capable of connecting between the host machine and the docker container via the Python API. It is not necessary for ROS2.] We can now test the AirSim environment running in the docker container. In a new powershell window or bash session, create a virtual environment within thedocker run -p 7410:7410/udp -p 7412:7412/udp -p 41451:41451 --gpus=all -v "/tmp/.X11-unix:/tmp/.X11-unix:rw" -e VM_IP=<ip address of vm or wsl container> -e HOST_IP=<host ip address> -e DISPLAY airsim_binary:22.04-cudagl11-x11
AirSimExtensions/PythonClient
folder, activate it, and install the requirements:
For Windows:
For Linuxcd AirSimExtensions\PythonClient\ python -m venv .venv .\.venv\scripts\activate python -m pip install -r requirements.txt
Navigate tocd AirSimExtensions/PythonClient/ python -m venv .venv source .venv/bin/activate python -m pip install -r requirements.txt
AirSimExtensions/PythonClient/multirotor
and run hello_drone.py:
python hello_drone.py
1. In a new local powershell window or bash session, connect to the running container:
docker exec -it (docker ps -q --format "{{.ID}}") bash
You should be logged in asairsim_user
. Navigate to the home directory:cd ~
. 1. Follow the directions for ROS2 package setup, starting from Build:
https://github.com/microsoft/AirSimExtensions/blob/main/docs/airsim_ros_pkgs.md#build
Note 1: In order to clone the AirSimExtensions private repository, you'll need to set up a personal access token on Github.
Note 2 : Once the ROS2 node is running on the container, you can see the topics and services by typingros2 topic list
andros2 service list
respectively, and subscribe usingros2 topic echo <topic-name>
(for example,ros2 topic echo /airsim_node/SimpleFlight/imu/imu
- If running on Linux: