증상: 앉아있다 일어서기만 해도 walking false-trigger.
원인: 사용자 실측 데이터 분석 — stand-up + 자세 조정 motion 이 wmean
5-10 dps 로 약 3-5초 지속. 이전 default (Start Wmean=4, Hold=1s) 는
이 motion 을 walking 으로 잡음.
수정:
Start Wmean: 4 → 15 (stand-up 의 typical wmean 보다 위)
Start Hold: 1초 → 6초 (stand-up settling 보다 김)
근거:
- 사용자 측정 stand-up motion: wmean 5-10 (저강도) ~ 100 (spike)
- 진짜 보행 (body-mounted, 예상): wmean 50+ 지속
- Hold 6초 — 정상 보행은 무한 지속이라 자동 만족, stand-up 은 5초 미만
비고:
- 임계는 여전히 dev slider 로 조정 가능 (이전 commit 18a4cee)
- 사용자별 / 디바이스별 튜닝 가능
- 향후 periodicity check (FFT) 추가 시 임계 다시 완화 가능
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
사용자: walking 이 너무 예민하게 뜸. 모든 임계를 dev settings 에서 조절하고 싶음.
추가된 슬라이더 (Pitch Threshold 아래에 그룹별 정렬):
1) Posture
- Pitch Threshold (lying ↔ non-lying) 기존
- Poll Interval 기존
2) Walking Thresholds
- Min Pitch (walking 인정 최소 pitch) 기존
- Start Wmean (시작 평균 gyro) 기존
- Start Wstd (시작 표준편차) 기존
- Keep Wmean (유지 평균) — range 0.5~30 (이전 10) 신규 범위↑
- **Start Hold** (시작 조건 hold 시간, 0.2~5초) ⭐신규
- **Keep Grace** (종료 grace 시간, 0.5~10초) ⭐신규
- **Window** (sliding window 크기, 0.5~5초) ⭐신규
3) Acc Magnitude Gate
- **Min** (UNKNOWN 하한, 0.3~1.0g) ⭐신규
- **Max** (UNKNOWN 상한, 1.0~3.0g) ⭐신규
내부 변경:
- GreenZoneConstants 에 postureAccMagMin/Max 추가
- ImuPostureClassifier 의 const ACC_MAG_MIN/MAX → GreenZoneConstants 참조
(런타임 변경 가능)
총 11개 슬라이더 — 사용자가 실측하며 튜닝 가능.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
새 flowchart 의 walking 검출 추가:
1) Posture enum: UNKNOWN/LYING/NON_LYING + **WALKING** (4-state)
2) WalkingDetector.kt 신규 (flowchart Path B 구현)
- Sliding window (default 1.5초) buffer 에 gyro magnitude 누적
- 매 cycle 마다 wmean (이동평균) + wstd (이동표준편차) 계산
- State machine:
IDLE → WALKING:
|pitch| > 45° AND wmean > 4 AND wstd > 2
→ 1초 이상 연속 만족 시 전이
WALKING → IDLE:
|pitch| > 45° AND wmean > 2
→ 미달 후 2초 grace 지나면 전이
3) GreenZoneConstants 에 walking 임계 7개 추가 (모두 dev 조정 가능):
- walkingMinPitchDeg=45, walkingStartWmean=4, walkingStartWstd=2,
walkingStartHoldMs=1000, walkingKeepWmean=2, walkingKeepHoldMs=2000,
walkingWindowMs=1500
4) PiezoMonitoring:
- walkingDetector 인스턴스
- imuCollector.onComplete: classifier + detector 동시 호출,
composite posture (WALKING > NON_LYING > LYING) 결정
- NON_WALKING → WALKING 전이 시 critical 알람 trigger
5) UI:
- 상단 status bar: Walking 아이콘 (DirectionsWalk, 빨강) 추가
- 기존 wakeup 팝업 색: 빨강 → 주황 (warning level)
- 신규 walking 팝업: 빨강 + DirectionsWalk + "환자가 걷고 있습니다 — fall risk"
6) Dev settings: walking 임계 슬라이더 4개 추가
(Min Pitch / Start Wmean / Start Wstd / Keep Wmean)
sliding window / hold 시간은 default 유지 (필요 시 추가)
2단계 알람 체계 (의료적):
- 주황 (warning): LYING N초 → NON_LYING/WALKING 전이 (일어남 감지)
- 빨강 (critical): NON_WALKING → WALKING 전이 (보행 시작 — fall risk 최고)
Tag phase2-pre-walking (28a8769) 이전 상태로 복원 가능.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
낙상 예방 시나리오상 자세 변화 즉시 감지 중요 → 1초 polling 으로 단축.
canSendMaa() 500ms throttle + mtb 응답 ~400ms 이라 1초가 사실상 한계.
사용자가 slider 로 더 늦출 수도 있음 (1~15초 범위).
BLE 부담: device active ~40% (mtb 한 cycle ≈ 400ms × 매초).
배터리 영향은 짧은 모니터링 세션 (수십분~수시간) 수준에선 무시 가능.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
feature/tab-navigation 의 V2 코드를 demo-final 로 가져와 임상 alignment session
에서 V1/V2 둘 다 선택 가능하도록.
복사된 파일 (feature/tab-navigation 그대로):
walldetect/algo/SgSmoothGeneric.kt
walldetect/algo/methodd/MethodDParams.kt
walldetect/algo/methodd/MethodDPreprocessing.kt
walldetect/algo/methodd/MethodDSpan.kt
walldetect/algo/methodd/MethodDWallSelect.kt
walldetect/algo/methodd/MethodDTgc.kt
walldetect/MethodDDetector.kt
walldetect/MethodDRunner.kt
managers/AlignmentAdvisorV2.kt
(RollingAligner + AlignGuide4Stage + AlignmentAdvice — alignment.py 1:1)
확장:
walldetect/algo/Otsu.kt
+ otsu1dWithSeparability(values) — Python otsu_1d 의 (threshold, sep) tuple 호환
method_d span fallback gate 에서 사용
managers/GreenZoneConstants.kt
+ enum AlignmentAlgo { V1, V2 }
+ @Volatile var alignmentAlgo: AlignmentAlgo = V1 (default = legacy)
ui/views/monitoring/PlacementGuideView.kt
+ val v2Aligner = remember { RollingAligner() }
+ V2 분기 (alignmentAlgo == V2 시): raw 6ch → push → state(accum/commit)
→ directionHint/directionIcon/placementScore/LED 설정
→ bleManager.debugLogger.info("ALIGN_V2 phase=... state=... bestSet=...")
+ ⚙ Settings overlay 에 V1 (legacy) / V2 (new) 토글 (보라색)
+ addAlignmentFrame 호출 시 V2 활성이면 v2Aligner.phase.name 사용 (4-stage)
ui/views/clinical/ClinicalHomeView.kt
+ ClinicalSession.alignmentAlgo 를 현재 GreenZoneConstants.alignmentAlgo 값으로 채움
(이전 demo-final 은 "V1" 하드코딩)
→ V2 토글 후 Sensor Alignment 진입 시 alignment_algo="V2" 가 json 에 기록
영향:
- 기존 V1 동작 그대로 (default 가 V1, 토글 안 하면 동일)
- V2 선택 시 demo-final 에서도 4-stage 진행 가능 + json 라벨 V2 명시
- 알고리즘 토글은 dev 모드 (⚙ 버튼) 에서만 가능 — 일반 사용자 노출 X
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- 좌우 방향 전면 수정: ch4(왼쪽)길다→←, ch5(오른쪽)길다→→
ch4만 감지→← (기기 오른쪽 치우침), ch5만→→
- Almost there 제거: 방향OK+CV미달 → 그냥 GREEN 통과
- postMaxIdx 런타임 슬라이더 (개발자 설정, 기본 80, 범위 50-95)
Method A/B 공통 적용 — 바닥반사 peak 무시
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Detection(A/B/C)과 BV(Frustum/V41) 독립 설정 (개발자 모드)
기본값: Detection=C, BV=V41
- Spot: 3회 median → 5회 1.5초간격 trimmed mean (Auto와 동일)
최대 8회 재시도, 최소 유효 3개
- 일반 모드 도넛 320dp, 간격 28dp, 버튼 62dp (화면 여유)
- Placement mm 표시 제거 — 방향만 안내
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Developer mode: 캐릭터 3탭 토글, dev-only settings/graphs/logs
- SWEEP placement (CKLaw): BladderSphereSeek circle fit + RTracker
+ argmax + coronal lateral + R-peak gate GREEN lock
- Gradient placement: weighted center gradient 기반 상하 판정,
방향 로직 수정 (ch0=위, ch3=아래), 초기 멘트 "치골 위에 배치"
- Spot 측정: isSpotInProgress 플래그로 중간값 화면 깜빡임 제거
- 좌우 애매한 ↔ 멘트 제거 → 구체적 방향 또는 상태 안내
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Foreground Service (BleForegroundService.kt):
- BLE 연결 시 자동 시작, 해제 시 자동 중단
- PARTIAL_WAKE_LOCK (최대 4시간)
- Notification: "VesiScan - BLE 기기 연결 중..."
- connectedDevice foregroundServiceType
- Doze 모드에서도 BLE 통신 유지
- keepScreenOn도 유지 (추가 안전장치)
Detachment 개선:
- THR_MEAN/STD 100→30 (완전 탈착만 감지, 거리 약화 무시)
- 6채널 모두 수신됐을 때만 체크 (BLE 거리 문제와 구분)
- Placement: if(false) 제거 → 활성화 + "센서가 부착되지 않았습니다"
- Monitoring: 정상 복귀 시 LED OFF
Placement 가이드 모드:
- Simple (기본): 3+채널 → 바로 좌우 (기존)
- Boundary: 올라갔다 내려오기 패턴 (경계 감지 → 최적점 복귀)
- 설정 톱니바퀴에 Simple/Boundary 스위치
BLE 로그:
- 역순 표시 (최신이 위) — 스크롤 위치 유지
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1. Low Echo Threshold: 800~2000 슬라이더 (기본 1150, 주황색)
→ GreenZoneConstants.lowEchoAmp 런타임 변경
→ CH4/CH5 threshold 조절로 lateral 감지 개선
2. Distance/Sample: 1.5~2.5mm 슬라이더 (기본 1.771, 초록색)
→ PiezoHW.distancePerSample 런타임 변경
→ 기기별 캘리브레이션 가능
3. 도넛차트 ml 실시간 표시: estimatedVolume → lastVolumeMl 직접 표시
→ 측정 즉시 정확한 ml 반영 (기존: 레벨 변환 후 재계산으로 지연)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
GreenZoneConstants.kt — all 16 constants (thresholds, physical)
UrinAI.kt — urine gatekeeper (binary threshold detection)
PiezoEchoAnalyzer.kt — low-echo detection with prominence-based wall selection
PiezoBVEstimator.kt — Frustum BV estimation with device presets
1:1 port from Swift, same logic, same constants.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>