lvsn / deeptracking

Deep 6 DOF Tracking
Other
35 stars 22 forks source link

question about quaternion #15

Closed mafda closed 5 years ago

mafda commented 5 years ago

Hi,

I have a question regarding the calculation of the quaternion.

In the function get_sample, you transform the initial_pose for a quaternion through the function to_paremeters.

def get_sample(self, index, image_buffer, prior_buffer, label_buffer, buffer_index):
    rgbA, depthA, initial_pose = self.load_image(index)

    prior_buffer[buffer_index] = initial_pose.to_parameters(isQuaternion=True)

The function to_parameters in turn calls the function euler2quat and this passes as parameters the angles a, b, c corresponding to the vector of the pose $[x, y, z, a, b, c]$. For the angle $a$ on the $x$ axis, $b$ the angle on the $y$ axis, and $c$ the angle on the $z$ axis, all in radians.

def to_parameters(self, isDegree=False, isQuaternion=False):
    qx, qy, qz, qw = ea.euler2quat(a, b, c)

However, the euler2quat function in angles.py receives the parameters:

def euler2quat(z=0, y=0, x=0)

and return:

what is not equivalent to the parameters in the to_parameters function:

qx, qy, qz, qw = ea.euler2quat(a, b, c)

I would like to know if I understood the procedure well and if that is the expected result.

Thank you,

MathGaron commented 5 years ago

Hi,

This is a bug, nice catch! I will change this (naming the rotations a, b, c was a poor choice and the quaternion parameters starting with z is a confusing design!)

That said, it does not affect the "vanilla" network, however that might fix the quaternion network (which was only under experimentation and is not guaranteed to work.

Also, we have a more recent version of the code (pytorch), with a more powerful network architecture. You can take a look at this link. There is a link to the github code and paper on the project page.

If you have any questions, just ask. Thank you!

mafda commented 5 years ago

Hi,

Thank you for your reply.

You modified the name of the variables in the to_parameters function, from:

def to_parameters(self, isDegree=False, isQuaternion=False):
    ...
    qx, qy, qz, qw = ea.euler2quat(a, b, c)
    ...

to:

def to_parameters(self, isDegree=False, isQuaternion=False):
    ...
    qx, qy, qz, qw = ea.euler2quat(x=rx, y=ry, z=rz)
    ...

In this way, it is more clear for me.

However, the euler2quat function in angles.py returns the quaternion ordered as w, x, y, z. Different from the current implementation which recives x, y, z, w.

Thank you

MathGaron commented 5 years ago

Thank you again for this bugfix, I just pushed the fix.

mafda commented 5 years ago

Nice, thank you!