《SLAM十四讲》slambook2 遇到的坑(持续更新ing)

《SLAM十四讲》slambook2 遇到的坑

ch5

01
安装opencv时,正常安装后便可以使用,注意检查CmakeLists.txt文件有没有搜索包含opencv库

02
问题:在编译高博的视觉SLAM十四讲第5讲的imageBasics.cpp时,出现编译错误:

Scanning dependencies of target joinMap
[ 87%] Building CXX object rgbd/CMakeFiles/joinMap.dir/joinMap.cpp.o
/home/wj/STUDY/slambook2/ch5/rgbd/joinMap.cpp:4:10: fatal error: boost/format.hpp: No such file or directory
    4 |
      |          ^~~~~~~~~~~~~~~~~~
compilation terminated.

make[2]: *** [rgbd/CMakeFiles/joinMap.dir/build.make:63: rgbd/CMakeFiles/joinMap.dir/joinMap.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:219: rgbd/CMakeFiles/joinMap.dir/all] Error 2
make: *** [Makefile:84: all] Error 2

解决方法:安装libboost-all-dev:

sudo apt-get install libboost-all-dev

————————————————
参考链接

03
问题:编译rgbd,链接joinMap报错

100%] Linking CXX executable joinMap
/usr/bin/ld: CMakeFiles/joinMap.dir/joinMap.cpp.o: in function char const* fmt::v8::detail::parse_replacement_field<char, fmt::v8::detail::format_string_checker<char, fmt::v8::detail::error_handler, Eigen::Transpose<Eigen::Matrix<double, 4, 1, 0, 4, 1> > >&>(char const*, char const*, fmt::v8::detail::format_string_checker<char, fmt::v8::detail::error_handler, Eigen::Transpose<Eigen::Matrix<double, 4, 1, 0, 4, 1> > >&)':
joinMap.cpp:(.text._ZN3fmt2v86detail23parse_replacement_fieldIcRNS1_21format_string_checkerIcNS1_13error_handlerEJN5Eigen9TransposeINS5_6MatrixIdLi4ELi1ELi0ELi4ELi1EEEEEEEEEEPKT_SE_SE_OT0_[_ZN3fmt2v86detail23parse_replacement_fieldIcRNS1_21format_string_checkerIcNS1_13error_handlerEJN5Eigen9TransposeINS5_6MatrixIdLi4ELi1ELi0ELi4ELi1EEEEEEEEEEPKT_SE_SE_OT0_]+0x149): undefined reference to ::v8::detail::throw_format_error(char const*)'
此处省略10240字符
/usr/bin/ld: joinMap.cpp:(.text._ZN3fmt2v86detail18fallback_formatterIN5Eigen9TransposeINS3_6MatrixIdLi4ELi1ELi0ELi4ELi1EEEEEcvE6formatINS0_8appenderEEET_RKS7_RNS0_20basic_format_contextISB_cEE[_ZN3fmt2v86detail18fallback_formatterIN5Eigen9TransposeINS3_6MatrixIdLi4ELi1ELi0ELi4ELi1EEEEEcvE6formatINS0_8appenderEEET_RKS7_RNS0_20basic_format_contextISB_cEE]+0xd62): undefined reference to fmt::v8::detail::throw_format_error(char const*)'
collect2: error: ld returned 1 exit status
make[2]: *** [rgbd/CMakeFiles/joinMap.dir/build.make:154: rgbd/joinMap] Error 1
make[1]: *** [CMakeFiles/Makefile2:219: rgbd/CMakeFiles/joinMap.dir/all] Error 2
make: *** [Makefile:84: all] Error 2
</code></pre>
<p>解决方法:
rgbd目录下CMakeLists.txt文件不完整(啊这~),对其进行补充。</p>
<pre><code class="language-bash">find_package(Sophus REQUIRED)
include_directories(${Sophus_INCLUDE_DIRS})

find_package(Pangolin REQUIRED)

add_executable(joinMap joinMap.cpp)
target_link_libraries(joinMap ${OpenCV_LIBS} ${Pangolin_LIBRARIES})
</code></pre>
<p>正确的内容如下:</p>
<pre><code class="language-bash">project(rgbd)

cmake_minimum_required(VERSION 3.10)

find_package(Sophus REQUIRED)

add_executable(joinMap joinMap.cpp)

include_directories(${Sophus_INCLUDE_DIRS})

find_package(OpenCV REQUIRED)

include_directories( ${OpenCV-INCLUDE_DIRS})

target_link_libraries(joinMap ${OpenCV_LIBS} ${Pangolin_LIBRARIES})

find_package(Pangolin REQUIRED)

target_link_libraries(joinMap ${OpenCV_LIBS} ${Pangolin_LIBRARIES})

include_directories("/usr/local/include/eigen3")

