From a21cd50e9c4cb0bb6b27f32a5f3af1b24452918e Mon Sep 17 00:00:00 2001 From: default Date: Wed, 7 Jan 2026 20:07:38 +0000 Subject: [PATCH] Fix Install Scripts --- scripts/run_ardupilot_controller.sh | 16 +++++++++++++--- setup/install_arch.sh | 8 +++++++- setup/install_ubuntu.sh | 8 +++++++- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/scripts/run_ardupilot_controller.sh b/scripts/run_ardupilot_controller.sh index 7c9c32f..a13d560 100755 --- a/scripts/run_ardupilot_controller.sh +++ b/scripts/run_ardupilot_controller.sh @@ -14,12 +14,18 @@ set -e SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" PROJECT_DIR="$(dirname "$SCRIPT_DIR")" +# Deactivate any existing virtual environment to avoid conflicts +if [ -n "$VIRTUAL_ENV" ]; then + deactivate 2>/dev/null || true +fi + # Source ArduPilot environment if [ -f "$HOME/.ardupilot_env" ]; then source "$HOME/.ardupilot_env" fi # Activate ArduPilot venv (has empy and other dependencies) +# This MUST be the active venv for sim_vehicle.py to work if [ -f "$HOME/venv-ardupilot/bin/activate" ]; then source "$HOME/venv-ardupilot/bin/activate" fi @@ -36,9 +42,13 @@ if ! command -v sim_vehicle.py &> /dev/null; then exit 1 fi -# Activate virtual environment if exists -if [ -f "$PROJECT_DIR/venv/bin/activate" ]; then - source "$PROJECT_DIR/venv/bin/activate" +# Verify correct Python environment (ArduPilot venv should have empy) +if ! python3 -c "import em" 2>/dev/null; then + echo "[WARN] empy not found in current Python environment" + echo "[INFO] Attempting to use ArduPilot venv..." + if [ -f "$HOME/venv-ardupilot/bin/activate" ]; then + source "$HOME/venv-ardupilot/bin/activate" + fi fi # Start SITL in background diff --git a/setup/install_arch.sh b/setup/install_arch.sh index ef2db3b..c397fc1 100755 --- a/setup/install_arch.sh +++ b/setup/install_arch.sh @@ -129,11 +129,17 @@ if [ -f "$HOME/.ardupilot_env" ]; then echo "[OK] ArduPilot environment" fi +# Deactivate any existing venv to avoid conflicts +if [ -n "$VIRTUAL_ENV" ]; then + deactivate 2>/dev/null || true +fi + # Activate ArduPilot venv (has empy and other dependencies) +# This is preferred over project venv for ArduPilot compatibility if [ -f "$HOME/venv-ardupilot/bin/activate" ]; then source "$HOME/venv-ardupilot/bin/activate" echo "[OK] ArduPilot venv" -# Fallback to project venv +# Fallback to project venv only if ArduPilot not installed elif [ -f "$SCRIPT_DIR/venv/bin/activate" ]; then source "$SCRIPT_DIR/venv/bin/activate" echo "[OK] Python venv activated" diff --git a/setup/install_ubuntu.sh b/setup/install_ubuntu.sh index 32e286c..c6bb84f 100755 --- a/setup/install_ubuntu.sh +++ b/setup/install_ubuntu.sh @@ -183,11 +183,17 @@ if [ -f "$HOME/.ardupilot_env" ]; then echo "[OK] ArduPilot environment" fi +# Deactivate any existing venv to avoid conflicts +if [ -n "$VIRTUAL_ENV" ]; then + deactivate 2>/dev/null || true +fi + # Activate ArduPilot venv (has empy and other dependencies) +# This is preferred over project venv for ArduPilot compatibility if [ -f "$HOME/venv-ardupilot/bin/activate" ]; then source "$HOME/venv-ardupilot/bin/activate" echo "[OK] ArduPilot venv" -# Fallback to project venv +# Fallback to project venv only if ArduPilot not installed elif [ -f "$SCRIPT_DIR/venv/bin/activate" ]; then source "$SCRIPT_DIR/venv/bin/activate" echo "[OK] Python venv"