将 note 笔记库同步到 note_sync,AI_compiler 作为 submodule
This commit is contained in:
@@ -0,0 +1,128 @@
|
||||
# ROS2 代码结构图
|
||||
|
||||
## ROS2 工作区目录结构
|
||||
|
||||
```mermaid
|
||||
flowchart TD
|
||||
Workspace[ROS2 工作区] --> src[src/ 源代码目录]
|
||||
Workspace --> build[build/ 构建目录]
|
||||
Workspace --> install[install/ 安装目录]
|
||||
Workspace --> log[log/ 日志目录]
|
||||
|
||||
src --> Package1[包1]
|
||||
src --> Package2[包2]
|
||||
src --> PackageN[...]
|
||||
|
||||
Package1 --> P1_CMake[CMakeLists.txt]
|
||||
Package1 --> P1_PackageXML[package.xml]
|
||||
Package1 --> P1_src[src/ 源代码]
|
||||
Package1 --> P1_include[include/ 头文件]
|
||||
Package1 --> P1_msgs[msg/ 消息定义]
|
||||
Package1 --> P1_srvs[srv/ 服务定义]
|
||||
Package1 --> P1_actions[action/ 动作定义]
|
||||
```
|
||||
|
||||
## ROS2 软件架构
|
||||
|
||||
```mermaid
|
||||
flowchart TD
|
||||
App[应用程序] --> ClientLibs[客户端库]
|
||||
|
||||
subgraph ClientLibs [客户端库]
|
||||
direction LR
|
||||
RCLcpp[C++ 客户端库 rclcpp]
|
||||
RCLpy[Python 客户端库 rclpy]
|
||||
RCL[C 客户端库 rcl]
|
||||
end
|
||||
|
||||
ClientLibs --> RCL_Interface[RCL 接口]
|
||||
RCL_Interface --> RMW[ROS 中间件接口 RMW]
|
||||
|
||||
subgraph DDS_Implementations [DDS 实现]
|
||||
direction LR
|
||||
FastDDS[Fast DDS]
|
||||
CycloneDDS[Cyclone DDS]
|
||||
RTI_Connext[RTI Connext]
|
||||
OpenSplice[OpenSplice]
|
||||
end
|
||||
|
||||
RMW --> DDS_Implementations
|
||||
DDS_Implementations --> Network[网络通信]
|
||||
```
|
||||
|
||||
## ROS2 核心包依赖关系
|
||||
|
||||
```mermaid
|
||||
flowchart TD
|
||||
ROS2_Core[ROS2 核心] --> ament_core[ament_core<br/>构建系统]
|
||||
ROS2_Core --> rcl[rcl<br/>C语言客户端库]
|
||||
ROS2_Core --> rclcpp[rclcpp<br/>C++客户端库]
|
||||
ROS2_Core --> rclpy[rclpy<br/>Python客户端库]
|
||||
|
||||
rcl --> rmw[rmw<br/>中间件接口]
|
||||
rclcpp --> rcl
|
||||
rclpy --> rcl
|
||||
|
||||
rmw --> rmw_implementation[rmw_implementation<br/>中间件实现]
|
||||
rmw_implementation --> DDS[DDS 实现]
|
||||
|
||||
ROS2_Tools[ROS2 工具] --> ros2cli[ros2cli<br/>命令行工具]
|
||||
ROS2_Tools --> colcon[colcon<br/>构建工具]
|
||||
ROS2_Tools --> launch_ros[launch_ros<br/>启动系统]
|
||||
```
|
||||
|
||||
## ROS2 节点通信模型
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
NodeA[ROS2 节点 A] -->|发布话题| Topic1[话题 /topic1]
|
||||
NodeB[ROS2 节点 B] -->|订阅话题| Topic1
|
||||
|
||||
NodeC[ROS2 节点 C] -->|请求服务| Service1[服务 /service1]
|
||||
NodeD[ROS2 节点 D] -->|提供服务| Service1
|
||||
|
||||
NodeE[ROS2 节点 E] -->|发送目标| Action1[动作 /action1]
|
||||
NodeF[ROS2 节点 F] -->|执行动作| Action1
|
||||
NodeF -->|反馈| NodeE
|
||||
NodeF -->|结果| NodeE
|
||||
```
|
||||
|
||||
## 说明
|
||||
|
||||
### 1. 工作区目录结构
|
||||
- **src/**: 包含所有ROS2包的源代码
|
||||
- **build/**: 构建过程中生成的中间文件
|
||||
- **install/**: 安装目录,包含可执行文件、库和资源
|
||||
- **log/**: 构建和运行时的日志文件
|
||||
|
||||
### 2. ROS2包的基本结构
|
||||
每个ROS2包通常包含:
|
||||
- `CMakeLists.txt`: CMake构建配置文件
|
||||
- `package.xml`: 包元数据文件
|
||||
- `src/`: C++或Python源代码
|
||||
- `include/`: C++头文件
|
||||
- `msg/`, `srv/`, `action/`: 消息、服务、动作定义文件
|
||||
|
||||
### 3. 软件架构层次
|
||||
1. **应用程序层**: 用户编写的ROS2节点
|
||||
2. **客户端库层**: 语言特定的API(C++、Python、C)
|
||||
3. **RCL层**: 通用的ROS客户端库
|
||||
4. **RMW层**: ROS中间件抽象接口
|
||||
5. **DDS层**: 具体的DDS实现
|
||||
|
||||
### 4. 通信模式
|
||||
- **话题(Topics)**: 发布/订阅模式,单向异步通信
|
||||
- **服务(Services)**: 请求/响应模式,同步通信
|
||||
- **动作(Actions)**: 目标/反馈/结果模式,长时间运行的任务
|
||||
|
||||
## 使用方法
|
||||
|
||||
1. 将本文件在支持 Mermaid 图的 Markdown 查看器中打开(如 VS Code with Mermaid 插件、GitHub、GitLab 等)
|
||||
2. 图表将自动渲染为可视化图形
|
||||
3. 如需修改图表,编辑对应的 Mermaid 代码块
|
||||
|
||||
## 相关资源
|
||||
|
||||
- [ROS2 官方文档](https://docs.ros.org/)
|
||||
- [ROS2 架构设计](https://design.ros2.org/)
|
||||
- [Mermaid 语法指南](https://mermaid.js.org/syntax/flowchart.html)
|
||||
@@ -0,0 +1,77 @@
|
||||
# 维护 ROS 2 源代码检出
|
||||
|
||||
## [概述](https://docs.ros.org/en/humble/Installation/Maintaining-a-Source-Checkout.html)
|
||||
|
||||
本文档介绍如何维护从源代码构建的 ROS 2 安装。如果您已经从源代码安装了 ROS 2,并且想要更新到最新的错误修复和功能,请遵循本指南。
|
||||
|
||||
## [更新 ROS 2 源代码](https://docs.ros.org/en/humble/Installation/Maintaining-a-Source-Checkout.html#updating-ros-2-source-code)
|
||||
|
||||
### 1. 更新仓库列表文件
|
||||
|
||||
首先,您需要获取最新的 `ros2.repos` 文件,该文件定义了构建 ROS 2 所需的所有仓库及其分支。
|
||||
|
||||
```bash
|
||||
# 对于 Humble Hawksbill 版本
|
||||
cd ~/ros2_humble
|
||||
wget https://raw.githubusercontent.com/ros2/ros2/humble/ros2.repos -O ros2.repos
|
||||
```
|
||||
|
||||
或者,如果您想使用特定分支(例如主分支)而不是发布分支:
|
||||
|
||||
```bash
|
||||
# 使用主分支(开发版本)
|
||||
wget https://raw.githubusercontent.com/ros2/ros2/master/ros2.repos -O ros2.repos
|
||||
```
|
||||
|
||||
### 2. 更新本地仓库
|
||||
|
||||
使用 `vcs` 工具更新您的本地仓库:
|
||||
|
||||
```bash
|
||||
# 更新所有仓库的远程引用
|
||||
vcs custom --args remote update
|
||||
```
|
||||
|
||||
### 3. 下载新的源代码
|
||||
|
||||
现在,使用新的 `ros2.repos` 文件导入并拉取最新的代码:
|
||||
|
||||
```bash
|
||||
# 导入新仓库定义
|
||||
vcs import src < ros2.repos
|
||||
|
||||
# 拉取所有仓库的最新代码
|
||||
vcs pull src
|
||||
```
|
||||
|
||||
**注意**:`vcs import` 命令将覆盖 `src` 目录中现有的仓库定义。如果您有本地修改或添加了额外的仓库,请确保在运行此命令之前备份您的更改。
|
||||
|
||||
### 4. 重新构建工作空间
|
||||
|
||||
更新源代码后,需要重新构建工作空间:
|
||||
|
||||
```bash
|
||||
# 返回到工作空间根目录
|
||||
cd ~/ros2_humble
|
||||
|
||||
# 使用 colcon 重新构建
|
||||
colcon build --symlink-install
|
||||
```
|
||||
|
||||
构建选项说明:
|
||||
- `--symlink-install`:使用符号链接而不是复制文件,这可以加快构建速度并减少磁盘空间使用
|
||||
|
||||
### 5. 检查源代码状态
|
||||
|
||||
要查看当前工作空间中所有仓库的状态,可以导出当前的仓库配置:
|
||||
|
||||
```bash
|
||||
# 导出当前仓库状态
|
||||
vcs export src > my_ros2.repos
|
||||
```
|
||||
|
||||
这将在当前目录下创建一个 `my_ros2.repos` 文件,其中包含所有仓库的当前提交哈希值。您可以将此文件用于:
|
||||
- 备份当前的源代码状态
|
||||
- 在其他机器上复制相同的配置
|
||||
- 调试构建问题
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
## [System requirements](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#id1)[](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#system-requirements "Link to this heading")
|
||||
|
||||
The current Debian-based target platforms for Humble Hawksbill are:
|
||||
|
||||
- Tier 1: Ubuntu Linux - Jammy (22.04) 64-bit
|
||||
|
||||
- Tier 3: Ubuntu Linux - Focal (20.04) 64-bit
|
||||
|
||||
- Tier 3: Debian Linux - Bullseye (11) 64-bit
|
||||
|
||||
|
||||
Other Linux platforms with varying support levels include:
|
||||
|
||||
- Arch Linux, see [alternate instructions](https://wiki.archlinux.org/index.php/ROS#ROS_2)
|
||||
|
||||
- Fedora Linux, see [alternate instructions](https://ros2docs.robook.org/humble/Installation/Alternatives/Fedora-Development-Setup.html)
|
||||
|
||||
- OpenEmbedded / webOS OSE, see [alternate instructions](https://github.com/ros/meta-ros/wiki/OpenEmbedded-Build-Instructions)
|
||||
|
||||
|
||||
As defined in [REP 2000](https://www.ros.org/reps/rep-2000.html).
|
||||
|
||||
## [System setup](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#id2)[](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#system-setup "Link to this heading")
|
||||
|
||||
### [Set locale](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#id3)[](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#set-locale "Link to this heading")
|
||||
|
||||
请确保您有一个支持 `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`
|
||||
|
||||
### [Add the ROS 2 apt repository](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#id4)[](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#add-the-ros-2-apt-repository "Link to this heading")
|
||||
|
||||
你需要将 ROS 2 apt 仓库添加到你的系统中。
|
||||
|
||||
首先确保 [Ubuntu Universe 仓库](https://help.ubuntu.com/community/Repositories/Ubuntu) 已启用。
|
||||
|
||||
`sudo apt install software-properties-common`
|
||||
`sudo add-apt-repository universe`
|
||||
|
||||
然后使用 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`
|
||||
|
||||
### [Install development tools and ROS tools](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#id5)[](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#install-development-tools-and-ros-tools "Link to this heading")
|
||||
|
||||
Install common packages.
|
||||
|
||||
`sudo apt update && sudo apt install -y \`
|
||||
`python3-flake8-docstrings \`
|
||||
`python3-pip \`
|
||||
`python3-pytest-cov \`
|
||||
`ros-dev-tools`
|
||||
|
||||
Install packages according to your Ubuntu version.
|
||||
|
||||
Ubuntu 22.04 LTS and laterUbuntu 20.04 LTS
|
||||
|
||||
`sudo apt install -y \`
|
||||
`python3-flake8-blind-except \`
|
||||
`python3-flake8-builtins \`
|
||||
`python3-flake8-class-newline \`
|
||||
`python3-flake8-comprehensions \`
|
||||
`python3-flake8-deprecated \`
|
||||
`python3-flake8-import-order \`
|
||||
`python3-flake8-quotes \`
|
||||
`python3-pytest-repeat \`
|
||||
`python3-pytest-rerunfailures`
|
||||
|
||||
## [Get ROS 2 code](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#id6)[](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#get-ros-2-code "Link to this heading")
|
||||
|
||||
Create a workspace and clone all repos:
|
||||
|
||||
`mkdir -p ~/ros2_humble/src`
|
||||
`cd ~/ros2_humble`
|
||||
`vcs import --input https://raw.githubusercontent.com/ros2/ros2/humble/ros2.repos src`
|
||||
|
||||
## [Install dependencies using rosdep](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#id7)[](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#install-dependencies-using-rosdep "Link to this heading")
|
||||
|
||||
ROS 2 包是在经常更新的 Ubuntu 系统上构建的。 在安装新包之前,建议您确保系统是最新的。
|
||||
|
||||
%% `sudo apt upgrade` %%
|
||||
|
||||
`sudo rosdep init`
|
||||
`rosdep update`
|
||||
`rosdep install --from-paths src --ignore-src -y --skip-keys "fastcdr rti-connext-dds-6.0.1 urdfdom_headers"`
|
||||
|
||||
**Note**: If you’re using a distribution that is based on Ubuntu (like Linux Mint) but does not identify itself as such, you’ll get an error message like `Unsupported OS [mint]`. In this case append `--os=ubuntu:jammy` to the above command.
|
||||
|
||||
## [Install additional DDS implementations (optional)](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#id8)[](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#install-additional-dds-implementations-optional "Link to this heading")
|
||||
|
||||
If you would like to use another DDS or RTPS vendor besides the default, you can find instructions [here](https://ros2docs.robook.org/humble/Installation/DDS-Implementations.html).
|
||||
|
||||
## [Build the code in the workspace](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#id9)[](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#build-the-code-in-the-workspace "Link to this heading")
|
||||
|
||||
If you have already installed ROS 2 another way (either via debs or the binary distribution), make sure that you run the below commands in a fresh environment that does not have those other installations sourced. Also ensure that you do not have `source /opt/ros/${ROS_DISTRO}/setup.bash` in your `.bashrc`. You can make sure that ROS 2 is not sourced with the command `printenv | grep -i ROS`. The output should be empty.
|
||||
|
||||
More info on working with a ROS workspace can be found in [this tutorial](https://ros2docs.robook.org/humble/Tutorials/Beginner-Client-Libraries/Colcon-Tutorial.html).
|
||||
|
||||
`cd ~/ros2_humble/`
|
||||
`colcon build --symlink-install`
|
||||
|
||||
Note: if you are having trouble compiling all examples and this is preventing you from completing a successful build, you can use `COLCON_IGNORE` in the same manner as [CATKIN_IGNORE](https://github.com/ros-infrastructure/rep/blob/master/rep-0128.rst) to ignore the subtree or remove the folder from the workspace. Take for instance: you would like to avoid installing the large OpenCV library. Well then simply run `touch COLCON_IGNORE` in the `cam2image` demo directory to leave it out of the build process.
|
||||
|
||||
## [Environment setup](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#id10)[](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#environment-setup "Link to this heading")
|
||||
|
||||
### [Source the setup script](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#id11)[](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#source-the-setup-script "Link to this heading")
|
||||
|
||||
Set up your environment by sourcing the following file.
|
||||
|
||||
# Replace ".bash" with your shell if you're not using bash
|
||||
# Possible values are: setup.bash, setup.sh, setup.zsh
|
||||
|
||||
`. ~/ros2_humble/install/local_setup.bash`
|
||||
|
||||
## [Try some examples](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#id12)[](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#try-some-examples "Link to this heading")
|
||||
|
||||
In one terminal, source the setup file and then run a C++ `talker`:
|
||||
|
||||
`. ~/ros2_humble/install/local_setup.bash`
|
||||
`ros2 run demo_nodes_cpp talker`
|
||||
|
||||
In another terminal source the setup file and then run a Python `listener`:
|
||||
|
||||
`. ~/ros2_humble/install/local_setup.bash`
|
||||
`ros2 run demo_nodes_py listener`
|
||||
|
||||
You should see the `talker` saying that it’s `Publishing` messages and the `listener` saying `I heard` those messages. This verifies both the C++ and Python APIs are working properly. Hooray!
|
||||
@@ -0,0 +1,161 @@
|
||||
## [系统要求](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#id1)[](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#system-requirements "Link to this heading")
|
||||
|
||||
当前 Humble Hawksbill 基于 Debian 的目标平台包括:
|
||||
|
||||
- 第一级:Ubuntu Linux - Jammy (22.04) 64位
|
||||
|
||||
- 第三级:Ubuntu Linux - Focal (20.04) 64位
|
||||
|
||||
- 第三级:Debian Linux - Bullseye (11) 64位
|
||||
|
||||
|
||||
其他支持程度不同的 Linux 平台包括:
|
||||
|
||||
- Arch Linux,请参阅[替代安装说明](https://wiki.archlinux.org/index.php/ROS#ROS_2)
|
||||
|
||||
- Fedora Linux,请参阅[替代安装说明](https://ros2docs.robook.org/humble/Installation/Alternatives/Fedora-Development-Setup.html)
|
||||
|
||||
- OpenEmbedded / webOS OSE,请参阅[替代安装说明](https://github.com/ros/meta-ros/wiki/OpenEmbedded-Build-Instructions)
|
||||
|
||||
|
||||
如 [REP 2000](https://www.ros.org/reps/rep-2000.html) 中所定义。
|
||||
|
||||
## [系统设置](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#id2)[](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#system-setup "Link to this heading")
|
||||
|
||||
### [设置区域](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#id3)[](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#set-locale "Link to this heading")
|
||||
|
||||
请确保您有一个支持 `UTF-8` 的区域设置。如果您处于最简环境中(例如 docker 容器),区域设置可能是一些类似 `POSIX` 的选项。我们使用以下设置通过了测试。但是,如果您使用不同的支持 `UTF-8` 的区域设置,也应该没问题。
|
||||
|
||||
```bash
|
||||
locale # 检查 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 # 验证设置
|
||||
```
|
||||
|
||||
### [添加 ROS 2 apt 仓库](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#id4)[](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#add-the-ros-2-apt-repository "Link to this heading")
|
||||
|
||||
你需要将 ROS 2 apt 仓库添加到你的系统中。
|
||||
|
||||
首先确保 [Ubuntu Universe 仓库](https://help.ubuntu.com/community/Repositories/Ubuntu) 已启用。
|
||||
|
||||
```bash
|
||||
sudo apt install software-properties-common
|
||||
sudo add-apt-repository universe
|
||||
```
|
||||
|
||||
然后使用 apt 添加 ROS 2 GPG 密钥。
|
||||
|
||||
```bash
|
||||
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
|
||||
```
|
||||
|
||||
然后将仓库添加到你的源列表中。
|
||||
|
||||
```bash
|
||||
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
|
||||
```
|
||||
|
||||
### [安装开发工具和 ROS 工具](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#id5)[](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#install-development-tools-and-ros-tools "Link to this heading")
|
||||
|
||||
安装常用软件包。
|
||||
|
||||
```bash
|
||||
sudo apt update && sudo apt install -y \
|
||||
python3-flake8-docstrings \
|
||||
python3-pip \
|
||||
python3-pytest-cov \
|
||||
ros-dev-tools
|
||||
```
|
||||
|
||||
根据您的 Ubuntu 版本安装软件包。
|
||||
|
||||
Ubuntu 22.04 LTS 及更高版本 Ubuntu 20.04 LTS
|
||||
|
||||
```bash
|
||||
sudo apt install -y \
|
||||
python3-flake8-blind-except \
|
||||
python3-flake8-builtins \
|
||||
python3-flake8-class-newline \
|
||||
python3-flake8-comprehensions \
|
||||
python3-flake8-deprecated \
|
||||
python3-flake8-import-order \
|
||||
python3-flake8-quotes \
|
||||
python3-pytest-repeat \
|
||||
python3-pytest-rerunfailures
|
||||
```
|
||||
|
||||
## [获取 ROS 2 代码](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#id6)[](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#get-ros-2-code "Link to this heading")
|
||||
|
||||
创建工作区并克隆所有仓库:
|
||||
|
||||
```bash
|
||||
mkdir -p ~/ros2_humble/src
|
||||
cd ~/ros2_humble
|
||||
vcs import --input https://raw.githubusercontent.com/ros2/ros2/humble/ros2.repos src
|
||||
```
|
||||
|
||||
## [使用 rosdep 安装依赖](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#id7)[](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#install-dependencies-using-rosdep "Link to this heading")
|
||||
|
||||
ROS 2 包是在经常更新的 Ubuntu 系统上构建的。在安装新包之前,建议您确保系统是最新的。
|
||||
|
||||
%% `sudo apt upgrade` %%
|
||||
|
||||
```bash
|
||||
sudo rosdep init
|
||||
rosdep update
|
||||
rosdep install --from-paths src --ignore-src -y --skip-keys "fastcdr rti-connext-dds-6.0.1 urdfdom_headers"
|
||||
```
|
||||
|
||||
**注意**:如果您使用的是基于 Ubuntu 的发行版(如 Linux Mint)但系统未标识为 Ubuntu,您可能会收到类似 `Unsupported OS [mint]` 的错误消息。在这种情况下,请在上述命令后追加 `--os=ubuntu:jammy`。
|
||||
|
||||
## [安装额外的 DDS 实现(可选)](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#id8)[](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#install-additional-dds-implementations-optional "Link to this heading")
|
||||
|
||||
如果您想使用默认之外的 DDS 或 RTPS 供应商,可以在此处找到说明[这里](https://ros2docs.robook.org/humble/Installation/DDS-Implementations.html)。
|
||||
|
||||
## [在工作区中构建代码](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#id9)[](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#build-the-code-in-the-workspace "Link to this heading")
|
||||
|
||||
如果您已经通过其他方式(deb 包或二进制发行版)安装了 ROS 2,请确保在未激活其他安装的新环境中运行以下命令。同时确保您的 `.bashrc` 中没有 `source /opt/ros/${ROS_DISTRO}/setup.bash`。您可以使用命令 `printenv | grep -i ROS` 来确保 ROS 2 未被激活。输出应为空。
|
||||
|
||||
有关使用 ROS 工作区的更多信息,请参阅[本教程](https://ros2docs.robook.org/humble/Tutorials/Beginner-Client-Libraries/Colcon-Tutorial.html)。
|
||||
|
||||
```bash
|
||||
cd ~/ros2_humble/
|
||||
colcon build --symlink-install
|
||||
```
|
||||
|
||||
**注意**:如果编译所有示例时遇到问题,导致无法成功构建,您可以像使用 [CATKIN_IGNORE](https://github.com/ros-infrastructure/rep/blob/master/rep-0128.rst) 一样使用 `COLCON_IGNORE` 来忽略子树或从工作区中移除文件夹。例如:如果您想避免安装庞大的 OpenCV 库,只需在 `cam2image` 演示目录中运行 `touch COLCON_IGNORE` 即可将其排除在构建过程之外。
|
||||
|
||||
## [环境设置](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#id10)[](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#environment-setup "Link to this heading")
|
||||
|
||||
### [源化安装脚本](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#id11)[](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#source-the-setup-script "Link to this heading")
|
||||
|
||||
通过源化以下文件来设置您的环境。
|
||||
|
||||
# 如果不使用 bash,请将 ".bash" 替换为您的 shell
|
||||
# 可能的取值为:setup.bash, setup.sh, setup.zsh
|
||||
|
||||
```bash
|
||||
. ~/ros2_humble/install/local_setup.bash
|
||||
```
|
||||
|
||||
## [尝试一些示例](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#id12)[](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#try-some-examples "Link to this heading")
|
||||
|
||||
在一个终端中,源化安装脚本然后运行 C++ `talker`:
|
||||
|
||||
```bash
|
||||
. ~/ros2_humble/install/local_setup.bash
|
||||
ros2 run demo_nodes_cpp talker
|
||||
```
|
||||
|
||||
在另一个终端中源化安装脚本然后运行 Python `listener`:
|
||||
|
||||
```bash
|
||||
. ~/ros2_humble/install/local_setup.bash
|
||||
ros2 run demo_nodes_py listener
|
||||
```
|
||||
|
||||
您应该能看到 `talker` 显示它正在 `Publishing` 消息,而 `listener` 显示 `I heard` 这些消息。这表明 C++ 和 Python API 都能正常工作。太好了!
|
||||
@@ -0,0 +1,8 @@
|
||||
``` bash
|
||||
source install/local_setup.bash
|
||||
# export ROS_DOMAIN_ID=<your_domain_id>
|
||||
# echo "export ROS_DOMAIN_ID=<your_domain_id>" >> ~/.bashrc
|
||||
# export ROS_LOCALHOST_ONLY=1
|
||||
# echo "export ROS_LOCALHOST_ONLY=1" >> ~/.bashrc
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user