From 347a5cc4f895714d01e37597ae3dbebe5f465069 Mon Sep 17 00:00:00 2001 From: default Date: Mon, 9 Feb 2026 06:06:07 +0000 Subject: [PATCH] Scripts Update 2 --- scripts/run_autonomous.sh | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/scripts/run_autonomous.sh b/scripts/run_autonomous.sh index 5587efe..b029a28 100755 --- a/scripts/run_autonomous.sh +++ b/scripts/run_autonomous.sh @@ -22,22 +22,17 @@ print_error() { echo -e "${RED}[ERROR]${NC} $1"; } SOFTWARE_RENDER=false WORLD="iris_runway.sdf" MISSION="hover" # hover, square, circle -USE_CONSOLE=true # Show MAVProxy console by default while [[ $# -gt 0 ]]; do case $1 in --software-render) SOFTWARE_RENDER=true; shift ;; --world) WORLD="$2"; shift 2 ;; --mission) MISSION="$2"; shift 2 ;; - --no-console) USE_CONSOLE=false; shift ;; - --console) USE_CONSOLE=true; shift ;; -h|--help) echo "Usage: $0 [options]" echo " --software-render Use software rendering (WSL/no GPU)" echo " --world World file to load (default: iris_runway.sdf)" echo " --mission Mission type: hover, square, circle (default: hover)" - echo " --console Show MAVProxy console (default: on)" - echo " --no-console Hide MAVProxy console" exit 0 ;; *) shift ;; @@ -93,38 +88,38 @@ print_success "Gazebo running (PID: $GZ_PID)" print_info "Starting ArduPilot SITL..." cd ~/ardupilot -# Build SITL command -SITL_ARGS="-v ArduCopter -f gazebo-iris --model JSON -I0" +# Build SITL command - always use --no-mavproxy for autonomous mode +# Our controller connects directly to SITL on port 5760 +# MAVProxy console conflicts with our controller's connection +SITL_ARGS="-v ArduCopter -f gazebo-iris --model JSON -I0 --no-mavproxy" -# Add console/map if requested -if [ "$USE_CONSOLE" = true ]; then - SITL_ARGS="$SITL_ARGS --console --map" - print_info "MAVProxy console enabled" -else - SITL_ARGS="$SITL_ARGS --no-mavproxy" -fi +# Add output port for external monitoring (e.g., QGroundControl on 14550) +SITL_ARGS="$SITL_ARGS --out 127.0.0.1:14550" # Check if custom param file exists PARAM_FILE="$PROJECT_DIR/config/ardupilot_gps_denied.parm" if [ -f "$PARAM_FILE" ]; then - print_info "Loading GPS-denied parameters..." + print_info "Loading custom parameters..." SITL_ARGS="$SITL_ARGS --add-param-file $PARAM_FILE" fi +print_info "SITL will output status to this terminal" +print_info "Connect GCS to udp:127.0.0.1:14550 for monitoring" + # Start SITL sim_vehicle.py $SITL_ARGS & SITL_PID=$! -# Wait longer for SITL to fully initialize -print_info "Waiting for SITL to initialize (this takes ~20 seconds)..." +# Wait for SITL to initialize +print_info "Waiting for SITL to initialize (~20 seconds)..." sleep 20 -# Check if SITL started -if ! kill -0 $SITL_PID 2>/dev/null; then +# Check if SITL started (check for arducopter process, not sim_vehicle.py) +if ! pgrep -f "arducopter" > /dev/null 2>&1; then print_error "ArduPilot SITL failed to start" exit 1 fi -print_success "ArduPilot SITL running (PID: $SITL_PID)" +print_success "ArduPilot SITL running" # Step 3: Start the autonomous controller print_info "Starting Autonomous Controller..."