Follow a patrol route
A patrol route is a sequence of GPS waypoints the robot visits in order. The navigation service handles driving between waypoints, replanning around obstacles, and retrying on failure. Your code defines the route and restarts it when the robot finishes.
Prerequisites
- The navigation service is configured and your robot can navigate to a single waypoint.
Define a patrol route
Add multiple waypoints in the order you want the robot to visit them. The navigation service visits waypoints in the order they were added.
How waypoint ordering works
The navigation service visits waypoints in the order they were added. When all waypoints have been visited, GetWaypoints returns an empty list. The service does not automatically loop. Your code is responsible for re-adding waypoints to repeat the patrol.
If the robot fails to reach a waypoint (obstacle it can’t navigate around, motion planning failure), the service retries that waypoint indefinitely. It does not skip to the next waypoint. To skip a stuck waypoint, remove it with RemoveWaypoint.
Using the memory vs MongoDB store
With the memory store (default), waypoints are lost if viam-server
restarts. If your robot reboots mid-patrol, your code needs to re-add the
waypoints on startup.
With the MongoDB store, waypoints persist across restarts. The robot resumes from the first unvisited waypoint after a reboot. This is better for long-running patrol deployments where the robot may restart due to updates or power cycling.
What’s next
- Avoid obstacles: add vision-based obstacle detection to your patrol.
- Run actions at waypoints: capture data or trigger actions at each patrol stop.
- Tune navigation behavior: adjust speed and deviation for your patrol 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!