docs: Improve quick start, ArduPilot setup, and troubleshooting, and add GPS mode option.

This commit is contained in:
2026-01-07 21:27:34 +00:00
parent 202465af99
commit 3251fc7b27
6 changed files with 350 additions and 294 deletions

View File

@@ -6,7 +6,7 @@
# Run Gazebo FIRST in another terminal!
#
# Usage:
# Terminal 1: ./scripts/run_ardupilot_sim.sh
# Terminal 1: ./scripts/run_ardupilot_sim.sh runway
# Terminal 2: ./scripts/run_ardupilot_controller.sh --pattern square
# =============================================================================
@@ -15,6 +15,10 @@ set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
# =============================================================================
# ENVIRONMENT SETUP
# =============================================================================
# Deactivate any existing venv
if [ -n "$VIRTUAL_ENV" ]; then
deactivate 2>/dev/null || true
@@ -34,7 +38,10 @@ echo " ArduPilot SITL + Controller"
echo "=============================================="
echo ""
# Check sim_vehicle.py
# =============================================================================
# CHECKS
# =============================================================================
if ! command -v sim_vehicle.py &> /dev/null; then
echo "[ERROR] sim_vehicle.py not found"
echo ""
@@ -43,7 +50,6 @@ if ! command -v sim_vehicle.py &> /dev/null; then
exit 1
fi
# Check empy
if ! python3 -c "import em" 2>/dev/null; then
echo "[ERROR] empy not found"
echo ""
@@ -52,13 +58,18 @@ if ! python3 -c "import em" 2>/dev/null; then
fi
echo "[OK] Environment ready"
echo "[INFO] Python: $(which python3)"
echo ""
# Start SITL with console
echo "[INFO] Starting SITL..."
# =============================================================================
# START SITL
# =============================================================================
echo "[INFO] Starting ArduCopter SITL..."
echo "[INFO] Make sure Gazebo is running first!"
echo ""
cd ~/ardupilot
sim_vehicle.py -v ArduCopter -f gazebo-iris --model JSON --console &
SITL_PID=$!
@@ -68,32 +79,42 @@ TRIES=0
while ! nc -z 127.0.0.1 5760 2>/dev/null; do
sleep 1
TRIES=$((TRIES + 1))
if [ $TRIES -ge 60 ]; then
echo "[ERROR] SITL timeout"
if [ $TRIES -ge 90 ]; then
echo ""
echo "[ERROR] SITL timeout (90s)"
kill $SITL_PID 2>/dev/null || true
exit 1
fi
if ! kill -0 $SITL_PID 2>/dev/null; then
echo "[ERROR] SITL died - is Gazebo running?"
echo ""
echo "[ERROR] SITL process died"
echo "[TIP] Is Gazebo running? Start it first with:"
echo " ./scripts/run_ardupilot_sim.sh runway"
exit 1
fi
echo -n "."
done
echo ""
echo "[OK] SITL ready"
echo "[OK] SITL ready on port 5760"
echo ""
# Cleanup on exit
trap "echo ''; echo '[INFO] Stopping...'; kill $SITL_PID 2>/dev/null; exit 0" INT TERM
# =============================================================================
# CLEANUP
# =============================================================================
# Wait a moment for SITL to stabilize
sleep 2
trap "echo ''; echo '[INFO] Stopping SITL...'; kill $SITL_PID 2>/dev/null; exit 0" INT TERM
# Run the controller
echo "[INFO] Starting flight controller..."
# Wait for SITL to stabilize
sleep 3
# =============================================================================
# RUN CONTROLLER
# =============================================================================
echo "[INFO] Starting drone controller..."
echo ""
cd "$PROJECT_DIR"
python scripts/run_ardupilot.py "$@"
# Cleanup
kill $SITL_PID 2>/dev/null
kill $SITL_PID 2>/dev/null || true