ubuntu16下利用loam_livox建图

2023-10-20 19:59
文章标签 建图 loam ubuntu16 livox

本文主要是介绍ubuntu16下利用loam_livox建图,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

0 引言

        最近在学习slam建图,想尝试使用大疆mid40利用loam_livox来进行建图,整个过程中遇到了特别多的坑,重装了五六次系统,所幸尝试之前将系统镜像了。
        这个算法不需要里程计,利用激光雷达发布的实时点云信息或者录制的bag包均可实时建图。
        loam_livox建图需要安装ceres_solver、eigen3、pcl1.9。个人感觉最困难的地方就在这里,pcl版本官方是给定了的,需要将ubuntu16自带的pcl1.7升级为pcl1.9,而ceres_slover与eigen3的版本是没有给的,版本不对应便无法编译成功,找了大半天,最后发现安装ceres_slover1.14.0与eigen3.3.7是可以跑通算法的。而我在利用cartographer进slam建图时,安装的ceres_slover1.11.0以及eigen3.2.92,采用正常的安装方法,两者只能跑一个,因此花了很多时间研究多版本兼容的问题。
        现将整个过程记录下来,供自己与大家参考。

1 源码下载
1.1 为loam_livox建立的工作空间

mkdir -p ~/loam_ws/src
cd ~/loam_ws/src
catkin_init_workspace


1.2 loam_livox下载

git clone https://github.com/hku-mars/loam_livox.git


1.3 安装依赖
 

sudo apt-get install ros-kinetic-cv-bridge ros-kinetic-tf ros-kinetic-message-filters ros-kinetic-image-transport

2 eigen3.3.7安装
2.1 源码下载
从下面这个网站中下载压缩包后解压到主目录

https://gitlab.com/libeigen/eigen/-/tree/3.3.7


2.2 编译
采用正常编译方式会将eigen编译到/usr/local/include下,而此目录已有我此前安装的eigen3.2.92,因此需将它安装在自己的指定目录下。

cd ~/eigen-3.3.7
mkdir build
mkdir eigen_loam


随后

cd build
cmake -DCMAKE_INSTALL_PREFIX="/home/lww/eigen-3.3.7/eigen_loam/" ..


注:这里build文件夹用来存放编译产生的文件,eigen_loam用来作为eigen的安装位置

make
sudo make install


安装成功
此时会发现eigen_loam文件夹中include文件下有eigen3文件,将它复制一份,重命名为eigen337,再复制到/usr/local/include/下

cd ~/eigen-3.3.7/eigen_loam/include
sudo cp -R eigen337 /usr/local/include/


至此,eigen3.3.7安装成功
3 ceres_solver1.14.0安装
3.1 源码下载
github上下载压缩包后解压到主目录

https://github.com/ceres-solver/ceres-solver/releases/tag/1.14.0


3.2 编译

cd ~/ceres-solver-1.14.0
mkdir build
mkdir cere_loam


由于cere-solver-1.14.0必须依赖于eigen3.3.7,无法采用eigen3.2.92编译,而默认目录下安装的是eigen3.2.92,因此需要为ceres指定eigen3.3.7安装目录,我们在上面已经将eigen3.3.7复制到了/usr/local/include下面,修改一下路径即可。
3.2.1 修改CMakeLists.txt文件

sudo gedit CMakeLists.txt


在find_package(Eigen REQUIRED)前加入

set(EIGEN_DIR /usr/local/include/eigen337)


3.2.2 修改FindEigen.cmake

cd cmake
sudo gedit FindEigen.cmake


修改如下所示,对比原文件参照:

