今天在编译LVI-SAM和LIO-SAM的时候都报错对‘pcl::PCLBase
初步怀疑是PCL版本问题,(ROS自带的PCL和我自己安装的PCL-1.8)于是彻底卸载PCL重装.
电脑系统是UBUNTU18.04,安装PCL时注意要先安装VTK,且VTK版本跟PCL版本还要对应,否则会出现一些问题,目前我感觉最好用的还是PCL-1.8对应VTK-7.1.1
下载对应的包,
1.pcl-1.8.1
https://github.com/PointCloudLibrary/pcl/tree/pcl-1.8.1
2. VTK-7.1.1
https://vtk.org/download/#earlier
安装都是
mkdir build
cd build
cmake ..
make -j16
sudo make install
ubuntu20编译报错fatal error: boost/uuid/sha1.hpp: 没有那个文件或目录
经验证,是pcl1.18.0和boost不同版本出现的问题
boost1.63可以和pcl1.18.0配合。
我安装完后,编译PCL测试程序正常
CMakeLists.txt:
cmake_minimum_required(VERSION 2.6)
project(test_pcl)
find_package(PCL REQUIRED)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
add_executable(test_pcl test.cpp)
target_link_libraries (test_pcl ${PCL_LIBRARIES})
install(TARGETS test_pcl RUNTIME DESTINATION bin)
main:
#include
#include
#include
#include
#include
#include
using namespace std;
int main(int argc, char **argv) {//柱型点云测试
cout << "Test PCL !" << endl;
pcl::PointCloud<pcl::PointXYZRGB>::Ptr point_cloud_ptr (new pcl::PointCloud<pcl::PointXYZRGB>);
uint8_t r(255), g(15), b(15);
for (float z(-1.0); z <= 1.0; z += 0.05) {//制作柱型点云集
for (float angle(0.0); angle <= 360.0; angle += 5.0) {
pcl::PointXYZRGB point;
point.x = cos (pcl::deg2rad(angle));
point.y = sin (pcl::deg2rad(angle));
point.z = z;
uint32_t rgb = (static_cast<uint32_t>(r) << 16 | static_cast<uint32_t>(g) << 8 | static_cast<uint32_t>(b));
point.rgb = *reinterpret_cast<float*>(&rgb);
point_cloud_ptr->points.push_back (point);
}
if (z < 0.0) {//颜色渐变
r -= 12;
g += 12;
}
else {
g -= 12;
b += 12;
}
}
point_cloud_ptr->width = (int) point_cloud_ptr->points.size ();
point_cloud_ptr->height = 1;
pcl::visualization::CloudViewer viewer ("pcl—test测试");
viewer.showCloud(point_cloud_ptr);
while (!viewer.wasStopped()){ };
return 0;
}
编译运行
cmake ..
make
./test_pcl
查看现存的版本:
Eigen3:
dpkg -s libeigen3-dev | grep Version
OpenCV
pkg-config --modversion opencv
Boost version:
dpkg -s libboost-dev | grep Version
查看cere-solover版本:
打开h安装ceres-solver的文件夹,然后打开ceres-solver的package.xml文件,在里面可以看到版本号
删除之前的ceres-solver版本(删除之前安装的2.0版本)
sudo rm -r /usr/local/lib/cmake/Ceres
sudo rm -rf /usr/local/include/ceres /usr/local/lib/libceres.a
sudo rm -r /usr/local/share/Ceres
下载ceres-solver-1.14.0
wget ceres-solver.org/ceres-solver-1.14.0.tar.gz
解压
tar xvf ceres-solver-1.14.0.tar.gz
编译
cd ceres-solver-1.14.0
mkdir build
cd build
cmake ..
sudo make
安装
sudo make install
如果有报错error: variable or field ‘it’ declared void for (typename C::const_iterator it = container.begin();
之类
原因就是eigen版本与ceres版本冲突
需要先删除eigen库,然后安装对应版本的,可以参考这个