Skip to content

Commit c46f121

Browse files
committed
Fix gyro axis mapping for NanoXRP
Move gyro delta calculations into the NanoXRP branch and correctly swap pitch/roll while inverting yaw. Previously the deltas were computed before the platform check and only yaw was negated, which produced incorrect pitch/roll mapping on NanoXRP devices. The original computation is preserved for other implementations.
1 parent 2a24ffb commit c46f121

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

XRPLib/imu.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -549,13 +549,16 @@ def _stop_timer(self):
549549
def _update_imu_readings(self):
550550
# Called every tick through a callback timer
551551
self.get_gyro_rates()
552-
delta_pitch = self.irq_v[1][0] / 1000 / self.timer_frequency
553-
delta_roll = self.irq_v[1][1] / 1000 / self.timer_frequency
554-
delta_yaw = self.irq_v[1][2] / 1000 / self.timer_frequency
555552

556553
# Flip and swap for NanoXRP
557554
if "NanoXRP" in implementation._machine:
558-
delta_yaw = -delta_yaw
555+
delta_pitch = self.irq_v[1][1] / 1000 / self.timer_frequency
556+
delta_roll = self.irq_v[1][0] / 1000 / self.timer_frequency
557+
delta_yaw = -1 * self.irq_v[1][2] / 1000 / self.timer_frequency
558+
else:
559+
delta_pitch = self.irq_v[1][0] / 1000 / self.timer_frequency
560+
delta_roll = self.irq_v[1][1] / 1000 / self.timer_frequency
561+
delta_yaw = self.irq_v[1][2] / 1000 / self.timer_frequency
559562

560563
state = disable_irq()
561564
self.running_pitch += delta_pitch

0 commit comments

Comments
 (0)