cartographer安装详细教程(Ubuntu 16.04)

本安装教程参考了以下链接,有需要可以结合这个链接安装cartographer。本人在这个基础上做了些改动,以适配自己的电脑。但是有些内容是通用的且本人也比较推荐这样的方法,比较实用!

参考链接:Cartographer安装教程及踩坑实录_白色小靴的博客-CSDN博客_vnc远程桌面怎么使用

一、首先要做好前期的准备工作

1.解决好GitHub下载速度慢的问题

方法①:在这个网址上搜索以下内容的IP地址,并将其写入到/etc/hosts下的hosts文件中

需要搜索的IP地址:
① github.com
② github.global.ssl.fastly.net
③ codeload.github.com

讲上述三个的IP写入到hosts文件中,如下所示:

140.82.114.4 github.com
199.232.69.194 github.global.ssl.fastly.net
140.82.113.10 codeload.github.com

点击保存,关闭hosts文件,然后执行以下命令重启网络:

/etc/init.d/networking restart

方法②:从码云上下载(重新选取图片)

首先需要在码云上注册账户并完成登录。然后点击右上角的+号新建仓库,我们不创建新的仓库,而是将我们需要下载的仓库导入到新建仓库里面。

点击导入仓库后,讲带有https://的GitHub链接粘贴进去,然后点击导入即可。

完成仓库导入后,找到我们刚刚新建的仓库,点击下载即可,速度很快。(但是当我们需要从这个仓库中下载固定内容时,这个方法就不太行,因为这个是直接下载整个仓库)

2、加入谷歌服务器域名

①:sudo gedit /tc/resolv.conf

②:将原先的nameserver注释掉,添加下面两行:
nameserver 8.8.8.8
nameserver 8.8.4.4

③点击保存并退出

3、安装依赖

sudo apt-get install -y \
    cmake \
    g++ \
    git \
    google-mock \
    libboost-all-dev \
    libcairo2-dev \
    libeigen3-dev \
    libgflags-dev \
    libgoogle-glog-dev \
    liblua5.2-dev \
    libsuitesparse-dev \
    libwebp-dev \
    ninja-build \
    protobuf-compiler \
    python-sphinx

4、安装protobuf3(重点)

(1)首先要查看自己protoc的版本:使用以下命令

protoc --version

(2)如果是protoc2的版本,需要完成以下内容(卸载protoc2版本,为安装protoc3做准备)

卸载libprotobuf-dev(使用aptitude)
sudo aptitude remove libprotobuf-dev

aptitude会将protoc依赖包也一并删除,非常好用,点击y接受方案即可

如果提示没有aptitude,使用以下命令安装aptitude:

sudo apt-get install aptitude

耐心等待卸载即可。

(3)安装protoc3

①安装依赖:

sudo apt-get install autoconf automake libtool curl make g++ unzip

② 从GitHub上下载3.6版本的protobuf

git clone -b v3.6.0 https://github.com/protocolbuffers/protobuf.git

这里使用了上述的用git代理加速的方法,亲测下载速度很快。

③ 依次执行以下命令(耐心等待执行过程)

cd protobuf

git submodule update --init --recursive
(一般卸载完protoc的各种依赖后添加子模块是不会报错的)

./autogen.sh

./configure

make
如果添加子模块失败,执行make check会报错,但不影响后面的步骤,只是后续使用时会出现一些问题
make check

sudo make install

sudo ldconfig

protoc --version 输出版本号成功

④ 按照上面步骤安装成功后,将protoc文件放在目录:/usr/bin下。这里不使用软连接,直接将目录:/usr/local/bin下的protoc文件复制过去。

① 执行复制命令
sudo cp -f /usr/local/bin/protoc /usr/bin/
② 查看是否复制成功
find /usr/bin -name 'protoc'
该命令会显示要查找的文件的所在路径

至此,前期的准备工作已经弄好了,接下来就是安装cartographer了。

二、安装cartographer

1、创建工作空间carto_ws

$ mkdir  -p carto_ws/src
$ cd carto_ws
$ wstool init src

2、使用gedit格式打开src下的.rosinstall文件,将下面内容添加进去

gedit /carto_ws/src/.rosinstall    //打开.rosinstall文件

将以下内容复制到.rosinstall文件中

- git: {local-name: cartographer, uri: 'https://github.com/googlecartographer/cartographer.git', version: '1.0.0'}
- git: {local-name: cartographer_ros, uri: 'https://github.com/googlecartographer/cartographer_ros.git', version: '1.0.0'}
- git: {local-name: ceres-solver, uri: 'https://ceres-solver.googlesource.com/ceres-solver.git', version: '1.13.0'}

点击保存并退出

3、依次执行以下命令,中途点击yes即可

wstool merge -t src https://raw.githubusercontent.com/googlecartographer/cartographer_ros/master/cartographer_ros.rosinstall
wstool update -t src

这个过程是从GitHub上下载cartographer、cartographer_ros、ceres_solver三个包,因为我一直开着git代理,所以一会儿就装好了。(ps:强烈推荐Pigcha加速器)

4、安装依赖并下载cartographer相关功能包(根据自己版本替换,我这里下载kinetic版本)

rosdep update
rosdep install --from-paths src --ignore-src --rosdistro=kinetic -y

如果做好了前期的准备工作,rosdep 这一步是可以直接通过的。

三、编译和安装

catkin_make_isolated --install --use-ninja

编译过程中遇到问题汇总:

1. 中间如果找不到absl的问题,可以用下面方法解决:

sudo apt-get install stow
sudo chmod +x ~/carto_ws/src/cartographer/scripts/install_abseil.sh
cd ~/carto_ws/src/cartographer/scripts
./install_abseil.sh

2.编译时出现.so文件丢失:

'/usr/lib/x86_64-linux-gnu/libtbb.so', needed by 'cartographer.io.internal.in_memory_proto_stream_test', missing and no known rule to make it

解决方法:

第一步:找到libtbb.so依赖的库。使用以下命令实现:
apt-file search libtbb.so

如果没有apt-file工具,可以通过以下命令下载

sudo apt-get install apt-file
apt-file update

查找之后,发现是libtbb-dev包没有下载,于是又重新下载这个包

sudo apt-get install -y libtbb-dev

3.当解决好.so文件的丢失问题后,他紧接着又出现了一推错误,错误如下:

解决方法:

cd ~/carto_ws/src
catkin_init_workspace

  • 1
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值