在《視覺slam十四講》第二版中,第4、7、8、9、10講都需要Sophus庫,因此我們需要安裝Sophus庫,并且需要的是Sophus模板庫,因此很多人因為安裝了非模板版本導致報錯,下面提供Sophus模板版本安裝方式,以及對應不報錯版本。
1.查看eigen版本
pkg-config --modversion eigen3
只要是?3.3以上的版本即可
2.安裝 fmt (8.1.1版)
官網(wǎng)進入,然后下載Tag里的fmt-8.1.1.zip,解壓
cd fmt
mkdir build
cd build
cmake ..
make
sudo make install
3.安裝Sophus模板庫?
git clone https://github.com/strasdat/Sophus.git
cd Sophus
mkdir build
cd build
cmake ..
make
sudo make install
最后雖然書上說只需編譯,無需安裝,但是如果不進行 sudo make install,cmake時會找不到Sophus的位置。要是不想更改cmakelist.txt,就進行安裝,讓 find package 自己去找路徑。
安裝完成后,然后去正常編譯視覺slam十四講里的源碼即可
4. 一些編譯問題
ch4:
錯誤1:cmake ..時:
CMake Error at CMakeLists.txt:9 (add_executable):
? Target "useSophus" links to target "Sophus::Sophus" but the target was not
? found. ?Perhaps a find_package() call is missing for an IMPORTED target, or
? an ALIAS target is missing?
解決方案:
在CMakeLists.txt中:加入
set(Sophus_DIR "/home/你自己的路徑/Sophus/build")
錯誤2:make 時:
[ 50%] Linking CXX executable trajectoryError
/usr/bin/ld: CMakeFiles/trajectoryError.dir/trajectoryError.cpp.o: in function `std::make_unsigned<int>::type fmt::v8::detail::to_unsigned<int>(int)':
trajectoryError.cpp:(.text._ZN3fmt2v86detail11to_unsignedIiEENSt13make_unsignedIT_E4typeES4_[_ZN3fmt2v86detail11to_unsignedIiEENSt13make_unsignedIT_E4typeES4_]+0x23): undefined reference to `fmt::v8::detail::assert_fail(char const*, int, char const*)'
解決方案
沒有鏈接fmt庫,鏈接上fmt 庫就沒問題了,將example中的CMakeLists.txt中:
target_link_libraries(trajectoryError ${Pangolin_LIBRARIES} ${FMT_LIBRARIES})改為
target_link_libraries(trajectoryError ${Pangolin_LIBRARIES} ${FMT_LIBRARIES} fmt)
錯誤3:./example/trajectoryError時:
trajectory ./example/groundtruth.txt not found.
trajectory ./example/estimated.txt not found.
trajectoryError: /home/tzy/shijue_ws/src/slambook14/ch4/example/trajectoryError.cpp:22: int main(int, char**): Assertion `!groundtruth.empty() && !estimated.empty()' failed.
Aborted (core dumped)
解決方案
因為我們是在 build下執(zhí)行命令,如果使用文件的相對路徑:則修改trajectoryError.cpp,改成:
string groundtruth_file = "../example/groundtruth.txt";
string estimated_file = "../example/estimated.txt";
保存重新 make 后執(zhí)行: ./example/trajectoryError文章來源:http://www.zghlxwxcb.cn/news/detail-816141.html
文章來源地址http://www.zghlxwxcb.cn/news/detail-816141.html
到了這里,關于踩坑 Sophus 模板庫安裝及編譯(視覺SLAM 十四講第二版 ch4 )的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!