# Ceres Solver - A fast non-linear least squares minimizer
# Copyright 2015 Google Inc. All rights reserved.
# http://ceres-solver.org/
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
#   this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
#   this list of conditions and the following disclaimer in the documentation
#   and/or other materials provided with the distribution.
# * Neither the name of Google Inc. nor the names of its contributors may be
#   used to endorse or promote products derived from this software without
#   specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# Author: alexs.mac@gmail.com (Alex Stewart)
## FindEigen.cmake - Find Eigen library, version >= 3.
#
# This module defines the following variables:
#
# EIGEN_FOUND: TRUE iff Eigen is found.
# EIGEN_INCLUDE_DIRS: Include directories for Eigen.
# EIGEN_VERSION: Extracted from Eigen/src/Core/util/Macros.h
# EIGEN_WORLD_VERSION: Equal to 3 if EIGEN_VERSION = 3.2.0
# EIGEN_MAJOR_VERSION: Equal to 2 if EIGEN_VERSION = 3.2.0
# EIGEN_MINOR_VERSION: Equal to 0 if EIGEN_VERSION = 3.2.0
# FOUND_INSTALLED_EIGEN_CMAKE_CONFIGURATION: True iff the version of Eigen
#                                            found was built & installed /
#                                            exported as a CMake package.
#
# The following variables control the behaviour of this module:
#
# EIGEN_PREFER_EXPORTED_EIGEN_CMAKE_CONFIGURATION: TRUE/FALSE, iff TRUE then
#                           then prefer using an exported CMake configuration
#                           generated by Eigen over searching for the
#                           Eigen components manually.  Otherwise (FALSE)
#                           ignore any exported Eigen CMake configurations and
#                           always perform a manual search for the components.
#                           Default: TRUE iff user does not define this variable
#                           before we are called, and does NOT specify
#                           EIGEN_INCLUDE_DIR_HINTS, otherwise FALSE.
# EIGEN_INCLUDE_DIR_HINTS: List of additional directories in which to
#                          search for eigen includes, e.g: /timbuktu/eigen3.
#
# The following variables are also defined by this module, but in line with
# CMake recommended FindPackage() module style should NOT be referenced directly
# by callers (use the plural variables detailed above instead).  These variables
# do however affect the behaviour of the module via FIND_[PATH/LIBRARY]() which
# are NOT re-called (i.e. search for library is not repeated) if these variables
# are set with valid values _in the CMake cache_. This means that if these
# variables are set directly in the cache, either by the user in the CMake GUI,
# or by the user passing -DVAR=VALUE directives to CMake when called (which
# explicitly defines a cache variable), then they will be used verbatim,
# bypassing the HINTS variables and other hard-coded search locations.
#
# EIGEN_INCLUDE_DIR: Include directory for CXSparse, not including the
#                    include directory of any dependencies.# Called if we failed to find Eigen or any of it's required dependencies,
# unsets all public (designed to be used externally) variables and reports
# error message at priority depending upon [REQUIRED/QUIET/<NONE>] argument.
macro(EIGEN_REPORT_NOT_FOUND REASON_MSG)unset(EIGEN_FOUND)unset(EIGEN_INCLUDE_DIRS)unset(FOUND_INSTALLED_EIGEN_CMAKE_CONFIGURATION)# Make results of search visible in the CMake GUI if Eigen has not# been found so that user does not have to toggle to advanced view.mark_as_advanced(CLEAR EIGEN_INCLUDE_DIR)# Note <package>_FIND_[REQUIRED/QUIETLY] variables defined by FindPackage()# use the camelcase library name, not uppercase.if (Eigen_FIND_QUIETLY)message(STATUS "Failed to find Eigen - " ${REASON_MSG} ${ARGN})elseif (Eigen_FIND_REQUIRED)message(FATAL_ERROR "Failed to find Eigen - " ${REASON_MSG} ${ARGN})else()# Neither QUIETLY nor REQUIRED, use no priority which emits a message# but continues configuration and allows generation.message("-- Failed to find Eigen - " ${REASON_MSG} ${ARGN})endif ()return()
endmacro(EIGEN_REPORT_NOT_FOUND)# Protect against any alternative find_package scripts for this library having
# been called previously (in a client project) which set EIGEN_FOUND, but not
# the other variables we require / set here which could cause the search logic
# here to fail.
unset(EIGEN_FOUND)# -----------------------------------------------------------------
# By default, if the user has expressed no preference for using an exported
# Eigen CMake configuration over performing a search for the installed
# components, and has not specified any hints for the search locations, then
# prefer an exported configuration if available.
if (NOT DEFINED EIGEN_PREFER_EXPORTED_EIGEN_CMAKE_CONFIGURATIONAND NOT EIGEN_INCLUDE_DIR_HINTS)message(STATUS "No preference for use of exported Eigen CMake configuration ""set, and no hints for include directory provided. ""Defaulting to preferring an installed/exported Eigen CMake configuration ""if available.")set(EIGEN_PREFER_EXPORTED_EIGEN_CMAKE_CONFIGURATION TRUE)
endif()if (EIGEN_PREFER_EXPORTED_EIGEN_CMAKE_CONFIGURATION)# Try to find an exported CMake configuration for Eigen.## We search twice, s/t we can invert the ordering of precedence used by# find_package() for exported package build directories, and installed# packages (found via CMAKE_SYSTEM_PREFIX_PATH), listed as items 6) and 7)# respectively in [1].## By default, exported build directories are (in theory) detected first, and# this is usually the case on Windows.  However, on OS X & Linux, the install# path (/usr/local) is typically present in the PATH environment variable# which is checked in item 4) in [1] (i.e. before both of the above, unless# NO_SYSTEM_ENVIRONMENT_PATH is passed).  As such on those OSs installed# packages are usually detected in preference to exported package build# directories.## To ensure a more consistent response across all OSs, and as users usually# want to prefer an installed version of a package over a locally built one# where both exist (esp. as the exported build directory might be removed# after installation), we first search with NO_CMAKE_PACKAGE_REGISTRY which# means any build directories exported by the user are ignored, and thus# installed directories are preferred.  If this fails to find the package# we then research again, but without NO_CMAKE_PACKAGE_REGISTRY, so any# exported build directories will now be detected.## To prevent confusion on Windows, we also pass NO_CMAKE_BUILDS_PATH (which# is item 5) in [1]), to not preferentially use projects that were built# recently with the CMake GUI to ensure that we always prefer an installed# version if available.## [1] http://www.cmake.org/cmake/help/v2.8.11/cmake.html#command:find_packagefind_package(Eigen3 QUIETNO_MODULENO_CMAKE_PACKAGE_REGISTRYNO_CMAKE_BUILDS_PATH)if (EIGEN3_FOUND)message(STATUS "Found installed version of Eigen: ${Eigen3_DIR}")else()# Failed to find an installed version of Eigen, repeat search allowing# exported build directories.message(STATUS "Failed to find installed Eigen CMake configuration, ""searching for Eigen build directories exported with CMake.")# Again pass NO_CMAKE_BUILDS_PATH, as we know that Eigen is exported and# do not want to treat projects built with the CMake GUI preferentially.find_package(Eigen3 QUIETNO_MODULENO_CMAKE_BUILDS_PATH)if (EIGEN3_FOUND)message(STATUS "Found exported Eigen build directory: ${Eigen3_DIR}")endif()endif()if (EIGEN3_FOUND)set(FOUND_INSTALLED_EIGEN_CMAKE_CONFIGURATION TRUE)set(EIGEN_FOUND ${EIGEN3_FOUND})set(EIGEN_INCLUDE_DIR "${EIGEN3_INCLUDE_DIR}" CACHE STRING"Eigen include directory" FORCE)else()message(STATUS "Failed to find an installed/exported CMake configuration ""for Eigen, will perform search for installed Eigen components.")endif()
endif()if (NOT EIGEN_FOUND)# Search user-installed locations first, so that we prefer user installs# to system installs where both exist.list(APPEND EIGEN_CHECK_INCLUDE_DIRS/usr/local/include/usr/local/homebrew/include # Mac OS X/opt/local/var/macports/software # Mac OS X./opt/local/include/usr/include/usr/local/include/eigen337)# Additional suffixes to try appending to each search path.list(APPEND EIGEN_CHECK_PATH_SUFFIXESeigen3 # Default root directory for Eigen.Eigen/include/eigen3 # Windows (for C:/Program Files prefix) < 3.3Eigen3/include/eigen3 ) # Windows (for C:/Program Files prefix) >= 3.3# Search supplied hint directories first if supplied.find_path(EIGEN_INCLUDE_DIRNAMES Eigen/CoreHINTS ${EIGEN_INCLUDE_DIR_HINTS}PATHS $"/usr/local/include/eigen337"PATH_SUFFIXES ${EIGEN_CHECK_PATH_SUFFIXES})if (NOT EIGEN_INCLUDE_DIR ORNOT EXISTS ${EIGEN_INCLUDE_DIR})eigen_report_not_found("Could not find eigen3 include directory, set EIGEN_INCLUDE_DIR to ""path to eigen3 include directory, e.g. /usr/local/include/eigen337.")endif (NOT EIGEN_INCLUDE_DIR ORNOT EXISTS ${EIGEN_INCLUDE_DIR})# Mark internally as found, then verify. EIGEN_REPORT_NOT_FOUND() unsets# if called.set(EIGEN_FOUND TRUE)
endif()# Extract Eigen version from Eigen/src/Core/util/Macros.h
if (EIGEN_INCLUDE_DIR)set(EIGEN_VERSION_FILE /usr/local/include/eigen337/Eigen/src/Core/util/Macros.h)if (NOT EXISTS ${EIGEN_VERSION_FILE})eigen_report_not_found("Could not find file: ${EIGEN_VERSION_FILE} ""containing version information in Eigen install located at: ""${EIGEN_INCLUDE_DIR}.")else (NOT EXISTS ${EIGEN_VERSION_FILE})file(READ ${EIGEN_VERSION_FILE} EIGEN_VERSION_FILE_CONTENTS)string(REGEX MATCH "#define EIGEN_WORLD_VERSION [0-9]+"EIGEN_WORLD_VERSION "${EIGEN_VERSION_FILE_CONTENTS}")string(REGEX REPLACE "#define EIGEN_WORLD_VERSION ([0-9]+)" "\\1"EIGEN_WORLD_VERSION "${EIGEN_WORLD_VERSION}")string(REGEX MATCH "#define EIGEN_MAJOR_VERSION [0-9]+"EIGEN_MAJOR_VERSION "${EIGEN_VERSION_FILE_CONTENTS}")string(REGEX REPLACE "#define EIGEN_MAJOR_VERSION ([0-9]+)" "\\1"EIGEN_MAJOR_VERSION "${EIGEN_MAJOR_VERSION}")string(REGEX MATCH "#define EIGEN_MINOR_VERSION [0-9]+"EIGEN_MINOR_VERSION "${EIGEN_VERSION_FILE_CONTENTS}")string(REGEX REPLACE "#define EIGEN_MINOR_VERSION ([0-9]+)" "\\1"EIGEN_MINOR_VERSION "${EIGEN_MINOR_VERSION}")# This is on a single line s/t CMake does not interpret it as a list of# elements and insert ';' separators which would result in 3.;2.;0 nonsense.set(EIGEN_VERSION "${EIGEN_WORLD_VERSION}.${EIGEN_MAJOR_VERSION}.${EIGEN_MINOR_VERSION}")endif (NOT EXISTS ${EIGEN_VERSION_FILE})
endif (EIGEN_INCLUDE_DIR)# Set standard CMake FindPackage variables if found.
if (EIGEN_FOUND)set(EIGEN_INCLUDE_DIRS ${EIGEN_INCLUDE_DIR})
endif (EIGEN_FOUND)# Handle REQUIRED / QUIET optional arguments and version.
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(EigenREQUIRED_VARS EIGEN_INCLUDE_DIRSVERSION_VAR EIGEN_VERSION)# Only mark internal variables as advanced if we found Eigen, otherwise
# leave it visible in the standard GUI for the user to set manually.
if (EIGEN_FOUND)mark_as_advanced(FORCE EIGEN_INCLUDE_DIREigen3_DIR) # Autogenerated by find_package(Eigen3)
endif (EIGEN_FOUND)


