Visual SLAM講義14—ch13実践(SLAMシステムの設計)

1. 実運用前の準備

  1. Kitti データセットをダウンロードします。ダウンロード URL: https://www.cvlibs.net/datasets/kitti/eval_odometry.php
    その走行距離データは約 22GB です。ダウンロードして解凍すると、いくつかのビデオ セグメントを取得できます。今回はセグメント 0 練習を使用します。
  2. ターミナルでch13フォルダに入り、以下のコマンドを実行してコンパイルします。
mkdir build
cd build
cmake ..
//注意,j8还是其他主要看自己的电脑情况
make -j8
  1. ch13 ファイルの下の bin ファイルで実行します。
    注:メイク プロセス中に、エラーが修正された後も、エラーが表示されます。警告、しかし私たちの練習のプロセスにはほとんど影響しません。
  2. config ディレクトリの下にあるdefault.yaml ファイルのファイル パスを変更し、そのパスを独自のデータが配置されているパスに変更します。
# 更改前
dataset_dir: /mnt/1A9286BD92869CBF/Dataset/Kitti/dataset/sequences/05
# 更改后
dataset_dir: /home/fighter/slam/slambook2/ch13/00
  1. 同様に、変更の前後で以下に示すように、run_kitti_stereo.cpp ファイル内のファイル パスを参照する必要もあります。
//更改前
DEFINE_string(config_file, "./config/default.yaml", "config file path");
//更改后
DEFINE_string(config_file, "/home/fighter/slam/slambook2/ch15/config/default.yaml", "config file path");
//更改原因:绝对路径可以避免一些后期不必要的麻烦,记得重新make。
  1. (オプション) VSCode で ch13 ワークスペースを開くと、多くのファイルのインクルード ヘッダー ファイルの下にエラーを報告する赤い波線があることがわかりますが、前の構成によれば、作業環境を直接実行しても問題ありません。調整された includePath には主に次のものが含まれます。
                "${workspaceFolder}/**",
                "/usr/include/eigen3",
                "/usr/include/opencv4",
                "/usr/include/suitesparse"

2. 練習プロセス

2.1 テストプログラムを実行する

ステートメントの実行:
ch13 ファイルで、bin フォルダーに移動し、次のステートメントを実行します。

./test_triangulation

操作結果:
テスト実行結果

2.2 00 データセットの実行

ステートメントを実行します:

 ./run_kitti_stereo

実行結果:
視覚的な結果:
https://download.csdn.net/download/qq_44164791/87934968
最初のビデオは ch13 のオリジナル コードです。いくつかのエラーが変更された後、プログラムは正常に実行できます。
端末出力の例:

I0620 16:27:00.055335 13144 visual_odometry.cpp:65] VO cost time: 0.0070335 seconds.
I0620 16:27:00.055406 13144 visual_odometry.cpp:44] VO is running
I0620 16:27:00.076495 13144 frontend.cpp:269] Find 128 in the last image.
I0620 16:27:00.077795 13144 frontend.cpp:215] Outlier/Inlier in pose estimating: 18/87
I0620 16:27:00.077836 13144 frontend.cpp:220] Current Pose =
00.888545 -0.427115 -0.167511 0-35.5003
00.393009 00.896979 -0.202415 0-462.659
00.236708 00.114022 00.964867 0-247.216
000000000 000000000 000000000 000000001
I0620 16:27:00.081686 13144 visual_odometry.cpp:65] VO cost time: 0.005869 seconds.
I0620 16:27:00.081735 13144 visual_odometry.cpp:44] VO is running
I0620 16:27:00.113430 13144 frontend.cpp:269] Find 112 in the last image.
I0620 16:27:00.115217 13144 frontend.cpp:215] Outlier/Inlier in pose estimating: 13/67
I0620 16:27:00.115278 13144 frontend.cpp:220] Current Pose =
00.890851 -0.421528 -0.169406 0-38.2629
000.38627 00.899102 0-0.20594 0-461.247
00.239123 00.118026 000.96379 0-250.589
000000000 000000000 000000000 000000001
I0620 16:27:00.115438 13144 map.cpp:79] remove keyframe 932
I0620 16:27:00.115639 13144 map.cpp:110] Removed 113 active landmarks
I0620 16:27:00.115675 13144 frontend.cpp:81] Set frame 4535 as keyframe 939
I0620 16:27:00.123732 13144 frontend.cpp:308] Detect 100 new features
I0620 16:27:00.124994 13144 frontend.cpp:350] Find 201 in the right image.
I0620 16:27:00.125965 13144 frontend.cpp:139] new landmarks: 123
I0620 16:27:00.144817 13144 visual_odometry.cpp:65] VO cost time: 0.0355153 seconds.
I0620 16:27:00.144896 13144 visual_odometry.cpp:44] VO is running
I0620 16:27:00.153093 13151 backend.cpp:163] Outlier/Inlier in optimization: 0/2147
I0620 16:27:00.186288 13144 frontend.cpp:269] Find 172 in the last image.
I0620 16:27:00.188879 13144 frontend.cpp:215] Outlier/Inlier in pose estimating: 22/137
I0620 16:27:00.188935 13144 frontend.cpp:220] Current Pose =
00.888264 -0.427094 -0.169049 0-35.2398
00.390936 00.896157 -0.209933 0-460.647
00.241156 00.120388 000.96299 0-253.153
000000000 000000000 000000000 000000001
I0620 16:27:00.192497 13144 visual_odometry.cpp:65] VO cost time: 0.0075273 seconds.
I0620 16:27:00.192548 13144 visual_odometry.cpp:44] VO is running
I0620 16:27:00.204964 13144 frontend.cpp:269] Find 132 in the last image.
I0620 16:27:00.206867 13144 frontend.cpp:215] Outlier/Inlier in pose estimating: 15/102
I0620 16:27:00.206925 13144 frontend.cpp:220] Current Pose =
00.889966 0-0.42294 -0.170536 0-37.2853
00.387267 00.898407 -0.207097 0-461.014
0000.2408 00.118266 00.963342 0-253.325
000000000 000000000 000000000 000000001
I0620 16:27:00.221396 13144 visual_odometry.cpp:65] VO cost time: 0.017146 seconds.
I0620 16:27:00.221469 13144 visual_odometry.cpp:44] VO is running
I0620 16:27:00.251788 13144 frontend.cpp:269] Find 119 in the last image.
I0620 16:27:00.253571 13144 frontend.cpp:215] Outlier/Inlier in pose estimating: 16/80
I0620 16:27:00.253782 13144 frontend.cpp:220] Current Pose =
000.89121 -0.419695 -0.172049 0-38.7982
00.384802 00.900376 -0.203104 0-461.756
00.240151 00.114803 00.963923 0-252.879
000000000 000000000 000000000 000000001
I0620 16:27:00.268241 13144 visual_odometry.cpp:65] VO cost time: 0.017168 seconds.
I0620 16:27:00.268343 13144 visual_odometry.cpp:44] VO is running
I0620 16:27:00.318046 13144 frontend.cpp:269] Find 111 in the last image.
I0620 16:27:00.322237 13144 frontend.cpp:215] Outlier/Inlier in pose estimating: 4/72
I0620 16:27:00.322328 13144 frontend.cpp:220] Current Pose =
00.891961 -0.417701 -0.173005 0-39.7112
00.383965 000.90189 -0.197902 0-462.921
00.238695 00.110093 00.964834 0-251.737
000000000 000000000 000000000 000000001
I0620 16:27:00.322566 13144 map.cpp:79] remove keyframe 933
I0620 16:27:00.322924 13144 map.cpp:110] Removed 114 active landmarks
I0620 16:27:00.322980 13144 frontend.cpp:81] Set frame 4539 as keyframe 940
I0620 16:27:00.330118 13144 frontend.cpp:308] Detect 103 new features
I0620 16:27:00.333930 13144 frontend.cpp:350] Find 193 in the right image.
I0620 16:27:00.335049 13144 frontend.cpp:139] new landmarks: 110
I0620 16:27:00.350602 13144 visual_odometry.cpp:65] VO cost time: 0.0332755 seconds.
I0620 16:27:00.350790 13144 visual_odometry.cpp:44] VO is running
I0620 16:27:00.362143 13151 backend.cpp:163] Outlier/Inlier in optimization: 0/2135
I0620 16:27:00.378190 13144 frontend.cpp:269] Find 169 in the last image.
I0620 16:27:00.380698 13144 frontend.cpp:215] Outlier/Inlier in pose estimating: 17/144
I0620 16:27:00.380779 13144 frontend.cpp:220] Current Pose =
00.887592 -0.427112 -0.172499 0-34.5528
00.394054 00.897983 -0.195827 0-464.253
00.238541 00.105841 00.965347 0-251.064
000000000 000000000 000000000 000000001
I0620 16:27:00.383298 13144 visual_odometry.cpp:65] VO cost time: 0.0060374 seconds.
I0620 16:27:00.383389 13144 visual_odometry.cpp:44] VO is running
W0620 16:27:00.425977 13144 dataset.cpp:61] cannot find images at index 4541
I0620 16:27:00.451663 13151 backend.cpp:163] Outlier/Inlier in optimization: 0/2135
I0620 16:27:00.463881 13152 viewer.cpp:78] Stop viewer
I0620 16:27:00.468593 13144 visual_odometry.cpp:53] VO exit

