BashRC Install Script Fixes

This commit is contained in:
2026-01-10 21:56:17 +00:00
parent 8dfc7c2241
commit 89cc3f403c
2 changed files with 8 additions and 63 deletions

View File

@@ -48,10 +48,10 @@ for arg in "$@"; do
done done
if [ "$INSTALL_ARDUPILOT" = true ]; then if [ "$INSTALL_ARDUPILOT" = true ]; then
TOTAL_STEPS=10 TOTAL_STEPS=9
echo "[INFO] Full installation with ArduPilot SITL" echo "[INFO] Full installation with ArduPilot SITL"
else else
TOTAL_STEPS=7 TOTAL_STEPS=6
echo "[INFO] Basic installation (no ArduPilot)" echo "[INFO] Basic installation (no ArduPilot)"
fi fi
echo "" echo ""
@@ -318,33 +318,6 @@ if [ "$INSTALL_ARDUPILOT" = true ]; then
echo "[OK] ArduPilot Gazebo plugin built" echo "[OK] ArduPilot Gazebo plugin built"
# =========================================================================
# STEP 10: Configure Environment
# =========================================================================
echo ""
echo "[STEP 10/$TOTAL_STEPS] Configuring shell environment..."
BASHRC_MARKER="# === RDC Simulation ArduPilot ==="
if ! grep -q "$BASHRC_MARKER" ~/.bashrc; then
cat >> ~/.bashrc << EOF
$BASHRC_MARKER
# Source ArduPilot environment
if [ -f ~/.ardupilot_env ]; then
source ~/.ardupilot_env
fi
export ARDUPILOT_HOME=$ARDUPILOT_HOME
export PATH=\$PATH:$ARDUPILOT_HOME/Tools/autotest
export PATH=\$PATH:\$HOME/.local/bin
export GZ_SIM_SYSTEM_PLUGIN_PATH=$ARDUPILOT_GZ/build:\$GZ_SIM_SYSTEM_PLUGIN_PATH
export GZ_SIM_RESOURCE_PATH=$ARDUPILOT_GZ/models:$ARDUPILOT_GZ/worlds:\$GZ_SIM_RESOURCE_PATH
EOF
echo "[OK] Added ArduPilot configuration to ~/.bashrc"
else
echo "[OK] ArduPilot configuration already in ~/.bashrc"
fi
# Install MAVProxy # Install MAVProxy
pip3 install --user pymavlink mavproxy pexpect pip3 install --user pymavlink mavproxy pexpect
@@ -352,7 +325,6 @@ EOF
echo "" echo ""
echo "Verifying ArduPilot installation..." echo "Verifying ArduPilot installation..."
source ~/.bashrc 2>/dev/null || true
export PATH=$PATH:$ARDUPILOT_HOME/Tools/autotest:$HOME/.local/bin export PATH=$PATH:$ARDUPILOT_HOME/Tools/autotest:$HOME/.local/bin
command -v sim_vehicle.py &> /dev/null && echo "[OK] sim_vehicle.py" || echo "[WARN] sim_vehicle.py not found" command -v sim_vehicle.py &> /dev/null && echo "[OK] sim_vehicle.py" || echo "[WARN] sim_vehicle.py not found"
@@ -371,17 +343,16 @@ echo "=============================================="
echo "" echo ""
if [ "$INSTALL_ARDUPILOT" = true ]; then if [ "$INSTALL_ARDUPILOT" = true ]; then
echo "IMPORTANT: Run this command to reload your environment:"
echo " source ~/.bashrc"
echo ""
echo "Quick Start (3 terminals):" echo "Quick Start (3 terminals):"
echo "" echo ""
echo "Terminal 1 - Start Gazebo:" echo "Terminal 1 - Start Gazebo:"
echo " cd ~/RDC_Simulation" echo " cd ~/RDC_Simulation"
echo " source activate.sh"
echo " ./scripts/run_ardupilot_sim.sh runway" echo " ./scripts/run_ardupilot_sim.sh runway"
echo "" echo ""
echo "Terminal 2 - Start ArduCopter SITL:" echo "Terminal 2 - Start ArduCopter SITL:"
echo " source ~/.bashrc" echo " cd ~/RDC_Simulation"
echo " source activate.sh"
echo " sim_vehicle.py -v ArduCopter -f gazebo-iris --model JSON --console" echo " sim_vehicle.py -v ArduCopter -f gazebo-iris --model JSON --console"
echo "" echo ""
echo "Terminal 3 - Run Controller:" echo "Terminal 3 - Run Controller:"