3.2.3 编译

cd ~/ceres-solver-1.14.0/build
cmake -DCMAKE_INSTALL_PREFIX="/home/lww/ceres-solver-1.14.0/ceres_loam/" ..
make -j4
sudo make install


编译成功
4 pcl1.9安装
4.1 安装依赖

     sudo apt-get updatesudo apt-get install git build-essential linux-libc-devsudo apt-get install cmake cmake-guisudo apt-get install libusb-1.0-0-dev libusb-dev libudev-devsudo apt-get install mpi-default-dev openmpi-bin openmpi-common  sudo apt-get install libflann1.8 libflann-devsudo apt-get install libeigen3-devsudo apt-get install libboost-all-devsudo apt-get install libvtk5.10-qt4 libvtk5.10 libvtk5-devsudo apt-get install libqhull* libgtest-devsudo apt-get install freeglut3-dev pkg-configsudo apt-get install libxmu-dev libxi-devsudo apt-get install mono-completesudo apt-get install qt-sdk openjdk-8-jdk openjdk-8-jre


4.2 源码下载
github上下载压缩包后解压到主目录下

https://github.com/PointCloudLibrary/pcl/releases


4.3 编译

cd ~/pcl-pcl-1.9.0
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=None -DCMAKE_INSTALL_PREFIX=/usr \-DBUILD_GPU=ON -DBUILD_apps=ON -DBUILD_examples=ON \-DCMAKE_INSTALL_PREFIX=/usr ..
make -j4
sudo make install


