当前位置:   article > 正文

手写VIO(一)

手写VIO(一)

第二题:四元数和李代数更新的区别

  1. #include <iostream>
  2. #include <Eigen/Dense>
  3. #include <unsupported/Eigen/MatrixFunctions>
  4. using namespace std;
  5. Eigen::Matrix3d skew_symmetric(Eigen::Vector3d &w)
  6. {
  7. Eigen::Matrix3d mat;
  8. mat << 0, -w.z(), w.y(), w.z(), 0, -w.x(), -w.y(), w.x(), 0;
  9. return mat;
  10. }
  11. int main() {
  12. Eigen::Vector4d q = Eigen::Vector4d::Random();//生成随机四元数
  13. q.normalize();//归一化
  14. Eigen::Quaterniond q_init(q[0], q[1], q[2], q[3]);
  15. Eigen::Matrix3d R_init = q_init.toRotationMatrix();//将四元数变为旋转矩阵
  16. Eigen::Vector3d w(0.01, 0.02, 0.03);
  17. Eigen::Quaterniond q_delta(1, 0.5 * w.x(), 0.5 * w.y(), 0.5 * w.z());
  18. Eigen::Quaterniond q_update= q_init * q_delta;
  19. q_update.normalize();
  20. Eigen::Matrix3d R_update = R_init * skew_symmetric(w).exp();
  21. Eigen::Quaterniond q_R(R_update);
  22. cout << "q_init = " << q_init.w() << " " << q_init.x() << " " << q_init.y() << " " << q_init.z() << endl;
  23. cout << "q_update = " << q_update.w() << " " << q_update.x() << " " << q_update.y() << " " << q_update.z() << endl;
  24. cout << "q_R = " << q_R.w() << " " << q_R.x() << " " << q_R.y() << " " << q_R.z() << endl;
  25. return 0;
  26. }

这里有点疑惑,为什么有些算出来会差个负号

 第三题:右扰动求导

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Guff_9hys/article/detail/891604
推荐阅读
相关标签
  

闽ICP备14008679号