Navigation service API
The navigation service API provides methods for controlling autonomous GPS-based navigation. Use these methods to set the navigation mode, manage waypoints, monitor the robot’s location, and query obstacles and paths.
GetMode
Get the current navigation mode.
Returns: Mode (MANUAL, WAYPOINT, or EXPLORE)
SetMode
Set the navigation mode.
| Parameter | Type | Description |
|---|---|---|
mode | Mode | The mode to set: MODE_MANUAL, MODE_WAYPOINT, or MODE_EXPLORE. |
In Manual mode, the navigation service is passive. You control the base directly. In Waypoint mode, the service takes control of the base and navigates to unvisited waypoints.
Switching from Waypoint to Manual stops the current motion plan but preserves all waypoints. Switching back to Waypoint resumes from the next unvisited waypoint.
Explore mode is accepted by SetMode and returned by GetMode but is not currently exposed in the Viam app’s navigation UI mode selector. To use it, call SetMode from an SDK.
GetLocation
Get the robot’s current GPS location and compass heading.
Returns: GeoPoint with latitude and longitude, plus compass heading
in degrees (0 = north, 90 = east, 180 = south, 270 = west).
GetWaypoints
Get all unvisited waypoints. Visited waypoints are not included.
Returns: list of Waypoint objects, each with an id and location
(GeoPoint).
AddWaypoint
Add a GPS waypoint to the navigation queue. Waypoints are visited in the order they are added.
| Parameter | Type | Description |
|---|---|---|
location | GeoPoint | The GPS coordinates (latitude, longitude) of the waypoint. |
RemoveWaypoint
Remove a waypoint by its ID. Use this to skip a waypoint the robot can’t reach, or to clear the queue.
| Parameter | Type | Description |
|---|---|---|
id | string | The waypoint ID from GetWaypoints. |
GetObstacles
Get all known obstacles, including both static obstacles from configuration and transient obstacles detected by vision services.
Returns: list of GeoGeometry objects.
GetPaths
Get the planned paths to waypoints, if any exist.
Returns: list of Path objects, each with a destination waypoint ID
and a list of GeoPoints defining the path.
GetProperties
Get the navigation service’s properties, including the map type.
Returns: MapType (NONE or GPS).
DoCommand
Send a model-specific command to the navigation service. The builtin model does not define any DoCommand keys, so this is useful only with custom navigation modules that document their own command schema.
| Parameter | Type | Description |
|---|---|---|
command | map | Key-value pairs defining the command. |
GetStatus
Return a generic status map for liveness checks. The content of the map is implementation-defined; treat it as opaque unless a specific model documents its fields.
Was this page helpful?
Glad to hear it! If you have any other feedback please let us know:
We're sorry about that. To help us improve, please tell us what we can do better:
Thank you!