目录
系统要求
系统设置
设置区域
启用所需的存储库
安装开发工具
构建 ROS 2
获取 ROS 2 代码
使用 rosdep 安装依赖项
安装额外的 RMW 实现(可选)
在工作区构建代码
设置环境
尝试一些例子
下一步
备用编译器
Clang
保持最新状态
故障排除
卸载
系统要求
当前基于 Debian 的 Jazzy Jalisco 目标平台是:
一级:Ubuntu Linux - Noble (24.04) 64 位
三级:Ubuntu Linux - Jammy (22.04) 64 位
第三层:Debian Linux - Bookworm(12)64 位
根据 REP 2000 定义。
系统设置
设置区域
请确保您有一个支持 UTF-8
的区域设置。如果您处于最小化环境中(例如 docker 容器),区域设置可能是像 POSIX
这样的最小化设置。我们使用以下设置进行测试。不过,如果您使用的是不同的 UTF-8 支持区域设置,也应该没问题。
locale # check for UTF-8
sudo apt update && sudo apt install locales
sudo locale-gen en_US en_US.UTF-8
sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
export LANG=en_US.UTF-8
locale # verify settings
cxy@ubuntu2404-cxy:~$ locale
LANG=zh_CN.UTF-8
LANGUAGE=zh_CN:en
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=en_US.UTF-8
启用所需的存储库
您需要将 ROS 2 apt 仓库添加到您的系统中。
首先确保启用了 Ubuntu Universe 仓库。
sudo apt install software-properties-common
sudo add-apt-repository universe
cxy@ubuntu2404-cxy:~$ sudo apt install software-properties-common
sudo add-apt-repository universe
正在读取软件包列表... 完成
正在分析软件包的依赖关系树... 完成
正在读取状态信息... 完成
software-properties-common 已经是最新版 (0.99.48)。
升级了 0 个软件包,新安装了 0 个软件包,要卸载 0 个软件包,有 0 个软件包未被升级。
正在添加组件‘universe’到所有软件源。
按 [ENTER] 继续,或按 Ctrl-c 取消。
命中:1 https://mirrors.tuna.tsinghua.edu.cn/ubuntu noble-security InRelease
命中:2 https://packages.microsoft.com/repos/edge stable InRelease
命中:3 http://security.ubuntu.com/ubuntu noble-security InRelease
命中:4 http://archive.ubuntu.com/ubuntu noble InRelease
命中:5 http://archive.ubuntu.com/ubuntu noble-updates InRelease
正在读取软件包列表... 完成
现在使用 apt 添加 ROS 2 GPG 密钥。
sudo apt update && sudo apt install curl -y
sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg
然后将该存储库添加到您的源列表中。
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
安装开发工具
sudo apt update && sudo apt install -y \
python3-flake8-blind-except \
python3-flake8-class-newline \
python3-flake8-deprecated \
python3-mypy \
python3-pip \
python3-pytest \
python3-pytest-cov \
python3-pytest-mock \
python3-pytest-repeat \
python3-pytest-rerunfailures \
python3-pytest-runner \
python3-pytest-timeout \
ros-dev-tools
构建 ROS 2
获取 ROS 2 代码
创建一个工作区并克隆所有仓库:
mkdir -p ~/ros2_jazzy/src #目录 admin:///home/cxy/ros2_jazzy/src
cd ~/ros2_jazzy
vcs import --input https://raw.githubusercontent.com/ros2/ros2/jazzy/ros2.repos src
cxy@ubuntu2404-cxy:~/ros2_jazzy$ vcs import --input https://raw.githubusercontent.com/ros2/ros2/jazzy/ros2.repos src
/usr/bin/vcs:6: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
from pkg_resources import load_entry_point
...........E....................................................................E..........................
=== src/ament/ament_cmake (git) ===
正克隆到 '.'...
=== src/ament/ament_index (git) ===
正克隆到 '.'...
=== src/ament/ament_lint (git) ===
正克隆到 '.'...
=== src/ament/ament_package (git) ===
正克隆到 '.'...
=== src/ament/google_benchmark_vendor (git) ===
正克隆到 '.'...
=== src/ament/googletest (git) ===
正克隆到 '.'...
=== src/ament/uncrustify_vendor (git) ===
正克隆到 '.'...
=== src/eProsima/Fast-CDR (git) ===
正克隆到 '.'...
=== src/eProsima/Fast-DDS (git) ===
正克隆到 '.'...
注意:正在切换到 'c2a4523a21a94302298bc995057719546b72df2d'。
您正处于分离头指针状态。您可以查看、做试验性的修改及提交,并且您可以在切换
回一个分支时,丢弃在此状态下所做的提交而不对分支造成影响。
如果您想要通过创建分支来保留在此状态下所做的提交,您可以通过在 switch 命令
中添加参数 -c 来实现(现在或稍后)。例如:
git switch -c <新分支名>
或者撤销此操作:
git switch -
通过将配置变量 advice.detachedHead 设置为 false 来关闭此建议
HEAD 目前位于 c2a4523a2 Implement copy_from_topic_qos method (#4719)
=== src/eProsima/foonathan_memory_vendor (git) ===
正克隆到 '.'...
=== src/eclipse-cyclonedds/cyclonedds (git) ===
正克隆到 '.'...
=== src/eclipse-iceoryx/iceoryx (git) ===
正克隆到 '.'...
=== src/gazebo-release/gz_cmake_vendor (git) ===
正克隆到 '.'...
=== src/gazebo-release/gz_math_vendor (git) ===
Could not determine ref type of version: fatal: 无法访问 'https://github.com/gazebo-release/gz_math_vendor.git/':gnutls_handshake() failed: The TLS connection was non-properly terminated.
=== src/gazebo-release/gz_utils_vendor (git) ===
正克隆到 '.'...
=== src/osrf/osrf_pycommon (git) ===
正克隆到 '.'...
=== src/osrf/osrf_testing_tools_cpp (git) ===
正克隆到 '.'...
=== src/ros-perception/image_common (git) ===
正克隆到 '.'...
=== src/ros-perception/laser_geometry (git) ===
正克隆到 '.'...
=== src/ros-perception/point_cloud_transport (git) ===
正克隆到 '.'...
=== src/ros-planning/navigation_msgs (git) ===
正克隆到 '.'...
=== src/ros-tooling/keyboard_handler (git) ===
正克隆到 '.'...
=== src/ros-tooling/libstatistics_collector (git) ===
正克隆到 &