WSLでSLAMを動かしてみたい、ということでビルドをしてみた。参考にしたサイトではビルドは成功したものの、画面に表示しないサンプルらしく動いているのかわからなかったので、表示されるサンプルを探した。また、画面が表示されない時に設定がおかしいんだかそういうものなんだかわからなかったので、実行時のログも丸々載せておいた。
動かしたのは以下のもの。
追記
スクラッチでインストールしてみたのでどうぞ。
WSLでORB SLAM3を動かす(完成版) - ぼうびろく
手順
ビルドするには以下のサイトが参考になった。なお、何点かコードの修正があるが、それはやっていない。
Setting up a virtual machine with ORB SLAM 3 | by Tristan BRAUD | Medium
修正前
- Install ROS
$ curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -
- Edit ~/.bashrc (this assumes you use bash) and add
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:$WORKDIR/ORB_SLAM3/Examples/ROS/
修正後
- Install ROS
$ curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add
- Edit ~/.bashrc (this assumes you use bash) and add
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:$WORKDIR/ORB_SLAM3/Examples_old/ROS/
サンプルの実行
サンプルを実行しようとしたものの、上記のサイトにある以下のサンプルはフレームやマップが表示されない。
$ ./Examples/Monocular/mono_euroc ./Vocabulary/ORBvoc.txt ./Examples/Monocular/EuRoC.yaml Datasets/EuRoc/MH01 ./Examples/Monocular/EuRoC_TimeStamps/MH01.txt dataset-MH01_mono
ログは以下の通り
num_seq = 1 file name: dataset-MH01_mono Loading images for sequence 0...LOADED! ------- ORB-SLAM3 Copyright (C) 2017-2020 Carlos Campos, Richard Elvira, Juan J. Gómez, José M.M. Montiel and Juan D. Tardós, University of Zaragoza. ORB-SLAM2 Copyright (C) 2014-2016 Raúl Mur-Artal, José M.M. Montiel and Juan D. Tardós, University of Zaragoza. This program comes with ABSOLUTELY NO WARRANTY; This is free software, and you are welcome to redistribute it under certain conditions. See LICENSE.txt. Input sensor was set to: Monocular Loading settings from ./Examples/Monocular/EuRoC.yaml Camera1.k3 optional parameter does not exist... -Loaded camera 1 -Loaded image info -Loaded ORB settings Viewer.imageViewScale optional parameter does not exist... -Loaded viewer settings System.LoadAtlasFromFile optional parameter does not exist... System.SaveAtlasToFile optional parameter does not exist... -Loaded Atlas settings System.thFarPoints optional parameter does not exist... -Loaded misc parameters ---------------------------------- SLAM settings: -Camera 1 parameters (Pinhole): [ 458.65399169921875 457.29598999023438 367.21499633789062 248.375 ] -Camera 1 distortion parameters: [ -0.28340810537338257 0.073959067463874817 0.00019359000725671649 1.7618711353861727e-05 ] -Original image size: [ 752 , 480 ] -Current image size: [ 600 , 350 ] -Camera 1 parameters after resize: [ 365.94735717773438 333.44500732421875 292.99069213867188 181.10678100585938 ] -Sequence FPS: 20 -Features per image: 1000 -ORB scale factor: 1.2000000476837158 -ORB number of scales: 8 -Initial FAST threshold: 20 -Min FAST threshold: 7 Loading ORB Vocabulary. This could take a while... Vocabulary loaded! Initialization of Atlas from scratch Creation of new map with id: 0 Creation of new map with last KF id: 0 Seq. Name: There are 1 cameras in the atlas Camera 0 is pinhole First KF:0; Map init KF:0 New Map created with 271 points ^C
代わりに以下のサンプルを使うと表示される。
$ ./Examples/Monocular-Inertial/mono_inertial_euroc ./Vocabulary/ORBvoc.txt ./Examples/Monocular-Inertial/EuRoC.yaml Datasets/EuRoc/MH01 ./Examples/Monocular/EuRoC_TimeStamps/MH01.txt dataset-MH01_mono
ログは以下の通り。
num_seq = 1 file name: dataset-MH01_mono Loading images for sequence 0...LOADED! Loading IMU for sequence 0...LOADED! ORB-SLAM3 Copyright (C) 2017-2020 Carlos Campos, Richard Elvira, Juan J. Gómez, José M.M. Montiel and Juan D. Tardós, University of Zaragoza. ORB-SLAM2 Copyright (C) 2014-2016 Raúl Mur-Artal, José M.M. Montiel and Juan D. Tardós, University of Zaragoza. This program comes with ABSOLUTELY NO WARRANTY; This is free software, and you are welcome to redistribute it under certain conditions. See LICENSE.txt. Input sensor was set to: Monocular-Inertial Loading settings from ./Examples/Monocular-Inertial/EuRoC.yaml Camera1.k3 optional parameter does not exist... -Loaded camera 1 -Loaded image info IMU.InsertKFsWhenLost optional parameter does not exist... -Loaded IMU calibration -Loaded ORB settings Viewer.imageViewScale optional parameter does not exist... -Loaded viewer settings System.LoadAtlasFromFile optional parameter does not exist... System.SaveAtlasToFile optional parameter does not exist... -Loaded Atlas settings System.thFarPoints optional parameter does not exist... -Loaded misc parameters ---------------------------------- SLAM settings: -Camera 1 parameters (Pinhole): [ 458.65399169921875 457.29598999023438 367.21499633789062 248.375 ] -Camera 1 distortion parameters: [ -0.28340810537338257 0.073959067463874817 0.00019359000725671649 1.7618711353861727e-05 ] -Original image size: [ 752 , 480 ] -Current image size: [ 600 , 350 ] -Camera 1 parameters after resize: [ 365.94735717773438 333.44500732421875 292.99069213867188 181.10678100585938 ] -Sequence FPS: 20 -Gyro noise: 0.00016999999934341758 -Accelerometer noise: 0.0020000000949949026 -Gyro walk: 1.9392999092815444e-05 -Accelerometer walk: 0.0030000000260770321 -IMU frequency: 200 -Features per image: 1000 -ORB scale factor: 1.2000000476837158 -ORB number of scales: 8 -Initial FAST threshold: 20 -Min FAST threshold: 7 Loading ORB Vocabulary. This could take a while... Vocabulary loaded! Initialization of Atlas from scratch Creation of new map with id: 0 Creation of new map with last KF id: 0 Seq. Name: There are 1 cameras in the atlas Camera 0 is pinhole Framebuffer with requested attributes not available. Using available framebuffer. You may see visual artifacts.First KF:0; Map init KF:0 New Map created with 271 points QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-hayashi' Fail to track local map! IMU is not or recently initialized. Reseting active map... SYSTEM-> Reseting active map in monocular case Starting the Viewer LM: Active map reset recieved LM: Active map reset, waiting... LM: Reseting current map in Local Mapping... LM: End reseting Local Mapping... LM: Reset free the mutex LM: Active map reset, Done!!! mnFirstFrameId = 3 mnInitialFrameId = 0 12 Frames set to lost First KF:4; Map init KF:0 New Map created with 353 points Fail to track local map! IMU is not or recently initialized. Reseting active map... SYSTEM-> Reseting active map in monocular case LM: Active map reset recieved LM: Active map reset, waiting... LM: Reseting current map in Local Mapping... LM: End reseting Local Mapping... LM: Reset free the mutex LM: Active map reset, Done!!! mnFirstFrameId = 23 mnInitialFrameId = 14 17 Frames set to lost First KF:6; Map init KF:4 New Map created with 289 points Fail to track local map! IMU is not or recently initialized. Reseting active map... SYSTEM-> Reseting active map in monocular case LM: Active map reset recieved LM: Active map reset, waiting... LM: Reseting current map in Local Mapping... LM: End reseting Local Mapping... LM: Reset free the mutex LM: Active map reset, Done!!! mnFirstFrameId = 29 mnInitialFrameId = 27 21 Frames set to lost First KF:8; Map init KF:6 New Map created with 358 points Fail to track local map! IMU is not or recently initialized. Reseting active map... SYSTEM-> Reseting active map in monocular case LM: Active map reset recieved LM: Active map reset, waiting... LM: Reseting current map in Local Mapping... LM: End reseting Local Mapping... LM: Reset free the mutex LM: Active map reset, Done!!! mnFirstFrameId = 36 mnInitialFrameId = 32 27 Frames set to lost First KF:11; Map init KF:8 New Map created with 140 points Fail to track local map! IMU is not or recently initialized. Reseting active map... SYSTEM-> Reseting active map in monocular case LM: Active map reset recieved LM: Active map reset, waiting... LM: Reseting current map in Local Mapping... LM: End reseting Local Mapping... LM: Reset free the mutex LM: Active map reset, Done!!! mnFirstFrameId = 45 mnInitialFrameId = 41 32 Frames set to lost First KF:13; Map init KF:11 New Map created with 194 points Fail to track local map! IMU is not or recently initialized. Reseting active map... SYSTEM-> Reseting active map in monocular case LM: Active map reset recieved LM: Active map reset, waiting... LM: Reseting current map in Local Mapping... LM: End reseting Local Mapping... LM: Reset free the mutex LM: Active map reset, Done!!! mnFirstFrameId = 51 mnInitialFrameId = 49 34 Frames set to lost First KF:15; Map init KF:13 New Map created with 257 points Fail to track local map! IMU is not or recently initialized. Reseting active map... SYSTEM-> Reseting active map in monocular case LM: Active map reset recieved LM: Active map reset, waiting... LM: Reseting current map in Local Mapping... LM: End reseting Local Mapping... LM: Reset free the mutex LM: Active map reset, Done!!! mnFirstFrameId = 55 mnInitialFrameId = 52 40 Frames set to lost First KF:18; Map init KF:15 New Map created with 335 points Fail to track local map! IMU is not or recently initialized. Reseting active map... SYSTEM-> Reseting active map in monocular case LM: Active map reset recieved LM: Active map reset, waiting... LM: Reseting current map in Local Mapping... LM: End reseting Local Mapping... LM: Reset free the mutex LM: Active map reset, Done!!! mnFirstFrameId = 62 mnInitialFrameId = 60 46 Frames set to lost First KF:20; Map init KF:18 New Map created with 430 points Fail to track local map! IMU is not or recently initialized. Reseting active map... SYSTEM-> Reseting active map in monocular case LM: Active map reset recieved LM: Active map reset, waiting... LM: Reseting current map in Local Mapping... LM: End reseting Local Mapping... LM: Reset free the mutex LM: Active map reset, Done!!! mnFirstFrameId = 70 mnInitialFrameId = 67 52 Frames set to lost First KF:23; Map init KF:20 New Map created with 293 points Fail to track local map! IMU is not or recently initialized. Reseting active map... SYSTEM-> Reseting active map in monocular case LM: Active map reset recieved LM: Active map reset, waiting... LM: Reseting current map in Local Mapping... LM: End reseting Local Mapping... LM: Reset free the mutex LM: Active map reset, Done!!! mnFirstFrameId = 77 mnInitialFrameId = 75 57 Frames set to lost First KF:25; Map init KF:23 New Map created with 174 points Fail to track local map! IMU is not or recently initialized. Reseting active map... SYSTEM-> Reseting active map in monocular case LM: Active map reset recieved LM: Active map reset, waiting... LM: Reseting current map in Local Mapping... LM: End reseting Local Mapping... LM: Reset free the mutex LM: Active map reset, Done!!! mnFirstFrameId = 83 mnInitialFrameId = 81 59 Frames set to lost First KF:27; Map init KF:25 New Map created with 197 points Fail to track local map! IMU is not or recently initialized. Reseting active map... SYSTEM-> Reseting active map in monocular case LM: Active map reset recieved LM: Active map reset, waiting... LM: Reseting current map in Local Mapping... LM: End reseting Local Mapping... LM: Reset free the mutex LM: Active map reset, Done!!! mnFirstFrameId = 86 mnInitialFrameId = 84 62 Frames set to lost First KF:29; Map init KF:27 New Map created with 194 points Fail to track local map! IMU is not or recently initialized. Reseting active map... SYSTEM-> Reseting active map in monocular case LM: Active map reset recieved LM: Active map reset, waiting... LM: Reseting current map in Local Mapping... LM: End reseting Local Mapping... LM: Reset free the mutex LM: Active map reset, Done!!! mnFirstFrameId = 90 mnInitialFrameId = 88 64 Frames set to lost First KF:31; Map init KF:29 New Map created with 227 points Fail to track local map! IMU is not or recently initialized. Reseting active map... SYSTEM-> Reseting active map in monocular case LM: Active map reset recieved LM: Active map reset, waiting... LM: Reseting current map in Local Mapping... LM: End reseting Local Mapping... LM: Reset free the mutex LM: Active map reset, Done!!! mnFirstFrameId = 93 mnInitialFrameId = 91 66 Frames set to lost First KF:33; Map init KF:31 New Map created with 381 points Fail to track local map! IMU is not or recently initialized. Reseting active map... SYSTEM-> Reseting active map in monocular case LM: Active map reset recieved LM: Active map reset, waiting... LM: Reseting current map in Local Mapping... LM: End reseting Local Mapping... LM: Reset free the mutex LM: Active map reset, Done!!! mnFirstFrameId = 96 mnInitialFrameId = 94 71 Frames set to lost First KF:35; Map init KF:33 New Map created with 365 points Fail to track local map! IMU is not or recently initialized. Reseting active map... SYSTEM-> Reseting active map in monocular case LM: Active map reset recieved LM: Active map reset, waiting... LM: Reseting current map in Local Mapping... LM: End reseting Local Mapping... LM: Reset free the mutex LM: Active map reset, Done!!! mnFirstFrameId = 104 mnInitialFrameId = 100 103 Frames set to lost First KF:43; Map init KF:35 New Map created with 365 points start VIBA 1 end VIBA 1 start VIBA 2 end VIBA 2 Shutdown Saving trajectory to CameraTrajectory.txt ... There are 1 maps in the atlas Map 0 has 221 KFs End of saving trajectory to CameraTrajectory.txt ... Saving keyframe trajectory to KeyFrameTrajectory.txt ... ^C
補足
ORB SLAM2をインストールしようとしたときにg2oをインストールしたのでこれも必要かも。
GitHub - RainerKuemmerle/g2o at 20170730_git
困った場合
よくエラーとして出てくるのは、ライブラリがない、というエラーである。Ubuntuではライブラリはほぼパッケージによってインストールされる。なのでパッケージをインストールしてしまえばいい。
パッケージはapt listコマンドでリストを取得できる。この中から必要なパッケージを見つければいい。ライブラリパッケージには先頭にlibがついている。またビルドするのに必要な、ヘッダーファイルなどを含んだ開発用パッケージは、最後に-devがついている。この2点に着目して探せばいい。
例えばboostというライブラリがない場合は、以下のように検索すればいい。
$ apt list | grep -i boost libboost-all-dev/bionic,now 1.65.1.0ubuntu1 amd64