Win10-WSL-Ubuntu18.04-ROS-melodi
2021-01-11 本文已影响0人
洗洗睡吧i
一、WSL 安装 Ubuntu18.04
- Win10 启用 WSL
管理员身份运行:
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
重启电脑。
-
打开 Microsoft Store,安装 Ubuntu18.04
-
启动 Ubuntu18.04,创建账号、密码
-
安装 Windows Terminal(可选)
用 scoop 安装。
scoop install windows-terminal
windows-terminal 简单设置:字体、启动目录。
{
"guid": "{c6eaf9f4-32a7-5fdc-b5cf-066e8a4b1e40}",
"hidden": false,
"fontFace": "Jetbrains Mono",
"fontSize": 11,
"name": "Ubuntu-18.04",
"source": "Windows.Terminal.Wsl",
"startingDirectory": "//wsl$/Ubuntu-18.04//home/bo",
}
- 设置源,更新(可选)
打开配置文件: sudo nano /etc/apt/sources.list
, 替换成以下内容:
# 默认注释了源码镜像以提高 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
ref: https://mirrors.tuna.tsinghua.edu.cn/help/ubuntu/
更新:sudo apt update
升级:sudo apt upgrade
- 安装 ZSH、oh-my-zsh(可选)
-略-
二、安装 ROS-melodic
ref: http://wiki.ros.org/melodic/Installation/Ubuntu
sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.tuna.tsinghua.edu.cn/ros/ubuntu/ `lsb_release -cs` main" > /etc/apt/sources.list.d/ros-latest.list'
- 设置 keys
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
- 安装
sudo apt update
# 建议完全安装 (Recommended)
# 含:ROS, rqt, rviz, robot-generic libraries,
# 2D/3D simulators and 2D/3D perception
sudo apt install ros-melodic-desktop-full
- 设置环境变量
# zsh
echo "source /opt/ros/melodic/setup.zsh" >> ~/.zshrc
source ~/.zshrc
- 安装必要的依赖
sudo apt install python-rosdep
sudo rosdep init
rosdep update
sudo rosdep init
需要从raw.githubusercontent.com
下载文件。如果报错,可以试下修改 hosts:
``` powershell # 打开hosts文件 sudo nano /etc/hosts # 在文件末尾添加 151.101.84.133 raw.githubusercontent.com ```
- 测试一下
roscore
# 会出现几行 log:
# started roslaunch server http://DESKTOP-FL776UK:56357/
# ros_comm version 1.14.10
#
#
# SUMMARY
# ========
#
# PARAMETERS
# * /rosdistro: melodic
# * /rosversion: 1.14.10
# ...
# started core service [/rosout]
#
- 测试一下小乌龟
-
先在 win10 下安装 X Server:
scoop install vcxsrv
. -
然后依次在 Ubuntu18.04下打开三个 terminal:
# terminal - 1
roscore
# terminal - 2
rosrun turtlesim turtlesim_node
# terminal - 3
rosrun turtlesim turtle_teleop_key
ROS-turtlesim.pngwindows terminal 分屏快捷键:
快捷键 功能 ctrl + shift + w closePane alt + shift + - splitPane: horizontal alt + shift + + splitPane: vertical