Simplify glanceboard-trigger angle setting; fix incorrectly-rotated accelerometer readings on G1

The glanceboard head-tilt option was more complicated than necessary,
because it wanted the user to take two angle measurements, a baseline
angle and a tilt angle. That was a workaround to not knowing the
accelerometer's orientation/calibration, but actually, we do know those.

(Except, as it turns out, on the G1, the accelerometer orientation is
different than it is on the G2, and there was a bug where EvenHub apps
got their accelerometer readings in the wrong orientation. So for
example the EvenHub Level app didn't work correctly.)
This commit is contained in:
James Babcock committed 2026-11-15 23:29:02 -08:00
1 parent 37d81d0308
commit e09f8eae96
17 files changed
+255 -281

No files matched your search

@@ -1130,7 +1130,8 @@ class G1FeaturesTest {
}
s.core.setImuReportEnabled(true, 200)
assertTrue(awaitTrue(3_000) { lock.withLock { readings.size >= 5 } }, "samples: " + lock.withLock { readings.size } + "\n" + s.tail())
assertEquals(listOf(0.1, -1.0, 0.25, BleProtocol.EVENT_SOURCE_GLASSES_R.toDouble()), lock.withLock { readings.first() })
// The G1's (x, y, z) arrive in the G2's frame as (-z, -x, y) (ImuOrientation).
assertEquals(listOf(-0.25, -0.1, -1.0, BleProtocol.EVENT_SOURCE_GLASSES_R.toDouble()), lock.withLock { readings.first() })
assertTrue(awaitTrue(1_000) { s.glasses.lock.withLock { s.glasses.rightArm.props[G1Protocol.PROP_IMU_RATE] == G1Protocol.IMU_RATE_STREAM } })
s.core.setImuReportEnabled(false, 0)
assertTrue(awaitTrue(1_000) { s.glasses.lock.withLock { s.glasses.rightArm.props[G1Protocol.PROP_IMU_RATE] == G1Protocol.IMU_RATE_IDLE } })
@@ -0,0 +1,25 @@
package com.faceclaw.app
import kotlin.math.abs
import kotlin.math.sqrt
import kotlin.test.*
class ImuOrientationTest {
private val s = sqrt(0.5)
private fun assertVec(expected: DoubleArray, actual: DoubleArray, what: String) {
for (i in 0..2) assertTrue(abs(expected[i] - actual[i]) < 1e-9, "$what: expected ${expected.toList()}, got ${actual.toList()}")
}
/** The poses measured on hardware (level, 45° up, 45° to the right) read the G2's values on every model. */
@Test fun measuredPosesMatchTheG2Frame() {
val level = doubleArrayOf(0.0, 0.0, 1.0)
val up = doubleArrayOf(s, 0.0, s)
val right = doubleArrayOf(0.0, s, s)
val g1 = listOf(doubleArrayOf(0.0, 1.0, 0.0), doubleArrayOf(0.0, s, -s), doubleArrayOf(-s, s, 0.0))
for ((name, canonical, raw) in listOf(Triple("level", level, g1[0]), Triple("up", up, g1[1]), Triple("right", right, g1[2]))) {
assertVec(canonical, ImuOrientation.toCanonical(GlassesType.G1, raw[0], raw[1], raw[2]), "G1 $name")
assertVec(canonical, ImuOrientation.toCanonical(GlassesType.G2, canonical[0], canonical[1], canonical[2]), "G2 $name")
}
}
}