adamlwgriffiths / Pyrr

3D mathematical functions using NumPy
Other
403 stars 57 forks source link

Problem with euler conventions ? #38

Closed AlexisTM closed 8 years ago

AlexisTM commented 8 years ago

Dear,

I were using the simplest code because my results were not correct.

The convention of the different object seems to be different

Exemple :

import numpy as np
from pyrr import *

roll = 60
pitch = 0
yaw = 0

def deg2rad(arr): 
    for i in xrange(len(arr)):
        arr[i] = 2*float(arr[i])*np.pi/180
    return arr

Eulers = [yaw,pitch,roll]
Eulers = deg2rad(Eulers)

matrix33 = Matrix33.from_eulers(Eulers)
q = Quaternion.from_eulers(Eulers)
print "Matrix33 :" 
print matrix33
print "Quaternion :"
print q.matrix33

Result :

Matrix33 :
[[ 0.5        0.         0.8660254]
 [ 0.         1.        -0.       ]
 [-0.8660254  0.         0.5      ]]
Quaternion :
[[-0.5        0.8660254  0.       ]
 [-0.8660254 -0.5        0.       ]
 [ 0.        -0.         1.       ]]
adamlwgriffiths commented 8 years ago

Looks like the euler -> quaternion code wasn't updated with the last refactor. I'll have to update the conversion and add more tests to catch this in future.

adamlwgriffiths commented 8 years ago

I've committed a fix to the matrix -> euler conversion. Please let me know if this fixes the issue, if not please re-open the issue.

Please be aware that the euler order is now [roll, pitch, yaw] This can be over-ridden by modifying euler.index.(roll, pitch, yaw) to the appropriate array indices.

adamlwgriffiths commented 8 years ago

I'm going to revert the change to the euler ordering. It seems the world of eulers is a mess and no one can come up with a standard representation, array-wise. So no point breaking the API at the moment.

adamlwgriffiths commented 8 years ago

Ignore that, the order will remain as [roll, pitch, yaw]

AlexisTM commented 8 years ago

Thanks a lot for your fast reaction ! Indeed, it seems that there is no euler convention order.

There is still the comment to edit

https://github.com/adamlwgriffiths/Pyrr/blob/master/pyrr/quaternion.py#L115-L116

adamlwgriffiths commented 8 years ago

Ah thanks! I'm away from my dev machine atm, but I'll get around to it this weekend.

AlexisTM commented 8 years ago

It seems to be [Roll Pitch Yaw] or [Yaw Pitch Roll] for the ROS (Robotic Operating System) data type transformation library.

Quaternion Library for ROS

adamlwgriffiths commented 8 years ago

I can make the euler indices remappable. But there needs to be a way to make it consistent with the rest of the library. If I call create_from_x_rotation, do I mean the zero-th element [x,y,z], or do I mean roll, which could be the 2nd element [yaw, pitch, roll] - or any other depending on how the user has remapped the indices.

Thoughts?