Autoware激光雷达与网络摄像机联合标定(一) ROS安装

197 阅读3分钟

本文已参与「新人创作礼」活动,一起开启掘金创作之路

前言

系统环境是Ubuntu 16.04,每完成一大步,将会把系统的完整镜像(VM Ware导出的虚拟机)发布到Github与Gitee,供使用。因为安装环境,本身是很耗费时间的,安装过程亦参考了网上很多的文章,踩了很多的坑,本系列旨在填坑,让后来人可以集中精力做实际的开发、学习。 每步会有步骤说明,命令的输出如果太多,就省略不再贴出来。 使用的设备是 Livox Horizon + 大华(Dahua) DH-IPC-HFW2433M-LED

安装ROS

ROS 官方安装步骤(需科学上网)

ningdr@ubuntu:~$ echo  ===========第一步===========
ningdr@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'
[sudo] password for ningdr: 
ningdr@ubuntu:~$ echo  ===========第二步===========
ningdr@ubuntu:~$ sudo apt update
....... 输出省略.........                                                                                                                                                                                                                                                                                                                                              
Reading package lists... Done
Building dependency tree       
Reading state information... Done
181 packages can be upgraded. Run 'apt list --upgradable' to see them.
ningdr@ubuntu:~$ echo  ===========第三步===========
ningdr@ubuntu:~$ sudo apt install ros-kinetic-desktop-full
....... 输出省略.........  
The following packages will be upgraded:
  libcurl3 libcurl3-gnutls libfreetype6 libglib2.0-0 libglib2.0-bin libgssapi-krb5-2 libjasper1 libk5crypto3 libkrb5-3 libkrb5support0 libldap-2.4-2 libssl1.0.0 libtiff5 libudev1 libx11-6 libx11-xcb1 udev
17 upgraded, 864 newly installed, 0 to remove and 164 not upgraded.
Need to get 466 MB of archives.
After this operation, 2,458 MB of additional disk space will be used.
....... 这里输入y,等待下载安装......... 
Do you want to continue? [Y/n] y
ningdr@ubuntu:~$ echo  ===========第四步===========
ningdr@ubuntu:~$ sudo rosdep init
Wrote /etc/ros/rosdep/sources.list.d/20-default.list
Recommended: please run

	rosdep update

ningdr@ubuntu:~$ 
ningdr@ubuntu:~$ echo  ===========第五步===========
# 报错的话切换一下科学上网的节点
ningdr@ubuntu:~$ rosdep update
reading in sources list data from /etc/ros/rosdep/sources.list.d
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/ruby.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/releases/fuerte.yaml
Query rosdistro index https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml
Skip end-of-life distro "ardent"
Skip end-of-life distro "bouncy"
Skip end-of-life distro "crystal"
Skip end-of-life distro "dashing"
Skip end-of-life distro "eloquent"
Add distro "foxy"
Add distro "galactic"
Skip end-of-life distro "groovy"
Skip end-of-life distro "hydro"
Skip end-of-life distro "indigo"
Skip end-of-life distro "jade"
Skip end-of-life distro "kinetic"
Skip end-of-life distro "lunar"
Add distro "melodic"
Add distro "noetic"
Add distro "rolling"
updated cache in /home/ningdr/.ros/rosdep/sources.cache
ningdr@ubuntu:~$ 
ningdr@ubuntu:~$ echo  ===========第六步===========
ningdr@ubuntu:~$ echo "source /opt/ros/kinetic/setup.bash" >> ~/.bashrc
ningdr@ubuntu:~$ source ~/.bashrc 
ningdr@ubuntu:~$ 
ningdr@ubuntu:~$ echo  ===========第七步===========
ningdr@ubuntu:~$ sudo apt install python-rosinstall python-rosinstall-generator python-wstool build-essential
ningdr@ubuntu:~$ echo  ===========第八步===========
ningdr@ubuntu:~$ printenv | grep ROS
ROS_ROOT=/opt/ros/kinetic/share/ros
ROS_PACKAGE_PATH=/opt/ros/kinetic/share
ROS_MASTER_URI=http://localhost:11311
ROS_PYTHON_VERSION=2
ROS_VERSION=1
ROSLISP_PACKAGE_DIRECTORIES=
ROS_DISTRO=kinetic
ROS_ETC_DIR=/opt/ros/kinetic/etc/ros
ningdr@ubuntu:~$ 

