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#

  1. Clone AirSimExtensions locally:
    git clone https://github.com/microsoft/AirSimExtensions.git
  2. Navigate to AirSimExtensions/docker:
    cd AirSimExtensions/docker
  3. 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
  4. 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
  5. Enable xhost for the docker container: xhost +local:root
  6. Now that the image is built, we can run the container. First:

    docker network create ros_network
    Then...

    • 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:

      docker 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
      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 the AirSimExtensions/PythonClient folder, activate it, and install the requirements:
      For Windows:
      cd AirSimExtensions\PythonClient\  
      python -m venv .venv
      .\.venv\scripts\activate
      python -m pip install -r requirements.txt
      For Linux
      cd AirSimExtensions/PythonClient/  
      python -m venv .venv
      source .venv/bin/activate
      python -m pip install -r requirements.txt
      Navigate to 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 as airsim_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 typing ros2 topic list and ros2 service list respectively, and subscribe using ros2 topic echo <topic-name> (for example, ros2 topic echo /airsim_node/SimpleFlight/imu/imu