Indoor navigation when GPS dies

Dẫn đường trong nhà khi GPS chết

Outdoors on a clear day, Wheria behaves like any parked-car application: a pin on the map, a distance readout, perhaps a photo of the parking spot. Underground, the same receiver that gave you five-meter accuracy at street level now reports horizontal error exceeding thirty to eighty meters — or loses fix entirely, leaving the map drawing a stale position from minutes ago. Indoor mode is not an attempt to make GPS work better through software tricks; it is pedestrian dead reckoning, the classical technique of estimating position by integrating discrete steps and heading changes from an inertial measurement unit, augmented by barometer floor hints and honest uncertainty display.

When you tap Park, Wheria captures an anchor: the last usable GPS fix if one exists, with latitude, longitude, and reported accuracy radius, plus a timestamp and optional photograph of a pillar number or row marker. If you are still at street level, the barometer records a pressure baseline at the garage entrance. The application then starts a high-rate IMU session — CoreMotion on iOS, SensorManager at game or fastest rates on Android — and begins drawing a polyline representing every step you take after leaving the car. Each detected footfall advances position by your stride length in the direction of current heading, computed in a local east-north-up coordinate frame centered on the park point. Heading itself comes from gyroscope integration between steps, corrected by the magnetometer when the magnetic field appears trustworthy, a condition that fails frequently in steel garages and is treated with appropriate skepticism as described in our compass calibration post.

What each sensor contributes — and what it cannot

The accelerometer and gyroscope together enable step detection by band-pass filtering acceleration magnitude around walking cadence, roughly one point five to three hertz for typical walking speeds. Peak picking with an adaptive threshold identifies individual footfalls; the gyroscope confirms turn events between steps. A common student mistake is to double-integrate acceleration to obtain position, which drifts meters per second because consumer MEMS biases are milligram-level and integration squares time. We do not use raw acceleration for position — only for step events.

The magnetometer measures Earth's magnetic field vector, providing absolute heading when the local environment has not distorted the field with steel columns, rebar, or the ferrous body of a parked car. In clean outdoor conditions it works well; in parking structures we down-weight compass measurements and rely on gyroscope integration between steps, surfacing an explicit "compass unreliable" indicator rather than pretending north is known. The barometer reports absolute atmospheric pressure, and because pressure decreases roughly twelve pascals per meter of altitude gain near sea level — a relationship derived from hydrostatic equilibrium — the change in pressure since parking can suggest which basement level you reached, though elevators and weather fronts complicate the reading as we detail in barometer floor math. GPS remains active until horizontal dilution of precision or reported accuracy exceeds usable thresholds, at which point we hide the drifting dot rather than display a lie.

Stride length and the error budget

Default stride length is approximately zero point seven two meters, adjustable from height using the anthropometric estimate of zero point four one five times height in meters. Users may optionally calibrate by walking a known twenty-meter distance in a straight line while the application counts steps and stores a personal stride coefficient. Stride error dominates long walks: a five percent overestimate on stride produces four meters of longitudinal error after eighty meters walked, before heading uncertainty adds a lateral component. That is why Wheria displays distance bands — "about forty-five meters" rather than "forty-four point seven meters" — and colors a confidence chip green, yellow, or red based on fusion covariance, connecting to the Extended Kalman Filter treatment in our Kalman filter post.

Honest interface choices

The path polyline ages visually: older segments fade so you recognize a stale trace if you paused mid-garage for coffee. When heading uncertainty exceeds twenty-five degrees — common near EV charging stations where DC cables and transformers distort magnetic fields — Find mode suppresses turn-by-turn voice guidance and shifts to distance-first presentation: walk approximately sixty meters, then rescan compass in a clearer area. We would rather stay quiet than shout wrong directions into a concrete wall. ktuyen validates these behaviors across garage architectures in her test matrix: open slab structures like Landmark 81, narrow spiral ramps in mall basements, outdoor-to-indoor transitions, and the magnetometer nightmares around electric vehicle bays. Success means the user finds the car within one wrong-turn correction on at least seventy percent of walks under one hundred twenty meters, using phone sensors alone without SLAM maps or Bluetooth beacons. For the step detection algorithm underneath, see step detection and IMU odometry; for why GPS fails in the first place, read why GPS lies to you.

Ngoài trời trời trong, Wheria hoạt động như app đỗ xe bình thường: pin trên bản đồ, khoảng cách, có thể ảnh chỗ đỗ. Dưới hầm, cùng receiver từng cho accuracy năm mét ở mặt đường giờ báo sai số ngang trên ba mươi đến tám mươi mét — hoặc mất fix hẳn, bản đồ vẽ vị trí cũ từ vài phút trước. Chế độ indoor không phải cố làm GPS tốt hơn bằng trick phần mềm; đó là pedestrian dead reckoning, kỹ thuật cổ điển ước lượng vị trí bằng cách tích lũy bước rời rạc và thay đổi hướng từ bộ đo quán tính, bổ sung gợi ý tầng từ áp kế và hiển thị độ không chắc chắn thật thà.

