Scripts Update 2
This commit is contained in:
@@ -22,22 +22,17 @@ print_error() { echo -e "${RED}[ERROR]${NC} $1"; }
|
|||||||
SOFTWARE_RENDER=false
|
SOFTWARE_RENDER=false
|
||||||
WORLD="iris_runway.sdf"
|
WORLD="iris_runway.sdf"
|
||||||
MISSION="hover" # hover, square, circle
|
MISSION="hover" # hover, square, circle
|
||||||
USE_CONSOLE=true # Show MAVProxy console by default
|
|
||||||
|
|
||||||
while [[ $# -gt 0 ]]; do
|
while [[ $# -gt 0 ]]; do
|
||||||
case $1 in
|
case $1 in
|
||||||
--software-render) SOFTWARE_RENDER=true; shift ;;
|
--software-render) SOFTWARE_RENDER=true; shift ;;
|
||||||
--world) WORLD="$2"; shift 2 ;;
|
--world) WORLD="$2"; shift 2 ;;
|
||||||
--mission) MISSION="$2"; shift 2 ;;
|
--mission) MISSION="$2"; shift 2 ;;
|
||||||
--no-console) USE_CONSOLE=false; shift ;;
|
|
||||||
--console) USE_CONSOLE=true; shift ;;
|
|
||||||
-h|--help)
|
-h|--help)
|
||||||
echo "Usage: $0 [options]"
|
echo "Usage: $0 [options]"
|
||||||
echo " --software-render Use software rendering (WSL/no GPU)"
|
echo " --software-render Use software rendering (WSL/no GPU)"
|
||||||
echo " --world <file> World file to load (default: iris_runway.sdf)"
|
echo " --world <file> World file to load (default: iris_runway.sdf)"
|
||||||
echo " --mission <type> Mission type: hover, square, circle (default: hover)"
|
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
|
exit 0
|
||||||
;;
|
;;
|
||||||
*) shift ;;
|
*) shift ;;
|
||||||
@@ -93,38 +88,38 @@ print_success "Gazebo running (PID: $GZ_PID)"
|
|||||||
print_info "Starting ArduPilot SITL..."
|
print_info "Starting ArduPilot SITL..."
|
||||||
cd ~/ardupilot
|
cd ~/ardupilot
|
||||||
|
|
||||||
# Build SITL command
|
# Build SITL command - always use --no-mavproxy for autonomous mode
|
||||||
SITL_ARGS="-v ArduCopter -f gazebo-iris --model JSON -I0"
|
# 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
|
# Add output port for external monitoring (e.g., QGroundControl on 14550)
|
||||||
if [ "$USE_CONSOLE" = true ]; then
|
SITL_ARGS="$SITL_ARGS --out 127.0.0.1:14550"
|
||||||
SITL_ARGS="$SITL_ARGS --console --map"
|
|
||||||
print_info "MAVProxy console enabled"
|
|
||||||
else
|
|
||||||
SITL_ARGS="$SITL_ARGS --no-mavproxy"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check if custom param file exists
|
# Check if custom param file exists
|
||||||
PARAM_FILE="$PROJECT_DIR/config/ardupilot_gps_denied.parm"
|
PARAM_FILE="$PROJECT_DIR/config/ardupilot_gps_denied.parm"
|
||||||
if [ -f "$PARAM_FILE" ]; then
|
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"
|
SITL_ARGS="$SITL_ARGS --add-param-file $PARAM_FILE"
|
||||||
fi
|
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
|
# Start SITL
|
||||||
sim_vehicle.py $SITL_ARGS &
|
sim_vehicle.py $SITL_ARGS &
|
||||||
SITL_PID=$!
|
SITL_PID=$!
|
||||||
|
|
||||||
# Wait longer for SITL to fully initialize
|
# Wait for SITL to initialize
|
||||||
print_info "Waiting for SITL to initialize (this takes ~20 seconds)..."
|
print_info "Waiting for SITL to initialize (~20 seconds)..."
|
||||||
sleep 20
|
sleep 20
|
||||||
|
|
||||||
# Check if SITL started
|
# Check if SITL started (check for arducopter process, not sim_vehicle.py)
|
||||||
if ! kill -0 $SITL_PID 2>/dev/null; then
|
if ! pgrep -f "arducopter" > /dev/null 2>&1; then
|
||||||
print_error "ArduPilot SITL failed to start"
|
print_error "ArduPilot SITL failed to start"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
print_success "ArduPilot SITL running (PID: $SITL_PID)"
|
print_success "ArduPilot SITL running"
|
||||||
|
|
||||||
# Step 3: Start the autonomous controller
|
# Step 3: Start the autonomous controller
|
||||||
print_info "Starting Autonomous Controller..."
|
print_info "Starting Autonomous Controller..."
|
||||||
|
|||||||
Reference in New Issue
Block a user