安装成功
5 loam_livox源码编译
5.1 修改loam_livox的CMakeLists.txt文件

cd ~/loam_ws/src/loam_livox
sudo gedit CMakeLists.txt


需修改部分如下所示

find_package(Eigen3 REQUIRED)
find_package(OpenCV REQUIRED)
find_package(Ceres 1.14.0 REQUIRED PATHS /home/lww/ceres-solver-1.14.0/ceres_loam NO_DEFAULT_PATH)
#find_package(Ceres REQUIRED)
find_package(PCL 1.9 REQUIRED)


5.2 源码编译

cd ~/loam_ws
catkin_make


6 loam_livox试跑
6.1 下载官方bag包
在下方链接中下载CYT_02.bag,放至主目录下

https://drive.google.com/drive/folders/1HWomWWPSEVvka2QVB2G41iRvSwIt5NWf


6.2 试跑

source ~/loam_ws/devel/setup.bash
roslaunch loam_livox rosbag.launch


另起终端

rosbag play CYT_02.bag


建图成功
可用自己录制的bag包进行试验

这篇关于ubuntu16下利用loam_livox建图的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/249402

相关文章

无人叉车3d激光slam多房间建图定位异常处理方案-墙体画线地图切分方案

墙体画线地图切分方案 针对问题:墙体两侧特征混淆误匹配,导致建图和定位偏差,表现为过门跳变、外月台走歪等 ·解决思路:预期的根治方案IGICP需要较长时间完成上线,先使用切分地图的工程化方案,即墙体两侧切分为不同地图,在某一侧只使用该侧地图进行定位 方案思路 切分原理:切分地图基于关键帧位置,而非点云。 理论基础:光照是直线的,一帧点云必定只能照射到墙的一侧,无法同时照到两侧实践考虑:关

