Navigate to a waypoint
This guide walks you through configuring the navigation service and sending your robot to its first GPS waypoint.
Prerequisites
- A configured base that drives your robot.
- A configured movement sensor that provides GPS position and compass heading. Verify it reports accurate data before proceeding.
- Your machine is online in the Viam app.
Add the navigation service
- Click the + button.
- Select Configuration block.
- Search for navigation and select the builtin model.
- Name it (for example,
my-nav) and click Create.
Configure required attributes
Set these attributes in the configuration panel:
- base: the name of your base component (for example,
my-base). - movement_sensor: the name of your GPS movement sensor (for example,
my-gps). - map_type: select GPS.
Leave the other attributes at their defaults for now. See navigation service configuration for all available attributes and what they control.
Click Save.
Send the robot to a waypoint
You can add waypoints through the Viam app’s Control tab or from code.
Using the Control tab
- Go to your machine’s CONTROL tab.
- Find the navigation service card. It shows a map centered on your robot’s GPS position.
- Click on the map to add a waypoint. A marker appears at that location.
- Switch the mode to Waypoint.
- The robot begins navigating to the waypoint. Watch its position update on the map.
When the robot reaches the waypoint, it marks the waypoint as visited. If you’ve added multiple waypoints, it navigates to the next one in order.
Using code
Add a waypoint and set the mode to Waypoint programmatically.
To get the credentials for the code below, go to your machine’s page in the Viam app, click the CONNECT tab, and select SDK code sample. Toggle Include API key on. Copy the machine address, API key, and API key ID from the code sample.
What to expect
When navigation starts:
- The robot turns to face the waypoint, then drives toward it.
- If the robot deviates from its path by more than
plan_deviation_m(default 2.6 meters), the service automatically replans. - If an obstacle is detected (from configured obstacle detectors), the service replans around it.
- When the robot reaches the waypoint, it marks it as visited and stops (or moves to the next waypoint if more are queued).
Troubleshooting
What’s next
- Follow a patrol route: navigate a sequence of waypoints in a loop.
- Avoid obstacles: add vision-based obstacle detection.
- Tune navigation behavior: adjust speed, deviation, and polling for your environment.
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!