Khi bấm Đỗ xe, Wheria chụp anchor: GPS fix cuối còn dùng được nếu có, gồm lat, lon và bán kính accuracy, cùng timestamp và ảnh tùy chọn số cột hoặc hàng. Nếu còn ở mặt đường, áp kế ghi baseline áp suất ở cửa hầm. App bật session IMU tốc cao — CoreMotion trên iOS, SensorManager ở tốc độ game hoặc fastest trên Android — và bắt đầu vẽ polyline mỗi bước sau khi rời xe. Mỗi bước chân phát hiện được tiến vị trí theo stride trong hướng heading hiện tại, tính trong khung east-north-up local quanh điểm đỗ. Heading đến từ tích phân con quay giữa các bước, hiệu chỉnh bởi từ kế khi từ trường có vẻ đáng tin — điều kiện hay fail trong hầm thép và được đối xử hoài nghi phù hợp như mô tả trong bài hiệu chuẩn la bàn.

Mỗi cảm biến đóng góp gì — và không làm gì

Gia tốc kế và con quay cùng cho phép phát hiện bước bằng lọc dải thông biên độ gia tốc quanh cadence đi bộ, khoảng 1,5–3 Hz ở tốc độ đi thông thường. Peak picking với ngưỡng thích ứng nhận diện từng bước; con quay xác nhận sự kiện quẹo giữa các bước. Lỗi kinh điển sinh viên là tích phân gia tốc hai lần để có vị trí, drift mét mỗi giây vì bias MEMS consumer cỡ milligram và tích phân bình phương thời gian. Team không dùng gia tốc thô cho vị trí — chỉ cho sự kiện bước.

Từ kế đo vector từ trường Trái Đất, cho heading tuyệt đối khi môi trường local chưa méo field bằng cột thép, cốt thép hay thân xe đỗ. Ngoài trời sạch thì ổn; trong hầm team giảm trọng số đo la bàn, dựa tích phân con quay giữa bước, hiện chỉ báo "la bàn không tin" thay vì giả vờ biết hướng bắc. Áp kế báo áp khí quyển tuyệt đối, và vì áp suất giảm khoảng mười hai pascal mỗi mét độ cao gần mực nước biển — quan hệ từ cân bằng thủy tĩnh — thay đổi áp từ lúc đỗ có thể gợi ý tầng hầm, dù thang máy và front thời tiết làm phức tạp như chi tiết trong toán tầng áp kế. GPS vẫn active đến khi dilution of precision ngang hoặc accuracy báo cáo vượt ngưỡng dùng được, rồi ẩn chấm trôi thay vì hiện lời nói dối.

Stride và ngân sách lỗi

Stride mặc định khoảng 0,72 m, chỉnh từ chiều cao bằng ước lượng nhân trắc 0,415 nhân chiều cao mét. User có thể calibrate bằng cách đi hai mươi mét thẳng trong khi app đếm bước và lưu hệ số stride cá nhân. Lỗi stride chi phối đường dài: overestimate 5% tạo lỗi dọc 4 m sau 80 m đi, trước khi uncertainty heading thêm thành phần ngang. Đó là lý do Wheria hiện band khoảng cách — "khoảng 45 m" thay vì "44,7 m" — và tô confidence chip xanh, vàng, đỏ theo covariance fusion, nối với Extended Kalman Filter trong bài Kalman.

Lựa chọn giao diện thật thà

Polyline đường đi già đi trực quan: đoạn cũ mờ để nhận trace cũ nếu dừng giữa hầm uống cà phê. Khi uncertainty heading vượt 25° — hay gặp gần trạm sạc EV nơi cáp DC và transformer méo từ trường — Find mode tắt voice turn-by-turn, chuyển presentation ưu tiên khoảng cách: đi khoảng 60 m, rồi quét la bàn ở vùng thoáng hơn. Team thà im còn hơn chỉ sai vào tường bê tông. ktuyen validate hành vi này trên kiến trúc hầm trong ma trận test: sàn mở kiểu Landmark 81, ramp xoắn hẹp hầm mall, chuyển ngoài–trong, cơn ác mộng từ kế quanh bãi sạc EV. Thành công nghĩa là user tìm xe trong một lần sửa hướng trên ít nhất 70% walk dưới 120 m, chỉ cảm biến điện thoại không SLAM hay beacon Bluetooth. Về thuật toán phát hiện bước bên dưới, xem phát hiện bước và IMU odometry; vì sao GPS fail từ đầu, đọc vì sao GPS nói dối.