NVIDIA AGX Orin 安装 pcl 1.12.1 and vtk 7.1

参考:

  1. Ubuntu 20.04安装PCL
  2. ubuntu20.04安装pcl

Orin安装的是 Ubuntu 20.04 的系统,跟 Ubuntu 18.04 安装 pcl 还稍有点不同

  1. 先安装辅助库:
$ sudo apt-get update  
$ sudo apt-get install git build-essential linux-libc-dev
$ sudo apt-get install cmake (cmake-gui 根据自己需要安装)
$ sudo apt-get install libusb-1.0-0-dev libusb-dev libudev-dev
$ sudo apt-get install mpi-default-dev openmpi-bin openmpi-common 
$ sudo apt-get install libflann1.9 libflann-dev
$ sudo apt-get install libeigen3-dev 
$ sudo apt-get install libboost-all-dev
$ sudo apt-get install libvtk7.1p-qt
$ sudo apt-get install libvtk7.1p 
$ sudo apt-get install libvtk7-qt-dev(按照错误提示一步一步安装所需要的东西)
$ sudo apt-get install libqhull* libgtest-dev
$ sudo apt-get install freeglut3-dev pkg-config
$ sudo apt-get install libxmu-dev libxi-dev
$ sudo apt-get install mono-complete
$ sudo apt-get install openjdk-8-jdk openjdk-8-jre

Ubuntu 20.04 与18.04 安装pcl不同之处在于 vtk,下面是 18.04 安装 vtk

sudo apt-get install vtk6 libvtk6.3 libvtk6-dev libvtk6.3-qt libvtk6-qt-dev 
  1. 编译PCL

先下载 pcl 源码

git clone https://gitee.com/mirrors/pcl.git

进入下载后的pcl目录,创建并进入build目录,执行编译:

cd pcl
# 切换到指定版本v1.12.1再编译
git checkout pcl-1.12.1
# 创建目录
mkdir build
# 进入目录
cd build

#安装在系统目录
cmake -DCMAKE_BUILD_TYPE=None \
      -DCMAKE_INSTALL_PREFIX=/usr/local \
      -DBUILD_GPU=ON \
      -DBUILD_apps=ON \
      -DBUILD_simulation=ON \
      -DBUILD_examples=ON ..
#安装在自己指定的目录
cmake -DCMAKE_BUILD_TYPE=None \
      -DCMAKE_INSTALL_PREFIX=~/softwares/lib/pcl1121 \
      -DBUILD_GPU=ON \
      -DBUILD_apps=ON \
      -DBUILD_simulation=ON \
      -DBUILD_examples=ON ..

# Orin 切换到 MAXN POWER MODE
# 进行编译
make -j10

#编译完后,执行安装
sudo make install
  1. 测试
$ cd ~/softwares/lib/pcl1121/bin
$ ./pcl_viewer ~/softwares/lib/pack/pcl_1_12_1/test/milk_color.pcd
The viewer window provides interactive commands; for help, press 'h' or 'H' from within the window.
> Loading /home/ls/softwares/lib/pack/pcl_1_12_1/test/milk_color.pcd [PCLVisualizer::setUseVbos] Has no effect when OpenGL version is ≥ 2
[done, 145.747 ms : 13704 points]
Available dimensions: x y z rgba

NVIDIA AGX Orin 安装 pcl 1.12.1 and vtk 7.1_第1张图片成功!!!

  1. 代码测试
    代码来自ubuntu20.04安装pcl
$ cd ~/softwares/lib/pcl1121/share/pcl-1.12
$ ls
Modules  PCLConfig.cmake  PCLConfigVersion.cmake
$ sudo cp PCLConfig.cmake FindPCL.cmake
$ ls
FindPCL.cmake  Modules  PCLConfig.cmake  PCLConfigVersion.cmake
$ gedit CMakeLists.txt

CMakeLists.txt 中的内容为:

cmake_minimum_required(VERSION 3.10)
project(pcl_test)


#set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ~/softwares/lib/pcl1121/share/pcl-1.12)
set(PCL_DIR /home/ls/softwares/lib/pcl1121/share/pcl-1.12)
find_package(PCL  REQUIRED)

include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})

add_executable(pcl_test pcl_test.cpp)

target_link_libraries (pcl_test ${PCL_LIBRARIES})

install(TARGETS pcl_test RUNTIME DESTINATION bin)

测试代码pcl_test.cpp内容如下:

#include 
#include 
#include 
#include 
#include 
#include 
 
 
int main(int argc, char **argv) {
    std::cout << "Test PCL !!!" << std::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 = 0.5 * cosf (pcl::deg2rad(angle));
	point.y = sinf (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 ("test");
    viewer.showCloud(point_cloud_ptr);
    while (!viewer.wasStopped()){ };
    return 0;
}

编译:

$ cmake -B build
$ cmake --build build -j4
$ cd build/
$ ls
CMakeCache.txt  CMakeFiles  cmake_install.cmake  Makefile  pcl_test
$ ./pcl_test 

NVIDIA AGX Orin 安装 pcl 1.12.1 and vtk 7.1_第2张图片成功!!!

你可能感兴趣的:(ubuntu,c/c++,自动驾驶,ubuntu,人工智能)