第二讲 【cartographer】Ubuntu16.04 kinetic 最新版cartographer安装(2020/11/4更新)

系列文章目录

第一讲【ROS-SLAM】2D激光雷达 cartographer构建地图

第二讲 【cartographer】Ubuntu16.04 kinetic 最新版cartographer安装(2020/11/4更新)

第三讲 【cartographer】 添加功能以从RVIZ为纯本地化模式设置初始姿势

第四讲 【cartographer】纯定位 纯本地化 pure_localization

第五讲【cartographer】在仿真环境中 建图 纯定位

第六讲【cartographer】纯定位参数优化(初级篇)


文章目录

  • 系列文章目录
  • 前言
  • 一、安装环境
    • 1、Ubuntu16.04虚拟机
    • 2、ros-kinetic
  • 二、安装步骤
    • 1.cartographer和cartographer_ros
    • 2.ceres
    • 3、lua
      • 1)源码下载
      • 2)报错
      • 3)于是用apt search搜索了这两个包,发现libreadline-dev没有安装
      • 4)安装好后重新编译就可以了,然后是配置/etc/profile环境变量
      • 5)lua报错1
      • 6)lua报错2
      • 7)解决lnurses库问题之/usr/bin/ld:can not find -lncurses
    • 4、编译
    • 5.运行bag包,测试是否安装成功
    • 总结


前言

前段时间已经安装过cartographer,结果发现以前的那个cartographer在纯定位上面有些不一样的地方。所以现在想安装最新版本的cartographer,2020/11/4

一、安装环境

1、Ubuntu16.04虚拟机

2、ros-kinetic

二、安装步骤

1.cartographer和cartographer_ros

参考链接:
https://google-cartographer-ros.readthedocs.io/en/latest/compilation.html

为了构建Cartographer ROS,我们建议使用wstool和rosdep。为了加快构建速度,我们还建议使用 Ninja。

在带有ROS Noetic的Ubuntu Focal上,使用以下命令安装上述工具:

sudo apt-get update
sudo apt-get install -y python3-wstool python3-rosdep ninja-build stow

在较早的发行版中:

sudo apt-get update
sudo apt-get install -y python-wstool python-rosdep ninja-build stow

安装工具后,在“ catkin_ws”中创建一个新的cartographer_ros工作空间。

mkdir catkin_ws
cd catkin_ws
wstool init src
wstool merge -t src https://raw.githubusercontent.com/cartographer-project/cartographer_ros/master/cartographer_ros.rosinstall
wstool update -t src

现在,您需要安装cartographer_ros的依赖项。首先,我们使用rosdep安装所需的软件包。如果自安装ROS以来已经执行过命令,则命令“ sudo rosdep init”将显示错误。该错误可以忽略。

sudo rosdep init
rosdep update
rosdep install --from-paths src --ignore-src --rosdistro=${ROS_DISTRO} -y

# Only on Ubuntu 16 / ROS Kinetic: src/cartographer/scripts/install_proto3.sh
# 至于Ubuntu18.04 Ubuntu20.04可以使用apt-get来安装proto

Cartographer使用abseil-cpp库,该库需要使用以下脚本手动安装:

src/cartographer/scripts/install_abseil.sh

由于版本冲突,您可能需要使用以下命令卸载ROS abseil-cpp

sudo apt-get remove ros-${ROS_DISTRO}-abseil-cpp

生成并安装。

catkin_make_isolated --install --use-ninja

这将从master分支的最新HEAD构建制图师。如果需要特定版本,则需要在cartographer_ros.rosinstall中更改版本。

2.ceres

参考链接:
https://github.com/cartographer-project/cartographer/issues/1471

sudo apt-get install libceres-dev

Ceres Solver
Ceres Solver 1 is an open source C++ library for modeling and solving large, complicated optimization problems. It can be used to solve Non-linear Least Squares problems with bounds constraints and general unconstrained optimization problems. It is a mature, feature rich, and performant library that has been used in production at Google since 2010. For more, see Why?.


