本文已参与「新人创作礼」活动,一起开启掘金创作之路。
虚拟机、ubuntu16.04、ubuntu18.04
下载链接:pan.baidu.com/s/1xCsTGzQG… 提取码:4jvr
注:推荐ubuntu16.04,标定的那个在ubuntu在18有问题。
1.ROS各个版本以及要求的环境
-
2014 Indigo
-
2015 Jade
-
2016 Kinetic
-
2017 Lunar
-
2018 Melodic
注:因为ubuntu是16.04的,所以这里我们安装Kinetic版本的ROS.
2.ROS简单介绍
-
通信机制:
-
开发工具:
-
应用功能:
生态系统:
3.安装ROS环境——Kinetic
1)先选择下载服务器位置
这里我选择的阿里云、清华云也可以。
2)设置sources.list
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
3)设置key(公钥已更新)
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
4)更新package
sudo apt-get update
5)安装ROS kinetic完整版
sudo apt-get install ros-kinetic-desktop-full
注:可能第一次安装会有个别包没有安装上,需要再次运行即可。---时间有点长!!!!
6)初始化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
原因: 由于raw.githubusercontent.com被墙,程序无法下载相应的文件。解决方法就是使raw.githubusercontent.com能够被正常访问。这个网站被墙的方式是dns污染,所以我们只要能够找到这个网站的正确ip就可以了,
解决: 修改hosts文件
-
1.sudo gedit /etc/hosts
-
2.把下面这些地址拷贝到hosts文件末尾,然后保存。
192.30.253.118 gist.github.com 185.199.110.153 github.io 151.101.113.194 github.global.ssl.fastly.net 52.216.227.168 github-cloud.s3.amazonaws.com 52.74.223.119 github.com 199.232.28.133 avatars1.githubusercontent.com 199.232.28.133 avatars2.githubusercontent.com 199.232.28.133 avatars0.githubusercontent.com 199.232.28.133 avatars3.githubusercontent.com 199.232.28.133 raw.githubusercontent.com 199.232.28.133 user-images.githubusercontent.com 199.232.28.133 avatars.githubusercontent.com 199.232.28.133 github.map.fastly.net 199.232.28.133 avatars7.githubusercontent.com 54.239.31.69 aws.amazon.com 54.239.30.25 console.aws.amazon.com 54.239.96.90 ap-northeast-1.console.aws.amazon.com 54.240.226.81 ap-southeast-1.console.aws.amazon.com 54.240.193.125 ap-southeast-2.console.aws.amazon.com 54.239.54.102 eu-central-1.console.aws.amazon.com 177.72.244.194 sa-east-1.console.aws.amazon.com 176.32.114.59 eu-west-1.console.aws.amazon.com 54.239.31.128 us-west-1.console.aws.amazon.com 54.240.254.230 us-west-2.console.aws.amazon.com 54.239.38.102 s3-console-us-standard.console.aws.amazon.com 54.231.49.3 s3.amazonaws.com 52.219.0.4 s3-ap-northeast-1.amazonaws.com 54.231.242.170 s3-ap-southeast-1.amazonaws.com 54.231.251.21 s3-ap-southeast-2.amazonaws.com 54.231.193.37 s3-eu-central-1.amazonaws.com 52.218.16.140 s3-eu-west-1.amazonaws.com 52.92.72.2 s3-sa-east-1.amazonaws.com 54.231.236.6 s3-us-west-1.amazonaws.com 54.231.168.160 s3-us-west-2.amazonaws.com 52.216.80.48 github-cloud.s3.amazonaws.com 54.231.40.3 github-com.s3.amazonaws.com 52.216.20.171 github-production-release-asset-2e65be.s3.amazonaws.com 52.216.228.168 github-production-user-asset-6210df.s3.amazonaws.com -
3.再干一件事,执行sudo gedit /etc/resolv.conf,将原有的nameserver这一行注释,并添加以下两行
nameserver 8.8.8.8 #google域名服务器 nameserver 8.8.4.4 #google域名服务器 -
4.再次执行sudo rosdep init,这次会报一个问题,就是文件已存在:
ERROR: default sources list file already exists: /etc/ros/rosdep/sources.list.d/20-default.list Please delete if you wish to re-initialize -
5.这时候直接删除这个文件sudo rm /etc/ros/rosdep/sources.list.d/20-default.list,再次执行sudo rosdep init,我至今操作过很多次,没有出现不成功的状态,如果实在不成功,试试换手机热点,多执行几次,最后输出如下信息就OK了:
wrote /etc/ros/rosdep/sources.list.d/20-default.list Recommended: please run rosdep update
注:其实上面一步一般可以解决问题,换手机热点挺好使的。
第二步
rosdep update
注:这个命令主要也是网络的问题,一般是读取超时,一般换手机热点、延长时间、以及fq多试试几次就可以了(这些方法参考www.cnblogs.com/zxzmnh/p/11…),但是如果上面不行,还有一种方法,就是先下载到本地,在配置, 这个问题困扰了我两天,最后看到大佬们的解决方法,实在是妙。。。
具体操作:
a.直接建在了/etc/ros/建了相应的目录。
链接: pan.baidu.com/s/19OCXIUgZ… 提取码: tnn9
从上面直接下载,解压到/etc/ros目录下。需要超级权限。
b.修改20-default.list脚本文件,需要超级权限。
其所在的目录是:/etc/ros/rosdep/sources.list.d/ 之前的内容:
# 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 https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml osx
yaml file:///etc/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
yaml file:///etc/ros/rosdistro/master/rosdep/base.yaml
yaml file:///etc/ros/rosdistro/master/rosdep/python.yaml
yaml file:///etc/ros/rosdistro/master/rosdep/ruby.yaml
gbpdistro file:///etc/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
c.继续修改
sudo 打开/usr/lib/python2.7/dist-packages/rosdistro/init.py这个文件,按照下面的代码进行修改。
# index information
#DEFAULT_INDEX_URL = 'https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml'
DEFAULT_INDEX_URL = 'file:///etc/ros/rosdistro/master/index-v4.yaml'
这样我就成功了!!!!!!不容易。
7)配置ROS环境
echo "source /opt/ros/kinetic/setup.bash" >> ~/.bashrc
source ~/.bashrc
8)安装依赖项
sudo apt-get install python-rosinstall python-rosinstall-generator python-wstool build-essential
9)测试ROS是否安装成功
(1)CTRL+ALT+T打开终端(Termial),输入以下命令,初始化ROS环境
roscore
(2)再 打开一个新的终端(Termial),输入以下命令,弹出一个小乌龟窗口:
rosrun turtlesim turtlesim_node
(3)出现一个小乌龟的LOGO后,再 打开一个新的终端(Termial),输入以下命令
rosrun turtlesim turtle_teleop_key
(4) 打开新的Termial,输入以下命令,可以查看ROS节点信息:
rosrun rqt_graph rqt_graph
5.标定包编译安装
标定代码: github.com/XidianLemon…
5.1创建ROS工作空间
创建工作环境:
mkdir -p ~/catkin_ws/src
cd ~/catkin_ws/src
catkin_init_workspace
注:catkin_ws可以任意起名字,但是src不可以。后面的编译工作环境这里就不用了弄了,这些操作在5.2编译功能包实现即可。
编译工作环境: cd ~/catkin_ws/ catkin_make
设置环境变量: source devel/setup.bash
检查环境变量:
echo $ROS_PACKAGE_PATH
5.2编译功能包
将下面代码
github.com/XidianLemon…
下载到本地,这部分代码就是标定的功能包,所以不需要自己创建功能包了,直接使用编译即可,在前面我们已经创建好了工作环境catkin_ws,接下来将解压后的代码文件夹Is_calibration放到src文件下,然后返回到catkin_ws路径下,重新编译:catkin_make,报一下错
解决: sudo apt install ros-kinetic-jsk-recognition-msgs
安装nlopt:
github.com/stevengj/nl…
按照其步骤走一遍,即可。
重新编译: catkin_make
运行:
一个终端:
roscore
另一个终端:
source ~/catin_ws/devel/setup.bash
rosrun calibration_camera_lidar calibration_toolkit
成功:
其他问题:
1:/home/qian/anaconda3/lib/libpng16.so.16: undefined reference to `inflateValidate@ZLIB_1.2.9'
解决: 直接删除anaconda3,因为冲突!!!!
2:编译内存不足
解决方法:虚拟机配置增加内存容量,这里我将2G提高我3G可以了。有时候多试几遍也可以,因为计算机的内存可能还没来得及清理,所以导致这时候的内存比较大。
3.rosrun calibration_camera_lidar calibration_toolkit报错
home/x/catkin_ws/devel/lib/calibration_camera_lidar/calibration_toolkit: error while loading shared libraries: libnlopt.so.0: cannot open shared object file: No such file or directory 这是因为链接问题(因为libnlopt.so.0的链接位置不对)
解决:
cd /etc/ld.so.conf.d
sudo touch libnlopt.conf
sudo gedit libnlopt.conf
在libnlopt.conf文件中添加内容为:/usr/local/lib, 最后使配置生效:
sudo ldconfig
4.如果想安装18.04的ubuntu以及melodic-ROS
因为autoware1.14只能在ubuntu18.04上安装并且依赖于ROS melodic,因此需要对calibration_camera_lidar功能包下的CMakeLists.txt进行修改,把所有的
if ("${ROS_VERSION}" MATCHES "(indigo|jade|kinetic)")
改成:
if ("${ROS_VERSION}" MATCHES "(indigo|jade|kinetic|melodic)")
因为这里使用了条件编译,默认不支持ROS melodic。