Ubuntu20.04的安裝以及配置SLAM環境中報錯


Ubuntu20.04的安裝

1. 分配磁盤空間

右鍵“計算機”,點擊“屬性”,進入到磁盤管理
image

中間是之前裝ubuntu18.04所用的空間,其實可以不用在這里“刪除卷”,可以統一到安裝ubuntu的時候在磁盤分區中進行刪除
image

2. 進入系統BIOS,設置啟動引導

image

image

3. 開始安裝

image

image

image

image
image

image

此處注意選擇最后一個,不然會刪除win系統資料

image

分配空間,根目錄“/”,選擇“主分區,起始地址”

image

掛載,系統所在的磁盤分區

image

安裝成功

image

4 Ubuntu20.04配置SLAM十四講的環境時存在的問題

4.1 fmt報錯

報錯詳情

/usr/bin/ld: CMakeFiles/pose_estimation_3d2d.dir/pose_estimation_3d2d.cpp.o: in function `void fmt::v8::print<Eigen::Transpose<Eigen::Matrix<double, 4, 1, 0, 4, 1> > >(fmt::v8::basic_format_string<char, fmt::v8::type_identity<Eigen::Transpose<Eigen::Matrix<double, 4, 1, 0, 4, 1> > >::type>, Eigen::Transpose<Eigen::Matrix<double, 4, 1, 0, 4, 1> >&&)':
/usr/local/include/fmt/core.h:3198: undefined reference to `fmt::v8::vprint(fmt::v8::basic_string_view<char>, fmt::v8::basic_format_args<fmt::v8::basic_format_context<fmt::v8::appender, char> >)'
/usr/bin/ld: CMakeFiles/pose_estimation_3d2d.dir/pose_estimation_3d2d.cpp.o: in function `void fmt::v8::print<>(fmt::v8::basic_format_string<char>)':
/usr/local/include/fmt/core.h:3198: undefined reference to `fmt::v8::vprint(fmt::v8::basic_string_view<char>, fmt::v8::basic_format_args<fmt::v8::basic_format_context<fmt::v8::appender, char> >)'

解決方案

修改CMakeLists
include_directories("usr/local/include/fmt" )
然后在target_link_libararies添加fmt
target_link_libraries(pose_estimation_3d2d
        g2o_core g2o_stuff
        ${OpenCV_LIBS}
        fmt)

【參考】https://blog.csdn.net/Evanzxh/article/details/119757742

4.2 ch8講,C++編譯標准的問題

需要修改c++編譯標准

set(CMAKE_CXX_FLAGS "-std=c++14 -O2 ${SSE_FLAGS} -msse4")

image

4.3 ch13講,運行slam系統報錯

要采用C++11的標准

image

找不到這個鏈接庫

先看有沒有,有的話建立軟鏈接

首先定位libglut.so*
locate libglut.so*

若沒有相應的庫,則安裝
sudo apt-get install libglut-dev

若有建立軟連接
cd /usr/lib/x86_64-linux-gnu/
sudo ln -s libglut.so.3 libglut.so

image

參考【https://www.jianshu.com/p/0695757d8111】

然后fmt又報錯,

先把原來的卸載掉
xargs rm < install_manifest.txt
進入安裝源文件 fmt/build中,找到CMakeCache.txt
改為CMAKE_CXX_FLAGS:STRING=-fPIC

再重新安裝
make
sudo make install

image

5 ubuntu20.04編譯ORB SLAM存在的問題

5.1 C++編譯標准的問題

和前面ch8講報錯一樣,可能是不支持C++11的編譯,還是不兼容?

我直接修改CMakeLists中編譯要求修改為

C++14的標准,並把前面判斷編譯標准的代碼注釋掉了

  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
   add_definitions(-DCOMPILEDWITHC0X)
   message(STATUS "Using flag -std=c++14.")

這個錯誤是因為pangoling教新的版文需要C++14以上的編譯器,
最好安裝pangoling0.3的版本

5.2 不知道的錯誤

:KeyFrame*, g2o::Sim3> > >’:
/home/hzhou/Documents/ORB_SLAM2-master/src/LoopClosing.cc:439:21:   required from here
/usr/include/c++/9/bits/stl_map.h:122:71: error: static assertion failed: std::map must have the same value_type as its allocator
  122 |       static_assert(is_same<typename _Alloc::value_type, value_type>::value,

image

打開LoopClosing.h,將

typedef map<KeyFrame*,g2o::Sim3,std::less<KeyFrame*>,
        Eigen::aligned_allocator<std::pair<const KeyFrame*, g2o::Sim3> > > KeyFrameAndPose;

改為

typedef map<KeyFrame*,g2o::Sim3,std::less<KeyFrame*>,
        Eigen::aligned_allocator<std::pair<KeyFrame *const, g2o::Sim3> > > KeyFrameAndPose;

參考【https://blog.csdn.net/lixujie666/article/details/90023059】

這個錯誤貌似也是因為C++編譯器版本的問題

把gcc和g++的版本降低到7以后就沒有這個問題了

[Ubuntu20.04終端安裝、切換低版本gcc/g++](

5.3 chrono時間報錯

報錯

error: ‘std::chrono::monotonic_clock’ has not been declared

網上說可能是因為不支持monotonic_clock,

解決方法,直接在EXample里面的幾個.cc文件中,定義

#define COMPILEDWITHC11
這樣就默認采用的是std::chrono::steady_clock

【參考】https://blog.csdn.net/weixin_45983731/article/details/117969879?utm_medium=distribute.pc_relevant.none-task-blog-2defaultBlogCommendFromBaidudefault-5.no_search_link&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2defaultBlogCommendFromBaidudefault-5.no_search_link


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM