Autonomous delivery robot
Play the simulation
The task
The robot lives at the supermarket in the middle of town. When people order something, it loads up their parcels, drives them round to each house and heads back. It can only carry three at a time, so on a busy day it's back and forth a lot.
What makes it interesting is that nothing stays put. New orders come in while it's out on the road, and streets get blocked without warning, sometimes the exact one it was about to turn into. If it just followed a route worked out at the start, it would be stuck within minutes. Instead it keeps checking what's changed and adjusts as it goes. That's what the MAPE-K loop is for.
The MAPE-K loop
MAPE-K is a reference model for self-adaptive systems, introduced by IBM for autonomic computing. A controller observes the system it manages, decides whether anything needs to change, plans a response and carries it out, with all four steps sharing one knowledge base. The robot runs this loop a couple of times every second.
Reads the robot's position and cargo and the current roadblocks.
Decides whether an adaptation is needed: a trip is due, the route is blocked, a roadblock was cleared, or the robot has reached a customer or its base.
Computes the route and the order of stops. If no route exists, the plan is to wait.
Moves the robot, loads and hands over parcels, and switches to new routes.
Shared by all four steps: waiting and loaded orders, the current route, the state of the trip, and metrics such as distance, re-plans and delivery times.
Adaptation in practice
Placing orders


Planning the trip

A roadblock on the route

No route available

Route planning
Paths between two points are found with A* search, using the Manhattan distance as the heuristic. On a grid where the robot moves in four directions this never overestimates the remaining distance, so A* always returns a shortest path.
The order of stops is a small travelling-salesman problem. With three parcels there are only six possible orders, so the robot evaluates all of them and keeps the shortest. Ties go to the order that reaches customers sooner.
After a roadblock, the robot re-solves the whole sequence rather than just the next path, because a change in the streets can make a different order of stops the better one.
Limitations
- Perfect sensing. The robot knows about every roadblock as soon as it appears. A real robot would only detect obstacles nearby.
- No learning. The knowledge base stores the current state, not past experience, so the robot cannot anticipate streets that are often blocked.
- Simple dispatching. Orders are served first come, first served by a single robot. Grouping nearby orders or coordinating a fleet would reduce delivery times.
Place a few orders, add some roadblocks, and watch it adapt.
Play the simulation