说在前面
- windows版本:win10
- linux:ubuntu18.0.4
- SLAM学习: 视觉SLAM十四讲-高翔pdf、对应github源码
- 其他:懒得装双系统了,突然想起windows的linux子系统挺强的,就来试试;想直接在windows下搞,但是装个g2o还得搞qt,太麻烦
- 2019.8.23补充:目前WSL好像并不支持USB设备,也就是说不能直接访问摄像头。
linux子系统安装
- 网上教程挺多,而且也很简单,不再提
不要点我 - 子系统安装路径(指通过应用商店安装)
装在C盘,不知道可不可以改路径,很慌啊C:\Users\admin\AppData\Local\Packages \CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState\rootfs
- 在子系统中可以直接访问windows文件,挂在mnt下
换源
- 可以直接在windows下改/etc/apt/sources.list,阿里云的源
# 阿里源ubuntu18.04
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
- sudo apt-get update
安装主要库
- cmake
sudo apt-get install cmake
- eigen
sudo apt-get install libeigen3-dev
- g2o
git clone https://github.com/RainerKuemmerle/g2o.git sudo apt-get install libsuitesparse-dev qtdeclarative5-dev qt5-qmake libqglviewer-dev-qt5 cd g2o mkdir build cd build cmake ../ make sudo make install
- Sophus
按照书上所说,用的双精度版本,然后make的时候报错:
需要将so2.cpp中构造函数改成如下:error: lvalue required as left operand of assignment unit_complex_.real() = 1.0f;
SO2::SO2() { unit_complex_.real(1.0f); unit_complex_.imag (0.0f); }
- opencv
完了,突然想起还得装opencv
先装VTK,下载后
然后下载opencv源码以及contrib源码,【opencv/编译】ubuntu安装python3.6、pip、vscode、opencvcd VTK-8.2.0 mkdir build cd build cmake ../ make sudo make install
有所区别的是编译时的选项,如下
目录结构sudo cmake \ -D CMAKE_BUILD_TYPE=RELEASE \ -D CMAKE_INSTALL_PREFIX=/usr/local \ -D OPENCV_EXTRA_MODULES_PATH=../opencv_contrib-4.0.1/modules/ \ -D WITH_VTK=ON \ -D BUILD_EXAMPLES=OFF \ -D BUILD_DOCS=OFF -D BUILD_PERF_TESTS=OFF -D BUILD_TESTS=OFF \ -D WITH_TBB=ON -D WITH_OPENMP=ON -D WITH_IPP=ON \ -D WITH_OPENGL=ON \ -D OPENCV_ENABLE_NONFREE=ON \ -D WITH_EIGEN=ON \ ..
- 图形界面
命令行界面玩傻子哟!
点这里
测试一下
-
使用高翔大佬的代码测试一下(git clone https://github.com/gaoxiang12/slambook.git)
-
eigen
cd slambook/ch3/useGeometry/ cmake . make ./eigenGeometry
-
opencv
测试为ch5中项目
-
g2o
在编译ch6时报错,解决方法:点我cd slambook/ch6/g2o_curve_fitting/ cmake . make ./curve_fitting
结束了