WSL(Window system for Linux)下安装ROS

关于WSL(Window system for Linux)下安装unbutu 18.04(Linux),网上很多博客很详尽了,不再赘述。

首先换unbutu 18.04的源:
可以直接用vim换会有点浪费时间,也可以采用下列最简单的办法:
复制下面内容,(这里是清华源,18.04的,如果是别的版本的Ubuntu,请到这里https://mirror.tuna.tsinghua.edu.cn/help/ubuntu/选择对应版本的源,复制):

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

如果是unbutu 16.04的源:

deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted universe multiverse

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

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

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

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

这里是中科大源,请选择对应版本的源,复制

接下来更新一下:

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

~~~~~~~~~~~~~~以下是正题:安装ROS~~~~~~~~~~~~~~
1、第一步:添加清华的ROS源

sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.tuna.tsinghua.edu.cn/ros/ubuntu/ $DISTRIB_CODENAME main" > /etc/apt/sources.list.d/ros-latest.list'

2、设置密钥

sudo apt-key adv --keyserver 'hkp://ha.pool.sks-keyservers.net:80' --recv-key 0x421C365BD9FF1F717815A3895523BAEEB01FA116
#或
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654

3、安装ROS

sudo apt-get update

18.04对应Melodic版本:

sudo apt install ros-melodic-desktop-full

16.04对应Kinetic版本:

sudo apt install ros-kinetic-desktop-full

4、初始化

sudo rosdep init
rosdep update

5、设置环境变量

18.04对应Melodic版本:

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

16.04对应Kinetic版本:

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

然后输入

source ~/.bashrc

6、安装rosinstall

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

7、检测

roscore

你可能感兴趣的:(ubuntu,ROS)