环境安装#

在课程规划里已明确每节课需要用到的开发环境。

开发环境 1#

本开发环境的安装分为多个步骤。根据网络环境,安装耗时约为 10 - 30 分钟。

  1. 目标: WSL 2 + Ubuntu 22.04 / 20.04

    参照 https://docs.microsoft.com/zh-cn/windows/wsl/install-manual 完成 WSL 及 Ubuntu 发行版的安装。 请先阅读第一句话,能自动安装时请选择自动安装。典型的自动安装过程如下图。

    如果你以前已经安装了 WSL 及其发行版,请使用 wsl --set-version 确保你使用了 WSL 2 。

    系统盘空间不够,代理服务的使用,Windows 10 上代替 WSLg ,可参考 https://dowww.spencerwoo.com/ 解决。但需注意该文档目前未活跃更新,如:https://github.com/spencerwooo/dowww/issues/103

    提示:你可以参考课程规划中的提示,使用已有的开发环境或替代方案。

  2. 目标: VS Code + platformIO

    按照步骤 1 安装好 WSL 后,在 https://code.visualstudio.com/download 处下载适用于 Windows 的 VS Code。若选择其他方案,请选择下载适用于 Linux 的 VS Code 。

    分清楚区别。

    提示:你是否知道中英文文档如何切换?

    稍微能借鉴的:https://zhuanlan.zhihu.com/p/61589772

  3. 目标: usb (可选)

    https://devblogs.microsoft.com/commandline/connecting-usb-devices-to-wsl/ https://dowww.spencerwoo.com/4-advanced/4-4-usb.html

  4. 杂记:clangd plugin

开发环境 2#

目标: STM32CubeMX

直接安装即可。

开发环境 3#

目标: ROS 2 humble / galactic

如果你还没有上第一节课,而且没有阅读 B.1.1 与 B.2,请你一定要先阅读它们和相关的课程实用链接。

这是中科大镜像源关于 ROS 的安装帮助:https://mirrors.ustc.edu.cn/help/ros.html

对应的官方安装帮助分别是 ROS noeticROS jammy

此时,上完了第一节课,你应该已经学会了查阅文档,已了解版本对应的基本概念。但是,你对 Linux shell 的操作和软件包管理器可能还不太了解。

根据下面的安装步骤,结合安装教程并查阅文档(如 man apt ),了解你正在做出哪些操作。完成后,描述一下安装 ROS 2 的一个发行版,需要做哪些事情?

# 本行使用管道 Pipeline 直接下载目前没有被墙的明文公钥,二进制化后利用提升权限的 tee ,将公钥放入 apt-secure 默认查找的目录 trusted.gpg.d/ 。由于是二进制文件,且 tee 也会将 stdin 继续输出到 stdout ,因此将 stdout 重定向到 /dev/null
# 区别:gpg --recv-keys 会将公钥先存到当前用户的密钥数据库中,目录位于 ~/.gnupg
curl "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0xc1cf6e31e6bade8868b172b4f42ed6fbab17c654" | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/ros-latest.gpg >/dev/null

# 本行使用<https://askubuntu.com/a/1197066>类似的方法,获取 code name ,并继续利用提升权限的 tee 输出仓库源信息(或覆盖),同时也将结果输出到 stdout
echo "deb http://mirrors.ustc.edu.cn/ros2/ubuntu $(. /etc/os-release && echo UBUNTU_CODENAME) main" | sudo tee /etc/apt/sources.list.d/ros2.list

# 本行(还有上面一行获取 code name 的方法)使用逻辑判断符 && ,各类 shell 顺序执行被该逻辑判断符连接的指令,在任一指令返回值非零(即 False )时,停止本语句执行并返回 1 。见<https://stackoverflow.com/questions/2933843/>。与之对应 ; 仅用于分隔语句,相当于换行。
# 本行默认用户使用交互式界面,若使用脚本时应使用 apt-get 。-y 避免用户确认安装操作。对于 Ubuntu focal 应安装 ros-galactic-desktop 。
sudo apt update && sudo apt install ros-humble-desktop-full -y

提示: 如果你遇到了问题,你应该像这样列出你配置的所有仓库源:

# 文档:`man cat` `man for`
cat /etc/apt/source.list; for file in /etc/apt/source.list.d/*; do echo "$file"; cat "$file"; done

根据 SOURCES.LIST(5) ,其文件格式和一些你可能会遇到问题如下:

[[one-line-style]]
deb[-src] [ option1=value1 option2=value2 ]             uri suite [component1] [component2] [...]
deb       [ arch=amd64 ] https://mirrors.cqu.edu.cn/ubuntu/ jammy-security main restricted universe multiverse

1. The source list /etc/apt/sources.list and the files contained in /etc/apt/sources.list.d/ are designed to support any number of active sources and a variety of source media.

(https://manpages.debian.org/stable/apt/sources.list.5.en.html#THE_DEB_AND_DEB-SRC_TYPES:_OPTIONS)

2. Architectures (arch) is a multivalue option defining for which architectures information should be downloaded. If this option isn't set the default is all architectures as defined by the APT::Architectures config option.

3. Signed-By (signed-by) is an option to require a repository to pass apt-secure(8) verification with a certain set of keys rather than all trusted keys apt has configured. It is specified as a list of absolute paths to keyring files (have to be accessible and readable for the _apt system user, so ensure everyone has read-permissions on the file) and fingerprints of keys to select from these keyrings. If no keyring files are specified the default is the trusted.gpg keyring and all keyrings in the trusted.gpg.d/ directory (see apt-key fingerprint). (...)

参考#

  1. 版本对应表格

  2. 偷懒的办法

开发环境 4#

目标: Docker

开发环境 5#

目标: Git

开发环境 6#

目标: OpenCV 或任意含图像处理的深度学习框架

请参见实操第一节课