要暂时转去学习机械臂控制相关,这部分留一个坑,以后有时间,手撕一遍代码,现在先做项目调试.
这里报错是因为还没安装 Geset 库,安装教程可参考博客: [Ubuntu]GTest安装和测试
或者直接执行下面指令进行安装:
sudo apt-get install libgtest-dev
cd /usr/src/gtest
sudo mkdir build
cd build
sudo cmake .. //一定要以sudo的方式运行,否则没有写入权限
sudo make //这个也一样要以sudo的方式
sudo cp libgtest*.a /usr/local/lib //将生成的libgtest.a 和 libgtest_main.a 拷贝到系统的lib路径下
make
报错,截取报错报告片段如下:
In file included from /usr/local/include/g2o/core/base_binary_edge.h:30:0,
from /home/lmf37/桌面/slambook2/ch13/include/myslam/g2o_types.h:10,
from /home/lmf37/桌面/slambook2/ch13/src/frontend.cpp:12:
/usr/local/include/g2o/core/base_fixed_sized_edge.h:199:32: error: ‘index_sequence’ is not a member of ‘std’
struct HessianTupleType<std::index_sequence<Ints...>> {
^~~~~~~~~~~~~~
/usr/local/include/g2o/core/base_fixed_sized_edge.h:199:32: error: ‘index_sequence’ is not a member of ‘std’
/usr/local/include/g2o/core/base_fixed_sized_edge.h:199:51: error: expected parameter pack before ‘...’
struct HessianTupleType<std::index_sequence<Ints...>> {
^~~
/usr/local/include/g2o/core/base_fixed_sized_edge.h:199:51: error: template argument 1 is invalid
/usr/local/include/g2o/core/base_fixed_sized_edge.h:199:54: error: expected unqualified-id before ‘>’ token
struct HessianTupleType<std::index_sequence<Ints...>> {
^~
/usr/local/include/g2o/core/base_fixed_sized_edge.h:207:12: error: ‘make_index_sequence’ is not a member of ‘std’
std::make_index_sequence<_nr_of_vertex_pairs>>::type;
^~~~~~~~~~~~~~~~~~~
/usr/local/include/g2o/core/base_fixed_sized_edge.h:207:12: error: ‘make_index_sequence’ is not a member of ‘std’
/usr/local/include/g2o/core/base_fixed_sized_edge.h:207:32: error: template argument 1 is invalid
std::make_index_sequence<_nr_of_vertex_pairs>>::type;
^~~~~~~~~~~~~~~~~~~
/usr/local/include/g2o/core/base_fixed_sized_edge.h:206:33: error: expected nested-name-specifier
using HessianTuple = typename HessianTupleType<
^~~~~~~~~~~~~~~~~
std::make_index_sequence<_nr_of_vertex_pairs>>::type;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/g2o/core/base_fixed_sized_edge.h:209:12: error: ‘make_index_sequence’ is not a member of ‘std’
std::make_index_sequence<_nr_of_vertex_pairs>>::typeTransposed;
^~~~~~~~~~~~~~~~~~~
/usr/local/include/g2o/core/base_fixed_sized_edge.h:209:12: error: ‘make_index_sequence’ is not a member of ‘std’
/usr/local/include/g2o/core/base_fixed_sized_edge.h:209:32: error: template argument 1 is invalid
std::make_index_sequence<_nr_of_vertex_pairs>>::typeTransposed;
^~~~~~~~~~~~~~~~~~~
/usr/local/include/g2o/core/base_fixed_sized_edge.h:208:43: error: expected nested-name-specifier
using HessianTupleTransposed = typename HessianTupleType<
^~~~~~~~~~~~~~~~~
std::make_index_sequence<_nr_of_vertex_pairs>>::typeTransposed;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/g2o/core/base_fixed_sized_edge.h:232:32: error: ‘std::index_sequence’ has not been declared
bool allVerticesFixedNs(std::index_sequence<Ints...>) const;
^~~~~~~~~~~~~~
/usr/local/include/g2o/core/base_fixed_sized_edge.h:232:46: error: expected ‘,’ or ‘...’ before ‘<’ token
bool allVerticesFixedNs(std::index_sequence<Ints...>) const;
^
/usr/local/include/g2o/core/base_fixed_sized_edge.h:238:37: error: ‘std::index_sequence’ has not been declared
std::index_sequence<Ints...>);
^~~~~~~~~~~~~~
/usr/local/include/g2o/core/base_fixed_sized_edge.h:238:51: error: expected ‘,’ or ‘...’ before ‘<’ token
std::index_sequence<Ints...>);
^
/usr/local/include/g2o/core/base_fixed_sized_edge.h:246:30: error: ‘std::index_sequence’ has not been declared
void linearizeOplusNs(std::index_sequence<Ints...>);
^~~~~~~~~~~~~~
/usr/local/include/g2o/core/base_fixed_sized_edge.h:246:44: error: expected ‘,’ or ‘...’ before ‘<’ token
void linearizeOplusNs(std::index_sequence<Ints...>);
^
/usr/local/include/g2o/core/base_fixed_sized_edge.h:275:38: error: ‘std::index_sequence’ has not been declared
std::index_sequence<Ints...>);
^~~~~~~~~~~~~~
/usr/local/include/g2o/core/base_fixed_sized_edge.h:275:52: error: expected ‘,’ or ‘...’ before ‘<’ token
std::index_sequence<Ints...>);
^
/usr/local/include/g2o/core/base_fixed_sized_edge.h:282:49: error: ‘std::index_sequence’ has not been declared
std::index_sequence<>);
^~~~~~~~~~~~~~
/usr/local/include/g2o/core/base_fixed_sized_edge.h:282:63: error: expected ‘,’ or ‘...’ before ‘<’ token
std::index_sequence<>);
^
/usr/local/include/g2o/core/base_fixed_sized_edge.h:286:49: error: ‘std::index_sequence’ has not been declared
std::index_sequence<Ints...>);
^~~~~~~~~~~~~~
/usr/local/include/g2o/core/base_fixed_sized_edge.h:286:63: error: expected ‘,’ or ‘...’ before ‘<’ token
std::index_sequence<Ints...>);
^
/usr/local/include/g2o/core/base_fixed_sized_edge.h:303:3: error: ‘HessianTuple’ does not name a type; did you mean ‘HessianTupleType’?
HessianTuple _hessianTuple;
^~~~~~~~~~~~
HessianTupleType
/usr/local/include/g2o/core/base_fixed_sized_edge.h:304:3: error: ‘HessianTupleTransposed’ does not name a type; did you mean ‘HessianTupleType’?
HessianTupleTransposed _hessianTupleTransposed;
^~~~~~~~~~~~~~~~~~~~~~
HessianTupleType
/usr/local/include/g2o/core/base_fixed_sized_edge.h: In constructor ‘g2o::BaseFixedSizedEdge<D, E, VertexTypes>::BaseFixedSizedEdge()’:
/usr/local/include/g2o/core/base_fixed_sized_edge.h:215:9: error: class ‘g2o::BaseFixedSizedEdge<D, E, VertexTypes>’ does not have any field named ‘_hessianTuple’
_hessianTuple(internal::createHessianMaps(_hessianTuple)),
^~~~~~~~~~~~~
/usr/local/include/g2o/core/base_fixed_sized_edge.h:215:51: error: ‘_hessianTuple’ was not declared in this scope
_hessianTuple(internal::createHessianMaps(_hessianTuple)),
^~~~~~~~~~~~~
/usr/local/include/g2o/core/base_fixed_sized_edge.h:215:51: note: suggested alternative: ‘HessianTupleType’
_hessianTuple(internal::createHessianMaps(_hessianTuple)),
^~~~~~~~~~~~~
HessianTupleType
.
.
.
.
.
.
/usr/local/include/sigslot/signal.hpp: In instantiation of ‘void sigslot::signal_base< <template-parameter-1-1>, <template-parameter-1-2> >::operator()(U&& ...) [with U = {pangolin::VarState::Event}; Lockable = std::mutex; T = {pangolin::VarState::Event}]’:
/usr/local/include/pangolin/var/varstate.h:264:23: required from ‘std::map<std::__cxx11::basic_string<char>, std::shared_ptr<pangolin::VarValueGeneric> >::iterator pangolin::VarState::AddUpgradedVar(const std::shared_ptr<pangolin::VarValue<T> >&, const iterator&, bool) [with T = bool; std::map<std::__cxx11::basic_string<char>, std::shared_ptr<pangolin::VarValueGeneric> >::iterator = std::_Rb_tree_iterator<std::pair<const std::__cxx11::basic_string<char>, std::shared_ptr<pangolin::VarValueGeneric> > >]’
/usr/local/include/pangolin/var/varstate.h:205:13: required from ‘std::shared_ptr<pangolin::VarValueGeneric> pangolin::VarState::GetOrCreateVar(const T&, const pangolin::VarMeta&) [with T = bool]’
/usr/local/include/pangolin/var/var.h:83:50: required from ‘pangolin::Var<T>::Var(const T&, const pangolin::VarMeta&) [with T = bool]’
/usr/local/include/pangolin/var/var.h:88:35: required from ‘pangolin::Var<T>::Var(const string&, const T&) [with T = bool; std::__cxx11::string = std::__cxx11::basic_string<char>]’
/usr/local/include/pangolin/display/widgets.h:153:50: required from here
/usr/local/include/sigslot/signal.hpp:1180:65: error: ‘slots_reference’ was not declared in this scope
cow_copy_type<list_type, Lockable> ref = slots_reference();
~~~~~~~~~~~~~~~^~
src/CMakeFiles/myslam.dir/build.make:173: recipe for target 'src/CMakeFiles/myslam.dir/backend.cpp.o' failed
make[2]: *** [src/CMakeFiles/myslam.dir/backend.cpp.o] Error 1
make[2]: *** 正在等待未完成的任务....
src/CMakeFiles/myslam.dir/build.make:159: recipe for target 'src/CMakeFiles/myslam.dir/frontend.cpp.o' failed
make[2]: *** [src/CMakeFiles/myslam.dir/frontend.cpp.o] Error 1
CMakeFiles/Makefile2:133: recipe for target 'src/CMakeFiles/myslam.dir/all' failed
make[1]: *** [src/CMakeFiles/myslam.dir/all] Error 2
Makefile:100: recipe for target 'all' failed
make: *** [all] Error 2
这里错误是 编译器版本错误,将下面两句注释掉(感慨一下,c++11)
改c++ 14
有亿点点万能
#set(CMAKE_CXX_FLAGS "-std=c++11 -Wall")
#set(CMAKE_CXX_FLAGS_RELEASE "-std=c++11 -O3 -fopenmp -pthread")
#可以修改为
set(CMAKE_CXX_FLAGS "-std=c++14 -O2 ${SSE_FLAGS} -msse4")
#或者是
set(CMAKE_CXX_STANDARD 14)
报了关于 fmt的错,这里根据之前经验只需要在所有 CmakeList文件中target_link_libraries(run_kitti_stereo myslam ${THIRD_PARTY_LIBS} fmt)
后面添加 fmt
继续报错
/usr/bin/ld: ../../bin/run_kitti_stereo: hidden symbol `_ZTIN3fmt2v712format_errorE' in //usr/local/lib/libfmt.a(format.cc.o) is referenced by DSO
/usr/bin/ld: 最后的链结失败: 错误的值
collect2: error: ld returned 1 exit status
app/CMakeFiles/run_kitti_stereo.dir/build.make:133: recipe for target '../bin/run_kitti_stereo' failed
make[2]: *** [../bin/run_kitti_stereo] Error 1
CMakeFiles/Makefile2:195: recipe for target 'app/CMakeFiles/run_kitti_stereo.dir/all' failed
make[1]: *** [app/CMakeFiles/run_kitti_stereo.dir/all] Error 2
Makefile:94: recipe for target 'all' failed
make: *** [all] Error 2
这里还需要将 src
文件中的SHARE
改为STATIC
add_library(myslam STATIC
frame.cpp
mappoint.cpp
map.cpp
camera.cpp
config.cpp
feature.cpp
frontend.cpp
backend.cpp
viewer.cpp
visual_odometry.cpp
dataset.cpp)
target_link_libraries(myslam
${THIRD_PARTY_LIBS} fmt)
即可编译通过
下载 Kitti数据集
大约22G
如果点击链接不能下载请参考 博客
终端执行
,加入新查到的IP52.219.169.17 s3.eu-central-1.amazonaws.com
sudo gedit /etc/hosts
127.0.0.1 localhost
127.0.1.1 lmf37-X542UQR
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
52.219.169.17 s3.eu-central-1.amazonaws.com
在终端进入bin
文件夹,输入./test_triangulation ,
进行测试,结果如下:
[==========] Running 1 test from 1 test case.
[----------] Global test environment set-up.
[----------] 1 test from MyslamTest
[ RUN ] MyslamTest.Triangulation
[ OK ] MyslamTest.Triangulation (0 ms)
[----------] 1 test from MyslamTest (0 ms total)
[----------] Global test environment tear-down
[==========] 1 test from 1 test case ran. (0 ms total)
[ PASSED ] 1 test.
这里又报错如下:
WARNING: Logging before InitGoogleLogging() is written to STDERR
I0501 20:32:45.548229 10796 visual_odometry.cpp:44] VO is running
段错误 (核心已转储)
修改app/run_kitti_stereo.cpp
,注释掉assert
这句代码,将vo->Init()
提取出来,重新编译运行:
修改如下
//assert(vo->Init() == true);
vo->Init();
vo->Run();
提示:记得更改 kitti数据集位置
在default.yaml
把dataset_dir
的路径改为前面下载的kitti数据集存放的绝对路径.
在终端进入chp
文件夹目录,输入.\bin\run_kitti_stereo
可参考这篇博客
注意一定不能进入bin目录下运行run_kitti_stereo
,否则会报如下错误:
WARNING: Logging before InitGoogleLogging() is written to STDERR
I20210712 22:42:13.808815 12504 visual_odometry.cpp:44] VO is running Segmentation fault (core dumped)段错误 (核心已转储)
结果如下:(运行的为dataset/sequences/00
数据)
(运行的为dataset/sequences/21
数据)
附加小技能
生成gif动图(默认已经下载好byzanz)
xwininfo //获取窗口参数数据
/*
xwininfo: Please select the window about which you
would like information by clicking the
mouse in that window.
xwininfo: Window id: 0x6c00003 "MySLAM"
Absolute upper-left X: 117
Absolute upper-left Y: 107
Relative upper-left X: 10
Relative upper-left Y: 38
Width: 1024
Height: 768
Depth: 24
Visual: 0x18c
Visual Class: TrueColor
Border width: 0
Class: InputOutput
Colormap: 0x6c00001 (not installed)
Bit Gravity State: ForgetGravity
Window Gravity State: NorthWestGravity
Backing Store State: NotUseful
Save Under State: no
Map State: IsViewable
Override Redirect State: no
Corners: +117+107 -779+107 -779-205 +117-205
-geometry 1024x768+107+69
*/
byzanz-record --help //获取帮助
/*
用法:
byzanz-record [OPTION…] 录制您的当前桌面会话
帮助选项:
-?, --help 显示帮助选项
--help-all 显示全部帮助选项
--help-gtk 显示 GTK+ 选项
应用程序选项:
-d, --duration=SECS 动画的时间 (默认:10 秒)
-e, --exec=COMMAND Command to execute and time
--delay=SECS 开始之前的延时(默认:1 秒)
-c, --cursor 录制鼠标光标
-a, --audio 录音
-x, --x=像素 要录制矩形的 X 坐标
-y, --y=像素 要录制矩形的 Y 坐标
-w, --width=像素 录制矩形的宽度
-h, --height=像素 录制矩形的高度
-v, --verbose 详细
--display=显示 要使用的 X 显示
*/
byzanz-record -d 2 -x 117 -y 107 -w 1024 -h 768 ~/a.gif