2.3 モーショントラックを描画するコードを変更する

ステートメントを実行します:

 ./run_kitti_stereo

実行結果:
可視化結果:
https://download.csdn.net/download/qq_44164791/87934968
2番目の動画はカメラの軌跡を描くためにコードを変更して可視化したものですが、動画からは以下のことが分かります。軌道の効果は良くありません。3
番目のビデオは 2 番目のビデオの実行コード上にあります。バックエンドの最適化部分をコメントアウトした後、軌道から効果が良くなっていることがわかります。これはオーバーのせいかもしれません。 -最適化中の修正。
出力情報は変更されていないため、端末の出力は2.2と同じです。

3. 発生した問題と解決策

3.1 cmake の場合の問題 ...

  1. 生じる問題:
CMake Error at CMakeLists.txt:18 (find_package):
  Could not find a configuration file for package "OpenCV" that is compatible
  with requested version "3.1".
  The following configuration files were considered but not accepted:
    /usr/local/lib/cmake/opencv4/OpenCVConfig.cmake, version: 4.5.0
    /usr/lib/x86_64-linux-gnu/cmake/opencv4/OpenCVConfig.cmake, version: 4.2.0
    /lib/x86_64-linux-gnu/cmake/opencv4/OpenCVConfig.cmake, version: 4.2.0
-- Configuring incomplete, errors occurred!
See also "/home/fighter/slam/slambook2/ch15/build/CMakeFiles/CMakeOutput.log".

理由:
これは、これまでに何度も遭遇した opencv バージョンの問題であり、以前と同じように変更するだけです。
解決策:
前の解決策と同じように、CMakeLists.txt ファイルの opencv バージョンを変更するだけです。

//更改前:
find_package(OpenCV 3.1 REQUIRED)
//更改后:
find_package(OpenCV REQUIRED)

3.2 メイク時の問題

  1. 生じる問題:

メイクの問題
原因:
このコンパイル エラーは、OpenCV ライブラリを使用するときに、以前のバージョンで定義された非推奨の定数 CV_FILLED を使用しているために発生します。OpenCV バージョン 4.x では、この定数の名前は cv::FILLED に変更されました。
解決:

// 在frontend.cpp文件中添加头文件
#include <opencv2/imgproc/imgproc_c.h>
//在viewer.cpp文件中添加头文件
#include <opencv2/imgproc/types_c.h>

opencv エラーについては、https:
//blog.csdn.net/qq_44164791/article/details/131210608 ?spm=1001.2014.3001.5501 を参照してください。

3.3 ヘッダー ファイルの下の赤色のエラー

例:
問題
解決策として、最初のオプションを直接クリックして、ワークスペースにツールキットのパスを追加します。
最後に、ファイル c_cpp_properties.json の内容 h は次のとおりです。

{
    
    
    "configurations": [
        {
    
    
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**",
                "/usr/include/eigen3",
                "/usr/include/opencv4",
                "/usr/include/suitesparse"
            ],
            "defines": [],
            "compilerPath": "/usr/bin/gcc",
            "cStandard": "c17",
            "cppStandard": "gnu++14",
            "intelliSenseMode": "linux-gcc-x64"
        }
    ],
    "version": 4
}

この記事はコードを詳しく読まずにコードの練習だけを行っている段階であり、コードは次の記事で読んでいきます。

おすすめ

転載: blog.csdn.net/qq_44164791/article/details/131294177