常用库的安装与配置(Eigen, PCL, OpenNI, Boost, G2O, Pangolin, Cuda, cuDNN)

4 篇文章 0 订阅
4 篇文章 0 订阅

Summary

Package lists for SLAM development

install.sh [updating]

echo "Boost"
sudo apt-get install libboost-all-dev

echo  "Install ROS"
sudo apt-get install ros-kinetic-desktop-full 
sudo apt-get install libsuitesparse-dev

System Environment

yubao@yubao-Z370M-S01:~/Software$ uname -a
Linux yubao-Z370M-S01 4.15.0-46-generic #49~16.04.1-Ubuntu SMP Tue Feb 12 17:45:24 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

By defult, I install these packages use apt-get rather than source code to avoid the lib conflict.

Cuda

Install Nvidia CUDA 8 and cuDNN 6

Install Nvidia CUDA 8 and cuDNN 6

Check Cuda Version

$ sudo apt-get install nvidia-cuda-toolkit

$ cat /proc/driver/nvidia/version
NVRM version: NVIDIA UNIX x86_64 Kernel Module  410.104  Tue Feb  5 22:58:30 CST 2019
GCC version:  gcc version 5.5.0 20171010 (Ubuntu 5.5.0-12ubuntu1~16.04)

$ nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2015 NVIDIA Corporation
Built on Tue_Aug_11_14:27:32_CDT_2015
Cuda compilation tools, release 7.5, V7.5.17

$ nvidia-smi
Fri Apr 12 17:43:14 2019
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 410.104      Driver Version: 410.104      CUDA Version: 10.0     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  GeForce GTX 108...  Off  | 00000000:01:00.0  On |                  N/A |
| 31%   43C    P0    60W / 250W |   1032MiB / 11175MiB |      5%      Default |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|    0      1258      G   /usr/lib/xorg/Xorg                           578MiB |
|    0      2126      G   compiz                                       232MiB |
|    0      9279      G   ...-token=630AA6D825DD2ACDCF1092603ADFB4B3   100MiB |
|    0      9445      G   ...uest-channel-token=13602414163039823553    77MiB |
|    0     22753      G   /usr/lib/firefox/firefox                       2MiB |
|    0     29540      G   ...-token=14C7735C917F5C9952221336AB59FB73    38MiB |
+-----------------------------------------------------------------------------+

cuDNN

Download: cuDNN

Pangolin

git clone https://github.com/stevenlovegrove/Pangolin.git
cd Pangolin
mkdir build
cd build
cmake ..
cmake --build .

G2O

$ git clone https://github.com/RainerKuemmerle/g2o.git 
$ cd g2o
$ mkdir build
$ cd build
$ cmake -DBUILD_WITH_MARCH_NATIVE=OFF ..
$ make -j4
$ sudo make install

Eigen

sudo apt-get install libeigen3-dev

Installed to:
/usr/include/eigen3

sensors

sudo apt-get install lm-sensors
sudo modprobe coretemp

Boost

sudo apt-get install libboost-all-dev

manually install

I cannot update boost because ROS use 1.58 by default.

Procedure, refer Installing Boost C++ libraries

  1. Log on to the computer as the root user or as a user with sudo permissions.
  2. Download the Boost C++ libraries. For example, go to https://sourceforge.net/projects/boost/files/boost/1.57.0/, and download boost_1_57_0.zip.
  3. Decompress boost_1_57_0.zip. For example, go to the directory where you downloaded boost_1_57_0.zip, and enter the following command: unzip boost_1_57_0.zip.
  4. Go to the boost_1_57_0 directory.
  5. Enter the following command to build the installer: ./bootstrap.sh.
  6. Enter the following command to run the installer: ./b2 install.

Installed to /usr/loca/lib

Test Example:

libboost-test.cpp:

#include<iostream>
#include<boost/bind.hpp>
using namespace std;
using namespace boost;
int fun(int x,int y){return x+y;}
int main(){
    int m=1;int n=2;
    cout<<boost::bind(fun,_1,_2)(m,n)<<endl;
    return 0;
}

g++ libboost-test.cpp -o libboost-test

Uninstall boost

sudo apt-get autoremove   libboost-all-dev

PCL

Install from pre-build

The installation instructions are:

sudo add-apt-repository ppa:v-launchpad-jochen-sprickerhof-de/pcl
sudo apt-get update
#sudo apt-get install libpcl-all
sudo apt-get install libpcl-dev

Compile PCL from source code

  1. Clone source code from [pcl-git]: https://github.com/PointCloudLibrary/pcl.git
  2. Read compile instruction on Compiling PCL from source on POSIX compliant systems
Remove preinstalled: sudo apt-get remove pcl

git clone https://github.com/PointCloudLibrary/pcl pcl-trunk

vim io/src/hdl_grabber.cpp  add #include <thread> 

cd pcl-trunk && mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_GPU=ON -DBUILD_apps=ON -DBUILD_examples=ON  ..
make -j2
sudo make -j2 install

Common Errors

/home/yubao/Software/3rdPartyLibs/pcl/io/src/hdl_grabber.cpp: In member function ‘void pcl::HDLGrabber::readPacketsFromPcap()’:
/home/yubao/Software/3rdPartyLibs/pcl/io/src/hdl_grabber.cpp:716:10: error: ‘std::this_thread’ has not been declared
     std::this_thread::sleep_for(std::chrono::microseconds(usec_delay));
          ^
/home/yubao/Software/3rdPartyLibs/pcl/io/src/hdl_grabber.cpp:716:38: error: ‘std::chrono’ has not been declared
     std::this_thread::sleep_for(std::chrono::microseconds(usec_delay));
                                      ^
