fix: Yaw inversion in web UI (P0 #38) #40
@ -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;
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user