install script updates 3
This commit is contained in:
@@ -16,8 +16,8 @@
|
|||||||
git clone <repo-url> RDC_Simulation
|
git clone <repo-url> RDC_Simulation
|
||||||
cd RDC_Simulation
|
cd RDC_Simulation
|
||||||
|
|
||||||
# Install everything (20-30 minutes)
|
# Full installation (20-30 minutes)
|
||||||
./setup/install_ubuntu.sh --with-ardupilot
|
./setup/install_ubuntu.sh
|
||||||
|
|
||||||
# Reload environment
|
# Reload environment
|
||||||
source ~/.bashrc
|
source ~/.bashrc
|
||||||
|
|||||||
@@ -18,8 +18,8 @@
|
|||||||
git clone <repo-url> ~/RDC_Simulation
|
git clone <repo-url> ~/RDC_Simulation
|
||||||
cd ~/RDC_Simulation
|
cd ~/RDC_Simulation
|
||||||
|
|
||||||
# Run full installer (includes ArduPilot)
|
# Run full installer (20-30 minutes)
|
||||||
./setup/install_ubuntu.sh --with-ardupilot
|
./setup/install_ubuntu.sh
|
||||||
|
|
||||||
# Reload shell
|
# Reload shell
|
||||||
source ~/.bashrc
|
source ~/.bashrc
|
||||||
@@ -52,7 +52,7 @@ sudo apt update && sudo apt upgrade -y
|
|||||||
# Clone and install
|
# Clone and install
|
||||||
git clone <repo-url> ~/RDC_Simulation
|
git clone <repo-url> ~/RDC_Simulation
|
||||||
cd ~/RDC_Simulation
|
cd ~/RDC_Simulation
|
||||||
./setup/install_ubuntu.sh --with-ardupilot
|
./setup/install_ubuntu.sh
|
||||||
|
|
||||||
# Reload shell
|
# Reload shell
|
||||||
source ~/.bashrc
|
source ~/.bashrc
|
||||||
@@ -72,7 +72,7 @@ source ~/.bashrc
|
|||||||
## Arch Linux
|
## Arch Linux
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
./setup/install_arch.sh --with-ardupilot
|
./setup/install_arch.sh
|
||||||
source ~/.bashrc
|
source ~/.bashrc
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -1,179 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
# =============================================================================
|
|
||||||
# ArduPilot SITL + Gazebo Installation Script (MAVLink Mode)
|
|
||||||
# =============================================================================
|
|
||||||
# Installs ArduPilot SITL with the ardupilot_gazebo plugin.
|
|
||||||
# This uses MAVLink instead of DDS - simpler and more reliable.
|
|
||||||
#
|
|
||||||
# Usage: ./install_ardupilot.sh
|
|
||||||
# =============================================================================
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
echo "=============================================="
|
|
||||||
echo " ArduPilot SITL + Gazebo Installation"
|
|
||||||
echo "=============================================="
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
# Get script directory
|
|
||||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
||||||
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
|
|
||||||
|
|
||||||
# Directories
|
|
||||||
ARDUPILOT_HOME="$HOME/ardupilot"
|
|
||||||
ARDUPILOT_GZ="$HOME/ardupilot_gazebo"
|
|
||||||
|
|
||||||
# Check for ROS 2
|
|
||||||
if [ -f "/opt/ros/humble/setup.bash" ]; then
|
|
||||||
source /opt/ros/humble/setup.bash
|
|
||||||
ROS_DISTRO="humble"
|
|
||||||
elif [ -f "/opt/ros/jazzy/setup.bash" ]; then
|
|
||||||
source /opt/ros/jazzy/setup.bash
|
|
||||||
ROS_DISTRO="jazzy"
|
|
||||||
else
|
|
||||||
echo "[WARN] ROS 2 not found, will install in standalone mode"
|
|
||||||
ROS_DISTRO=""
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "[INFO] ROS 2: ${ROS_DISTRO:-not installed}"
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
# Step 1: System Dependencies
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
echo "[STEP 1/5] Installing system dependencies..."
|
|
||||||
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install -y \
|
|
||||||
git cmake build-essential \
|
|
||||||
python3 python3-pip python3-dev \
|
|
||||||
wget curl
|
|
||||||
|
|
||||||
echo "[OK] System dependencies"
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
# Step 2: Clone and Setup ArduPilot
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
echo ""
|
|
||||||
echo "[STEP 2/5] Setting up ArduPilot SITL..."
|
|
||||||
|
|
||||||
if [ ! -d "$ARDUPILOT_HOME" ]; then
|
|
||||||
git clone --recurse-submodules https://github.com/ArduPilot/ardupilot.git "$ARDUPILOT_HOME"
|
|
||||||
fi
|
|
||||||
|
|
||||||
cd "$ARDUPILOT_HOME"
|
|
||||||
|
|
||||||
# Install ArduPilot prerequisites
|
|
||||||
Tools/environment_install/install-prereqs-ubuntu.sh -y
|
|
||||||
. ~/.profile || true
|
|
||||||
|
|
||||||
# Source ArduPilot environment (created by install-prereqs-ubuntu.sh)
|
|
||||||
if [ -f "$HOME/.ardupilot_env" ]; then
|
|
||||||
source "$HOME/.ardupilot_env"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Build ArduCopter SITL (without DDS to avoid complexity)
|
|
||||||
./waf configure --board sitl
|
|
||||||
./waf copter
|
|
||||||
|
|
||||||
echo "[OK] ArduPilot SITL built"
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
# Step 3: Install Gazebo Harmonic
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
echo ""
|
|
||||||
echo "[STEP 3/5] Installing Gazebo..."
|
|
||||||
|
|
||||||
# Add Gazebo repo
|
|
||||||
sudo wget https://packages.osrfoundation.org/gazebo.gpg -O /usr/share/keyrings/pkgs-osrf-archive-keyring.gpg 2>/dev/null
|
|
||||||
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/pkgs-osrf-archive-keyring.gpg] http://packages.osrfoundation.org/gazebo/ubuntu-stable $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/gazebo-stable.list > /dev/null
|
|
||||||
sudo apt-get update
|
|
||||||
|
|
||||||
# Install Gazebo
|
|
||||||
sudo apt-get install -y gz-harmonic || sudo apt-get install -y gz-garden || {
|
|
||||||
echo "[WARN] Could not install Gazebo Harmonic/Garden"
|
|
||||||
}
|
|
||||||
|
|
||||||
echo "[OK] Gazebo installed"
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
# Step 4: Build ArduPilot Gazebo Plugin
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
echo ""
|
|
||||||
echo "[STEP 4/5] Building ArduPilot Gazebo plugin..."
|
|
||||||
|
|
||||||
if [ ! -d "$ARDUPILOT_GZ" ]; then
|
|
||||||
git clone https://github.com/ArduPilot/ardupilot_gazebo.git "$ARDUPILOT_GZ"
|
|
||||||
fi
|
|
||||||
|
|
||||||
cd "$ARDUPILOT_GZ"
|
|
||||||
mkdir -p build && cd build
|
|
||||||
cmake .. -DCMAKE_BUILD_TYPE=Release
|
|
||||||
make -j$(nproc)
|
|
||||||
|
|
||||||
echo "[OK] ArduPilot Gazebo plugin built"
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
# Step 5: Configure Environment
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
echo ""
|
|
||||||
echo "[STEP 5/5] Configuring environment..."
|
|
||||||
|
|
||||||
BASHRC_MARKER="# === ArduPilot SITL ==="
|
|
||||||
|
|
||||||
if ! grep -q "$BASHRC_MARKER" ~/.bashrc; then
|
|
||||||
cat >> ~/.bashrc << EOF
|
|
||||||
|
|
||||||
$BASHRC_MARKER
|
|
||||||
# Source ArduPilot environment (venv + tools)
|
|
||||||
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] Environment configured"
|
|
||||||
else
|
|
||||||
echo "[OK] Environment already configured"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Install MAVProxy and Python dependencies
|
|
||||||
pip3 install --user pymavlink mavproxy pexpect
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
# Verification
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
echo ""
|
|
||||||
echo "=============================================="
|
|
||||||
echo " Verifying Installation"
|
|
||||||
echo "=============================================="
|
|
||||||
|
|
||||||
source ~/.bashrc 2>/dev/null || true
|
|
||||||
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 gz &> /dev/null && echo "[OK] Gazebo (gz)" || echo "[WARN] Gazebo not found"
|
|
||||||
command -v mavproxy.py &> /dev/null && echo "[OK] MAVProxy" || echo "[WARN] MAVProxy not in PATH"
|
|
||||||
[ -f "$ARDUPILOT_GZ/build/libArduPilotPlugin.so" ] && echo "[OK] ArduPilot Gazebo plugin" || echo "[WARN] Plugin not built"
|
|
||||||
|
|
||||||
echo ""
|
|
||||||
echo "=============================================="
|
|
||||||
echo " Installation Complete!"
|
|
||||||
echo "=============================================="
|
|
||||||
echo ""
|
|
||||||
echo "Run: source ~/.bashrc"
|
|
||||||
echo ""
|
|
||||||
echo "Quick Start (2 terminals):"
|
|
||||||
echo ""
|
|
||||||
echo "Terminal 1 - Start Gazebo:"
|
|
||||||
echo " gz sim -v4 -r $ARDUPILOT_GZ/worlds/iris_runway.sdf"
|
|
||||||
echo ""
|
|
||||||
echo "Terminal 2 - Start SITL + MAVProxy:"
|
|
||||||
echo " sim_vehicle.py -v ArduCopter -f gazebo-iris --model JSON --console"
|
|
||||||
echo ""
|
|
||||||
echo "Or use sim_vehicle.py standalone (no Gazebo):"
|
|
||||||
echo " sim_vehicle.py -v ArduCopter --console --map"
|
|
||||||
echo ""
|
|
||||||
@@ -1,18 +1,19 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
# Drone Simulation - Ubuntu/Debian Installation Script
|
# RDC Simulation - Ubuntu/WSL2 Installation Script
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
# Installs ROS 2, Gazebo, PyBullet, and all required dependencies
|
# Complete installation for GPS-Denied Drone Landing Simulation
|
||||||
|
# Installs: ROS 2, Gazebo, ArduPilot SITL, and all dependencies
|
||||||
#
|
#
|
||||||
# Usage:
|
# Usage:
|
||||||
# ./install_ubuntu.sh # Basic installation
|
# ./setup/install_ubuntu.sh # Full installation (recommended)
|
||||||
# ./install_ubuntu.sh --with-ardupilot # Include ArduPilot SITL
|
# ./setup/install_ubuntu.sh --skip-ardupilot # Skip ArduPilot (basic only)
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
echo "=============================================="
|
echo "=============================================="
|
||||||
echo " Drone Simulation - Ubuntu Installation"
|
echo " RDC Simulation - Ubuntu Installation"
|
||||||
echo "=============================================="
|
echo "=============================================="
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
@@ -21,6 +22,10 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|||||||
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
|
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
|
||||||
VENV_DIR="$PROJECT_ROOT/venv"
|
VENV_DIR="$PROJECT_ROOT/venv"
|
||||||
|
|
||||||
|
# ArduPilot directories
|
||||||
|
ARDUPILOT_HOME="$HOME/ardupilot"
|
||||||
|
ARDUPILOT_GZ="$HOME/ardupilot_gazebo"
|
||||||
|
|
||||||
echo "[INFO] Project root: $PROJECT_ROOT"
|
echo "[INFO] Project root: $PROJECT_ROOT"
|
||||||
echo "[INFO] Virtual environment: $VENV_DIR"
|
echo "[INFO] Virtual environment: $VENV_DIR"
|
||||||
|
|
||||||
@@ -34,19 +39,27 @@ else
|
|||||||
UBUNTU_VERSION="22.04"
|
UBUNTU_VERSION="22.04"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check for ArduPilot option
|
# Check for skip ArduPilot option (default is to install ArduPilot)
|
||||||
INSTALL_ARDUPILOT=false
|
|
||||||
for arg in "$@"; do
|
|
||||||
if [ "$arg" = "--with-ardupilot" ]; then
|
|
||||||
INSTALL_ARDUPILOT=true
|
INSTALL_ARDUPILOT=true
|
||||||
|
for arg in "$@"; do
|
||||||
|
if [ "$arg" = "--skip-ardupilot" ]; then
|
||||||
|
INSTALL_ARDUPILOT=false
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
if [ "$INSTALL_ARDUPILOT" = true ]; then
|
||||||
# Step 1: System Dependencies
|
TOTAL_STEPS=10
|
||||||
# -----------------------------------------------------------------------------
|
echo "[INFO] Full installation with ArduPilot SITL"
|
||||||
|
else
|
||||||
|
TOTAL_STEPS=7
|
||||||
|
echo "[INFO] Basic installation (no ArduPilot)"
|
||||||
|
fi
|
||||||
echo ""
|
echo ""
|
||||||
echo "[STEP 1/7] Installing system dependencies..."
|
|
||||||
|
# =============================================================================
|
||||||
|
# STEP 1: System Dependencies
|
||||||
|
# =============================================================================
|
||||||
|
echo "[STEP 1/$TOTAL_STEPS] Installing system dependencies..."
|
||||||
|
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y \
|
sudo apt-get install -y \
|
||||||
@@ -57,18 +70,26 @@ sudo apt-get install -y \
|
|||||||
python3 \
|
python3 \
|
||||||
python3-pip \
|
python3-pip \
|
||||||
python3-venv \
|
python3-venv \
|
||||||
|
python3-dev \
|
||||||
git \
|
git \
|
||||||
cmake \
|
cmake \
|
||||||
build-essential \
|
build-essential \
|
||||||
wget
|
wget \
|
||||||
|
netcat-openbsd \
|
||||||
|
libgstreamer1.0-dev \
|
||||||
|
libgstreamer-plugins-base1.0-dev \
|
||||||
|
gstreamer1.0-plugins-bad \
|
||||||
|
gstreamer1.0-libav \
|
||||||
|
gstreamer1.0-gl \
|
||||||
|
libopencv-dev
|
||||||
|
|
||||||
echo "[INFO] System dependencies installed"
|
echo "[OK] System dependencies installed"
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# =============================================================================
|
||||||
# Step 2: ROS 2 Repository Setup
|
# STEP 2: ROS 2 Installation
|
||||||
# -----------------------------------------------------------------------------
|
# =============================================================================
|
||||||
echo ""
|
echo ""
|
||||||
echo "[STEP 2/7] Setting up ROS 2 repository..."
|
echo "[STEP 2/$TOTAL_STEPS] Installing ROS 2..."
|
||||||
|
|
||||||
# Add ROS 2 GPG key
|
# Add ROS 2 GPG key
|
||||||
sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg
|
sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg
|
||||||
@@ -88,63 +109,50 @@ echo "[INFO] Using ROS 2 $ROS_DISTRO"
|
|||||||
# Add repository
|
# Add repository
|
||||||
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(. /etc/os-release && echo $UBUNTU_CODENAME) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null
|
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(. /etc/os-release && echo $UBUNTU_CODENAME) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
# Step 3: Install ROS 2
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
echo ""
|
|
||||||
echo "[STEP 3/7] Installing ROS 2 $ROS_DISTRO..."
|
|
||||||
|
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y ros-${ROS_DISTRO}-ros-base ros-${ROS_DISTRO}-geometry-msgs ros-${ROS_DISTRO}-std-msgs ros-${ROS_DISTRO}-nav-msgs ros-${ROS_DISTRO}-sensor-msgs
|
sudo apt-get install -y ros-${ROS_DISTRO}-ros-base ros-${ROS_DISTRO}-geometry-msgs ros-${ROS_DISTRO}-std-msgs ros-${ROS_DISTRO}-nav-msgs ros-${ROS_DISTRO}-sensor-msgs
|
||||||
|
|
||||||
echo "[INFO] ROS 2 $ROS_DISTRO installed"
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
# Step 4: Install Gazebo
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
echo ""
|
|
||||||
echo "[STEP 4/7] Installing Gazebo..."
|
|
||||||
|
|
||||||
# Install ros-gz bridge
|
# Install ros-gz bridge
|
||||||
sudo apt-get install -y ros-${ROS_DISTRO}-ros-gz || {
|
sudo apt-get install -y ros-${ROS_DISTRO}-ros-gz || {
|
||||||
echo "[WARN] Could not install ros-gz"
|
echo "[WARN] Could not install ros-gz"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Install Gazebo
|
echo "[OK] ROS 2 $ROS_DISTRO installed"
|
||||||
if [ "$ROS_DISTRO" = "jazzy" ]; then
|
|
||||||
sudo apt-get install -y gz-harmonic || true
|
# =============================================================================
|
||||||
else
|
# STEP 3: Gazebo Installation
|
||||||
sudo apt-get install -y gz-fortress || sudo apt-get install -y ros-${ROS_DISTRO}-ros-ign-gazebo || true
|
# =============================================================================
|
||||||
fi
|
echo ""
|
||||||
|
echo "[STEP 3/$TOTAL_STEPS] Installing Gazebo..."
|
||||||
|
|
||||||
|
# Add Gazebo repository
|
||||||
|
sudo wget https://packages.osrfoundation.org/gazebo.gpg -O /usr/share/keyrings/pkgs-osrf-archive-keyring.gpg 2>/dev/null
|
||||||
|
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/pkgs-osrf-archive-keyring.gpg] http://packages.osrfoundation.org/gazebo/ubuntu-stable $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/gazebo-stable.list > /dev/null
|
||||||
|
sudo apt-get update
|
||||||
|
|
||||||
|
# Install Gazebo Harmonic (preferred) or Garden as fallback
|
||||||
|
sudo apt-get install -y gz-harmonic || sudo apt-get install -y gz-garden || {
|
||||||
|
echo "[WARN] Could not install Gazebo Harmonic/Garden"
|
||||||
|
}
|
||||||
|
|
||||||
# Verify installation
|
# Verify installation
|
||||||
if command -v gz &> /dev/null; then
|
if command -v gz &> /dev/null; then
|
||||||
echo "[INFO] Gazebo installed (gz command available)"
|
echo "[OK] Gazebo installed ($(gz sim --version 2>/dev/null | head -1 || echo 'version unknown'))"
|
||||||
elif command -v ign &> /dev/null; then
|
|
||||||
echo "[INFO] Gazebo Fortress installed (ign command available)"
|
|
||||||
else
|
else
|
||||||
echo "[WARN] Gazebo command not found - use standalone mode"
|
echo "[WARN] Gazebo command not found"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# =============================================================================
|
||||||
# Step 5: Create Python Virtual Environment
|
# STEP 4: Python Virtual Environment
|
||||||
# -----------------------------------------------------------------------------
|
# =============================================================================
|
||||||
echo ""
|
echo ""
|
||||||
echo "[STEP 5/7] Creating Python virtual environment..."
|
echo "[STEP 4/$TOTAL_STEPS] Creating Python virtual environment..."
|
||||||
|
|
||||||
if [ -d "$VENV_DIR" ]; then
|
if [ -d "$VENV_DIR" ]; then
|
||||||
rm -rf "$VENV_DIR"
|
rm -rf "$VENV_DIR"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
python3 -m venv "$VENV_DIR"
|
python3 -m venv "$VENV_DIR"
|
||||||
echo "[INFO] Virtual environment created at: $VENV_DIR"
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
# Step 6: Install Python Dependencies
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
echo ""
|
|
||||||
echo "[STEP 6/7] Installing Python dependencies..."
|
|
||||||
|
|
||||||
source "$VENV_DIR/bin/activate"
|
source "$VENV_DIR/bin/activate"
|
||||||
pip install --upgrade pip
|
pip install --upgrade pip
|
||||||
|
|
||||||
@@ -154,17 +162,18 @@ else
|
|||||||
pip install pybullet numpy pillow opencv-python pymavlink pexpect
|
pip install pybullet numpy pillow opencv-python pymavlink pexpect
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "[INFO] Python packages installed"
|
echo "[OK] Python virtual environment created"
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# =============================================================================
|
||||||
# Step 7: Create Activation Script
|
# STEP 5: Create Activation Script
|
||||||
# -----------------------------------------------------------------------------
|
# =============================================================================
|
||||||
echo ""
|
echo ""
|
||||||
echo "[STEP 7/7] Creating activation script..."
|
echo "[STEP 5/$TOTAL_STEPS] Creating activation script..."
|
||||||
|
|
||||||
cat > "$PROJECT_ROOT/activate.sh" << 'EOF'
|
cat > "$PROJECT_ROOT/activate.sh" << 'EOF'
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Drone Simulation - Environment Activation
|
# RDC Simulation - Environment Activation
|
||||||
|
# Usage: source activate.sh
|
||||||
|
|
||||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
|
||||||
@@ -197,7 +206,7 @@ fi
|
|||||||
# Set Gazebo paths
|
# Set Gazebo paths
|
||||||
export GZ_SIM_RESOURCE_PATH="$SCRIPT_DIR/gazebo/models:$GZ_SIM_RESOURCE_PATH"
|
export GZ_SIM_RESOURCE_PATH="$SCRIPT_DIR/gazebo/models:$GZ_SIM_RESOURCE_PATH"
|
||||||
|
|
||||||
# Add paths for ArduPilot tools and MAVProxy
|
# Add paths for ArduPilot tools
|
||||||
export PATH="$PATH:$HOME/.local/bin"
|
export PATH="$PATH:$HOME/.local/bin"
|
||||||
export PATH="$PATH:$HOME/ardupilot/Tools/autotest"
|
export PATH="$PATH:$HOME/ardupilot/Tools/autotest"
|
||||||
|
|
||||||
@@ -212,15 +221,13 @@ echo "Ready! See README.md for usage instructions."
|
|||||||
EOF
|
EOF
|
||||||
|
|
||||||
chmod +x "$PROJECT_ROOT/activate.sh"
|
chmod +x "$PROJECT_ROOT/activate.sh"
|
||||||
echo "[INFO] Created: $PROJECT_ROOT/activate.sh"
|
echo "[OK] Created: $PROJECT_ROOT/activate.sh"
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# =============================================================================
|
||||||
# Verification
|
# STEP 6: Verify Base Installation
|
||||||
# -----------------------------------------------------------------------------
|
# =============================================================================
|
||||||
echo ""
|
echo ""
|
||||||
echo "=============================================="
|
echo "[STEP 6/$TOTAL_STEPS] Verifying base installation..."
|
||||||
echo " Verifying Installation"
|
|
||||||
echo "=============================================="
|
|
||||||
|
|
||||||
source "$PROJECT_ROOT/activate.sh"
|
source "$PROJECT_ROOT/activate.sh"
|
||||||
|
|
||||||
@@ -229,42 +236,148 @@ python3 -c "import numpy; print('[OK] NumPy')" || echo "[FAIL] NumPy"
|
|||||||
python3 -c "import cv2; print('[OK] OpenCV')" || echo "[WARN] OpenCV not installed"
|
python3 -c "import cv2; print('[OK] OpenCV')" || echo "[WARN] OpenCV not installed"
|
||||||
python3 -c "from pymavlink import mavutil; print('[OK] pymavlink')" || echo "[WARN] pymavlink not installed"
|
python3 -c "from pymavlink import mavutil; print('[OK] pymavlink')" || echo "[WARN] pymavlink not installed"
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# =============================================================================
|
||||||
# ArduPilot Installation (if requested)
|
# ARDUPILOT INSTALLATION (Steps 7-10, if not skipped)
|
||||||
# -----------------------------------------------------------------------------
|
# =============================================================================
|
||||||
if [ "$INSTALL_ARDUPILOT" = true ]; then
|
if [ "$INSTALL_ARDUPILOT" = true ]; then
|
||||||
|
|
||||||
|
# =========================================================================
|
||||||
|
# STEP 7: Clone and Setup ArduPilot
|
||||||
|
# =========================================================================
|
||||||
echo ""
|
echo ""
|
||||||
echo "[INFO] Installing ArduPilot SITL..."
|
echo "[STEP 7/$TOTAL_STEPS] Setting up ArduPilot SITL..."
|
||||||
|
|
||||||
if [ -f "$SCRIPT_DIR/install_ardupilot.sh" ]; then
|
if [ ! -d "$ARDUPILOT_HOME" ]; then
|
||||||
bash "$SCRIPT_DIR/install_ardupilot.sh"
|
echo "[INFO] Cloning ArduPilot repository..."
|
||||||
|
git clone --recurse-submodules https://github.com/ArduPilot/ardupilot.git "$ARDUPILOT_HOME"
|
||||||
else
|
else
|
||||||
echo "[ERROR] install_ardupilot.sh not found at $SCRIPT_DIR/"
|
echo "[INFO] ArduPilot directory already exists"
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
cd "$ARDUPILOT_HOME"
|
||||||
|
|
||||||
|
# Install ArduPilot prerequisites (this creates ~/.ardupilot_env)
|
||||||
|
echo "[INFO] Installing ArduPilot prerequisites (this may take a while)..."
|
||||||
|
Tools/environment_install/install-prereqs-ubuntu.sh -y
|
||||||
|
. ~/.profile || true
|
||||||
|
|
||||||
|
# Source ArduPilot environment
|
||||||
|
if [ -f "$HOME/.ardupilot_env" ]; then
|
||||||
|
source "$HOME/.ardupilot_env"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "[OK] ArduPilot prerequisites installed"
|
||||||
|
|
||||||
|
# =========================================================================
|
||||||
|
# STEP 8: Build ArduCopter SITL
|
||||||
|
# =========================================================================
|
||||||
|
echo ""
|
||||||
|
echo "[STEP 8/$TOTAL_STEPS] Building ArduCopter SITL..."
|
||||||
|
|
||||||
|
cd "$ARDUPILOT_HOME"
|
||||||
|
./waf configure --board sitl
|
||||||
|
./waf copter
|
||||||
|
|
||||||
|
echo "[OK] ArduCopter SITL built"
|
||||||
|
|
||||||
|
# =========================================================================
|
||||||
|
# STEP 9: Build ArduPilot Gazebo Plugin
|
||||||
|
# =========================================================================
|
||||||
|
echo ""
|
||||||
|
echo "[STEP 9/$TOTAL_STEPS] Building ArduPilot Gazebo plugin..."
|
||||||
|
|
||||||
|
if [ ! -d "$ARDUPILOT_GZ" ]; then
|
||||||
|
echo "[INFO] Cloning ardupilot_gazebo repository..."
|
||||||
|
git clone https://github.com/ArduPilot/ardupilot_gazebo.git "$ARDUPILOT_GZ"
|
||||||
|
else
|
||||||
|
echo "[INFO] ardupilot_gazebo directory already exists"
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd "$ARDUPILOT_GZ"
|
||||||
|
mkdir -p build && cd build
|
||||||
|
cmake .. -DCMAKE_BUILD_TYPE=Release
|
||||||
|
make -j$(nproc)
|
||||||
|
|
||||||
|
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
|
||||||
|
pip3 install --user pymavlink mavproxy pexpect
|
||||||
|
|
||||||
|
# Verify ArduPilot installation
|
||||||
|
echo ""
|
||||||
|
echo "Verifying ArduPilot installation..."
|
||||||
|
|
||||||
|
source ~/.bashrc 2>/dev/null || true
|
||||||
|
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 gz &> /dev/null && echo "[OK] Gazebo (gz)" || echo "[WARN] Gazebo not found"
|
||||||
|
command -v mavproxy.py &> /dev/null && echo "[OK] MAVProxy" || echo "[WARN] MAVProxy not in PATH"
|
||||||
|
[ -f "$ARDUPILOT_GZ/build/libArduPilotPlugin.so" ] && echo "[OK] ArduPilot Gazebo plugin" || echo "[WARN] Plugin not built"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# =============================================================================
|
||||||
|
# INSTALLATION COMPLETE
|
||||||
|
# =============================================================================
|
||||||
echo ""
|
echo ""
|
||||||
echo "=============================================="
|
echo "=============================================="
|
||||||
echo " Installation Complete!"
|
echo " Installation Complete!"
|
||||||
echo "=============================================="
|
echo "=============================================="
|
||||||
echo ""
|
echo ""
|
||||||
echo "Quick start (3 terminals):"
|
|
||||||
|
if [ "$INSTALL_ARDUPILOT" = true ]; then
|
||||||
|
echo "IMPORTANT: Run this command to reload your environment:"
|
||||||
|
echo " source ~/.bashrc"
|
||||||
|
echo ""
|
||||||
|
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 " ./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 ~/.ardupilot_env"
|
echo " source ~/.bashrc"
|
||||||
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:"
|
||||||
echo " cd ~/RDC_Simulation"
|
echo " cd ~/RDC_Simulation"
|
||||||
echo " source activate.sh"
|
echo " source activate.sh"
|
||||||
echo " python scripts/run_ardupilot.py --pattern square"
|
echo " python scripts/run_ardupilot.py --pattern square"
|
||||||
|
else
|
||||||
|
echo "Basic installation complete."
|
||||||
echo ""
|
echo ""
|
||||||
if [ "$INSTALL_ARDUPILOT" != true ]; then
|
echo "To install ArduPilot SITL later, run:"
|
||||||
echo "For ArduPilot SITL (required for flight):"
|
echo " ./setup/install_ubuntu.sh"
|
||||||
echo " ./setup/install_ardupilot.sh"
|
|
||||||
echo ""
|
echo ""
|
||||||
|
echo "Or run manually:"
|
||||||
|
echo " cd ~/RDC_Simulation"
|
||||||
|
echo " source activate.sh"
|
||||||
fi
|
fi
|
||||||
|
echo ""
|
||||||
|
|||||||
@@ -230,7 +230,7 @@ Write-Host " # Restart your computer when prompted" -ForegroundColor DarkGray
|
|||||||
Write-Host ""
|
Write-Host ""
|
||||||
Write-Host "Step 2: Open Ubuntu and install" -ForegroundColor Yellow
|
Write-Host "Step 2: Open Ubuntu and install" -ForegroundColor Yellow
|
||||||
Write-Host " cd /mnt/c/path/to/RDC_Simulation" -ForegroundColor White
|
Write-Host " cd /mnt/c/path/to/RDC_Simulation" -ForegroundColor White
|
||||||
Write-Host " ./setup/install_ubuntu.sh --with-ardupilot" -ForegroundColor White
|
Write-Host " ./setup/install_ubuntu.sh" -ForegroundColor White
|
||||||
Write-Host " source ~/.bashrc" -ForegroundColor White
|
Write-Host " source ~/.bashrc" -ForegroundColor White
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
Write-Host "Step 3: Run simulation (3 terminals)" -ForegroundColor Yellow
|
Write-Host "Step 3: Run simulation (3 terminals)" -ForegroundColor Yellow
|
||||||
|
|||||||
Reference in New Issue
Block a user