poj 3181 网络流,建图。

题意: 农夫约翰为他的牛准备了F种食物和D种饮料。 每头牛都有各自喜欢的食物和饮料,而每种食物和饮料都只能分配给一头牛。 问最多能有多少头牛可以同时得到喜欢的食物和饮料。 解析: 由于要同时得到喜欢的食物和饮料,所以网络流建图的时候要把牛拆点了。 如下建图: s -> 食物 -> 牛1 -> 牛2 -> 饮料 -> t 所以分配一下点: s  =  0, 牛1= 1~

在Ubuntu16环境下用QT调试caffe

用qt调试caffe需要配置一些东西具体方法可以参考一下链接: https://www.zhihu.com/question/27987666/answer/80728225 https://blog.csdn.net/xg123321123/article/details/52817658

A-loam源码注释-头文件lidarFactor.hpp

本篇博客是A-loam学习的笔记,用于SLAM初学者一起学习。 lidarFactor.hpp #include <ceres/ceres.h> #include <ceres/rotation.h> #include <eigen3/Eigen/Dense> #include <pcl/point_cloud.h> #include <pcl/point_types.h> #include

用python fastapi写一个http接口,使ros2机器人开始slam toolbox建图

如果你想使用Python的FastAPI框架编写一个HTTP接口,以便通过接口启动ROS 2机器人的SLAM Toolbox建图,可以按照以下方式进行: 首先,确保你已经安装了fastapi和uvicorn库。你可以使用以下命令进行安装: pip install fastapi uvicorn 接下来,创建一个Python文件(例如app.py),并将以下代码添加到文件中: import

