首先下载了https://github.com/erik-nelson/blam.git的代码,编译过程中出现了下面问题:
1.
_CMake Error at laser_loop_closure/CMakeLists.txt:9 (find_package):
By not providing "FindGTSAM.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "GTSAM", but
CMake did not find one.
Could not find a package configuration file provided by "GTSAM" with any of
the following names:
GTSAMConfig.cmake
gtsam-config.cmake
Add the installation prefix of "GTSAM" to CMAKE_PREFIX_PATH or set
"GTSAM_DIR" to a directory containing one of the above files. If "GTSAM"
provides a separate development package or SDK, be sure it has been
installed.
根据搜索结果的提示,我安装了gtsam
但是在http://borg.cc.gatech.edu/download.html#download
下载的gtsam-3.2.1.tgz,结果出现了一系列问题:
1.Rot3.h出错
In file included from /usr/local/include/gtsam/geometry/Point3.h:24:0,
from /usr/local/include/gtsam/geometry/Pose3.h:29,
from /home/ye/blam_ws/blam-master/internal/src/laser_loop_closure/include/laser_loop_closure/LaserLoopClosure.h:46,
from /home/ye/blam_ws/blam-master/internal/src/laser_loop_closure/src/LaserLoopClosure.cc:37:
/usr/local/include/gtsam/base/Matrix.h: In function ‘void gtsam::inplace_QR(MATRIX&)’:
/usr/local/include/gtsam/base/Matrix.h:313:71: error: expected ‘;’ before ‘::’ token
Eigen::internal::householder_qr_inplace_blocked<MATRIX, HCoeffsType>::run(A, hCoeffs, 48, temp.data());
^
In file included from /usr/local/include/gtsam/geometry/Pose3.h:30:0,
from /home/ye/blam_ws/blam-master/internal/src/laser_loop_closure/include/laser_loop_closure/LaserLoopClosure.h:46,
from /home/ye/blam_ws/blam-master/internal/src/laser_loop_closure/src/LaserLoopClosure.cc:37:
/usr/local/include/gtsam/geometry/Rot3.h: In static member function ‘static gtsam::Rot3 gtsam::Rot3::rodriguez(double, double, double)’:
/usr/local/include/gtsam/geometry/Rot3.h:197:51: error: no matching function for call to ‘gtsam::Rot3::rodriguez(Eigen::CommaInitializer<Eigen::Matrix<double, -1, 1> >&)’
{ return rodriguez((Vector(3) << wx, wy, wz));}
^
/usr/local/include/gtsam/geometry/Rot3.h:197:51: note: candidates are:
/usr/local/include/gtsam/geometry/Rot3.h:164:17: note: static gtsam::Rot3 gtsam::Rot3::rodriguez(const Vector&, double)
static Rot3 rodriguez(const Vector& w, double theta);
^
/usr/local/include/gtsam/geometry/Rot3.h:164:17: note: candidate expects 2 arguments, 1 provided
/usr/local/include/gtsam/geometry/Rot3.h:172:17: note: static gtsam::Rot3 gtsam::Rot3::rodriguez(const gtsam::Point3&, double)
static Rot3 rodriguez(const Point3& w, double theta);
^
/usr/local/include/gtsam/geometry/Rot3.h:172:17: note: candidate expects 2 arguments, 1 provided
/usr/local/include/gtsam/geometry/Rot3.h:180:17: note: static gtsam::Rot3 gtsam::Rot3::rodriguez(const gtsam::Unit3&, double)
static Rot3 rodriguez(const Unit3& w, double theta);
^
/usr/local/include/gtsam/geometry/Rot3.h:180:17: note: candidate expects 2 arguments, 1 provided
/usr/local/include/gtsam/geometry/Rot3.h:187:17: note: static gtsam::Rot3 gtsam::Rot3::rodriguez(const Vector&)
static Rot3 rodriguez(const Vector& v);
^
/usr/local/include/gtsam/geometry/Rot3.h:187:17: note: no known conversion for argument 1 from ‘Eigen::CommaInitializer<Eigen::Matrix<double, -1, 1> >’ to ‘const Vector& {aka const Eigen::Matrix<double, -1, 1>&}’
/usr/local/include/gtsam/geometry/Rot3.h:196:17: note: static gtsam::Rot3 gtsam::Rot3::rodriguez(double, double, double)
static Rot3 rodriguez(double wx, double wy, double wz)
^
/usr/local/include/gtsam/geometry/Rot3.h:196:17: note: candidate expects 3 arguments, 1 provided
In file included from /home/ye/blam_ws/blam-master/internal/src/laser_loop_closure/include/laser_loop_closure/LaserLoopClosure.h:46:0,
from /home/ye/blam_ws/blam-master/internal/src/laser_loop_closure/src/LaserLoopClosure.cc:37:
/usr/local/include/gtsam/geometry/Pose3.h: In static member function ‘static gtsam::Matrix gtsam::Pose3::wedge(double, double, double, double, double, double)’:
/usr/local/include/gtsam/geometry/Pose3.h:226:28: error: could not convert ‘(&(&(&(&(&(&(&(&(&(&(&(&(&(& Eigen::DenseBase::operator<<(const Scalar&) [with Derived = Eigen::Matrix<double, -1, -1>; Eigen::DenseBase::Scalar = double]((* &0.0)).Eigen::CommaInitializer::operator,<Eigen::Matrix<double, -1, -1> >((* &(- wz))))->Eigen::CommaInitializer::operator,<Eigen::Matrix<double, -1, -1> >(((const Scalar)(& wy))))->Eigen::CommaInitializer::operator,<Eigen::Matrix<double, -1, -1> >(((const Scalar)(& vx))))->Eigen::CommaInitializer::operator,<Eigen::Matrix<double, -1, -1> >(((const Scalar)(& wz))))->Eigen::CommaInitializer::operator,<Eigen::Matrix<double, -1, -1> >((* &0.0)))->Eigen::CommaInitializer::operator,<Eigen::Matrix<double, -1, -1> >((* &(- wx))))->Eigen::CommaInitializer::operator,<Eigen::Matrix<double, -1, -1> >(((const Scalar)(& vy))))->Eigen::CommaInitializer::operator,<Eigen::Matrix<double, -1, -1> >((* &(- wy))))->Eigen::CommaInitializer::operator,<Eigen::Matrix<double, -1, -1> >(((const Scalar)(& wx))))->Eigen::CommaInitializer::operator,<Eigen::Matrix<double, -1, -1> >((* &0.0)))->Eigen::CommaInitializer::operator,<Eigen::Matrix<double, -1, -1> >(((const Scalar)(& vz))))->Eigen::CommaInitializer::operator,<Eigen::Matrix<double, -1, -1> >((* &0.0)))->Eigen::CommaInitializer::operator,<Eigen::Matrix<double, -1, -1> >((* &0.0)))->Eigen::CommaInitializer::operator,<Eigen::Matrix<double, -1, -1> >((* &0.0)))->Eigen::CommaInitializer::operator,<Eigen::Matrix<double, -1, -1> >((* &0.0))’ from ‘Eigen::CommaInitializer<Eigen::Matrix<double, -1, -1> >’ to ‘gtsam::Matrix {aka Eigen::Matrix<double, -1, -1>}’
0., 0., 0., 0.);
^
In file included from /usr/local/include/gtsam/nonlinear/NonlinearFactorGraph.h:24:0,
from /usr/local/include/gtsam/nonlinear/ISAM2.h:22,
from /home/ye/blam_ws/blam-master/internal/src/laser_loop_closure/include/laser_loop_closure/LaserLoopClosure.h:49,
from /home/ye/blam_ws/blam-master/internal/src/laser_loop_closure/src/LaserLoopClosure.cc:37:
/usr/local/include/gtsam/geometry/Point2.h: In static member function ‘static gtsam::Vector gtsam::Point2::Logmap(const gtsam::Point2&)’:
/usr/local/include/gtsam/geometry/Point2.h:175:86: error: could not convert ‘Eigen::DenseBase::operator<<(const Scalar&) [with Derived = Eigen::Matrix<double, -1, 1>; Eigen::DenseBase::Scalar = double]((* &(& dp)->gtsam::Point2::x())).Eigen::CommaInitializer::operator,<Eigen::Matrix<double, -1, 1> >((* &(& dp)->gtsam::Point2::y()))’ from ‘Eigen::CommaInitializer<Eigen::Matrix<double, -1, 1> >’ to ‘gtsam::Vector {aka Eigen::Matrix<double, -1, 1>}’
static inline Vector Logmap(const Point2& dp) { return (Vector(2) << dp.x(), dp.y()); }
^
/home/ye/blam_ws/blam-master/internal/src/laser_loop_closure/src/LaserLoopClosure.cc: In member function ‘bool LaserLoopClosure::LoadParameters(const ros::NodeHandle&)’:
/home/ye/blam_ws/blam-master/internal/src/laser_loop_closure/src/LaserLoopClosure.cc:146:35: error: no matching function for call to ‘gtsam::Pose3::Pose3(gtsam::Rot3&, gtsam::Vector3&)’
Pose3 pose(rotation, translation);
^
/home/ye/blam_ws/blam-master/internal/src/laser_loop_closure/src/LaserLoopClosure.cc:146:35: note: candidates are:
In file included from /home/ye/blam_ws/blam-master/internal/src/laser_loop_closure/include/laser_loop_closure/LaserLoopClosure.h:46:0,
from /home/ye/blam_ws/blam-master/internal/src/laser_loop_closure/src/LaserLoopClosure.cc:37:
/usr/local/include/gtsam/geometry/Pose3.h:78:3: note: gtsam::Pose3::Pose3(const Matrix&)
Pose3(const Matrix &T) :
^
/usr/local/include/gtsam/geometry/Pose3.h:78:3: note: candidate expects 1 argument, 2 provided
/usr/local/include/gtsam/geometry/Pose3.h:75:12: note: gtsam::Pose3::Pose3(const gtsam::Pose2&)
explicit Pose3(const Pose2& pose2);
^
/usr/local/include/gtsam/geometry/Pose3.h:75:12: note: candidate expects 1 argument, 2 provided
/usr/local/include/gtsam/geometry/Pose3.h:70:3: note: gtsam::Pose3::Pose3(const gtsam::Rot3&, const gtsam::Point3&)
Pose3(const Rot3& R, const Point3& t) :
^
/usr/local/include/gtsam/geometry/Pose3.h:70:3: note: no known conversion for argument 2 from ‘gtsam::Vector3 {aka Eigen::Matrix<double, 3, 1>}’ to ‘const gtsam::Point3&’
/usr/local/include/gtsam/geometry/Pose3.h:65:3: note: gtsam::Pose3::Pose3(const gtsam::Pose3&)
Pose3(const Pose3& pose) :
^
/usr/local/include/gtsam/geometry/Pose3.h:65:3: note: candidate expects 1 argument, 2 provided
/usr/local/include/gtsam/geometry/Pose3.h:61:3: note: gtsam::Pose3::Pose3()
Pose3() {
^
/usr/local/include/gtsam/geometry/Pose3.h:61:3: note: candidate expects 0 arguments, 2 provided
/home/ye/blam_ws/blam-master/internal/src/laser_loop_closure/src/LaserLoopClosure.cc: In member function ‘gtsam::Pose3 LaserLoopClosure::ToGtsam(const Transform3&) const’:
/home/ye/blam_ws/blam-master/internal/src/laser_loop_closure/src/LaserLoopClosure.cc:407:20: error: no matching function for call to ‘gtsam::Pose3::Pose3(gtsam::Rot3&, gtsam::Vector3&)’
return Pose3(r, t);
^
/home/ye/blam_ws/blam-master/internal/src/laser_loop_closure/src/LaserLoopClosure.cc:407:20: note: candidates are:
In file included from /home/ye/blam_ws/blam-master/internal/src/laser_loop_closure/include/laser_loop_closure/LaserLoopClosure.h:46:0,
from /home/ye/blam_ws/blam-master/internal/src/laser_loop_closure/src/LaserLoopClosure.cc:37:
/usr/local/include/gtsam/geometry/Pose3.h:78:3: note: gtsam::Pose3::Pose3(const Matrix&)
Pose3(const Matrix &T) :
^
/usr/local/include/gtsam/geometry/Pose3.h:78:3: note: candidate expects 1 argument, 2 provided
/usr/local/include/gtsam/geometry/Pose3.h:75:12: note: gtsam::Pose3::Pose3(const gtsam::Pose2&)
explicit Pose3(const Pose2& pose2);
^
/usr/local/include/gtsam/geometry/Pose3.h:75:12: note: candidate expects 1 argument, 2 provided
/usr/local/include/gtsam/geometry/Pose3.h:70:3: note: gtsam::Pose3::Pose3(const gtsam::Rot3&, const gtsam::Point3&)
Pose3(const Rot3& R, const Point3& t) :
^
/usr/local/include/gtsam/geometry/Pose3.h:70:3: note: no known conversion for argument 2 from ‘gtsam::Vector3 {aka Eigen::Matrix<double, 3, 1>}’ to ‘const gtsam::Point3&’
/usr/local/include/gtsam/geometry/Pose3.h:65:3: note: gtsam::Pose3::Pose3(const gtsam::Pose3&)
Pose3(const Pose3& pose) :
^
/usr/local/include/gtsam/geometry/Pose3.h:65:3: note: candidate expects 1 argument, 2 provided
/usr/local/include/gtsam/geometry/Pose3.h:61:3: note: gtsam::Pose3::Pose3()
Pose3() {
^
/usr/local/include/gtsam/geometry/Pose3.h:61:3: note: candidate expects 0 arguments, 2 provided
/home/ye/blam_ws/blam-master/internal/src/laser_loop_closure/src/LaserLoopClosure.cc: In member function ‘LaserLoopClosure::Mat66 LaserLoopClosure::ToGu(const shared_ptr&) const’:
/home/ye/blam_ws/blam-master/internal/src/laser_loop_closure/src/LaserLoopClosure.cc:412:3: error: ‘Matrix66’ is not a member of ‘gtsam’
gtsam::Matrix66 gtsam_covariance = covariance->covariance();
^
/home/ye/blam_ws/blam-master/internal/src/laser_loop_closure/src/LaserLoopClosure.cc:412:19: error: expected ‘;’ before ‘gtsam_covariance’
gtsam::Matrix66 gtsam_covariance = covariance->covariance();
^
/home/ye/blam_ws/blam-master/internal/src/laser_loop_closure/src/LaserLoopClosure.cc:417:40: error: ‘gtsam_covariance’ was not declared in this scope
out(i, j) = gtsam_covariance(i, j);
^
/home/ye/blam_ws/blam-master/internal/src/laser_loop_closure/src/LaserLoopClosure.cc: In member function ‘gtsam::noiseModel::Gaussian::shared_ptr LaserLoopClosure::ToGtsam(const Mat66&) const’:
/home/ye/blam_ws/blam-master/internal/src/laser_loop_closure/src/LaserLoopClosure.cc:424:3: error: ‘Matrix66’ is not a member of ‘gtsam’
gtsam::Matrix66 gtsam_covariance;
^
/home/ye/blam_ws/blam-master/internal/src/laser_loop_closure/src/LaserLoopClosure.cc:424:19: error: expected ‘;’ before ‘gtsam_covariance’
gtsam::Matrix66 gtsam_covariance;
^
/home/ye/blam_ws/blam-master/internal/src/laser_loop_closure/src/LaserLoopClosure.cc:428:28: error: ‘gtsam_covariance’ was not declared in this scope
gtsam_covariance(i, j) = covariance(i, j);
^
/home/ye/blam_ws/blam-master/internal/src/laser_loop_closure/src/LaserLoopClosure.cc:430:31: error: ‘gtsam_covariance’ was not declared in this scope
return Gaussian::Covariance(gtsam_covariance);
^
make[2]: *** [laser_loop_closure/CMakeFiles/laser_loop_closure.dir/src/LaserLoopClosure.cc.o] Error 1
make[1]: *** [laser_loop_closure/CMakeFiles/laser_loop_closure.dir/all] Error 2
make: *** [all] Error 2
网上找了一大堆,一路错过去,才发现有个明白人说的话是正确的,那就是:
It is the problem of the version of GTSAM. I got the same error in gtsam3.2.1.There are no errors when I install 4.0.
解决办法:
所以,各位谨记,去下载GTSAM4.0!!!!!!!不要用3.2这个坑了!!
地址是:
https://bitbucket.org/gtborg/gtsam/src/develop/
2.出现ros.h找不到问题:
fatal error: ros/ros.h: No such file or directory
这个原因是roscpp没加进编译选项中,修改下CMakeList和
解决办法:
1.cd blam/internal/src/geometry_utils
2.add two lines below to package.xml
<build_depend>roscpp</build_depend>
<run_depend>roscpp</run_depend>
3.edit CMakeList.txt
find_package(catkin REQUIRED COMPONENTS roscpp)
include_directories(include ${catkin_INCLUDE_DIRS})