target_link_libraries(joinMap ${Sophus_LIBRARIES} fmt)

set(CMAKE_CXX_FLAGS "-std=c++11")
</code></pre>
<p>————————————————
<a href="https://blog.csdn.net/weixin_53660567/article/details/120074124">参考链接</a></p>
<p>ch10</p>
<p><strong>01</strong>
问题:编译安装g2o_viewer
解决方法:</p>
<p>1、先安装一些库:</p>
<pre><code class="language-bash">sudo apt-get install libsuitesparse-dev qtdeclarative5-dev qt5-qmake
sudo apt-get install libqglviewer-dev-qt5
</code></pre>
<p>2、重新编译整个g2o库</p>
<pre><code class="language-bash">cd g2o
mkdir build
cd build
cmake ..

make
sudo make install
</code></pre>
<p>3、 打开g2o_viewer</p>
<p>在g2o/bin目录下运行:</p>
<pre><code class="language-bash">~/slambook2/3rdparty/g2o/bin$ ./g2o_viewer
</code></pre>
<p>————————————————
<a href="https://blog.csdn.net/weixin_43728093/article/details/121027502">参考链接</a></p>
<p>ch12</p>
<p><strong>01</strong>
问题:PCL相关报错</p>
<pre><code class="language-bash">** WARNING ** io features related to pcap will be disabled
** WARNING ** io features related to png will be disabled
-- Eigen found (include: /usr/include/eigen3, version: 3.3.7)
-- OpenNI found (version: 1.5.4.0, include: /usr/include/ni, lib: /usr/lib/libOpenNI.so;libusb::libusb)
-- OpenNI2 found (version: 2.2.0.33, include: /usr/include/openni2, lib: /usr/lib/libOpenNI2.so;libusb::libusb)
-- Could NOT find Qhull (missing: QHULL_INCLUDE_DIR)
** WARNING ** surface features related to qhull will be disabled

</code></pre>
<p>解决方法:</p>
<p>1、删除build目录。重新cmake,不管pcap和png</p>
<p>————————————————
<a href="https://github.com/cnr-isti-vclab/meshlab/discussions/872">参考链接</a>
————————————————
<strong>02</strong></p>
<p>编译问题:</p>
<pre><code class="language-bash">This header is deprecated. Use the facilities in <boost/timer/timer.hpp> instead.

 BOOST_HEADER_DEPRECATED( "the facilities in " )
</code></pre>
<p>办法:</p>
<pre><code class="language-bash">将dense_mapping.cpp头文件
</code></pre>
<p>编译问题:</p>
<pre><code class="language-bash"> 'CV_GRAY2BGR' was not declared in this scope
     cv::cvtColor(ref, ref_show, CV_GRAY2BGR);
</code></pre>
<p>办法:</p>
<pre><code class="language-bash">将所有cv::cvtColor(ref, ref_show, CV_GRAY2BGR)中CV_GRAY2BGR改为COLOR_GRAY2BGR
</code></pre>
<p>————————————————
<a href="https://www.cxyzjd.com/article/dahailuoa6/94555333">参考链接</a>
————————————————
<strong>03</strong>
fmt相关
编译问题:</p>
<pre><code class="language-bash">dense_mapping.cpp:(.text+0x31): undefined reference to ::v8::vprint(fmt::v8::basic_string_view<char>, fmt::v8::basic_format_args<fmt::v8::basic_format_context<fmt::v8::appender, char> >)'
...

解决方法:
修改CMakeLists.txt:

find_package(fmt REQUIRED)
set(FMT_LIBRARIES fmt::fmt)
...

target_link_libraries(xxx ${xxx} ${FMT_LIBRARIES})

————————————————
04
编译问题:pcl相关

...

 error: 'plus' is not a member of 'pcl::traits'
 ...

解决方法:
修改CMakeLists.txt:

set(CMAKE_CXX_STANDARD 14)

————————————————
参考链接
————————————————

05
编译问题:pcl相关

surfel_mapping.cpp:31:9: error:
'class pcl::MovingLeastSquares<pcl::PointXYZRGB, pcl::PointXYZRGBNormal>'
has no member named 'setPolynomialFit';
did you mean 'setPolynomialOrder'?

解决方法:

注释报错行

————————————————
参考链接

06
问题:

segmentation fault (core dumped)  ./build/dense_mono/dense_mapping test_data

解决方法:
1 (无效)

在程序中,加上头文件<Eigen/StdVector>,并将所有
vector<Eigen::??> 都改为:
vector<Eigen::??,Eigen::aligned_allocator<Eigen::??>>(不是真的问号,根据变量类型而定)

具体的:
首先加上头文件

并在定义 vector 时做如下修改:
比如修改前:

vector<Eigen::Isometry3d>

修改后:

