在window10下安装Ubuntu(Window system for Linux)【WSL绕坑安装ROS】

在电脑上装个Ubuntu单系统真的坑太多(就算双系统,来回切换,硬盘分区啥的也很烦),一个人有多爱Ubuntu,就重装过多少次系统。

所以在此感谢伟大的Microsoft,整了个WSL,Windows System for Linux,光说它能够同时运行window和Linux这一点就很牛逼,就相当于把Linux做成一个APP了,可能有很多坑,但是我相信总会有解决的办法。

现在要在window里先安装一个Linux子系统,然后再安装ROS,安装的过程中有些教程里没提到的东西,不注意的话会卡主或者浪费时间。

关于在windows上安装Linux子系统,网上很多博客很详尽了,这篇博客比较好https://www.jianshu.com/p/6b02948b3d37

这里给出绕坑版本的出主要步骤:

 

1、左下角菜单栏搜索:PowerShell,点开它,输入以下内容,同意重启:

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

在window10下安装Ubuntu(Window system for Linux)【WSL绕坑安装ROS】

 

2、到微软的软件商城下载 Linux 系统(这里选Ubuntu,自动给你安装最新版的18.04)

在window10下安装Ubuntu(Window system for Linux)【WSL绕坑安装ROS】

 

3、安装完以后根据提示设置用户名和密码;

4、换源!!

直接用vim换会有点浪费时间,最简单的办法:

复制下面内容,(这里是清华源,18.04的,如果是别的版本的Ubuntu,请到这里https://mirror.tuna.tsinghua.edu.cn/help/ubuntu/选择对应版本的源,复制):

# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse

# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse

找到目录(这就是Linux子系统的目录):

C:\Users\%USERNAME%\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState\rootfs

打开,在etc\apt里直接用notepad++打开,替换掉原来的源,记得保存,很方便!!

5、可以更新了

sudo apt-get update  #更新源  
sudo apt-get upgrade  #更新软件 

~~~~~~~~~~~ 下面是安装ROS  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

参考网址:https://janbernloehr.de/2017/06/10/ros-windows(需要*)

1、第一步:

sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'

2、第二步,这是坑点,为了避免混淆,我就不贴出错误的写法,你可以按照官网的做法试一次

     如果报错内容如下

gpg: balabalabalabala  failed: IPC connect call failed
gpg: keyserver receive failed: No dirmngr

   第二步正确版本的输入:

curl -sL "http://keyserver.ubuntu.com/pks/lookup?op=get&rearch=0x421C365BD9FF1F717815A3895523BAEEB01FA116" | sudo apt-key add

3、然后就可以安装ROS了

sudo apt update
sudo apt install ros-melodic-desktop-full

4、初始化

sudo rosdep init
rosdep update

5、环境变量

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

在window10下安装Ubuntu(Window system for Linux)【WSL绕坑安装ROS】

 

6、依赖

sudo apt install python-rosinstall python-rosinstall-generator python-wstool build-essential