View File

@@ -56,7 +56,7 @@ for arg in "$@"; do
echo " - ~/ardupilot_gazebo (ArduPilot Gazebo plugin)" echo " - ~/ardupilot_gazebo (ArduPilot Gazebo plugin)"
echo " - Project venv/ directory" echo " - Project venv/ directory"
echo " - Project activate.sh" echo " - Project activate.sh"
echo " - ArduPilot configuration from ~/.bashrc" echo " - ~/.ardupilot_env (ArduPilot environment file)"
echo "" echo ""
echo "What is NOT removed:" echo "What is NOT removed:"
echo " - ROS 2 (use: sudo apt remove 'ros-*')" echo " - ROS 2 (use: sudo apt remove 'ros-*')"
@@ -139,30 +139,7 @@ remove_activate() {
fi fi
} }
# =============================================================================
# REMOVE BASHRC CONFIGURATION
# =============================================================================
remove_bashrc_config() {
BASHRC_MARKER="# === RDC Simulation ArduPilot ==="
OLD_MARKER="# === ArduPilot SITL ==="
if grep -q "$BASHRC_MARKER" ~/.bashrc 2>/dev/null || grep -q "$OLD_MARKER" ~/.bashrc 2>/dev/null; then
echo "[INFO] Removing ArduPilot configuration from ~/.bashrc"
# Create backup
cp ~/.bashrc ~/.bashrc.backup.$(date +%Y%m%d_%H%M%S)
# Remove the configuration block (everything from marker to next blank line or EOF)
# This handles both old and new markers
sed -i "/$BASHRC_MARKER/,/^$/d" ~/.bashrc 2>/dev/null || true
sed -i "/$OLD_MARKER/,/^$/d" ~/.bashrc 2>/dev/null || true
echo "[OK] ArduPilot configuration removed from ~/.bashrc"
echo "[INFO] Backup saved to ~/.bashrc.backup.*"
else
echo "[SKIP] No ArduPilot configuration found in ~/.bashrc"
fi
}
# ============================================================================= # =============================================================================
# REMOVE ARDUPILOT ENV FILE # REMOVE ARDUPILOT ENV FILE
@@ -188,7 +165,6 @@ if [ "$REMOVE_ALL" = true ]; then
remove_ardupilot_gazebo remove_ardupilot_gazebo
remove_venv remove_venv
remove_activate remove_activate
remove_bashrc_config
remove_ardupilot_env remove_ardupilot_env
elif [ "$REMOVE_ARDUPILOT" = true ]; then elif [ "$REMOVE_ARDUPILOT" = true ]; then
@@ -196,7 +172,6 @@ elif [ "$REMOVE_ARDUPILOT" = true ]; then
echo "" echo ""
remove_ardupilot remove_ardupilot
remove_ardupilot_gazebo remove_ardupilot_gazebo
remove_bashrc_config
remove_ardupilot_env remove_ardupilot_env
else else
@@ -231,8 +206,7 @@ else
remove_activate remove_activate
fi fi
if ask_yes_no "Remove ArduPilot configuration from ~/.bashrc?"; then if ask_yes_no "Remove ArduPilot environment file (~/.ardupilot_env)?"; then
remove_bashrc_config
remove_ardupilot_env remove_ardupilot_env
fi fi
fi fi