vector<Eigen::Isometry3d,Eigen::aligned_allocator<Eigen::Isometry3d>>

参考链接
————————————————
2 (无效)

~/STUDY/slambook2/ch12/dense_mono > ulimit -a
-t: cpu time (seconds)              unlimited
-f: file size (blocks)              unlimited
-d: data seg size (kbytes)          unlimited
-s: stack size (kbytes)             8192
-c: core file size (blocks)         0
-m: resident set size (kbytes)      unlimited
-u: processes                       31081
-n: file descriptors                1024
-l: locked-in-memory size (kbytes)  65536
-v: address space (kbytes)          unlimited
-x: file locks                      unlimited
-i: pending signals                 31081
-q: bytes in POSIX msg queues       819200
-e: max nice                        0
-r: max rt priority                 0
-N 15:                              unlimited

~/STUDY/slambook2/ch12/dense_mono > ulimit -s 102400

参考链接
————————————————
3(OK!)
bool update 函数缺少return 语句。
(其实在make过程中有warnning,我没注意…这就是教训了。)

[ 12%] Building CXX object dense_mono/CMakeFiles/dense_mapping.dir/dense_mapping.cpp.o
/home/wj/STUDY/slambook2/ch12/dense_mono/dense_mapping.cpp: In function 'bool update(const cv::Mat&, const cv::Mat&, const SE3d&, cv::Mat&, cv::Mat&)':
/home/wj/STUDY/slambook2/ch12/dense_mono/dense_mapping.cpp:290:1: warning: no return statement in function returning non-void [-Wreturn-type]
  290 | }
      | ^
[ 25%] Linking CXX executable dense_mapping
[ 25%] Built target dense_mapping
[ 50%] Built target surfel_mapping
[ 75%] Built target octomap_mapping
[100%] Built target pointcloud_mapping

在bool update函数体最后(290行附近)添加 return true;


bool update(const Mat &ref, const Mat &curr, const SE3d &T_C_R, Mat &depth, Mat &depth_cov2) {
    for (int x = boarder; x < width - boarder; x++)
        for (int y = boarder; y < height - boarder; y++) {

            if (depth_cov2.ptr<double>(y)[x] < min_cov || depth_cov2.ptr<double>(y)[x] > max_cov)
                continue;

            Vector2d pt_curr;
            Vector2d epipolar_direction;
            bool ret = epipolarSearch(
                ref,
                curr,
                T_C_R,
                Vector2d(x, y),
                depth.ptr<double>(y)[x],
                sqrt(depth_cov2.ptr<double>(y)[x]),
                pt_curr,
                epipolar_direction
            );

            if (ret == false)
                continue;

            updateDepthFilter(Vector2d(x, y), pt_curr, T_C_R, epipolar_direction, depth, depth_cov2);
        }
    return true;
}

再次运行,终于成功了!

《SLAM十四讲》slambook2 遇到的坑(持续更新ing)

ch13

01
问题:修改opencv 版本及代码,添加fmt库,make 链接过程报错!

/usr/bin/ld: /usr/local/lib/libfmt.a(format.cc.o): relocation R_X86_64_PC32 against symbol `stderr@@GLIBC_2.2.5' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status
make[2]: *** [src/CMakeFiles/myslam.dir/build.make:309: ../lib/libmyslam.so] Error 1
make[1]: *** [CMakeFiles/Makefile2:136: src/CMakeFiles/myslam.dir/all] Error 2
make: *** [Makefile:95: all] Error 2

解决方法:
报错原因是CMakeLists.txt中其他三方库是用的共享库,而fmt是静态库(libfmt.a),需要对重新对fmt进行动态编译,得到(libfmt.so)再进行安装。

/STUDY/slambook2/3rdparty/fmt/build > cmake -DBUILD_SHARED_LIBS=TRUE ..

再在ch13/build下重新make:

~/STUDY/slambook2/ch13/build > make
[  6%] Linking CXX shared library ../../lib/libmyslam.so
[ 75%] Built target myslam
Scanning dependencies of target test_triangulation
[ 81%] Building CXX object test/CMakeFiles/test_triangulation.dir/test_triangulation.cpp.o
[ 87%] Linking CXX executable ../../bin/test_triangulation
[ 87%] Built target test_triangulation
Scanning dependencies of target run_kitti_stereo
[ 93%] Building CXX object app/CMakeFiles/run_kitti_stereo.dir/run_kitti_stereo.cpp.o
[100%] Linking CXX executable ../../bin/run_kitti_stereo
[100%] Built target run_kitti_stereo

————————————————
参考链接

Original: https://blog.csdn.net/m0_50910915/article/details/122150847
Author: WoooChi
Title: 《SLAM十四讲》slambook2 遇到的坑(持续更新ing)

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/702335/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球