io/CMakeFiles/pcl_io.dir/build.make:218: recipe for target 'io/CMakeFiles/pcl_io.dir/src/hdl_grabber.cpp.o' failed
make[2]: *** [io/CMakeFiles/pcl_io.dir/src/hdl_grabber.cpp.o] Error 1
CMakeFiles/Makefile2:499: recipe for target 'io/CMakeFiles/pcl_io.dir/all' failed
make[1]: *** [io/CMakeFiles/pcl_io.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 12%] Building CXX object sample_consensus/CMakeFiles/pcl_sample_consensus.dir/src/sac_model_cone.cpp.o

Refer https://github.com/PointCloudLibrary/pcl/issues/2952 to solve.
Try to add #include at the top of “hdl_grabber.cpp” file.


OpenNI

Install from apt-get

Refer Install libopenni2-dev

sudo apt-get update

sudo apt-get install libopenni-dev 
sudo apt-get install libopenni2-dev

# Install NiViewer
sudo apt-get install openni-utils

# Install NiViewer2
sudo apt-get install openni2-utils

Install from prebuild

Download and install prebuild version from OpenNI 2 SDK Binaries & Docs

Build from OpenSource

make
sudo ./install.sh

Config environment

check file “OpenNIDevEnvironment”

Add these to your ~/.bashrc and then source ~/.bashrc

Header and libraries: You will find a OpenNIDevEnvironment file containing the paths for two environment variables: OPENNI2_INCLUDE and OPENNI2_REDIST. Use these include and library paths when you build your own C++ code that uses OpenNI. To link with OpenNI libraries add the -lOpenNI2 directive.

export OPENNI2_INCLUDE=/home/yubao/Software/4rdPartyLibs/install/OpenNI-Linux-x64-2.2/Include
export OPENNI2_REDIST=/home/yubao/Software/3rdPartyLibs/install/OpenNI-Linux-x64-2.2/Redist

or

cat OpenNIDevEnvironment >> ~/.bashrc

Additional Config

Tools$ sudo cp OpenNI2 /usr/lib -r
OpenNI-Linux-x64-2.2/Include$ sudo cp * /usr/include/openni2/ -r
OpenNI-Linux-x64-2.2$ sudo cp Redist/libOpenNI2.* /usr/lib

You may see this error when you build OpenKinect/libfreenect2 if you do not config them.

[ 70%] Building CXX object CMakeFiles/freenect2-openni2.dir/src/openni2/ColorStream.cpp.o
In file included from /home/yubao/Software/3rdPartyLibs/libfreenect2/src/openni2/ColorStream.cpp:29:0:
/home/yubao/Software/3rdPartyLibs/libfreenect2/src/openni2/ColorStream.hpp:31:33: fatal error: Driver/OniDriverAPI.h: No such file or directory
compilation terminated.
CMakeFiles/freenect2-openni2.dir/build.make:62: recipe for target 'CMakeFiles/freenect2-openni2.dir/src/openni2/ColorStream.cpp.o' failed

How to use librealsense with OpenNI

Compile libreasense driver and then copy librs2driver.so and
librealsense2.so to the Drivers folder.

For example:

cp _out/librs2driver.so [PATH]/OpenNI2/Bin/x64-Release/OpenNI2/Drivers/
cp librealsense2.so [PATH]/OpenNI2/Bin/x64-Release/OpenNI2/Drivers/
cd Tools
./NiViewer

在这里插入图片描述


Common Errors

libOpenNI.so.0

yubao@yubao-Z370M-S01:~/Software/3rdPartyLibs/install/OpenNI-Linux-x64-2.2$ NiViewer
NiViewer: error while loading shared libraries: libOpenNI.so.0: cannot open shared object file: No such file or directory

Reference

[1] Compiling PCL from source on POSIX compliant systems
[2] Ubuntu16.04下PCL库的安装与测试

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要在VSCode中配置eigenpcl,你需要按照以下步骤进行操作: 1. 打开VSCode,并按下快捷键Ctrl + Shift + P。然后输入"edit configuration"并选择"C/Cpp: Edit Configurations(JSON)",这将在.vscode文件夹下生成一个配置文件c_cpp_properties.json。 2. 在c_cpp_properties.json文件中,找到"includePath"字段,并添加以下路径: - "${workspaceFolder}/**":表示包括当前工作空间的所有文件 - "/usr/include/**":表示包括系统的所有标准文件 - "/usr/local/include/**":表示包括系统的所有本地文件 - "/usr/include/eigen3":表示包括eigen的路径 3. 对于pcl配置,你可以在c_cpp_properties.json文件的"includePath"字段中添加以下路径: - "/usr/include/pcl-1.8":表示包括pcl的路径,如果你的pcl版本不是1.8,请替换为你的版本号 4. 请确保你已经正确配置了"compilerPath"字段,该字段指向你系统上的C/C++编译器的路径。在示例中,路径为"/usr/bin/gcc"。如果你使用的是不同的编译器,请相应地修改这个路径。 5. 对于"C/Cpp: Edit Configurations(JSON)"中的其他字段,你可以根据你的需求进行相应的配置,比如"cStandard"和"cppStandard"字段可以设置C和C++的标准版本。 请注意,这些配置是基于Ubuntu系统的,如果你使用的是其他操作系统,请相应地修改路径。此外,请确保你的系统中已经安装eigenpcl。 希望这个解答能够帮到你。如果你有任何其他问题,请随时提问。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值