debug(imu): rim: raw byte/int16 dump (ImuRaw tag) — FSR/format 진단용

증상:
  - JSON 의 imu_samples 에 gz=0 같은 의심값
  - sqrt(ax²+ay²+az²) 가 1g 아닌 ~0.5g 일관 표시
  - 펌웨어 FSR vs 앱 변환 (/8192) 불일치 가능성

수정: ImuPacketCollector.parseRim 에 raw dump 로깅 추가.
  - 전체 byte hex dump (188B)
  - 첫 sample + 마지막 sample 의 raw int16 값 (division 전)
  - 참고용으로 /8192 시 g 환산값 같이 표시

logcat:
  adb logcat | grep ImuRaw

기대 출력:
  ImuRaw: rim FULL HEX (188B): 72 69 6D 3A 00 0F ...
  ImuRaw: rim sample[0] raw int16: ax=-170 ay=4034 az=735 gx=-8 gy=16 gz=0
          (g if /8192: ax=-0.0208 ay=0.4925 az=0.0898)

진단 판정:
  - raw az ≈ 8192 → ±4g FSR 정상
  - raw az ≈ 4096 → ±8g FSR (앱 변환식과 mismatch, FSR=±8g)
  - raw az ≈ 2048 → ±16g FSR
  - raw gz=0 일관적 → 펌웨어가 GZ 안 보내거나 sensitivity 다름
  - bytes 순서 다르면 endian/offset 문제

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-06-23 15:33:03 +09:00
parent a17c6dac69
commit eee065a76a
@@ -129,6 +129,10 @@ class ImuPacketCollector {
onLog?.invoke("rim: too short (${data.size}B)") onLog?.invoke("rim: too short (${data.size}B)")
return return
} }
// RAW DUMP — division 전 원본 byte + int16 값 logcat 으로 출력 (디버그용).
val totalHex = data.joinToString(" ") { "%02X".format(it) }
android.util.Log.d("ImuRaw", "rim FULL HEX (${data.size}B): $totalHex")
val numSamples = readBe16(data, 4) val numSamples = readBe16(data, 4)
val payloadBytes = data.size - HEADER_BYTES - CRC_BYTES val payloadBytes = data.size - HEADER_BYTES - CRC_BYTES
val expectedBytes = numSamples * SAMPLE_SIZE_BYTES val expectedBytes = numSamples * SAMPLE_SIZE_BYTES
@@ -145,6 +149,15 @@ class ImuPacketCollector {
val gxRaw = readBe16Signed(data, off + 6) val gxRaw = readBe16Signed(data, off + 6)
val gyRaw = readBe16Signed(data, off + 8) val gyRaw = readBe16Signed(data, off + 8)
val gzRaw = readBe16Signed(data, off + 10) val gzRaw = readBe16Signed(data, off + 10)
// 첫 sample / 마지막 sample 만 raw int16 dump (모든 sample 로깅하면 폭주)
if (i == 0 || i == numSamples - 1) {
android.util.Log.d("ImuRaw",
"rim sample[$i] raw int16: ax=$axRaw ay=$ayRaw az=$azRaw " +
"gx=$gxRaw gy=$gyRaw gz=$gzRaw " +
"(g if /8192: ax=${"%.4f".format(axRaw / 8192f)} ay=${"%.4f".format(ayRaw / 8192f)} az=${"%.4f".format(azRaw / 8192f)})")
}
parsed.add(ImuSample( parsed.add(ImuSample(
ax = axRaw / ACCEL_LSB_PER_G, ax = axRaw / ACCEL_LSB_PER_G,
ay = ayRaw / ACCEL_LSB_PER_G, ay = ayRaw / ACCEL_LSB_PER_G,