使用Eigen库从旋转矩阵获得俯仰和偏航 [英] Roll pitch and yaw from Rotation matrix with Eigen Library

查看:310
本文介绍了使用Eigen库从旋转矩阵获得俯仰和偏航的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从旋转矩阵中提取滚动俯仰偏航角,并且我想确保自己所做的是正确的.

I need to extract the roll pitch yaw angles from a rotation matrix and I want to be sure that what I do is correct.

    Eigen::Matrix< simFloat, 3, 1> rpy = orientation.toRotationMatrix().eulerAngles(0,1,2);
    const double r = ((double)rpy(0));
    const double p = ((double)rpy(1));
    const double y = ((double)rpy(2));

那是正确的吗?因为我在这里阅读: http://eigen.tuxfamily.org/dox/group__Geometry__Module.html#gad118fececd448d7485ffea485877>

Is that correct? Because I was reading here: http://eigen.tuxfamily.org/dox/group__Geometry__Module.html#gad118fececd448d7485ffea4858775e5a

在描述的最后,我说到有点困惑,其中定义了角度.

And I was a bit confused when it says, at the end of the description, in which intervals are defined the angles.

推荐答案

我认为这就是您想要的.取决于我们的使用方式 m.eulerAngles(0, 1, 2); 这是用rotx*roty*rotz

I think this is what you are looking for. Depending on how we use m.eulerAngles(0, 1, 2); Here's the code which get rotx, roty, rotz that is reconstructed with rotx*roty*rotz

Matrix3f m;

m = AngleAxisf(0.25*M_PI, Vector3f::UnitX())
  * AngleAxisf(0.5*M_PI, Vector3f::UnitY())
  * AngleAxisf(0.33*M_PI, Vector3f::UnitZ());

cout << "original rotation:" << endl;
cout << m << endl << endl;

Vector3f ea = m.eulerAngles(0, 1, 2); 
cout << "to Euler angles:" << endl;
cout << ea << endl << endl;

Matrix3f n;
n = AngleAxisf(ea[0], Vector3f::UnitX())
  * AngleAxisf(ea[1], Vector3f::UnitY())
  * AngleAxisf(ea[2], Vector3f::UnitZ()); 

cout << "recalc original rotation:" << endl;
cout << n << endl;

谢谢您的参考!我也首先使用本征.简单地节省了很多工作!

Thank you for your reference! I also firstly use Eigen. It's simply save a lot of work!

这篇关于使用Eigen库从旋转矩阵获得俯仰和偏航的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