SLAM十四讲——ch4实践(李群李代数)

一、ch4的实践的准备工作

  1. 确保已经有Sophus库,Sophus库是一个较好的李代数库。

注意: 开始时slambook2文件夹下的3rdparty文件夹里面的内容为空,还需要在终端输入:

cd slambook2/
git submodule update --init --recursive

说明: Sophus库支持SO(3)、SE(3)、SO(2)、SE(2)及变换Sim(3);时在Eigen基础上开发的,不需要安装额外的依赖库。

  1. 先安装依赖环境,终端输入:
sudo apt-get install libglew-dev libboost-dev libboost-thread-dev libboost-filesystem-dev libpython3.8-dev python3-pip
  1. 在slambook2/3rdparty/Sophus文件夹下打开终端并输入:
mkdir build
cd build/
cmake ..
make -j4
sudo make install
  1. 在终端中进入ch4文件夹下,顺序执行以下命令进行编译。
mkdir build
cd build
cmake ..
//注意,j4还是其他主要看自己的电脑情况
make -j4
  1. 在build文件中执行。

二、各个实践操作

1. Sophus的基本使用方法

在build文件中执行 ./useSophus,结果如下所示:

SO(3) from matrix:
2.22045e-16          -1           0
          1 2.22045e-16           0
          0           0           1
SO(3) from quaternion:
2.22045e-16          -1           0
          1 2.22045e-16           0
          0           0           1
they are equal
so3 =      0      0 1.5708
so3 hat=
      0 -1.5708       0
 1.5708       0      -0
     -0       0       0
so3 hat vee=      0      0 1.5708
SO3 updated =
          0          -1           0
          1           0     -0.0001
     0.0001 2.03288e-20           1
*******************************
SE3 from R,t=
2.22045e-16          -1           0           1
          1 2.22045e-16           0           0
          0           0           1           0
          0           0           0           1
SE3 from q,t=
2.22045e-16          -1           0           1
          1 2.22045e-16           0           0
          0           0           1           0
          0           0           0           1
se3 =  0.785398 -0.785398         0         0         0    1.5708
se3 hat =
        0   -1.5708         0  0.785398
   1.5708         0        -0 -0.785398
       -0         0         0         0
        0         0         0         0
se3 hat vee =  0.785398 -0.785398         0         0         0    1.5708
SE3 updated =
2.22045e-16          -1           0      1.0001
          1 2.22045e-16           0           0
          0           0           1           0
          0           0           0           1

2. 例子:评估轨迹误差

在build中进入 examples,执行 ./trajectoryError后,结果如下:
trajectoryError
同时终端会输出:RMSE = 2.20728

三、遇到的问题

  1. 问题:在安装Sophus,出现问题。
    解决办法: 需要在CMakeLists.txt文件中添加以下内容,注意,添加到第30行刚好。如果是添加到14行前或者最后,问题不会被解决。
set(CMAKE_CXX_FLAGS"-Wno-error=deprecated-declarations-Wno-deprecated-declarations ")

最后再安装软件包:

sudo make install

  1. 在执行./trajectoryError出现如下提示:
trajectory ./example/groundtruth.txt not found.
trajectory ./example/estimated.txt not found.
trajectoryError: /home/fighter/slam/slambook2/ch4/example/trajectoryError.cpp:22: int main(int, char**): Assertion `!groundtruth.empty() && !estimated.empty()' failed.
Aborted

解决办法: 更改trajectoryError.cpp文件的第10行和11行:

//改之前
string groundtruth_file = "./example/groundtruth.txt";
string estimated_file = "./example/estimated.txt";
//改之后
string groundtruth_file = "/home/fighter/slam/slambook2/ch4/example/groundtruth.txt";
string estimated_file = "/home/fighter/slam/slambook2/ch4/example/estimated.txt";

记得改完之后需要重新在build中执行make进行编译。

原因:主要是因为找不到文件导致,这里为了避免更多的问题和麻烦出现,建议直接改为绝对路径。

猜你喜欢

转载自blog.csdn.net/qq_44164791/article/details/131143742