Scripts Update 2
This commit is contained in:
@@ -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 <file> World file to load (default: iris_runway.sdf)"
|
||||
echo " --mission <type> 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..."
|
||||
|
||||
Reference in New Issue
Block a user