From 09273292c28c0dcb5cb9eaf8f6ae29533b7f55a2 Mon Sep 17 00:00:00 2001 From: Mario Kleiner Date: Fri, 31 May 2024 03:26:31 +0100 Subject: [PATCH] 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 Part-of: --- src/xrt/drivers/depthai/depthai_driver.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/xrt/drivers/depthai/depthai_driver.cpp b/src/xrt/drivers/depthai/depthai_driver.cpp index 15ba2e879..b4fba2f34 100644 --- a/src/xrt/drivers/depthai/depthai_driver.cpp +++ b/src/xrt/drivers/depthai/depthai_driver.cpp @@ -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.