- 🐳 Pre-configured Docker environment with ROS2 Humble
- 🛩️ ArduPilot SITL (Software In The Loop) integration
- 🌎 Gazebo Harmonic for simulation
- 🔌 ArduPilot-Gazebo plugins and integration
- 📡 DDS middleware for ArduPilot communication
- 🏗️ Ready-to-use development workspace
- 💻 Visual Studio Code DevContainer support for seamless development
- 🐳 Docker installed on your system
- 🔄 Docker Compose installed on your system
- 🖥️ X11 server running for GUI applications (on Linux this is normally running by default)
- 💻 Visual Studio Code with Remote - Containers extension (for DevContainer support)
-
Clone this repository:
git clone https://github.com/farshidrayhancv/ROS2_ardupilot_Iris_docker.git cd ardupilot-ros2-docker
-
Build and start the container:
docker compose build docker compose up -d
-
Connect to the container:
docker compose exec ardupilot_ros bash
- Install the "Remote - Containers" extension in VS Code
- Clone this repository and open it in VS Code
- Click on the green button in the bottom-left corner of VS Code
- Select "Reopen in Container" from the menu
- VS Code will build the container and open it automatically
The DevContainer configuration is located in the .devcontainer
directory, containing:
devcontainer.json
: Configuration for VS Code integrationdocker-compose.yml
: Container configuration for the development environment
.
├── bashrc # Custom bashrc for the container
├── docker-compose.yml # Docker Compose configuration
├── Dockerfile # Docker image definition
├── entrypoint.sh # Container entrypoint script
├── install-prereqs-ubuntu.sh # ArduPilot prerequisites installer
├── instruction.sh # Additional instructions
├── ros2_gz.repos # ROS2 Gazebo repos file
├── ros2.repos # ROS2 repos file
├── workspace # Shared workspace directory
└── .devcontainer/ # VS Code DevContainer configuration
├── devcontainer.json
└── docker-compose.yml
The container includes a helper script ~/Ardupilot_ROS.sh
that provides various testing commands for ArduPilot SITL and ROS2 integration.
Run the following commands to test SITL with different options. After running, close all processes cleanly using Ctrl+C:
# Basic ArduCopter simulation
cd ~/ardupilot
./sim_vehicle.py -v ArduCopter -w
# ArduCopter with console and map
./sim_vehicle.py -v ArduCopter --console --map
# ArduCopter at San Francisco International Airport
./sim_vehicle.py -v ArduCopter -L KSFO --console --map
# ArduCopter in quadcopter configuration with console, map, and OSD
./sim_vehicle.py -v ArduCopter -f quadcopter --console --map --osd
# Launch ROS2 with SITL using DDS over UDP
cd ~/ros2_ws
source install/setup.bash
ros2 launch ardupilot_sitl sitl_dds_udp.launch.py transport:=udp4 refs:=$(ros2 pkg prefix ardupilot_sitl)/share/ardupilot_sitl/config/dds_xrce_profile.xml synthetic_clock:=True wipe:=False model:=quad speedup:=1 slave:=0 instance:=0 defaults:=$(ros2 pkg prefix ardupilot_sitl)/share/ardupilot_sitl/config/default_params/copter.parm,$(ros2 pkg prefix ardupilot_sitl)/share/ardupilot_sitl/config/default_params/dds_udp.parm sim_address:=127.0.0.1 master:=tcp:127.0.0.1:5760 sitl:=127.0.0.1:5501
Terminal 1 (Launch the container with display support):
docker run -it --user ros --network=host --ipc=host -v /tmp/.X11-unix:/tmp/.X11-unix:rw --env=DISPLAY ros_humble
cd ~/ros2_ws
source install/setup.bash
ros2 launch ardupilot_gz_bringup iris_runway.launch.py
Terminal 2 (Connect to the running container):
docker exec -it [container_name] /bin/bash
mavproxy.py --console --map --aircraft test --master=:14550
Note: Replace [container_name] with the actual container name.
The workspace comes pre-built, but if you need to rebuild:
cd ~/ros2_ws
colcon build
source install/setup.bash
The Docker container includes:
- 🤖 ROS2 Humble Desktop
- 🌎 Gazebo Harmonic
- 🚁 ArduPilot source code with SITL capabilities
- 📡 MAVProxy
- 🔄 Micro-XRCE-DDS-Gen for DDS communication
- 📦 All ROS2 packages needed for ArduPilot-ROS2 integration
- 🔌 ROS2-Gazebo bridges and plugins
-
Source the workspace: Always remember to source the workspace setup file before running ROS2 commands:
source ~/ros2_ws/install/setup.bash
-
Customizing ArduPilot parameters: You can modify the default parameters in the
ros2_ws/src/ardupilot_sitl/config/default_params/
directory. -
Using tmuxinator: A tmuxinator configuration is included for managing multiple terminal sessions:
tmuxinator start -p ~/tmuxinator.yml
-
Debugging: To debug ROS2 nodes, you can use:
ros2 run --prefix 'gdb -ex run --args' package_name node_name
You can modify the Dockerfile
to add additional dependencies or change the build configuration.
-
❌ X11 Display Issues: If GUI applications don't appear, check that your X11 server is properly configured. You may need to run
xhost +local:docker
on the host. -
⚠️ Permission Issues: Ensure the USER_UID and USER_GID in the docker-compose.yml match your host system:echo "UID: $(id -u), GID: $(id -g)"
-
🔄 DevContainer Issues: Check that your Docker is properly configured and that the Remote - Containers extension is up to date.
-
📦 ROS2 Package Not Found: If you get package not found errors, make sure you've sourced the workspace:
source ~/ros2_ws/install/setup.bash
-
🌎 Gazebo Models Not Loading: Set the GAZEBO_MODEL_PATH environment variable:
export GAZEBO_MODEL_PATH=$GAZEBO_MODEL_PATH:~/ros2_ws/src/ardupilot_gz/models
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- 🚁 ArduPilot - ArduPilot project
- 🤖 ROS2 - ROS2 Humble documentation
- 🌎 Gazebo - Gazebo simulation platform
- 🔌 ArduPilot-Gazebo-ROS2 Integration - ArduPilot Gazebo integration