鹏程万里---ubuntu16搭建git服务器

首先要搞清楚一个概念,就是用什么账户执行什么操作 一开始登陆ubuntu是root账户 执行操作,在用vi的时候会遇到一个很蛋疼的,使用vi编辑时上下左右方向键被转化为A、B、C、D怎么办? root@GIT:/home# echo "set nocp" >> ~/.vimrc root@GIT:/home# source ~/.vimrc 解决了,然后才开始搞服务器 sudo apt-

RoadLib---这两年值得一看的建图定位项目

0. 简介 好久都没有看到比较条理清晰的开源项目了,这个项目目前看来有作为记忆行车这类比较火的项目的前提。虽然特征比较少,但是作为建图和定位来说还是基本可以胜任的。这一篇文章我们将着重来看一下整个代码的逻辑,相关的代码注释以及详细内容已经在Github上开源了。由于作者能力有限,欢迎大家一起来讨论 轻量级道路特征地图(开源了) 1. RoadLib之roadlib.h

ubuntu16安装和卸载mysql5.6

因为ubuntu16 apt-get默认安装是mysql5.7,这里改成安装5.6 apt-get install software-properties-commonsudo add-apt-repository 'deb http://archive.ubuntu.com/ubuntu trusty universe'sudo apt-get updatesudo apt install m

HDU 2548Kindergarten (最大独立集 + 建图细节)

题意:有男孩,女孩两个集合,男孩都相互认识,女孩也都相互认识, 现在找出最多的人,他们之间都是相互认识的,如果按题目给的男孩认识女孩的关系建立图,那么就是求极大完全子图,无法做,所以反过来思考 把不认识的人建立关系,求最大独立集。 #include<cstdio>#include<iostream>#include<algorithm>#include<cmath>#include

Poj 2049 Finding Nemo(建图+BFS)

先把DP放一放,开始刷Poj上的图论。从基础走起。。 http://poj.org/problem?id=2049 题意:给一个map,它包含墙,门及空地。输入n,m分别代表墙的个数及门的个数。 对于墙,输入x,y,d,t,(x,y)是墙的左下角的坐标;d = 1平行y轴,d=0平行x轴;t代表墙延伸的长度。 对于门,输入x,y,d,(x,y)是门的左下角坐标,d同上,因为门的长度始