Ch3練習とピット回避
1. ch3の全体手順
- C++ オープン ソースの線形代数ライブラリである Eigen ライブラリがインストールされていることを確認してください。
sudo apt-get install libeigen3-dev
説明:行列に対する高速な線形代数演算を提供し、方程式を解くなどの関数も含まれています。g2o\Sophus などの上位レベルのソフトウェア ライブラリも、Eigen ライブラリを使用します。
- ターミナルでch3フォルダに入り、以下のコマンドを実行してコンパイルします。
mkdir build
cd build
cmake ..
//注意,j4还是其他主要看自己的电脑情况
make -j4
- ビルドファイル内で実行します。
2. 書類の執行
1.練習:固有
ビルド ファイルの useEigen にさらに進み、./eigenMatrix を実行すると、次の結果が得られます。
matrix 2x3 from 1 to 6:
1 2 3
4 5 6
print matrix 2x3:
1 2 3
4 5 6
[1,2,3;4,5,6]*[3,2,1]=10 28
[1,2,3;4,5,6]*[4,5,6]: 32 77
random matrix:
0.680375 0.59688 -0.329554
-0.211234 0.823295 0.536459
0.566198 -0.604897 -0.444451
transpose:
0.680375 -0.211234 0.566198
0.59688 0.823295 -0.604897
-0.329554 0.536459 -0.444451
sum: 1.61307
trace: 1.05922
times 10:
6.80375 5.9688 -3.29554
-2.11234 8.23295 5.36459
5.66198 -6.04897 -4.44451
inverse:
-0.198521 2.22739 2.8357
1.00605 -0.555135 -1.41603
-1.62213 3.59308 3.28973
det: 0.208598
Eigen values =
0.0242899
0.992154
1.80558
Eigen vectors =
-0.549013 -0.735943 0.396198
0.253452 -0.598296 -0.760134
-0.796459 0.316906 -0.514998
time of normal inverse is 0.14ms
x = -55.7896 -298.793 130.113 -388.455 -159.312 160.654 -40.0416 -193.561 155.844 181.144 185.125 -62.7786 19.8333 -30.8772 -200.746 55.8385 -206.604 26.3559 -14.6789 122.719 -221.449 26.233 -318.95 -78.6931 50.1446 87.1986 -194.922 132.319 -171.78 -4.19736 11.876 -171.779 48.3047 84.1812 -104.958 -47.2103 -57.4502 -48.9477 -19.4237 28.9419 111.421 92.1237 -288.248 -23.3478 -275.22 -292.062 -92.698 5.96847 -93.6244 109.734
time of Qr decomposition is 0.089ms
x = -55.7896 -298.793 130.113 -388.455 -159.312 160.654 -40.0416 -193.561 155.844 181.144 185.125 -62.7786 19.8333 -30.8772 -200.746 55.8385 -206.604 26.3559 -14.6789 122.719 -221.449 26.233 -318.95 -78.6931 50.1446 87.1986 -194.922 132.319 -171.78 -4.19736 11.876 -171.779 48.3047 84.1812 -104.958 -47.2103 -57.4502 -48.9477 -19.4237 28.9419 111.421 92.1237 -288.248 -23.3478 -275.22 -292.062 -92.698 5.96847 -93.6244 109.734
time of ldlt decomposition is 0.043ms
x = -55.7896 -298.793 130.113 -388.455 -159.312 160.654 -40.0416 -193.561 155.844 181.144 185.125 -62.7786 19.8333 -30.8772 -200.746 55.8385 -206.604 26.3559 -14.6789 122.719 -221.449 26.233 -318.95 -78.6931 50.1446 87.1986 -194.922 132.319 -171.78 -4.19736 11.876 -171.779 48.3047 84.1812 -104.958 -47.2103 -57.4502 -48.9477 -19.4237 28.9419 111.421 92.1237 -288.248 -23.3478 -275.22 -292.062 -92.698 5.96847 -93.6244 109.734
2. 演習: 固有幾何学モジュール
(1) 固有収集モジュールのデータデモ ビルド
に useGeometry を入力して ./eigenGeometry を実行すると、結果は次のようになります。
rotation matrix =
0.707 -0.707 0
0.707 0.707 0
0 0 1
(1,0,0) after rotation (by angle axis) = 0.707 0.707 0
(1,0,0) after rotation (by matrix) = 0.707 0.707 0
yaw pitch roll = 0.785 -0 0
Transform matrix =
0.707 -0.707 0 1
0.707 0.707 0 3
0 0 1 4
0 0 0 1
v tranformed = 1.71 3.71 4
quaternion from rotation vector = 0 0 0.383 0.924
quaternion from rotation matrix = 0 0 0.383 0.924
(1,0,0) after rotation = 0.707 0.707 0
should be equal to 0.707 0.707 0 0
(2) 実際の座標変換例
build に例を入力し、./cooperativeTransform を実行すると以下のようになります。
-0.0309731 0.73499 0.296108
3. ビジュアルプレゼンテーション
(1) 軌跡の表示
ビルドにサンプルを入力し、./plotTrajectory を実行すると以下のようになります。
同時に端末出力:
合計 620 個のポーズ エントリを読み取りました
(2) 固有収集モジュールのビジュアルデモンストレーション
ビルドに VisualizeGeometry を入力して ./visualizeGeometry を実行すると、結果は次のようになります。
問題
1. タイトルが表示されます: ./plotTrajectory を実行すると次のエラーが発生します
cannot find trajectory file at ./examples/trajectory.txt
解決策: LotTrajectory.cpp ファイルを変更し、行 11 ./examples/trajectory.txt を次のように変更します。
// path to trajectory file
string trajectory_file = "/home/fighter/slam/slambook2/ch3/examples/trajectory.txt";
理由: ファイルが見つからないことが主な理由ですが、さらなる問題やトラブルを避けるために、絶対パスに直接変更することをお勧めします。