赞
踩
在实习公司要求安装Ubuntu20.04进行ROS开发,由于以前都是在18.04上做的开发因此遇到了一些问题,这里记录一下其中ROS的安装过程与cartographer的安装过程,与18.04最大的不同主要来自python版本。
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
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
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。