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 convert quaternion to yaw #523

Closed
yustaub opened this issue Dec 18, 2020 · 9 comments
Closed

question about convert quaternion to yaw #523

yustaub opened this issue Dec 18, 2020 · 9 comments

Comments

@yustaub
Copy link

yustaub commented Dec 18, 2020

Hi, sir. I have got 3D bbox in nuscenes lidar coords and transform it to kitti lidar coords by kitti_to_nu_lidar_inv, and get box_lidar_kitti:
微信图片_20201218163231
and I want to use nuscenes data in kitti lidar coordinate system to train some 3D detection model which don't support nuscenes dataset, but I have no idea about converting quaternion to yaw; In box_to_string, it converts quaternion to yaw in kitti image frame, and how to convert quaternion to yaw in kitti lidar frame? Can I use quaternion_yaw? Appreciate for your reply!

@holger-motional
Copy link
Contributor

Please check
https://github.com/nutonomy/nuscenes-devkit/blob/master/python-sdk/nuscenes/scripts/export_kitti.py#L305

and specifically

quat_box = Quaternion(axis=(0, 1, 0), angle=yaw_camera) * Quaternion(axis=(1, 0, 0), angle=np.pi/2)

@yustaub
Copy link
Author

yustaub commented Dec 18, 2020

thanks for your quick reply! but I can not figure out what it means quat_box = Quaternion(axis=(0, 1, 0), angle=yaw_camera) * Quaternion(axis=(1, 0, 0), angle=np.pi/2), and still have no idea about convert quaternion to yaw in kitti lidar coordiante system. Can you share some advice? @holger-nutonomy

@holger-motional
Copy link
Contributor

The first part Quaternion(axis=(0, 1, 0), angle=yaw_camera) is the standard definition of yaw in nuScenes. We rotate around the vertical (y) axis by yaw degrees. The second part is the conversion from KITTI to nuScenes - a rotation of 90 degrees around the x axis. Understanding the different coordinate systems is often tricky, but it is very easy to just try out the different options and visualize the result. E.g. there are only 6 possible 90 degree rotations (around an axis), 2 for each axis, so you can just try each.

@yustaub
Copy link
Author

yustaub commented Dec 20, 2020

Thank you, sir. sorry for my late reply, I will try it.

@yustaub
Copy link
Author

yustaub commented Dec 20, 2020

Hello,
I understand that quaternion to yaw in nuscenes lidar coordinate system: v = np.dot(q.rotation_matrix, np.array([1, 0, 0])) yaw = np.arctan2(v[1], v[0]), I convert nuscenes lidar data to kitti lidar coordinates system and it is x front, y left, z up, about its converting quaternion to yaw, should be yaw = np.arctan2(v[0],-v[1])? Very appreciate for your reply. @holger-nutonomy

@holger-motional
Copy link
Contributor

Unfortunately I don't remember the conventions of KITTI and don't have it installed to run some checks. You can see our conventions at https://www.nuscenes.org/public/images/data.png .

@yustaub
Copy link
Author

yustaub commented Dec 21, 2020

There is another question that about quaternion condused me. kitti_to_nu_lidar = Quaternion(axis=(0, 0, 1), angle=np.pi / 2), as I known that in kitti, its lidar coordinate system is : x front, y left, z up, and in nuscenes, its lidar coordinate system is : x right, y front, z up, kitti_to_nu_lidar is rotate pi/2 around z axis, according to right-handed, x front will turn to x left, does the z axis point down? @holger-nutonomy

@holger-motional
Copy link
Contributor

You can see whether z points up or down in https://www.nuscenes.org/public/images/data.png.
The circle with an X means downwards, the circle with a dot means upwards.
x right, y front, z up is correct for nuScenes.
KITTI: For your right hand, point the thumb forward, index finger left, middle finger up.
Go to nuScenes: rotate your hand by 90 degrees clockwise around the middle finger.

@yustaub
Copy link
Author

yustaub commented Dec 22, 2020

from wiki, right hand rule is For right-handed coordinates the right thumb points along the Z axis in the positive direction and the curl of the fingers represents a motion from the first or X axis to the second or Y axis. When viewed from the top or Z axis the system is counter-clockwise., what I know about right hand rule is also this, and z is up in kitti lidar and nuscenes lidar, follow the right hand rule, x front z up in kitti lidar will turn to x left which is just opposite from x right in nuscenes, it confused me. If there are some errors, please tell me. Thanks!

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

No branches or pull requests

2 participants