Ensure you have Docker installed on your system. You can follow the official installation guide:
Docker Installation Guide
For systems with NVIDIA GPUs, install the NVIDIA Container Toolkit (official installation guide):
distribution=$(. /etc/os-release;echo $ID$VERSION_ID) curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg
curl -s -L https://nvidia.github.io/libnvidia-container/$distribution/libnvidia-container.list | \
sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \
sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
sudo apt update
sudo apt install -y nvidia-container-toolkit
sudo systemctl restart docker
Download the prebuilt Docker image from Docker Hub:
docker image pull staskolo/knr-drone-sim:latest
Navigate to the docker
directory and execute the setup script:
If your host has nvidia gpu:
cd docker
./setup_container_gpu.sh staskolo/knr-drone-sim:latest
If your host doesnt have nvidia gpu:
cd docker
./setup_container_cpu.sh staskolo/knr-drone-sim:latest
Once executed, you will be attached to the newly created Docker container.
Inside the container:
cd ~/ros_ws
colcon build
source install/setup.bash
To launch the Webots simulator along with required ROS2 packages:
ros2 launch drone_bringup drone_simulation.launch.py
To start the ArduPilot SITL environment, open new terminal and run the following command outside the Docker container:
./run_ardupilot_sitl.sh
First run can take a while since ardupilot will build required components.
You can now control the drone using:
- Command-line interface
- ROS2 interface
Press Ctrl + P
then Ctrl + Q
docker attach knr_drone
docker start knr_drone
docker stop knr_drone
- The
src
directory is shared between the host and the Docker container. In the container, it is located at~/ros_ws/src
. - Your development code should be placed inside this directory to be visible in the container.
- After stopping the container, its memory persists. However, if the container is removed, all data outside the shared
src
directory will be lost. - Keep everything in the
src
directory to prevent data loss.