0

I have a sequence of camera poses and want to compute the angular change (pitch, yaw, roll) from the previous camera pose to the current one. As input I have 3x3 rotation matrices.

When I run the following code, it works 90% of the time, but in some cases -- like in the example below -- the Euler angles look funky despite very small changes in the quaternion: They jump from near 0 to values near PI, which might be still correct, but I cannot compute my relevant angles since I did not spontaneously flip the camera by PI. Is there any better way?

Code (looping, skipped first iteration)

std::cout << "----------\n";
std::cout << "R:\n" << R << std::endl;
Eigen::Quaternionf newQ(R);
Eigen::Quaternionf deltaQ = previousQ.conjugate()*newQ;
previousQ = newQ;
std::cout << "deltaQ:\nw = " << deltaQ.w() << "\nx = " << deltaQ.x() << "\ny = " << deltaQ.y() << "\nz = " << deltaQ.z() << std::endl;
std::cout << "Euler:\n" << deltaQ.toRotationMatrix().eulerAngles(0, 1, 2) << std::endl;

Console log

...
----------
R:
0.977515  -0.0134678    0.210437
0.0123623    0.999902  0.00656816
-0.210505 -0.00381899    0.977585
deltaQ:
w = 0.999747
x = 0.000164772
y = 0.022509
z = -0.000187157
Euler:
 0.000338229
   0.0450218
-0.000382023
----------
R:
   0.966075  -0.0153634    0.257802
  0.0136485    0.999871   0.0084406
  -0.257899 -0.00463564    0.966161
deltaQ:
w = 0.999702
x = -0.000619047
y = 0.0243718
z = 0.000825906
Euler:
 3.14031
 3.09285
-3.13991
----------
...
Close Call
  • 653
  • 1
  • 6
  • 18
  • 2
    Euler angles are not always continuous. What exactly do you need? The difference between a previous pose and the current pose? How do you want to represent the move from pi-epsilon to pi+epsilon? – Avi Ginsburg Sep 12 '18 at 09:59
  • I want the euler angles of the rotation from camera pose t-1 to camera pose t. Why: I want to model rotational pose erros and my idea was to use noise on the real pitch, yaw and roll, which are used to move the old optical axis to the new one as seen from the old camera system. Not sure if this is the right way with Euler angles, but it made intuitve sense to me to rotate the CS with three rotations (so that X axis aligns, so that Y axis aligns, so that Z axis aligns). – Close Call Sep 12 '18 at 10:49
  • 1
    "Not sure if this is the right way with Euler angles" Probably it wrong. It is not continuous, and not intuitive for big rotations of 3 axis. For modeling of noises and etc. Common practice to use RodriguesParameters or SO3 params. It is continues for small rotations and have good linearization. – minorlogic Sep 17 '18 at 07:48
  • Thank you, @minorlogic! – Close Call Sep 18 '18 at 17:07

0 Answers0