Files
RDC_Simulation/docker-compose.yml
2026-02-05 19:09:24 +00:00

133 lines
4.2 KiB
YAML
Executable File

# =============================================================================
# RDC Simulation - Docker Compose (Software Rendering / Stability Mode)
# =============================================================================
# Reverted to Software Rendering (llvmpipe) to guarantee visible GUI.
# - GPU acceleration is notoriously unstable on NVIDIA+Wayland Docker.
# - This config ensures the simulation window works so mission logic can be tested.
# =============================================================================
x-common: &common
image: rdc-simulation:latest
build:
context: .
dockerfile: Dockerfile
# GPU Configuration: STRICT NVIDIA (2026 Guide)
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: 1
capabilities: [ gpu ]
environment:
# Display Settings (PURE X11/XCB Bypass)
&common-env
- DISPLAY=${DISPLAY:-:0}
# Removed WAYLAND_DISPLAY to strictly force X11 path
# - WAYLAND_DISPLAY=${WAYLAND_DISPLAY:-wayland-0}
- XDG_RUNTIME_DIR=/tmp
# Platform: XCB (X11) for stability on Wayland
- QT_QPA_PLATFORM=xcb
- QT_X11_NO_MITSHM=1
# Network: Force Localhost (Fixes "Empty World" black screen)
- GZ_IP=127.0.0.1
- GZ_PARTITION=sim_partition
# NVIDIA DRIVERS: FORCE GPU 0 (The one running kwin_wayland)
- NVIDIA_VISIBLE_DEVICES=0
- NVIDIA_DRIVER_CAPABILITIES=all
# Force NVIDIA EGL/GLX
- __NV_PRIME_RENDER_OFFLOAD=1
- __GLX_VENDOR_LIBRARY_NAME=nvidia
- __EGL_VENDOR_LIBRARY_FILENAMES=/usr/share/glvnd/egl_vendor.d/10_nvidia.json
# Ogre Fixes
- OGRE_RTT_MODE=Copy
# Prevent software fallback
- LIBGL_ALWAYS_SOFTWARE=0
# Gazebo/ArduPilot Extensions
- GZ_SIM_SYSTEM_PLUGIN_PATH=/home/pilot/ardupilot_gazebo/build
- GZ_SIM_RESOURCE_PATH=/home/pilot/ardupilot_gazebo/models:/home/pilot/ardupilot_gazebo/worlds:/home/pilot/RDC_Simulation/gazebo/models
# Mounts
volumes:
# X11 Socket ONLY (Bypassing Wayland socket)
- /tmp/.X11-unix:/tmp/.X11-unix:rw
# Wayland Socket (Removed for strict X11)
# - ${XDG_RUNTIME_DIR:-/run/user/1000}/${WAYLAND_DISPLAY:-wayland-0}:/tmp/${WAYLAND_DISPLAY:-wayland-0}:rw
# GPU Access
- /dev/dri:/dev/dri:rw
network_mode: host
user: "1000:1000"
stdin_open: true
tty: true
working_dir: /home/pilot/RDC_Simulation
services:
# Service 1: Gazebo
gazebo:
<<: *common
container_name: rdc-gazebo
entrypoint: [ "/bin/bash", "-c" ]
command:
- |
echo "Starting Gazebo (Software Rendering)..."
source /opt/ros/jazzy/setup.bash
source ~/.bashrc
export GZ_SIM_SYSTEM_PLUGIN_PATH=/home/pilot/ardupilot_gazebo/build
export GZ_SIM_RESOURCE_PATH=/home/pilot/ardupilot_gazebo/models:/home/pilot/ardupilot_gazebo/worlds:/home/pilot/RDC_Simulation/gazebo/models
cd /home/pilot/RDC_Simulation
gz sim -r /home/pilot/ardupilot_gazebo/worlds/iris_runway.sdf
healthcheck:
test: [ "CMD-SHELL", "pgrep -x gz || exit 1" ]
interval: 5s
timeout: 10s
retries: 30
# Service 2: SITL
sitl:
<<: *common
container_name: rdc-sitl
depends_on:
gazebo:
condition: service_started
entrypoint: [ "/bin/bash", "-c" ]
command:
- |
echo "Waiting for Gazebo..."
for i in {1..60}; do nc -z localhost 9002 2>/dev/null && break; sleep 2; done
echo "Starting ArduPilot SITL..."
cd /home/pilot/ardupilot
sim_vehicle.py -v ArduCopter -f gazebo-iris --model JSON --console --map
# Service 3: Controller
controller:
<<: *common
container_name: rdc-controller
depends_on:
sitl:
condition: service_started
entrypoint: [ "/bin/bash", "-c" ]
command:
- |
echo "Waiting for SITL..."
for i in {1..90}; do nc -z localhost 14550 2>/dev/null && break; sleep 2; done
sleep 10
echo "Starting Mission..."
source /home/pilot/RDC_Simulation/venv/bin/activate
cd /home/pilot/RDC_Simulation
python scripts/run_ardupilot.py --pattern square
# Debug Shell
simulation:
<<: *common
container_name: rdc-sim
entrypoint: [ "/home/pilot/docker-entrypoint.sh" ]
command: [ "bash" ]