以上,我们安装了cartographer,cartographer_ros,ceres,proto3,下面编译一下

3、lua

参考链接:
https://www.lua.org/download.html

1)源码下载

curl -R -O http://www.lua.org/ftp/lua-5.2.0.tar.gz
tar zxf lua-5.2.0.tar.gz
cd lua-5.2.0
make linux test

2)报错

lua.c:82:31: fatal error: readline/readline.h: 没有那个文件或目录
compilation terminated.
<builtin>: recipe for target 'lua.o' failed
make[2]: *** [lua.o] Error 1
make[2]: Leaving directory '/opt/software/lua-5.2.0/src'
Makefile:110: recipe for target 'linux' failed
make[1]: *** [linux] Error 2
make[1]: Leaving directory '/opt/software/lua-5.2.0/src'
Makefile:55: recipe for target 'linux' failed
make: *** [linux] Error 2

官方的解释如下:
If you’re running Linux and get compilation errors, make sure you have installed the readline development package (which is probably named libreadline-dev or readline-devel). If you get link errors after that, then try “make linux MYLIBS=-ltermcap”.

3)于是用apt search搜索了这两个包,发现libreadline-dev没有安装

sudo apt-get install libreadline-dev

4)安装好后重新编译就可以了,然后是配置/etc/profile环境变量

可以不配置

export PATH=$PATH:/opt/software/lua-5.2.0/src

再执行

sudo make linux test

sudo make install

5)lua报错1

参考链接:
https://blog.csdn.net/sinat_24820331/article/details/54096647

错误为:
/usr/bin/ld: /usr/local/lib/liblua.a(lapi.o): relocation R_X86_64_32 against `luaO_nilobject_' can not be used when making a shared object; recompile with -fPIC  
/usr/local/lib/liblua.a: could not read symbols: 错误的值  

解决方法:
lua官网下载Lua 5.2.0 解压后修改src目录下的Makefile:CFLAGS=加上-fPIC
然后再编译安装

make linux

make isntall

6)lua报错2

参考链接:
https://blog.csdn.net/spy14414/article/details/107977497

 undefined reference to symbol 'dlclose@@GLIBC_2.2.5' //lib/x86_64-linux-gnu/libdl.so.2: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status

解决方法:

加一个 -ldl,将下面这句话加在CMakeLists.txt里面

set (CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} -ldl") 

7)解决lnurses库问题之/usr/bin/ld:can not find -lncurses

参考链接:
https://blog.csdn.net/yuesichiu/article/details/38495991

ncurses是字符终端下屏幕控制的基本库,在编译grub时出现如下错误:

/usr/bin/ld:can not find -lncurses

collect2: ld returned 1 exit status

第二讲 【cartographer】Ubuntu16.04 kinetic 最新版cartographer安装(2020/11/4更新)_第1张图片

首先安装ncurses。

Fedora:

yum install ncurses-devel

Ubantu:

apt-get install libncurses5-dev

安装成功后,make编译还是出现这种错误,检查/lib和/usr/lib目录均存在libncurses.so,后来做了个软连接,编译还是不行。

这时需要安装ncurses-static即可

yum install ncurses-static

成功编译

4、编译

catkin_make_isolated --install --use-ninja

编译不通过是正常现象,若出现问题可以一一解决

5.运行bag包,测试是否安装成功

下载bag包
https://google-cartographer-ros.readthedocs.io/en/latest/data.html#d-cartographer-backpack-deutsches-museum

https://www.ncnynl.com/archives/201810/2783.html

测试bag包

roslaunch cartographer_ros demo_backpack_2d.launch bag_filename:=

后面添加bag包的文件地址,也可以直接将bag包拖进去

总结

以上就是今天要讲的内容,本文介绍了cartographer最新版的安装。

你可能感兴趣的:(SLAM算法,ubuntu,linux,cartographer)