Lean-And-LiveMap-Fixes

This commit is contained in:
Developer 2026-08-27 03:43:58 -04:00
parent ba29dc2a02
commit 781da32a7c
1 changed files with 2 additions and 2 deletions

View File

@ -74,13 +74,13 @@ class SensorFusionService {
final gy = event.y * (180.0 / math.pi); final gy = event.y * (180.0 / math.pi);
_currentPitch += gx * dt; _currentPitch += gx * dt;
_currentRoll += gy * dt; _currentRoll -= gy * dt;
}); });
_accelSub = accelerometerEventStream(samplingPeriod: const Duration(milliseconds: 20)).listen((AccelerometerEvent event) { _accelSub = accelerometerEventStream(samplingPeriod: const Duration(milliseconds: 20)).listen((AccelerometerEvent event) {
// Calculate roll/pitch from accelerometer (accounting for gravity) // Calculate roll/pitch from accelerometer (accounting for gravity)
// Assuming phone is mounted roughly vertical or horizontal, we calculate basic roll // Assuming phone is mounted roughly vertical or horizontal, we calculate basic roll
final accelRoll = math.atan2(event.x, math.sqrt(event.y * event.y + event.z * event.z)) * (180.0 / math.pi); final accelRoll = -math.atan2(event.x, math.sqrt(event.y * event.y + event.z * event.z)) * (180.0 / math.pi);
final accelPitch = math.atan2(-event.y, event.z) * (180.0 / math.pi); final accelPitch = math.atan2(-event.y, event.z) * (180.0 / math.pi);
// Complementary filter: Combine integrated gyro with absolute accel // Complementary filter: Combine integrated gyro with absolute accel