原程序编译后出现如下报错:
/usr/local/include/pangolin/var/var.h:218:29: error: ‘class pangolin::VarValueT’ has no member named ‘Get’
return var->Get();
^
/usr/local/include/pangolin/var/var.h:222:29: error: ‘class pangolin::VarValueT’ has no member named ‘Get’
return var->Get();
^
/usr/local/include/pangolin/var/varvalue.h:99:23: error: ‘class pangolin::VarValue’ has no member named ‘str’
this->str = (VarValueT*)this;
^
/usr/local/include/pangolin/var/varvalue.h:102:23: error: ‘class pangolin::VarValue’ has no member named ‘str’
this->str = str_ptr;
^
解决办法:找到该工程 CMakeLists.txt
加入如下代码:
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
即可解决
再编译仍存在问题,报错如下:
/home/sky/LQT/slambook2/ch3/examples/plotTrajectory.cpp:14:28: error: ‘Isometry3d’ was not declared in this scope
void DrawTrajectory(vector>);
^
/home/sky/LQT/slambook2/ch3/examples/plotTrajectory.cpp:14:65: error: ‘Isometry3d’ was not declared in this scope
void DrawTrajectory(vector>);
^
/home/sky/LQT/slambook2/ch3/examples/plotTrajectory.cpp:14:65: error: template argument 1 is invalid
/home/sky/LQT/slambook2/ch3/examples/plotTrajectory.cpp:14:75: error: template argument 1 is invalid
void DrawTrajectory(vector>);
^
/home/sky/LQT/slambook2/ch3/examples/plotTrajectory.cpp:14:75: error: template argument 2 is invalid
/home/sky/LQT/slambook2/ch3/examples/plotTrajectory.cpp: In function ‘int main(int, char**)’:
/home/sky/LQT/slambook2/ch3/examples/plotTrajectory.cpp:18:10: error: ‘Isometry3d’ was not declared in this scope
vector> poses;
^
/home/sky/LQT/slambook2/ch3/examples/plotTrajectory.cpp:18:47: error: the value of ‘Isometry3d’ is not usable in a constant expression
vector> poses;
^
/home/sky/LQT/slambook2/ch3/examples/plotTrajectory.cpp:18:10: note: ‘Isometry3d’ was not declared ‘constexpr’
vector> poses;
^
/home/sky/LQT/slambook2/ch3/examples/plotTrajectory.cpp:18:47: error: type/value mismatch at argument 1 in template parameter list for ‘template class Eigen::aligned_allocator’
vector> poses;
^
/home/sky/LQT/slambook2/ch3/examples/plotTrajectory.cpp:18:47: note: expected a type, got ‘Isometry3d’
/home/sky/LQT/slambook2/ch3/examples/plotTrajectory.cpp:18:57: error: template argument 1 is invalid
vector> poses;
^
/home/sky/LQT/slambook2/ch3/examples/plotTrajectory.cpp:18:57: error: template argument 2 is invalid
/home/sky/LQT/slambook2/ch3/examples/plotTrajectory.cpp:28:16: error: expected ‘;’ before ‘Twr’
Isometry3d Twr(Quaterniond(qw, qx, qy, qz));
^
/home/sky/LQT/slambook2/ch3/examples/plotTrajectory.cpp:29:5: error: ‘Twr’ was not declared in this scope
Twr.pretranslate(Vector3d(tx, ty, tz));
^
/home/sky/LQT/slambook2/ch3/examples/plotTrajectory.cpp:30:11: error: request for member ‘push_back’ in ‘poses’, which is of non-class type ‘int’
poses.push_back(Twr);
^
/home/sky/LQT/slambook2/ch3/examples/plotTrajectory.cpp:32:34: error: request for member ‘size’ in ‘poses’, which is of non-class type ‘int’
cout << "read total " << poses.size() << " pose entries" << endl;
^
/home/sky/LQT/slambook2/ch3/examples/plotTrajectory.cpp: At global scope:
/home/sky/LQT/slambook2/ch3/examples/plotTrajectory.cpp:40:28: error: ‘Isometry3d’ was not declared in this scope
void DrawTrajectory(vector> poses) {
^
/home/sky/LQT/slambook2/ch3/examples/plotTrajectory.cpp:40:65: error: ‘Isometry3d’ was not declared in this scope
void DrawTrajectory(vector> poses) {
^
/home/sky/LQT/slambook2/ch3/examples/plotTrajectory.cpp:40:65: error: template argument 1 is invalid
/home/sky/LQT/slambook2/ch3/examples/plotTrajectory.cpp:40:75: error: template argument 1 is invalid
void DrawTrajectory(vector> poses) {
^
/home/sky/LQT/slambook2/ch3/examples/plotTrajectory.cpp:40:75: error: template argument 2 is invalid
/home/sky/LQT/slambook2/ch3/examples/plotTrajectory.cpp: In function ‘void DrawTrajectory(int)’:
/home/sky/LQT/slambook2/ch3/examples/plotTrajectory.cpp:61:34: error: request for member ‘size’ in ‘poses’, which is of non-class type ‘int’
for (size_t i = 0; i < poses.size(); i++) {
^
/home/sky/LQT/slambook2/ch3/examples/plotTrajectory.cpp:63:28: error: invalid types ‘int[std::size_t {aka long unsigned int}]’ for array subscript
Vector3d Ow = poses[i].translation();
^
/home/sky/LQT/slambook2/ch3/examples/plotTrajectory.cpp:64:28: error: invalid types ‘int[std::size_t {aka long unsigned int}]’ for array subscript
Vector3d Xw = poses[i] * (0.1 * Vector3d(1, 0, 0));
^
/home/sky/LQT/slambook2/ch3/examples/plotTrajectory.cpp:65:28: error: invalid types ‘int[std::size_t {aka long unsigned int}]’ for array subscript
Vector3d Yw = poses[i] * (0.1 * Vector3d(0, 1, 0));
^
/home/sky/LQT/slambook2/ch3/examples/plotTrajectory.cpp:66:28: error: invalid types ‘int[std::size_t {aka long unsigned int}]’ for array subscript
Vector3d Zw = poses[i] * (0.1 * Vector3d(0, 0, 1));
^
/home/sky/LQT/slambook2/ch3/examples/plotTrajectory.cpp:80:34: error: request for member ‘size’ in ‘poses’, which is of non-class type ‘int’
for (size_t i = 0; i < poses.size(); i++) {
^
/home/sky/LQT/slambook2/ch3/examples/plotTrajectory.cpp:83:24: error: invalid types ‘int[std::size_t {aka long unsigned int}]’ for array subscript
auto p1 = poses[i], p2 = poses[i + 1];
^
/home/sky/LQT/slambook2/ch3/examples/plotTrajectory.cpp:85:18: error: ‘p2’ was not declared in this scope
glVertex3d(p2.translation()[0], p2.translation()[1], p2.translation()[2]);
仔细阅读报错,查看代码发现主要是对 Isometry3d Vector3d等几何模块不支持,发现缺少集合模块头文件,补上头文件:
#include <Eigen/Geometry>
编译成功
若发现程序编译成功后仍不可运行,返回错误:
cannot find trajectory file at ./examples/trajectory.txt
将路径修改为绝对路径即可
// path to trajectory file
string trajectory_file = "/home/sky/LQT/slambook2/ch3/examples/trajectory.txt";