Gazebo 仿真环境搭建指南(Ubuntu 22.04)
这里以 Ubuntu 22.04 和 ROS 2 Humble Hawksbill 为例。注意,Ubuntu 22.04 通常推荐使用 ROS 2 Humble。
完整 ROS 2 Humble 安装流程
# 1. 确保系统最新
sudo apt update && sudo apt upgrade -y
# 2. 安装基础依赖
sudo apt install software-properties-common curl gnupg lsb-release
# 3. 添加 Ubuntu Universe 仓库(如果未启用)
sudo add-apt-repository universe
# 4. 添加 ROS 源(使用现代方法)
curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key | sudo tee /usr/share/keyrings/ros-archive-keyring.gpg > /dev/null
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/ros2.list
# 5. 更新并安装 ROS
sudo apt update
sudo apt install ros-humble-desktop -y
# 6. 安装构建工具
sudo apt install python3-colcon-common-extensions python3-rosdep -y
sudo rosdep init
rosdep update
# 7. 配置环境
echo "source /opt/ros/humble/setup.bash" >> ~/.bashrc
source ~/.bashrc
安装 Gazebo Fortress(ROS Humble 推荐版本)
# 1. 确保系统已更新
sudo apt update
sudo apt upgrade -y
# 2. 安装与 ROS Humble 兼容的 Gazebo
sudo apt install -y \
gazebo \
libgazebo-dev \
gazebo-plugin-base \
gazebo-common \
ros-humble-gazebo-ros-pkgs
# 3. 验证安装的 Gazebo 版本
gazebo --version

