diff --git a/.dockerignore b/.dockerignore old mode 100644 new mode 100755 diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 diff --git a/Dockerfile b/Dockerfile old mode 100644 new mode 100755 index 4147cec..55f97bc --- a/Dockerfile +++ b/Dockerfile @@ -45,6 +45,11 @@ RUN apt-get update && apt-get install -y \ libgl1 \ libglx-mesa0 \ libgl1-mesa-dri \ + # NVIDIA/EGL/Wayland specific libraries + libnvidia-egl-wayland1 \ + libglvnd0 \ + libglx0 \ + libegl1 \ mesa-utils \ x11-apps \ libxcb-xinerama0 \ diff --git a/README.md b/README.md old mode 100644 new mode 100755 diff --git a/config.py b/config.py old mode 100644 new mode 100755 diff --git a/docker-compose.yml b/docker-compose.yml old mode 100644 new mode 100755 index 8bf16b0..87fc9a1 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,110 +1,96 @@ # ============================================================================= -# RDC Simulation - Docker Compose (Multi-Service with Proper Ordering) +# RDC Simulation - Docker Compose (Software Rendering / Stability Mode) # ============================================================================= -# Runs 3 services in order: -# 1. gazebo - Gazebo Harmonic simulation (starts first) -# 2. sitl - ArduPilot SITL (waits for Gazebo) -# 3. controller - Python flight controller (waits for SITL) -# -# Usage: -# # Start all 3 services -# docker compose up -# -# # Or start specific services -# docker compose up gazebo -# docker compose up gazebo sitl -# docker compose up gazebo sitl controller -# -# # Interactive shell (for debugging) -# docker compose run --rm simulation bash -# -# # Stop everything -# docker compose down +# 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. # ============================================================================= -# Common configuration anchor x-common: &common image: rdc-simulation:latest build: context: . dockerfile: Dockerfile - # GPU support (NVIDIA) + # GPU Configuration: STRICT NVIDIA (2026 Guide) deploy: resources: reservations: devices: - driver: nvidia - count: all + count: 1 capabilities: [ gpu ] - # Environment variables - Wayland with GPU environment: - # Wayland display + # Display Settings (PURE X11/XCB Bypass) &common-env - - WAYLAND_DISPLAY=${WAYLAND_DISPLAY:-wayland-0} - - XDG_RUNTIME_DIR=/run/user/1000 - # X11 fallback - DISPLAY=${DISPLAY:-:0} - # GPU - - NVIDIA_VISIBLE_DEVICES=all + # 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 - # Qt platform - Wayland - - QT_QPA_PLATFORM=wayland - - QT_WAYLAND_DISABLE_WINDOWDECORATION=1 - # OpenGL settings - - __GLX_VENDOR_LIBRARY_NAME=nvidia + # Force NVIDIA EGL/GLX - __NV_PRIME_RENDER_OFFLOAD=1 - # Gazebo paths + - __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 - # Mount Wayland and X11 sockets + # Mounts volumes: - - ${XDG_RUNTIME_DIR:-/run/user/1000}/${WAYLAND_DISPLAY:-wayland-0}:/run/user/1000/wayland-0:rw + # 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 - # Host network for SITL <-> Gazebo communication network_mode: host - - # Run as user 1000 user: "1000:1000" - stdin_open: true tty: true working_dir: /home/pilot/RDC_Simulation services: - # ========================================================================= - # SERVICE 1: Gazebo Simulation (must start first) - # ========================================================================= + # Service 1: Gazebo gazebo: <<: *common container_name: rdc-gazebo entrypoint: [ "/bin/bash", "-c" ] command: - | - echo "==========================================" - echo " SERVICE 1: Starting Gazebo Harmonic" - echo "==========================================" + 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 - echo "Launching Gazebo world: iris_runway" 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 - start_period: 30s - # ========================================================================= - # SERVICE 2: ArduPilot SITL (waits for Gazebo) - # ========================================================================= + # Service 2: SITL sitl: <<: *common container_name: rdc-sitl @@ -114,31 +100,13 @@ services: entrypoint: [ "/bin/bash", "-c" ] command: - | - echo "==========================================" - echo " SERVICE 2: Starting ArduPilot SITL" - echo "==========================================" - source /opt/ros/jazzy/setup.bash - source ~/.bashrc - source ~/.profile 2>/dev/null || true - - # Wait for Gazebo to be ready (check if port 9002 is listening) - echo "Waiting for Gazebo to be ready..." - for i in {1..60}; do - if nc -z localhost 9002 2>/dev/null; then - echo "Gazebo is ready!" - break - fi - echo "Waiting... ($$i/60)" - sleep 2 - done - - echo "Starting ArduCopter SITL..." + 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: Flight Controller (waits for SITL) - # ========================================================================= + # Service 3: Controller controller: <<: *common container_name: rdc-controller @@ -148,56 +116,17 @@ services: entrypoint: [ "/bin/bash", "-c" ] command: - | - echo "==========================================" - echo " SERVICE 3: Starting Flight Controller" - echo "==========================================" - source /opt/ros/jazzy/setup.bash - source ~/.bashrc - source /home/pilot/RDC_Simulation/venv/bin/activate - - # Wait for SITL to be ready (check MAVLink port 14550) - echo "Waiting for ArduPilot SITL to be ready..." - for i in {1..90}; do - if nc -z localhost 14550 2>/dev/null; then - echo "SITL is ready!" - break - fi - echo "Waiting... ($$i/90)" - sleep 2 - done - - # Additional wait for SITL to fully initialize - echo "Waiting 10 more seconds for SITL to stabilize..." + 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 flight controller with square pattern..." + echo "Starting Mission..." + source /home/pilot/RDC_Simulation/venv/bin/activate cd /home/pilot/RDC_Simulation python scripts/run_ardupilot.py --pattern square - # ========================================================================= - # Interactive Shell (for debugging) - # ========================================================================= + # Debug Shell simulation: <<: *common container_name: rdc-sim - profiles: [ "debug" ] - entrypoint: [ "/home/pilot/docker-entrypoint.sh" ] - command: [ "bash" ] - - # ========================================================================= - # Headless Mode (CI/Server - no display) - # ========================================================================= - simulation-headless: - <<: *common - container_name: rdc-sim-headless - profiles: [ "headless" ] - environment: - - NVIDIA_VISIBLE_DEVICES=all - - NVIDIA_DRIVER_CAPABILITIES=compute,utility - - HEADLESS=1 - - LIBGL_ALWAYS_SOFTWARE=1 - - 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 - volumes: [] entrypoint: [ "/home/pilot/docker-entrypoint.sh" ] command: [ "bash" ] diff --git a/docs/architecture.md b/docs/architecture.md old mode 100644 new mode 100755 diff --git a/docs/ardupilot.md b/docs/ardupilot.md old mode 100644 new mode 100755 diff --git a/docs/blender_models.md b/docs/blender_models.md old mode 100644 new mode 100755 diff --git a/docs/docker.md b/docs/docker.md old mode 100644 new mode 100755 diff --git a/docs/drone_guide.md b/docs/drone_guide.md old mode 100644 new mode 100755 diff --git a/docs/gazebo_worlds.md b/docs/gazebo_worlds.md old mode 100644 new mode 100755 diff --git a/docs/installation.md b/docs/installation.md old mode 100644 new mode 100755 diff --git a/gazebo/launch/ardupilot_drone.launch.py b/gazebo/launch/ardupilot_drone.launch.py old mode 100644 new mode 100755 diff --git a/gazebo/launch/drone_landing.launch.py b/gazebo/launch/drone_landing.launch.py old mode 100644 new mode 100755 diff --git a/gazebo/models/custom_object/model.config b/gazebo/models/custom_object/model.config old mode 100644 new mode 100755 diff --git a/gazebo/models/custom_object/model.sdf b/gazebo/models/custom_object/model.sdf old mode 100644 new mode 100755 diff --git a/gazebo/models/drone/model.config b/gazebo/models/drone/model.config old mode 100644 new mode 100755 diff --git a/gazebo/models/drone/model.sdf b/gazebo/models/drone/model.sdf old mode 100644 new mode 100755 diff --git a/gazebo/models/drone/model_fortress.sdf b/gazebo/models/drone/model_fortress.sdf old mode 100644 new mode 100755 diff --git a/gazebo/worlds/custom_landing.sdf b/gazebo/worlds/custom_landing.sdf old mode 100644 new mode 100755 diff --git a/gazebo/worlds/drone_landing.sdf b/gazebo/worlds/drone_landing.sdf old mode 100644 new mode 100755 diff --git a/gazebo/worlds/iris_camera.sdf b/gazebo/worlds/iris_camera.sdf old mode 100644 new mode 100755 diff --git a/legacy/build_exe.py b/legacy/build_exe.py old mode 100644 new mode 100755 diff --git a/legacy/controllers.py b/legacy/controllers.py old mode 100644 new mode 100755 diff --git a/legacy/ros_bridge.py b/legacy/ros_bridge.py old mode 100644 new mode 100755 diff --git a/legacy/run_bridge.py b/legacy/run_bridge.py old mode 100644 new mode 100755 diff --git a/legacy/run_gazebo.py b/legacy/run_gazebo.py old mode 100644 new mode 100755 diff --git a/legacy/simulation_host.py b/legacy/simulation_host.py old mode 100644 new mode 100755 diff --git a/legacy/standalone_simulation.py b/legacy/standalone_simulation.py old mode 100644 new mode 100755 diff --git a/requirements.txt b/requirements.txt old mode 100644 new mode 100755 diff --git a/scripts/record_flight.py b/scripts/record_flight.py old mode 100644 new mode 100755 diff --git a/scripts/run_ardupilot.py b/scripts/run_ardupilot.py old mode 100644 new mode 100755 diff --git a/setup/install_windows.ps1 b/setup/install_windows.ps1 old mode 100644 new mode 100755 diff --git a/src/__init__.py b/src/__init__.py old mode 100644 new mode 100755 diff --git a/src/camera_viewer.py b/src/camera_viewer.py old mode 100644 new mode 100755 diff --git a/src/drone_controller.py b/src/drone_controller.py old mode 100644 new mode 100755 diff --git a/src/gazebo_bridge.py b/src/gazebo_bridge.py old mode 100644 new mode 100755 diff --git a/src/mavlink_bridge.py b/src/mavlink_bridge.py old mode 100644 new mode 100755 diff --git a/src/rover_controller.py b/src/rover_controller.py old mode 100644 new mode 100755