Follow a patrol route
A patrol route is a sequence of GPS waypoints the robot visits in order. The navigation service drives between waypoints, replans around obstacles, and retries on failure, but it does not loop. Your code has to re-add the waypoints when the robot finishes to keep the patrol going.
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 cannot reach a waypoint, the service retries indefinitely rather than skipping ahead. To move past a stuck waypoint, remove it with RemoveWaypoint.
Persist waypoints across restarts
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!