removed potentially faulty environment detection in favor of explicit setting
This commit is contained in:
@@ -41,22 +41,19 @@ def load_config():
|
|||||||
return yaml.safe_load(f)
|
return yaml.safe_load(f)
|
||||||
|
|
||||||
|
|
||||||
def detect_environment():
|
def get_environment():
|
||||||
"""Detect whether we're on the AERPAW testbed or running locally."""
|
"""Get environment from AERPAW_ENV variable. Fails if not set."""
|
||||||
# Check for AERPAW_ENV environment variable first
|
|
||||||
env = os.environ.get('AERPAW_ENV')
|
env = os.environ.get('AERPAW_ENV')
|
||||||
if env in ('local', 'testbed'):
|
if env is None:
|
||||||
return env
|
raise RuntimeError(
|
||||||
|
"AERPAW_ENV environment variable not set. "
|
||||||
# Auto-detect based on network (testbed uses 192.168.122.x)
|
"Set to 'local' or 'testbed', or use: ./run_uav.sh [local|testbed]"
|
||||||
import subprocess
|
)
|
||||||
try:
|
if env not in ('local', 'testbed'):
|
||||||
result = subprocess.run(['ip', 'addr'], capture_output=True, text=True, timeout=5)
|
raise RuntimeError(
|
||||||
if '192.168.122' in result.stdout:
|
f"Invalid AERPAW_ENV '{env}'. Must be 'local' or 'testbed'."
|
||||||
return 'testbed'
|
)
|
||||||
except Exception:
|
return env
|
||||||
pass
|
|
||||||
return 'local'
|
|
||||||
|
|
||||||
|
|
||||||
def parse_target(message: str):
|
def parse_target(message: str):
|
||||||
@@ -74,7 +71,7 @@ class UAVRunner(BasicRunner):
|
|||||||
def initialize_args(self, extra_args):
|
def initialize_args(self, extra_args):
|
||||||
"""Load configuration from YAML config file."""
|
"""Load configuration from YAML config file."""
|
||||||
config = load_config()
|
config = load_config()
|
||||||
env = detect_environment()
|
env = get_environment()
|
||||||
print(f"[UAV] Environment: {env}")
|
print(f"[UAV] Environment: {env}")
|
||||||
|
|
||||||
# Load origin
|
# Load origin
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# run_uav.sh - Auto-detecting wrapper for UAV runner
|
# run_uav.sh - Wrapper for UAV runner
|
||||||
# Detects testbed vs local environment and launches with appropriate connection
|
# Launches UAV client with environment-specific configuration
|
||||||
#
|
#
|
||||||
# Usage:
|
# Usage:
|
||||||
# ./run_uav.sh # Auto-detect and run
|
# ./run_uav.sh local # Use local/simulation configuration
|
||||||
# ./run_uav.sh testbed # Force testbed mode
|
# ./run_uav.sh testbed # Use AERPAW testbed configuration
|
||||||
# ./run_uav.sh local # Force local mode
|
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
@@ -17,30 +16,22 @@ if [ -d "venv" ]; then
|
|||||||
source venv/bin/activate
|
source venv/bin/activate
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Function to check if we're in testbed environment
|
# Determine environment from argument (required)
|
||||||
check_testbed() {
|
|
||||||
ip addr | grep -q "192.168.122"
|
|
||||||
return $?
|
|
||||||
}
|
|
||||||
|
|
||||||
# Determine environment based on argument or auto-detection
|
|
||||||
if [ "$1" = "testbed" ]; then
|
if [ "$1" = "testbed" ]; then
|
||||||
ENV="testbed"
|
ENV="testbed"
|
||||||
echo "[run_uav] Forced testbed mode"
|
|
||||||
elif [ "$1" = "local" ]; then
|
elif [ "$1" = "local" ]; then
|
||||||
ENV="local"
|
ENV="local"
|
||||||
echo "[run_uav] Forced local mode"
|
|
||||||
else
|
else
|
||||||
echo "[run_uav] Auto-detecting environment..."
|
echo "Error: Environment not specified."
|
||||||
if check_testbed; then
|
echo "Usage: $0 [local|testbed]"
|
||||||
ENV="testbed"
|
echo ""
|
||||||
echo "[run_uav] Testbed detected"
|
echo " local - Use local/simulation configuration"
|
||||||
else
|
echo " testbed - Use AERPAW testbed configuration"
|
||||||
ENV="local"
|
exit 1
|
||||||
echo "[run_uav] Local mode"
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo "[run_uav] Environment: $ENV"
|
||||||
|
|
||||||
# Export environment for Python to use
|
# Export environment for Python to use
|
||||||
export AERPAW_ENV="$ENV"
|
export AERPAW_ENV="$ENV"
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Info>
|
||||||
|
<Category UUID="FileClassCategory">
|
||||||
|
<Label UUID="design"/>
|
||||||
|
</Category>
|
||||||
|
</Info>
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Info location="tmwtypes.h" type="File"/>
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Info>
|
||||||
|
<Category UUID="FileClassCategory">
|
||||||
|
<Label UUID="design"/>
|
||||||
|
</Category>
|
||||||
|
</Info>
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Info location="loadTargetsFromYaml.m" type="File"/>
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Info location="controller.coderprj" type="File"/>
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Info/>
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Info location="compile.sh" type="File"/>
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Info/>
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Info location="run_uav.sh" type="File"/>
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Info/>
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Info location="uav_runner.py" type="File"/>
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Info/>
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Info location=".gitmodules" type="File"/>
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<Info location="targets.txt" type="File"/>
|
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Info/>
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Info location="config.yaml" type="File"/>
|
||||||
Reference in New Issue
Block a user