Ubuntu20.04-ROS-Noetic安装教程及python兼容性解决办法

8 篇文章 0 订阅
2 篇文章 0 订阅

Ubuntu20.04-ROS-Noetic安装教程及兼容性解决办法

在实习公司要求安装Ubuntu20.04进行ROS开发,由于以前都是在18.04上做的开发因此遇到了一些问题,这里记录一下其中ROS的安装过程与cartographer的安装过程,与18.04最大的不同主要来自python版本。

一、ROS-Noetic的安装

  ROS-Noetic的安装过程与其他版本基本一致,重点在于安装后的填坑。

1. 换源,使用清华源

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'

2. 设置密钥

sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654

3. 安装

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

4. 安装依赖(官方教程:https://wiki.ros.org/cn/noetic/Installation/Ubuntu。只有上面三步,但是为了保险,建议加上后面的步骤)该部分还有另一种方法见5.方便快捷一点
这里的正常步骤是sudo rosdep init接rosdep update完成依赖安装,但是国内几乎做不到,所以采用另外的方法。
a. 安装python依赖

sudo apt-get install python3-rosdep
sudo apt-get install python3-rosinstall

b. 下载依赖包

cd ~
git clone https://github.com/ros/rosdistro.git

c.修改20-default.list(xxx改为自己的用户名)

sudo gedit /home/xxx/rosdistro/rosdep/sources.list.d/20-default.list

替换为:

# os-specific listings first
yaml file:///home/xxx/rosdistro/rosdep/osx-homebrew.yaml osx

# generic
yaml file:///home/xxx/rosdistro/rosdep/base.yaml
yaml file:///home/xxx/rosdistro/rosdep/python.yaml
yaml file:///home/xxx/rosdistro/rosdep/ruby.yaml
gbpdistro file:///home/xxx/rosdistro/releases/fuerte.yaml fuerte

# newer distributions (Groovy, Hydro, ...) must not be listed anymore, they are being fetched from the rosdistro index.yaml instead

d.修改sources_list.py文件

sudo gedit /usr/lib/python3/dist-packages/rosdep2/sources_list.py

将DEFAULT_SOURCES_LIST_URL = ‘https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/sources.list.d/20-default.list’
修改为:

DEFAULT_SOURCES_LIST_URL = 'file:///home/xxx/rosdistro/rosdep/sources.list.d/20-default.list'

e. 修改__init__.py文件

sudo gedit /usr/lib/python3/dist-packages/rosdistro/__init__.py

将DEFAULT_INDEX_URL = ‘https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml’
修改为:

DEFAULT_INDEX_URL = 'file:///home/xxx/rosdistro/index-v4.yaml'

f. 修改rep3.py 文件

sudo gedit /usr/lib/python3/dist-packages/rosdep2/rep3.py

将REP3_TARGETS_URL = ‘https://raw.githubusercontent.com/ros/rosdistro/master/releases/targets.yaml’
修改为:

REP3_TARGETS_URL = 'file:///home/xxx/rosdistro/releases/targets.yaml'

g. 完成依赖安装

sudo rosdep init
rosdep update

5.另一种安装ros依赖的方法
1.安装rosdepc

sudo apt-get install python3-pip
pip install rosdepc

1.1 pip加速

cd ~
mkdir .pip
sudo vim ~/.pip/pip.conf

粘贴以下内容:

[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple/ 
[install]
trusted-host = pypi.tuna.tsinghua.edu.cn
  1. 重启电脑sudo reboot,重启才能加载刚刚的rosdepc
  2. 使用rosdepc代替rosdep完成依赖安装,以后每次使用rosdep都替换
sudo rosdepc init
rosdepc update

注:加sudo报错就去掉
6. 设置环境变量,完成安装

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

7. python3与ros兼容性解决方法

sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.8 1
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值