win10 wsl2 + ubuntu20.04 配置 ROS-Noetic

7 篇文章 2 订阅

最近研究ROS,最好的环境还是linux。
现在WSL(Windows Sub Linux)用着还不错,决定就是它了,不用弄双系统了。

安装WSL2+Ubuntu+OpenGL3.3

网上帖子很多,可参此文
运行ROS程序,需要启用OpenGL3.3

安装ROS-Noetic

步骤清晰,细节曲折,主要是科学上网的问题。

1. 添加ROS官方源

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

2. 添加密钥

下载官方ROS密钥并添加到本地

sudo apt install curl  # 安装linux下载工具
# 这条命令不一定能成功
curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -
# 上一条不成功,使用这一条
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654

3. 安装ROS Noetic桌面完整版

一定要下载ROS的官方PPA源的软件,直接apt install ros-desktop-full的运行有点问题

安装完整的ROS-Noetic

sudo apt update #更新ROS源的内容
sudo apt install ros-noetic-desktop-full

这个过程一般不会有问题,出错了就多来几次。

4. 设置环境变量

把ROS的启动目录添加到配置中

echo "source /opt/ros/noetic/setup.bash" >> ~/.bashrc # 添加ROS配置文件到环境变量文件
source ~/.bashrc # 使用环境变量生效

5. 安装ROS配套工具

sudo apt install python3-rosdep python3-rosinstall python3-rosinstall-generator python3-wstool build-essential

6. 初始化rosdep

要命的来了,整两天才搞定。。。
此步骤极其简单,就是两条命令,无奈找不到去github的路。
所以学会科学上网很重要

sudo rosdep init
rosdep update

本地直接运行命令时,总是类似

ERROR: unable to process source [https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml]:
        <urlopen error [Errno 111] Connection refused> (https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml)
  1. 有梯子的同学
    • 有梯子工具的同学直接启动梯子,更新下,这个过程就愉快地结束了。
    • 用socket5工具的同学,这个金光闪闪的工具对HTTP访问的作用不大,本人测试即使启用工具,第二条命令依然运行失败。据说需要sockets5转http,没有尝试
  2. 使用非客户端代理的同学,本人测试了网上查到的几种,不稳定,总之我没成功
  3. 手工搭建个模拟环境,成功!
    感谢博主

7. 手工配置rosdep init (如第6步成功,可跳过)

思路:ROS默认从github仓库更新数据,网址是 raw.githubusercontent.com。
github的rosdistro仓库直接访问、下载文件都没问题,但rosdep init就出问题。
那么,把仓库变成本地,就可以解决问题

  1. 下载github的rosdistro仓库,两者等价
    • 克隆仓库git clone https://github.com/ros/rosdistro.git,这个方法因为网络安全做得好,可能要试很多次
    • 下载zip压缩包,这个更加保险
  2. 修改下载的git仓库的源配置文件。
    • ${rosdistro仓库}/rosdep/source.list.d/20-default.list中的https://raw.githubusercontent.com全改成file:///${rosdistro仓库}
yaml file:///${rosdistro仓库}/rosdep/osx-homebrew.yaml osx
yaml file:///${rosdistro仓库}/rosdep/base.yaml
yaml file:///${rosdistro仓库}/rosdep/python.yaml
yaml file:///${rosdistro仓库}/rosdep/ruby.yaml
gbpdistro file:///h${rosdistro仓库}/releases/fuerte.yaml fuerte
  1. 修改代码中的URL指向
    /usr/lib/python3/dist-packages/rosdistro/rosdep2/sources_list.py中对应修改
    DEFAULT_SOURCES_LIST_URL = 'file:///${rosdistro仓库}/rosdep/sources.list.d/20-default.list'
    
    /usr/lib/python3/dist-packages/rosdistro/rosdep2/rep3.py中对应修改
    REP3_TARGETS_URL = 'file:///${rosdistro仓库}/releases/targets.yaml'
    
    /usr/lib/python3/dist-packages/rosdistro/__init__.py中对应修改
    DEFAULT_INDEX_URL = 'file:///${rosdistro仓库}/index-v4.yaml'
    
    再执行rosdep init && rosdep update就正常了。

8. 效果

在3个terminal中按顺序各其运行一条命令

roscore
 rosrun turtlesim turtlesim_node
 rosrun turtlesim turtle_teleop_key

在这里插入图片描述

  • 3
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值