编译代码时,报错
error: ‘ReturnScalar’ was not declared in this scope using HomogeneousPointProduct = Vector3<ReturnScalar<HPointDerived>>;
error: template argument 1 is invalid using SO2Product = SO2<ReturnScalar<OtherDerived>>;
等很多错误,原因是:Eigen和Sophus版本不匹配。
经检查,是我不知道什么时候安装了3.2.10版本的eigen,版本太低了。
一般情况下,ros系统自动安装了3.3.7版本的eigen,完全够用。所以这个版本冲突问题一般也不会遇到。
版本正确后,编译出现报错:
error: ‘std::optional’ has not been declared std::optional<Scalar> const& theta_o = std::nullopt) {
error: expected ‘,’ or ‘...’ before ‘<’ token std::optional<Scalar> const& theta_o = std::nullopt) {
等多个错误,原因是编译环境(比如编译器版本或编译选项)不支持 C++17 标准或者没有启用 C++17 标准。
解决方法:改成C++17就行
add_compile_options(-std=c++17)
之前在使用其他库的时候也遇到过C++标准不对应问题,现在简单总结,感觉只要是std:: 的error就可能是C++标准问题