|
Download mobile/docs/module/crust/Navigation.md from Anirudh1950/MentraOS: direct link, hf CLI and curl.
- Browser
- Download file 2.55 kB
-
https://huggingface.co/Anirudh1950/MentraOS/resolve/main/mobile/docs/module/crust/Navigation.md
- Command line
-
hf download hf://Anirudh1950/MentraOS/mobile/docs/module/crust/Navigation.md
-
curl -L -o Navigation.md https://huggingface.co/Anirudh1950/MentraOS/resolve/main/mobile/docs/module/crust/Navigation.md
2.55 kB
| # Crust: Navigation | |
| How the crust native module delivers turn-by-turn navigation to JS. | |
| ## Overview | |
| Turn-by-turn guidance backed by Google Navigation SDK. Runs on iOS and Android with parity. JS calls the module via Expo `AsyncFunction`s; the native side streams results back as events. | |
| ## Flow | |
| 1. JS calls `requestNavigationPermission()` β shows the Google T&C dialog. Must be accepted before `startNavigation` works. | |
| 2. JS calls `startNavigation(lat, lng, options)` with optional `stops`, `mode`, `simulate`, `speedMultiplier`. | |
| 3. Native `NavigationManager` registers the Google API key, creates an off-screen `GMSMapView`, grabs its navigator, sets waypoints, and activates guidance. Voice is muted. | |
| 4. As the route is computed and the user moves, the manager emits events to JS: | |
| - `onNavRoute` β polyline points + step metadata (road / maneuver / distance). | |
| - `onNavManeuver` β current step, distance to next turn, ETA. | |
| - `onNavLocation` β road-snapped GPS ticks. | |
| - `onNavRerouting` β fired when the route changes. | |
| - `onNavOffRoute` β once per off-route episode (>30m from polyline). | |
| - `onNavArrived` β final waypoint reached. | |
| 5. JS calls `stopNavigation()` β tears down the navigator, clears callbacks, resets cached state. | |
| Simulation mode replays a route at `speedMultiplier`Γ speed; a 1Hz polling timer reads `mapView.myLocation` as a fallback when the road-snapped provider stays quiet. | |
| ## Files | |
| ### iOS | |
| - [CrustModule.swift](../../../modules/crust/ios/CrustModule.swift) β Expo module entry point; declares `AsyncFunction`s and event names, bridges to the manager below. | |
| - [NavigationManager.swift](../../../modules/crust/ios/navigation/NavigationManager.swift) β owns the `GMSNavigator` lifecycle, route/step/off-route detection, simulation polling. | |
| - [NavPayloads.swift](../../../modules/crust/ios/navigation/NavPayloads.swift) β `maneuverString()` enum mapping and `pathToPoints()` polyline encoder. | |
| ### Android | |
| - [CrustModule.kt](../../../modules/crust/android/src/main/java/com/mentra/crust/CrustModule.kt) β Expo module entry point; mirror of the iOS module. | |
| - [NavigationManager.kt](../../../modules/crust/android/src/main/java/com/mentra/crust/navigation/NavigationManager.kt) β Google Nav SDK lifecycle, parity with `NavigationManager.swift`. | |
| - [NavInfoReceiverService.kt](../../../modules/crust/android/src/main/java/com/mentra/crust/navigation/NavInfoReceiverService.kt) β receives `NavInfo` ticks from the SDK; source of step metadata. | |