Windows11 installs Linux subsystem (Ubuntu22.04LTS) + installs ROS

Table of contents

1. Preparation

2. Install Ubuntu 22.04.1 LTS

3. Errors and solutions encountered when starting Ubuntu

Fourth, change the source

5. Install ROS

set encoding

add source

Install ROS

set environment variables

test


1. Preparation

Control Panel - Programs - Programs and Features - Turn Windows features on or off

 

 

Open the three items shown in the figure and restart the computer

 

2. Install Ubuntu 22.04.1 LTS

Open Microsoft Store, search and download Ubuntu 22.04.1 LTS

( Be sure to install Ubuntu before installing Windows Subsystem for Linux , otherwise an error will be reported if you move the location of Ubuntu )

 

ps : By default, it is installed on the C drive, and the installation location can be moved. It is recommended to move to another drive

 

3. Errors and solutions encountered when starting Ubuntu

Error:

WslRegisterDistribution failed with error: 0x800701bc

solution:

Download and install the latest WSL2 Linux kernel update package for x64 computers

download link

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

After installation

Error:

adduser: Please enter a username matching the regular expression configured

via the NAME_REGEX[_SYSTEM] configuration variable.  Use the `--force-badname'

option to relax this check or reconfigure NAME_REGEX.

solution:

Change capital letters to lowercase

ps : the entered password is not displayed

Fourth, change the source

The default software source of Ubuntu is abroad, which may cause the download software to freeze, so the source needs to be changed. Here I choose to change to Ali source.

1. Double-click the Ubuntu22.04 LTS icon, enter in the command line

# 备份原来的软件源

sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak

# 编辑软件源

sudo nano /etc/apt/sources.list

2. Replace the original content with Aliyuan

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 to save , enter, Ctrl + X to exit

 

3. After the change

 

4. Update and upgrade software

Execute the following commands in sequence on the Ubuntu command line:

# 更新软件源

sudo apt-get update -y

# 升级所有软件

sudo apt-get upgrade -y

 

5. Install ROS

set encoding

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

 

add source

1. Make sure the Ubuntu Universe repository is enabled by checking the output of this command.

apt-cache policy | grep universe

normal situation

 

If you do not see the output line like above, execute the following commands in sequence:

sudo apt install software-properties-common

sudo add-apt-repository universe

2. Continue to execute the following commands:

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

normal situation

 

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

solve

sudo nano /etc/hosts

add a line

199.232.28.133 raw.githubusercontent.com

Ctrl + O to save , enter, Ctrl + X to exit

 

Install ROS

sudo apt update

sudo apt upgrade

Install the desktop version

sudo apt install ros-humble-desktop

 

 

The installation time is long, wait slowly

set environment variables

source /opt/ros/humble/setup.bash

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

test

Start a data publisher node with the following command:

ros2 run demo_nodes_cpp talker

 

②Start another terminal and start a data subscriber node through the following command

ros2 run demo_nodes_py listener

 

Guess you like

Origin blog.csdn.net/m0_63834988/article/details/128672234