removed potentially faulty environment detection in favor of explicit setting

This commit is contained in:
2026-02-01 11:34:35 -08:00
parent 79b03345ba
commit f6e1f13bb5
19 changed files with 64 additions and 40 deletions

View File

@@ -41,22 +41,19 @@ def load_config():
return yaml.safe_load(f)
def detect_environment():
"""Detect whether we're on the AERPAW testbed or running locally."""
# Check for AERPAW_ENV environment variable first
def get_environment():
"""Get environment from AERPAW_ENV variable. Fails if not set."""
env = os.environ.get('AERPAW_ENV')
if env in ('local', 'testbed'):
return env
# Auto-detect based on network (testbed uses 192.168.122.x)
import subprocess
try:
result = subprocess.run(['ip', 'addr'], capture_output=True, text=True, timeout=5)
if '192.168.122' in result.stdout:
return 'testbed'
except Exception:
pass
return 'local'
if env is None:
raise RuntimeError(
"AERPAW_ENV environment variable not set. "
"Set to 'local' or 'testbed', or use: ./run_uav.sh [local|testbed]"
)
if env not in ('local', 'testbed'):
raise RuntimeError(
f"Invalid AERPAW_ENV '{env}'. Must be 'local' or 'testbed'."
)
return env
def parse_target(message: str):
@@ -74,7 +71,7 @@ class UAVRunner(BasicRunner):
def initialize_args(self, extra_args):
"""Load configuration from YAML config file."""
config = load_config()
env = detect_environment()
env = get_environment()
print(f"[UAV] Environment: {env}")
# Load origin

View File

@@ -1,11 +1,10 @@
#!/bin/bash
# run_uav.sh - Auto-detecting wrapper for UAV runner
# Detects testbed vs local environment and launches with appropriate connection
# run_uav.sh - Wrapper for UAV runner
# Launches UAV client with environment-specific configuration
#
# Usage:
# ./run_uav.sh # Auto-detect and run
# ./run_uav.sh testbed # Force testbed mode
# ./run_uav.sh local # Force local mode
# ./run_uav.sh local # Use local/simulation configuration
# ./run_uav.sh testbed # Use AERPAW testbed configuration
set -e
@@ -17,30 +16,22 @@ if [ -d "venv" ]; then
source venv/bin/activate
fi
# Function to check if we're in testbed environment
check_testbed() {
ip addr | grep -q "192.168.122"
return $?
}
# Determine environment based on argument or auto-detection
# Determine environment from argument (required)
if [ "$1" = "testbed" ]; then
ENV="testbed"
echo "[run_uav] Forced testbed mode"
elif [ "$1" = "local" ]; then
ENV="local"
echo "[run_uav] Forced local mode"
else
echo "[run_uav] Auto-detecting environment..."
if check_testbed; then
ENV="testbed"
echo "[run_uav] Testbed detected"
else
ENV="local"
echo "[run_uav] Local mode"
fi
echo "Error: Environment not specified."
echo "Usage: $0 [local|testbed]"
echo ""
echo " local - Use local/simulation configuration"
echo " testbed - Use AERPAW testbed configuration"
exit 1
fi
echo "[run_uav] Environment: $ENV"
# Export environment for Python to use
export AERPAW_ENV="$ENV"

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Info>
<Category UUID="FileClassCategory">
<Label UUID="design"/>
</Category>
</Info>

View File

@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<Info location="tmwtypes.h" type="File"/>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Info>
<Category UUID="FileClassCategory">
<Label UUID="design"/>
</Category>
</Info>

View File

@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<Info location="loadTargetsFromYaml.m" type="File"/>

View File

@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<Info location="controller.coderprj" type="File"/>

View File

@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<Info/>

View File

@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<Info location="compile.sh" type="File"/>

View File

@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<Info/>

View File

@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<Info location="run_uav.sh" type="File"/>

View File

@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<Info/>

View File

@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<Info location="uav_runner.py" type="File"/>

View File

@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<Info/>

View File

@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<Info location=".gitmodules" type="File"/>

View File

@@ -1,2 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<Info location="targets.txt" type="File"/>

View File

@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<Info/>

View File

@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<Info location="config.yaml" type="File"/>