Windows 11 子系统: Ubuntu 18.04 安装ROS Melodic
一、从Microsoft Store安装Ubuntu 18.04
二、配置环境
- 1、快捷键 win + R
- 2、控制面板->启用或关闭windows功能,勾选 Hyper-V、适用于 Linux 的 Windows 子系统、虚拟机平台,勾选这三个选项。
- 3、重启电脑
三、更换ubuntu源
- 1、搜索找到ubuntu 18.04,打开ubuntu
- 2、备份源
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
- 3、更换源
sudo vi /etc/apt/sources.list
复制以下内容:
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
- 4、更新软件
sudo apt-get update
sudo apt-get upgrade
四、添加ROS源
- 1、在终端运行以下内容
sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.ustc.edu.cn/ros/ubuntu/ $DISTRIB_CODENAME main" > /etc/apt/sources.list.d/ros-latest.list'
- 2、添加ROS密钥
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116
- 3、更新软件
sudo apt-get update
sudo apt-get upgrade
五、安装ros-melodic-desktop-full
sudo apt-get install ros-melodic-desktop-full
六、安装python-rosdep
sudo apt-get install python-rosdep
更新软件
sudo apt-get update
sudo apt-get upgrade
七、运行rosdep init
rosdep init
八、运行rosdep update
rosdep update
也许会报错:
这里需要我们开vpn去下载 !! 或者多试几次 !
九、测试
运行:
roscore
如果出现以下内容,说明ROS Melodic安装成功!
安装ROS报错方案集合:
- 问题:
- 解决:
在终端运行以下命令:
vim apt-info.sh
输入以下内容:
#!/bin/bash
set -e
# Clean out /var/cache/apt/archives
apt-get clean
# Fill it with all the .debs we need
apt-get --reinstall -dy install $(dpkg --get-selections | grep '[[:space:]]install' | cut -f1)
DIR=$(mktemp -d -t info-XXXXXX)
for deb in /var/cache/apt/archives/*.deb
do
# Move to working directory
cd "$DIR"
# Create DEBIAN directory
mkdir -p DEBIAN
# Extract control files
dpkg-deb -e "$deb"
# Extract file list, fixing up the leading ./ and turning / into /.
dpkg-deb -c "$deb" | awk '{print $NF}' | cut -c2- | sed -e 's/^\/$/\/./' > DEBIAN/list
# Figure out binary package name
DEB=$(basename "$deb" | cut -d_ -f1)
# Copy each control file into place
cd DEBIAN
for file in *
do
cp -a "$file" /var/lib/dpkg/info/"$DEB"."$file"
done
# Clean up
cd ..
rm -rf DEBIAN
done
rmdir "$DIR"
保存退出后,运行:
bash apt-info.sh
【有些小问题我就没有一 一说明,如果有其他问题欢迎咨询 ~】
!! 在折腾了两天图形界面显示之后,奉劝大家也别折腾了,目前的xlaunch方法还支持不足,各种错误层出不穷(就不多说了),期待微软之后推出的相关功能,到时候再来更新一波~
------------------------------------分界线-----------------------------------------------
如果想打开Linux UI界面,参考:https://www.linuxprobe.com/win10-subsystem-gui.html
参考:
- https://blog.csdn.net/u014531804/article/details/106124512
- https://www.pianshen.com/article/5486845506/
- https://blog.csdn.net/p942005405/article/details/86567416