
Windows11 WSL2 安装ubuntu18.04并运行ROS
Windows11使用wlsg安装ubuntu18.04并运行ROS
Windows11 WSL2 安装ubuntu18.04并运行ROS
Windows11 WSL2 ubuntu开发环境使用分享
第一章 Windows11 WSL2 安装ubuntu18.04并运行ROS
第二章 Windows11 WSL2 Ubuntu18.04环境中配置cuda及PyTorch
文章目录
前言
以前我的开发电脑和个人电脑都使用“Windows10+Ubuntu18.04”双系统,今年电脑换代使用上了Widnows11系统,自然研究了一番Windows11上的wslg。以下是自己的配置记录。
先放出结果:Windows11的wslg可以高效运行Ubuntu18.04。
基本说明:
什么是Windows的wslg?怎么安装?
参考:microsoft wslg github
ROS介绍,怎么安装?
参考:melodic ros installation
基本步骤:
- 设置 WSL 开发环境
- 安装Ubuntu18.04
- 安装ROS并测试
1 设置 WSL 开发环境
我的Windows11电脑已经有了wslg,只需要做一些简单的配置,操作如下:
wsl --set-default-version 2
wsl --update
wsl --shutdown
如果是Windows10或者其他的Widonws11版本,请参考微软的WSL安装指南和微软的WSL设置指南。
2 安装Ubuntu18.04
两种方法可以在WSL上安装Ubuntu系统。
命令安装:
wsl --list --online
wsl --install -d <DistroName>
微软商店安装:
打开Microsoft Store,搜索“ubuntu”,根据需要选择版本进行安装。
安装完成后根据提示设置用户名和密码。
Ubuntu中的应用可以在Windows11中以app的形式开启,并具有独立的窗口,默认图标目录:
C:\Users\your_name\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Ubuntu-18.04。
3 安装ROS并测试
安装ROS可参考Ubuntu install of ROS Melodic或者ubuntu18.04安装ROS Melodic。
目前(2022.02)国内的网络环境基本可以把ROS安装过程走完,到了初始化rosdep部分会出现问题,
sudo rosdep init
# 常见的问题
# ERROR: cannot download default sources list from:
# https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/sources.list.d/20-default.list
# Website may be down.
rosdep update
原因:
国内对raw.githubusercontent.com的访问有问题,如果有某些工具可以加速的话,尝试访问以下网址进行测试:
https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml
访问正常后,可以直接执行初始化rosdep。
我没有某些加速网络的工具,探索出以下两种解决方法,具体如下。
解决方法
主要是修改hosts和离线安装两种方式。
3.1 修改hosts
先检查ping的结果:
ping raw.githubusercontent.com
在ping结果正常时修改hosts文件
sudo gedit /etc/hosts
# 添加如下:
199.232.28.133 raw.githubusercontent.com
151.101.228.133 raw.github.com
然后再尝试:
sudo rosdep init
rosdep update
3.2 使用离线方式
在执行sudo rosdep init后, 以上在线方式不能正常工作时,可以采用离线的方式进行rosdep update。
首先,下载rosdistro:
git clone https://github.com/ros/rosdistro.git
# 或git加速方式
git clone https://github.com.cnpmjs.org/ros/rosdistro.git
其次,替换rep3.py和**init.py**文件,将在线链接替换为本地文件。
cd /usr/lib/python2.7/dist-packages/rosdep2
sudo gedit rep3.py
修改/usr/lib/python2.7/dist-packages/rosdep2/rep3.py中的“https://raw.githubusercontent.com/ros/rosdistro/master/releases/targets.yaml”,替换为:“file:///home/your_name/rosdistro/releases/targets.yaml”。
cd /usr/lib/python2.7/dist-packages/rosdistro
sudo gedit __init__.py
修改/usr/lib/python2.7/dist-packages/rosdistro/init.py中的
“https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml”,替换为:
“file:///home/your_name/rosdistro/index-v4.yaml”。
再者,修改20-default.list文件,将在线链接替换为本地文件。
sudo gedit /etc/ros/rosdep/sources.list.d/20-default.list
原文件:
# os-specific listings first
yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml osx
# generic
yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml
yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yaml
yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/ruby.yaml
gbpdistro https://raw.githubusercontent.com/ros/rosdistro/master/releases/fuerte.yaml fuerte
# newer distributions (Groovy, Hydro, ...) must not be listed anymore, they are being fetched from the rosdistro index.yaml instead
替换为:
# os-specific listings first
yaml file:///home/your_name/rosdistro/rosdep/osx-homebrew.yaml osx
yaml file:///home/your_name/rosdistro/rosdep/osx-homebrew.yaml osx
# generic
yaml file:///home/your_name/rosdistro/rosdep/base.yaml
yaml file:///home/your_name/rosdistro/rosdep/python.yaml
yaml file:///home/your_name/rosdistro/rosdep/ruby.yaml
gbpdistro file:///home/your_name/rosdistro/releases/fuerte.yaml fuerte
# newer distributions (Groovy, Hydro, ...) must not be listed anymore, they are being fetched from the rosdistro index.yaml instead
最后,执行
rosdep update
运行ROS,并测试:
roscore
# 另起一个terminal
rosrun rviz rviz
rviz的运行示例:
更多推荐
所有评论(0)