至此,ROS 安装成功 完整系统镜像,点我下载(解压后登录密码见README.md)

ROS 安装步骤(无需科学上网)

ningdr@ubuntu:~$ echo  ===========第一步===========
ningdr@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'
ningdr@ubuntu:~$ 
ningdr@ubuntu:~$ echo  ===========第二步===========
ningdr@ubuntu:~$ sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
Executing: /tmp/tmp.Wi5QWPM9yL/gpg.1.sh --keyserver
hkp://keyserver.ubuntu.com:80
--recv-key
C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
gpg: requesting key AB17C654 from hkp server keyserver.ubuntu.com
gpg: key AB17C654: public key "Open Robotics <info@osrfoundation.org>" imported
gpg: Total number processed: 1
gpg:               imported: 1  (RSA: 1)
ningdr@ubuntu:~$ 
# 更新库
ningdr@ubuntu:~$ echo  ===========第三步===========
ningdr@ubuntu:~$ sudo apt update
Hit:1 http://mirrors.tuna.tsinghua.edu.cn/ubuntu xenial InRelease
Hit:2 http://mirrors.tuna.tsinghua.edu.cn/ubuntu xenial-updates InRelease
Hit:3 http://mirrors.tuna.tsinghua.edu.cn/ubuntu xenial-backports InRelease
Hit:4 http://mirrors.tuna.tsinghua.edu.cn/ubuntu xenial-security InRelease
Ign:5 http://mirrors.tuna.tsinghua.edu.cn/ros/ubuntu focal InRelease
Get:6 http://mirrors.tuna.tsinghua.edu.cn/ros/ubuntu focal Release [3,794 B]
Get:7 http://mirrors.tuna.tsinghua.edu.cn/ros/ubuntu focal Release.gpg [833 B]
Get:8 http://mirrors.tuna.tsinghua.edu.cn/ros/ubuntu focal/main i386 Packages [18.1 kB]
Get:9 http://mirrors.tuna.tsinghua.edu.cn/ros/ubuntu focal/main amd64 Packages [619 kB]
Fetched 642 kB in 3s (240 kB/s)   
Reading package lists... Done
Building dependency tree       
Reading state information... Done
1 package can be upgraded. Run 'apt list --upgradable' to see it.
ningdr@ubuntu:~$
# 安装完整版,这一步耗时较长
ningdr@ubuntu:~$ echo  ===========第四步===========
ningdr@ubuntu:~$ sudo apt install ros-kinetic-desktop-full
# 完毕后,初始化
ningdr@ubuntu:~$ echo  ===========第五步===========
ningdr@ubuntu:~$ sudo rosdep init
[sudo] password for ningdr: 
Wrote /etc/ros/rosdep/sources.list.d/20-default.list
Recommended: please run

	rosdep update

