Ubuntu18.04 compiles faster-lio without upgrading gcc/g++ 9.0 version (C++17)

Faster-lio is an open-source laser inertial mileage calculation method by the Gaobo team of Zhixingzhe. This algorithm is based on the Fast-LIO2 algorithm. The main innovation point is to propose an incremental sparse voxel structure: iVox, which greatly improves the efficiency of the algorithm. .

In github, the author has given the configuration method based on Docker, the environment configuration method of ubuntu20.04 and Ubuntu18.04. For Ubuntu 18.04, my gcc/g++ version is 7.5.0, and a higher version of gcc needs to be installed online. This is not very friendly to workers whose computers cannot be connected to the Internet, and upgrading the gcc version may cause compilation exceptions in other projects . This article aims to solve the problem of compiling faster-lio without upgrading the gcc version.

 

 1. Why upgrade gcc/g++?

Because in order to improve the algorithm efficiency in faster-lio, some new features of C++17 are used, so a higher version of gcc/g++ is required. Therefore, a solution is to replace the part of faster-lio that uses the new features of C++17 with the syntax of the lower version.

 

2. Where are the new features of C++17 used?

After reading the entire program, through the include header file in the program, it can be found that the new feature <execution> is used in the program ,

<execution> is a new library of C++17 and a part of <algorithm>. It mainly defines three strategies for parallel functions to run in multi-threads to improve the efficiency of the algorithm. Please refer to this blog for details: <execution> . The application of execution in faster-lio is used as the parameter of for_each.

#include <execution>

std::for_each(std::execution::par_unseq, index.begin(), index.end(), [&cloud, &closest_cloud, this](size_t idx)
{****}

Therefore, it is also very simple to modify, as long as the <execution> header files in all related files are commented out, and the std::execution::par_unseq behind for_each is deleted, as follows:

//#include <execution>

std::for_each(index.begin(), index.end(), [&cloud, &closest_cloud, this](size_t idx)
{****}

3. Compile

Create a new project folder work_space, create a build folder and a src folder in it, and put the faster-lio package in the src folder. Open the terminal in the work_space folder, use catkin_make to compile, and then source.

catkin_make
source devel/setup.bash

 Note that faster-lio also has the following dependent libraries, which should be installed before compiling. If any library is missing, you can install it offline alone. There are already many tutorials on CSDN.

Dependent library:

  1. ROS (melodic or noetic)
  2. hawthorn: sudo apt-get install libgoogle-glog-dev
  3. own: sudo apt-get install libeigen3-dev
  4. pcl: sudo apt-get install libpcl-dev
  5. yaml-cpp: sudo apt-get install libyaml-cpp-dev

Guess you like

Origin blog.csdn.net/weixin_44884315/article/details/131189298