From 627e87c144d12fea53d638431f4aeeec304b7e5d Mon Sep 17 00:00:00 2001 From: Patrick Nicolas Date: Fri, 13 Feb 2026 23:25:45 +0100 Subject: [PATCH] Ensure pose quaternions are normalized --- server/driver/pose_list.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/server/driver/pose_list.cpp b/server/driver/pose_list.cpp index a091c261..b3dd7326 100644 --- a/server/driver/pose_list.cpp +++ b/server/driver/pose_list.cpp @@ -260,13 +260,19 @@ std::pair pose_list::get_at(XrTime at_timestamp_ns) if (orientation.y) { - flags(XRT_SPACE_RELATION_ORIENTATION_VALID_BIT | XRT_SPACE_RELATION_ORIENTATION_TRACKED_BIT); + if (auto norm2 = orientation.y->squaredNorm(); + norm2 > 0.9 and norm2 < 1.1) + { + flags(XRT_SPACE_RELATION_ORIENTATION_VALID_BIT | XRT_SPACE_RELATION_ORIENTATION_TRACKED_BIT); - ret.pose.orientation = { - .x = (*orientation.y)[1], - .y = (*orientation.y)[2], - .z = (*orientation.y)[3], - .w = (*orientation.y)[0]}; + orientation.y->normalize(); + + ret.pose.orientation = { + .x = (*orientation.y)[1], + .y = (*orientation.y)[2], + .z = (*orientation.y)[3], + .w = (*orientation.y)[0]}; + } if (orientation.dy) {