d/dai: Swap x and -y axis to account for orientation of IMU in the camera.

We need a different axis assignment before submitting samples from the
DepthAI driven Luxonis Oak cameras IMU to the imu sinks, to account for
the orientation of the IMU in those cameras. On those cameras, the IMU
y axis points to the right, the x axis points downwards, the z axis
backwards. See following official Luxonis answer for reference:

https://discuss.luxonis.com/d/1044-about-oak-d-pro-w-imu-coordinate-system/8

One way to confirm the current wrong assignment and this fix is to select
"Use 3DOF tracking instead of SLAM" checkbox in the "Generic inside out
head tracker" debug UI.

Tested with a Luxonis Oak-D Pro camera.

Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Part-of: <https://gitlab.freedesktop.org/monado/monado/-/merge_requests/2228>
This commit is contained in:
Mario Kleiner 2024-05-31 03:26:31 +01:00 committed by Marge Bot
parent e7cbcefac6
commit 09273292c2

View file

@ -573,12 +573,14 @@ depthai_do_one_imu_frame(struct depthai_fs *depthai)
// Prepare sample
xrt_imu_sample sample;
sample.timestamp_ns = ts;
sample.accel_m_s2.x = a.x;
sample.accel_m_s2.y = a.y;
// Need to swap x and y axis for Oak-D cameras at least:
sample.accel_m_s2.x = a.y;
sample.accel_m_s2.y = -a.x;
sample.accel_m_s2.z = a.z;
sample.gyro_rad_secs.x = g.x;
sample.gyro_rad_secs.y = g.y;
sample.gyro_rad_secs.x = g.y;
sample.gyro_rad_secs.y = -g.x;
sample.gyro_rad_secs.z = g.z;
// Sample prepared, now push it out.