ningdr@ubuntu:~$ 
# 噩梦来了,无论你试多少次,就是不成功,继续往下看,100%解决这个错误
ningdr@ubuntu:~$ echo  ===========第六步===========
ningdr@ubuntu:~$ rosdep update
reading in sources list data from /etc/ros/rosdep/sources.list.d
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/ruby.yaml
ERROR: unable to process source [https://raw.githubusercontent.com/ros/rosdistro/master/releases/fuerte.yaml]:
	Failed to download target platform data for gbpdistro:
	<urlopen error ('_ssl.c:574: The handshake operation timed out',)>
Query rosdistro index https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml
Skip end-of-life distro "ardent"
Skip end-of-life distro "bouncy"
Skip end-of-life distro "crystal"
Skip end-of-life distro "dashing"
Skip end-of-life distro "eloquent"
Add distro "foxy"
Add distro "galactic"
ERROR: error loading sources list:
	<urlopen error <urlopen error ('_ssl.c:574: The handshake operation timed out',)> (https://raw.githubusercontent.com/ros/rosdistro/master/galactic/distribution.yaml)>
ningdr@ubuntu:~$ 
# 下载 ros 的源码:https://github.com/ros/rosdistro.git
# 由于网络原因,将 git 导入到gitee,因此我从 gitee 下载
# 装 git
ningdr@ubuntu:~$ sudo apt install git
# 自己习惯,将软件安装到 soft 目录
ningdr@ubuntu:~$ cd soft/
ningdr@ubuntu:~$ echo  ===========第七步===========
ningdr@ubuntu:~/soft$ git clone https://gitee.com/ningdro/rosdistro.git
# 下载完毕,修改文件:/etc/ros/rosdep/sources.list.d,改地址
ningdr@ubuntu:~$ echo  ===========第八步===========
ningdr@ubuntu:~/soft$ sudo vim /etc/ros/rosdep/sources.list.d/20-default.list
# 更改后的内容如下
=======================file content=======================
# os-specific listings first
yaml file:///home/ningdr/soft/rosdistro/rosdep/osx-homebrew.yaml osx

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

# newer distributions (Groovy, Hydro, ...) must not be listed anymore, they are being fetched from the rosdistro index.yaml instead
=======================file content=======================
ningdr@ubuntu:~$ echo  ===========第九步===========
# 修改变量,将 FUERTE_GBPDISTRO_URL 改为如下值
ningdr@ubuntu:~$ sudo vim /usr/lib/python2.7/dist-packages/rosdep2/gbpdistro_support.py
FUERTE_GBPDISTRO_URL = 'file:///home/ningdr/soft/rosdistro/releases/fuerte.yaml'
# 修改变量,将 REP3_TARGETS_URL 改为如下值
ningdr@ubuntu:~$ sudo vim /usr/lib/python2.7/dist-packages/rosdep2/rep3.py
REP3_TARGETS_URL = 'file:///home/ningdr/soft/rosdistro/releases/targets.yaml'
# 修改变量,将 DEFAULT_INDEX_URL 改为如下值
ningdr@ubuntu:~$ sudo vim /usr/lib/python2.7/dist-packages/rosdistro/__init__.py
DEFAULT_INDEX_URL = 'file:///home/ningdr/soft/rosdistro/index-v4.yaml'
# 重新更新
ningdr@ubuntu:~$ echo  ===========第十步===========
ningdr@ubuntu:~$ rosdep update
reading in sources list data from /etc/ros/rosdep/sources.list.d
Hit file:///home/ningdr/soft/rosdistro/rosdep/osx-homebrew.yaml
Hit file:///home/ningdr/soft/rosdistro/rosdep/base.yaml
Hit file:///home/ningdr/soft/rosdistro/rosdep/python.yaml
Hit file:///home/ningdr/soft/rosdistro/rosdep/ruby.yaml
Hit file:///home/ningdr/soft/rosdistro/releases/fuerte.yaml
Query rosdistro index file:///home/ningdr/soft/rosdistro/index-v4.yaml
Skip end-of-life distro "ardent"
Skip end-of-life distro "bouncy"
Skip end-of-life distro "crystal"
Skip end-of-life distro "dashing"
Skip end-of-life distro "eloquent"
Add distro "foxy"
Add distro "galactic"
Skip end-of-life distro "groovy"
Skip end-of-life distro "hydro"
Skip end-of-life distro "indigo"
Skip end-of-life distro "jade"
Skip end-of-life distro "kinetic"
Skip end-of-life distro "lunar"
Add distro "melodic"
Add distro "noetic"
Add distro "rolling"
updated cache in /home/ningdr/.ros/rosdep/sources.cache
ningdr@ubuntu:~$ 
# 环境配置
ningdr@ubuntu:~$ echo  ===========第十一步===========
ningdr@ubuntu:~$ echo "source /opt/ros/kinetic/setup.bash" >> ~/.bashrc
ningdr@ubuntu:~$ source ~/.bashrc
ningdr@ubuntu:~$
# 验证安装结果
ningdr@ubuntu:~$ echo  ===========第十二步===========
ningdr@ubuntu:~$ printenv | grep ROS
ROS_ROOT=/opt/ros/kinetic/share/ros
ROS_PACKAGE_PATH=/opt/ros/kinetic/share
ROS_MASTER_URI=http://localhost:11311
ROS_PYTHON_VERSION=2
ROS_VERSION=1
ROSLISP_PACKAGE_DIRECTORIES=
ROS_DISTRO=kinetic
ROS_ETC_DIR=/opt/ros/kinetic/etc/ros
ningdr@ubuntu:~$ 

该方式暂未提供镜像下载链接