安装:
跟着readme就可以
但安装Sophus要求使用非模板类版本,下载作者推荐得make时会有报错:
/home/zf/LIBS/Sophus/sophus/so2.cpp:32:26: error: lvalue required as left operand of assignment
32 | unit_complex_.real() = 1.;
| ^~
/home/zf/LIBS/Sophus/sophus/so2.cpp:33:26: error: lvalue required as left operand of assignment
33 | unit_complex_.imag() = 0.;
|
参照下文:fatal error: sophus/se3.h: 没有那个文件或目录_古路的博客-优快云博客
将相关代码改掉即可。
#so2.cpp的构造函数改掉:
//unit_complex_.real() = 1.;
//unit_complex_.imag() = 0.;
unit_complex_.real(1.);
unit_complex_.imag(0.);
编译有包依赖Sophus时,报错:
/usr/bin/ld: /home/zf/ROS_PROJECT2/devel/lib/libvikit_common.so: undefined reference to `Sophus::SE3::exp(Eigen::Matrix<double, 6, 1, 0, 6, 1> const&)'
/usr/bin/ld: /home/zf/ROS_PROJECT2/devel/lib/libvikit_common.so: undefined reference to `Sophus::SE3::operator=(Sophus::SE3 const&)'
/usr/bin/ld: /home/zf/ROS_PROJECT2/devel/lib/libvikit_common.so: undefined reference to `Sophus::SE3::SE3()'
/usr/bin/ld: /home/zf/ROS_PROJECT2/devel/lib/libvikit_common.so: undefined reference to `Sophus::SE3::SE3(Sophus::SE3 const&)'
解决办法是硬性将cmake链接到/usr/local/lib/libSophus.so上:
find_package(sophus REQUIRED)
set(Sophus_LIBRARIES libSophus.so)
include_directories( ${Sophus_INCLUDE_DIRS} )
target_link_libraries(${PROJECT_NAME} ${Sophus_LIBRARIES})