目录

一、准备工作

二、安装Ubuntu 22.04.1 LTS

1. 下载Ubuntu 22.04.1 LTS

2. 移动到非系统盘

三、启动Ubuntu遇到的报错及解决方案



控制面板——程序——程序功能——启动关闭Windows功能

 

开启如图所示三项重启电脑

打开Microsoft Store,搜索下载Ubuntu 22.04.1 LTS

安装Windows Subsystem for Linux前一定要先安装Ubuntu,否则移动Ubuntu位置报错

ps默认安装C盘,可以移动安装位置建议移动到其它盘

报错

WslRegisterDistribution failed with error: 0x800701bc

解决方案

下载安装用于 x64 计算机最新 WSL2 Linux 内核更新

下载链接

https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi

安装

报错

adduser: Please enter a username matching the regular expression configured

via the NAME_REGEX[_SYSTEM] configuration variable.  Use the `–forcebadname

option to relax this check or reconfigure NAME_REGEX.

解决方案

大写首字母,改成小写即可

ps输入密码显示

Ubuntu默认软件源在国外可能会造成下载软件卡顿,因此需要换源这里选择更换阿里源。

1.双击Ubuntu22.04 LTS图标,在命令行输入

# 备份原来的软件sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak

# 编辑软件sudo nano /etc/apt/sources.list

2.将原来的内容替换阿里

deb http://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ jammy-proposed main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ jammy-proposed main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse

Ctrl + O保存, enter, Ctrl + X退出

3.更改

4. 更新升级软件

在Ubuntu命令行中依次执行如下命令

# 更新软件sudo apt-get update -y

# 升级所有软件

sudo apt-get upgrade -y

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

1.通过检查命令输出,确保已启用Ubuntu Universe存储库。

apt-cache policy | grep universe

正常情况

​ 

没有看到像上面这样的输出行,依次执行如下命令

sudo apt install software-properties-common

sudo add-apt-repository universe

2.继续执行如下命令

sudo apt update && sudo apt install curl gnupg lsb-release

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 $(source /etc/os-release && echo $UBUNTU_CODENAME) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null

正常情况

报错:curl: (7) Failed to connect to raw.githubusercontent.com port 443 after 0 ms: Connection refused

解决

sudo nano /etc/hosts

加上一行

199.232.28.133 raw.githubusercontent.com

Ctrl + O保存, enter, Ctrl + X退出

sudo apt update

sudo apt upgrade

安装桌面版

sudo apt install ros-humble-desktop

安装时间较长,慢慢等待

source /opt/ros/humble/setup.bash

echo " source /opt/ros/humble/setup.bash" >> ~/.bashrc

通过以下命令启动个数据的发布节点

ros2 run demo_nodes_cpp talker

启动一个终端通过以下命令启动个数据的订阅节点

ros2 run demo_nodes_py listener

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注