參考文章:
ubuntu20.04下ros運行A-LOAM
Ubuntu20.04下運行LOAM系列:A-LOAM、LeGO-LOAM、SC-LeGO-LOAM、LIO-SAM 和 LVI-SAM
需要學(xué)習(xí)源碼的同學(xué)可以下載LOAM論文
LOAM論文鏈接
1.需要安裝的庫文件
1.1Eigen 3.3
可以直接使用apt命令安裝,或者去官網(wǎng)下載源碼安裝
sudo apt-get install libeigen3-dev
安裝成功如下,我這里之前裝過所以顯示如下,可以看到安裝的版本為3.3.7
1.2 ceres
//克隆下來,如果網(wǎng)絡(luò)不好一直下載不了就去官網(wǎng)下載源碼然后解壓
git clone https://ceres-solver.googlesource.com/ceres-solver
//在當(dāng)前目錄下創(chuàng)建文件夾ceres-bin
sudo mkdir ceres-bin
cd ceres-bin
cmake ../ceres-solver
make -j4
make test
sudo make install
按照上面的步驟裝好之后,我們再來測試一下ceres是否裝好了
測試ceres
sudo mkdir ceres_test
cd ceres_test
touch CMakeLists.txt
touch cere_example.cpp
sudo mkdir build
cd build
cmake ..
make
./ceres_example
其中CMakeLists.txt和ceres_example.cpp文件內(nèi)容分別如下
CMakeLists.txt
cmake_minimum_required(VERSION 3.8.0)
project(ceres_example)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(Ceres REQUIRED)
include_directories(
${CERES_INCLUDE_DIRS}
)
add_executable(ceres_example
ceres_example.cpp)
target_link_libraries(ceres_example
${CERES_LIBRARIES}
)
ceres_example
#include <ceres/ceres.h>
class CostFunctor {
public:
template <typename T>
bool operator()(const T* const x, T* residual) const
{
residual[0] = 10.0 - x[0];
return true;
}
};
int main(int argc, char const* argv[])
{
double initial_x = 5.0;
double x = initial_x;
// Build the problem.
ceres::Problem problem;
// Set up the only cost function (also known as residual). This uses
// auto-differentiation to obtain the derivative (jacobian).
ceres::CostFunction* cost_function = new ceres::AutoDiffCostFunction<CostFunctor, 1, 1>(new CostFunctor);
problem.AddResidualBlock(cost_function, nullptr, &x);
// Run the solver!
ceres::Solver::Options options;
options.linear_solver_type = ceres::DENSE_QR;
options.minimizer_progress_to_stdout = true;
ceres::Solver::Summary summary;
Solve(options, &problem, &summary);
std::cout << summary.BriefReport() << "\n";
std::cout << "x : " << initial_x
<< " -> " << x << "\n";
return 0;
}
運行后輸出如下,就代表測試成功,ceres安裝成功
1.3 pcl
同樣的可以使用apt安裝,或者去官網(wǎng)下載源碼自行安裝
sudo apt install libpcl-dev
2 下載編譯A-LOAM
2.1下載源碼
A-LOAM開源地址
//建立A-LOAM工作空間
sudo mkdir ALOAM
cd ALOAM
sudo mkdir src
cd src
//clone下來,如果網(wǎng)絡(luò)不好同樣可以直接去官網(wǎng)下載源碼下來解壓
git clone https://github.com/HKUST-Aerial-Robotics/A-LOAM.git
2.2修改CMakeLists.txt
由于PCL版本1.10,將C++標(biāo)準(zhǔn)改為14,在A-LOAM源碼中的CMakeLists.txt中進(jìn)行如下修改
//set(CMAKE_CXX_FLAGS "-std=c++11")
set(CMAKE_CXX_FLAGS "-std=c++14")
2.2 修改源碼
如果我們下載下來源碼之后直接對其編譯,是會發(fā)生報錯的,因此我們需要對源碼進(jìn)行一些修改
- 將四個.cpp文件中的/camera_init修改為camera_init
- 將scanRegistration.cpp中的 #include <opencv/cv.h> 修改為#include <opencv2/imgproc.hpp>
- 修改kittiHelper.cpp中 CV_LOAD_IMAGE_GRAYSCALE為 cv::IMREAD_GRAYSCALE
- 如果編譯遇到大量未找到Eigen相關(guān)錯誤,將四個.cpp文件中的#include <eigen3/Eigen/Dense>修改為#include <Eigen/Dense>
2.3 編譯ALOAM
//定位至我們原來新建的工作空間中進(jìn)行編譯
cd ~/ALOAM/
catkin_make
編譯成功顯示如下
3 運行測試ALOAM
在A-LOAM源碼中新建dataSet文件夾存放我們的數(shù)據(jù)集,將nsh_indooroutdoor.bag數(shù)據(jù)集下載至該文件夾中。
在A-LOAM源碼中找打launch文件夾,在該文件夾中打開終端并輸入如下命令
roslaunch aloam_velodyne_VLP_16.launch
然后再在dateSet文件夾中打開一個終端,輸入如下命令開始播放數(shù)據(jù)集
rosbag play nsh_indoor_outdoor.bag
顯示效果如下:
最后測試成功。
4 關(guān)于報錯
如果我們在編譯ALOAM的時候出現(xiàn)大量關(guān)于ceres的報錯,如下圖所示
解決方法:
是因為ceres版本的問題,我們可以將ceres更換至和A-LOAM配套的版本,或者進(jìn)行如下的源碼修改:
在laserMapping.cpp(row567-568)和 laserOdometry.cpp(row286-287)這兩個cpp文件中,將如下代碼
ceres::LocalParameterization *q_parameterization = new ceres::EigenQuaternionParameterization();
改為:文章來源:http://www.zghlxwxcb.cn/news/detail-792582.html
ceres::Manifold *q_parameterization = new ceres::EigenQuaternionManifold();
再次進(jìn)行catkin_make發(fā)現(xiàn)編譯成功,問題解決!文章來源地址http://www.zghlxwxcb.cn/news/detail-792582.html
到了這里,關(guān)于Ubuntu20.04下A-LOAM配置安裝及測試教程(包含報錯問題踩坑)的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!