|
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 AsyncFunctions; the native side streams results back as events.
Flow
- JS calls
requestNavigationPermission()β shows the Google T&C dialog. Must be accepted beforestartNavigationworks. - JS calls
startNavigation(lat, lng, options)with optionalstops,mode,simulate,speedMultiplier. - Native
NavigationManagerregisters the Google API key, creates an off-screenGMSMapView, grabs its navigator, sets waypoints, and activates guidance. Voice is muted. - 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.
- 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 β Expo module entry point; declares
AsyncFunctions and event names, bridges to the manager below. - NavigationManager.swift β owns the
GMSNavigatorlifecycle, route/step/off-route detection, simulation polling. - NavPayloads.swift β
maneuverString()enum mapping andpathToPoints()polyline encoder.
Android
- CrustModule.kt β Expo module entry point; mirror of the iOS module.
- NavigationManager.kt β Google Nav SDK lifecycle, parity with
NavigationManager.swift. - NavInfoReceiverService.kt β receives
NavInfoticks from the SDK; source of step metadata.