Gazebo Sim World Update
This commit is contained in:
@@ -1,61 +1,56 @@
|
||||
#!/bin/bash
|
||||
# Activate virtual environment and setup for UAV-UGV Simulation
|
||||
# UAV-UGV Simulation - Environment Activation
|
||||
# Usage: source activate_venv.sh
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
# Detect ROS distro
|
||||
ROS_DISTRO=""
|
||||
for distro in humble jazzy iron galactic; do
|
||||
if [ -d "/opt/ros/$distro" ]; then
|
||||
ROS_DISTRO="$distro"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
# Source ROS 2
|
||||
if [ -n "$ROS_DISTRO" ] && [ -f "/opt/ros/${ROS_DISTRO}/setup.bash" ]; then
|
||||
source /opt/ros/${ROS_DISTRO}/setup.bash
|
||||
# ROS 2 Setup
|
||||
if [ -f "/opt/ros/jazzy/setup.bash" ]; then
|
||||
source /opt/ros/jazzy/setup.bash
|
||||
ROS_VER="jazzy"
|
||||
elif [ -f "/opt/ros/humble/setup.bash" ]; then
|
||||
source /opt/ros/humble/setup.bash
|
||||
ROS_VER="humble"
|
||||
else
|
||||
echo "[WARN] ROS 2 not found in /opt/ros/"
|
||||
ROS_VER="none"
|
||||
fi
|
||||
|
||||
# Source Gazebo setup (critical for shader/resource paths)
|
||||
if [ -f /usr/share/gazebo/setup.bash ]; then
|
||||
source /usr/share/gazebo/setup.bash
|
||||
elif [ -f /usr/share/gazebo-11/setup.bash ]; then
|
||||
source /usr/share/gazebo-11/setup.bash
|
||||
# ArduPilot Environment
|
||||
export ARDUPILOT_HOME="$HOME/ardupilot"
|
||||
export PATH="$ARDUPILOT_HOME/Tools/autotest:$PATH"
|
||||
export PATH="$HOME/.local/bin:$PATH"
|
||||
|
||||
# Deactivate existing venv
|
||||
if [ -n "$VIRTUAL_ENV" ]; then
|
||||
deactivate 2>/dev/null || true
|
||||
fi
|
||||
|
||||
# Activate Python virtual environment
|
||||
# Activate project venv
|
||||
if [ -f "$SCRIPT_DIR/venv/bin/activate" ]; then
|
||||
source "$SCRIPT_DIR/venv/bin/activate"
|
||||
fi
|
||||
|
||||
# Source ROS workspace if built
|
||||
if [ -f "$SCRIPT_DIR/../install/setup.bash" ]; then
|
||||
source "$SCRIPT_DIR/../install/setup.bash"
|
||||
elif [ -f "$SCRIPT_DIR/install/setup.bash" ]; then
|
||||
source "$SCRIPT_DIR/install/setup.bash"
|
||||
# Gazebo paths (new Gazebo - Ignition/Harmonic)
|
||||
export GZ_SIM_RESOURCE_PATH="$SCRIPT_DIR/models:$SCRIPT_DIR/worlds:${GZ_SIM_RESOURCE_PATH:-}"
|
||||
|
||||
# ArduPilot Gazebo plugin
|
||||
if [ -d "$HOME/ardupilot_gazebo/build" ]; then
|
||||
export GZ_SIM_SYSTEM_PLUGIN_PATH="$HOME/ardupilot_gazebo/build:${GZ_SIM_SYSTEM_PLUGIN_PATH:-}"
|
||||
export GZ_SIM_RESOURCE_PATH="$HOME/ardupilot_gazebo/models:$HOME/ardupilot_gazebo/worlds:$GZ_SIM_RESOURCE_PATH"
|
||||
fi
|
||||
|
||||
# Gazebo model and resource paths
|
||||
export GAZEBO_MODEL_PATH="$SCRIPT_DIR/models:${GAZEBO_MODEL_PATH:-}"
|
||||
export GAZEBO_RESOURCE_PATH="$SCRIPT_DIR/worlds:${GAZEBO_RESOURCE_PATH:-}"
|
||||
|
||||
# ArduPilot Gazebo (if installed)
|
||||
if [ -d "$HOME/ardupilot_gazebo" ]; then
|
||||
export GAZEBO_MODEL_PATH="$HOME/ardupilot_gazebo/models:$GAZEBO_MODEL_PATH"
|
||||
export GAZEBO_RESOURCE_PATH="$HOME/ardupilot_gazebo/worlds:$GAZEBO_RESOURCE_PATH"
|
||||
fi
|
||||
|
||||
# WSL environment (if applicable)
|
||||
# WSL environment
|
||||
if grep -qEi "(microsoft|wsl)" /proc/version 2>/dev/null; then
|
||||
if [ -f "$SCRIPT_DIR/wsl_env.sh" ]; then
|
||||
source "$SCRIPT_DIR/wsl_env.sh"
|
||||
if [ -d "/mnt/wslg" ]; then
|
||||
export DISPLAY=:0
|
||||
else
|
||||
export DISPLAY=$(cat /etc/resolv.conf 2>/dev/null | grep nameserver | awk '{print $2}'):0
|
||||
fi
|
||||
export LIBGL_ALWAYS_INDIRECT=0
|
||||
export MESA_GL_VERSION_OVERRIDE=3.3
|
||||
fi
|
||||
|
||||
echo -e "\033[0;32mEnvironment activated (ROS 2 ${ROS_DISTRO:-not found})\033[0m"
|
||||
echo "Run: bash scripts/run_simulation.sh"
|
||||
echo -e "\033[0;32mEnvironment activated (ROS 2 $ROS_VER)\033[0m"
|
||||
echo ""
|
||||
echo "Options:"
|
||||
echo " bash scripts/run_simulation.sh # Default world"
|
||||
echo " bash scripts/run_simulation.sh --software-render # For WSL/rendering issues"
|
||||
echo "Run simulation: bash scripts/run_simulation.sh"
|
||||
|
||||
Reference in New Issue
Block a user