From 36abbde93a2b35fde486644e545befcdf9ff2d02 Mon Sep 17 00:00:00 2001 From: sl-firmware Date: Sat, 28 Feb 2026 21:51:29 -0500 Subject: [PATCH] fix: correct yaw inversion in web UI (P0 #38) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove erroneous negate on targetYaw — yaw was spinning opposite to physical rotation. Update resetYaw() formula to match (+ instead of -). Pitch and roll were unaffected. Co-Authored-By: Claude Sonnet 4.6 --- ui/index.html | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/ui/index.html b/ui/index.html index 6058620..931609b 100644 --- a/ui/index.html +++ b/ui/index.html @@ -195,11 +195,10 @@ window.updateIMU = function(data) { // pitch → rotation.x positive = nose up (Three.js +x rotates -Z end upward ✓) // roll → -rotation.z positive = right bank (Three.js +z is CCW from camera = left bank, // so negate to match right-bank-positive convention) - // yaw → -rotation.y positive = CW from above (Three.js +y is CCW, sensor Z points down - // so gz+ = CW physical; negate so model spins correctly) + // yaw → +rotation.y positive = CW from above (Three.js +y = CCW but gz sign matches) targetPitch = pitch * Math.PI / 180; targetRoll = -roll * Math.PI / 180; // negate: Three.js +z = left bank, we want right bank+ - targetYaw = -yaw * Math.PI / 180; // negate: Three.js +y = CCW, sensor gz+ = CW + targetYaw = yaw * Math.PI / 180; // no negate: measured yaw matches Three.js rotation.y document.getElementById('v-pitch').textContent = pitch.toFixed(1); document.getElementById('v-roll').textContent = roll.toFixed(1); @@ -274,9 +273,9 @@ function animate() { animate(); window.resetYaw = function() { - // Capture current raw firmware yaw (before negate) as new zero reference. - // targetYaw = -(yawRaw - yawOffset) * pi/180, so yawRaw = yawOffset - targetYaw*180/pi - const currentFirmwareYaw = yawOffset - targetYaw * 180 / Math.PI; + // Capture current raw firmware yaw as new zero reference. + // targetYaw = (yawRaw - yawOffset) * pi/180, so yawRaw = yawOffset + targetYaw*180/pi + const currentFirmwareYaw = yawOffset + targetYaw * 180 / Math.PI; yawOffset = currentFirmwareYaw; targetYaw = 0; };