Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

question about allocentric_to_egocentric #31

Open
yrj88351 opened this issue Jun 5, 2022 · 3 comments
Open

question about allocentric_to_egocentric #31

yrj88351 opened this issue Jun 5, 2022 · 3 comments

Comments

@yrj88351
Copy link

yrj88351 commented Jun 5, 2022

Hi, actually i have some problem with this (allocentric_to_egocentric).
I can't really understand how 'R_local_to_global' come from after i read code and paper.
Could you help recommend some knowledge material about this question? I would really appreciate that

I think it's something like 'alpha' observation angle in KITTI.(To get rot_y, we need to consider 'alpha' and ray angle.)
But i can't exact reason this process in DD3D. (allocentric_to_egocentric)

image

@yrj88351 yrj88351 changed the title allocentric_to_egocentric question about allocentric_to_egocentric Jun 5, 2022
@sanmin0312
Copy link

@emc222
Copy link

emc222 commented Sep 9, 2022

I also want to know how allocentric_to_egocentric works, i tried to use this function to convert a quaternion which yaw=1.1035268306732178, pitch=0, roll=0 to its global angle yaw=0.599697574750902, pitch=0, roll=0 (this is computed by simplified method as mentioned above), and i get yaw_pitch_roll (1.1051701660724589, -0.503826789884737, 0.003403815156846349). The converted yaw doesn't match global yaw but i notice the pitch value very close to the difference between local yaw and global yaw groundtruth, more tries also prove this. So I wonder if different definition of coordinate influence the result of conversion?

@yudai-kato-aisin
Copy link

yudai-kato-aisin commented Feb 1, 2023

I also found allocentric_to_egocentric does not work when other than yaw angle is not zero.
Because the gram-shmit process compute orthogonal axis but it's not guranteed to be what we expected as x, y, z axis.

update:
I noticed local to global rotation assume roll angle is 0.
In this case, we can compute rotation angles using tranlation from orthogonal coordinate to sphere coordinate.

The below code is a snipet to show an example to recover angles from a vector.

import numpy as np
from scipy.spatial.transform import Rotation
 
# examle angles. roll should be zero.
pitch, yaw, roll = [66, 120, 0]
print("pitch, yaw, roll", pitch, yaw, roll)
 
rot_matrix = Rotation.from_euler("xyz", [pitch, yaw, roll], degrees=True).as_matrix()
 
# compute a ray represents allocentric-egocentric rotation
ray = rot_matrix @ [0, 0, 1]
 
def angle_in_sphere_coord(x, y, z):
    r = np.sqrt(x**2 + y**2 + z**2)
    theta = np.arccos(y / r) - np.pi / 2
    phi = - np.sign(z) * np.arccos(x / np.sqrt(x**2 + z**2)) + np.pi / 2
    return r, theta, phi
 
r, theta, phi = angle_in_sphere_coord(*ray)
print("theta, phi", np.degrees(theta), np.degrees(phi))

outputs:

pitch, yaw, roll 66 120 0
theta, phi 66.00000000000001 119.99999999999997

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants