在对高翔的slam14讲第7讲中3d3d估计相机位置中,在使用BA非线性优化中的一个小bug
问题描述
书中的示例程序报错 error: ‘const EstimateType {aka const class Sophus::SE3}’ has no member named ‘rotationMatrix’
Eigen::Matrix3d R_ = pose->estimate().rotationMatrix();
解决方案:
右键该行下一句的 translation
,点击 jump to declaration
可以发现在其附近有对旋转矩阵的操作定义。
Matrix3d rotation_matrix() const
{
return so3_.matrix();
}
void setRotationMatrix(const Matrix3d & rotation_matrix)
{
so3_.setQuaternion(Quaterniond(rotation_matrix));
}
故将文中代码改为
Eigen::Matrix3d R_ = pose->estimate().rotation_matrix();
即可
在一些函数未定义时,要去查看头文件,仔细了解函数的使用。