zhao-zhibo / Test-GTSAM

手写高斯牛顿法和gtsam学习心得
4 stars 2 forks source link

[version] 该代码可以运行的gtsam版本是什么? #1

Closed haohaoalt closed 7 months ago

haohaoalt commented 7 months ago

终端部分报错

[ 84%] Built target test_gtsam_gaussNewton
/home/hayden/dev/0221_ws/src/test_gtsam/src/curveFitting.cpp:45:51: error: ‘boost::optional’ has not been declared
   45 |     Vector evaluateError(const gtsam::Vector3 &p, boost::optional<Matrix &> H = boost::none) const override
      |                                                   ^~~~~
/home/hayden/dev/0221_ws/src/test_gtsam/src/curveFitting.cpp:45:66: error: expected ‘,’ or ‘...’ before ‘<’ token
   45 |     Vector evaluateError(const gtsam::Vector3 &p, boost::optional<Matrix &> H = boost::none) const override
      |                                                                  ^
/home/hayden/dev/0221_ws/src/test_gtsam/src/curveFitting.cpp:45:12: error: ‘gtsam::Vector curvfitFactor::evaluateError(const Vector3&, int) const’ marked ‘override’, but does not override
   45 |     Vector evaluateError(const gtsam::Vector3 &p, boost::optional<Matrix &> H = boost::none) const override
      |            ^~~~~~~~~~~~~
/home/hayden/dev/0221_ws/src/test_gtsam/src/curveFitting.cpp: In member function ‘gtsam::Vector curvfitFactor::evaluateError(const Vector3&, int) const’:
/home/hayden/dev/0221_ws/src/test_gtsam/src/curveFitting.cpp:48:13: error: ‘H’ was not declared in this scope; did you mean ‘gtsam::symbol_shorthand::H’?
   48 |         if (H) // 残差为1维,优化变量为3维,雅可比矩阵为1*3
haohaoalt commented 7 months ago

源码编译后安装成功了4.1.1 但还有报错

process[test_gtsam_testGtsam-2]: started with pid [64835]
/home/hayden/dev/0221_ws/devel/lib/test_gtsam/test_gtsam_testGtsam: Symbol `_ZTVN5gtsam6FactorE' has different size in shared object, consider re-linking
/home/hayden/dev/0221_ws/devel/lib/test_gtsam/test_gtsam_testGtsam: Symbol `_ZTVN5gtsam20NonlinearFactorGraphE' has different size in shared object, consider re-linking
/home/hayden/dev/0221_ws/devel/lib/test_gtsam/test_gtsam_testGtsam: Symbol `_ZTVN5gtsam16NoiseModelFactorE' has different size in shared object, consider re-linking
[ INFO] [1708501184.276228144]: ----> testGtsam Started.
terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc
[test_gtsam_testGtsam-2] process has died [pid 64835, exit code -6, cmd /home/hayden/dev/0221_ws/devel/lib/test_gtsam/test_gtsam_testGtsam __name:=test_gtsam_testGtsam __log:=/home/hayden/.ros/log/611a0d84-d08c-11ee-8fca-4739f33cd47f/test_gtsam_testGtsam-2.log].
log file: /home/hayden/.ros/log/611a0d84-d08c-11ee-8fca-4739f33cd47f/test_gtsam_testGtsam-2*.log
[test_gtsam_testGtsam-2] restarting process
zhao-zhibo commented 7 months ago

@haohaoalt 清理你的构建目录,并重新构建整个项目。我用的gtsam是2023年七月的版本,是4.0

haohaoalt commented 7 months ago

@haohaoalt 清理你的构建目录,并重新构建整个项目。我用的gtsam是2023年七月的版本,是4.0

最终成功了,可能的原因在安装gtsam时eigen版本选择 从/home/hayden/app/gtsam-4.2a9/CMakeLists.txt 找到/home/hayden/app/gtsam-4.2a9/cmake/HandleEigen.cmake 修改 option(GTSAM_USE_SYSTEM_EIGEN "Find and use system-installed Eigen. If 'off', use the one bundled with GTSAM" ON) 然后

cmake ..
make 
make install

安装成功gtsam-4.2a9版本,之前遇到的报错都没了

zhao-zhibo commented 7 months ago

@zhao-zhibo eigen确定经常冲突,之前我也遇到过类似的问题,Eigen官方明确说明在一台设备上只安装一个版本的eigen。