Routing
UAT 363 Unmanned Aircraft Systems Technology for Transportation and Smart Warehousing
Lesson
By the end of this module you will be able to
- Compute the distance and energy of multi-stop delivery routes
- Find the shortest route by exhaustive search and compare it with the nearest-neighbour method
- Check energy feasibility including reserve, and split work into several trips
- Explain drone–truck routing problems from the research literature
- Explain outdoor navigation with GNSS and RTK, convert coordinates for route planning, and set geofence and landing margins from position accuracy
Why this matters
The hospital must deliver to four health centres. Flying out and back to each one works but is wasteful. One round trip visiting all four is cheaper, but if the battery is insufficient the drone may come down on the way. A good visiting order cuts distance substantially, and checking energy with reserve before take-off is a safety matter, not just an economy.
The routing problem
Finding the order that visits every point and returns to the start with the shortest total distance is the traveling salesman problem (TSP). The number of possible orders grows very fast: stops have orders (counting both directions). Four stops have only 24, so all can be searched, but 15 stops have more than a trillion. Real systems therefore use heuristics that find good-enough answers quickly, such as the nearest-neighbour method, which always goes to the closest unvisited stop.
Example 1. Exhaustive search versus nearest neighbour
Assumed coordinates in kilometres; H is the hospital.
import math
from itertools import permutations
SITES = {"H": (0, 0), "A": (1.0, 2.5), "B": (1.5, 0.0), "C": (-2.0, 1.0), "D": (4.0, 0.5)}
def length(order):
stops = ["H", *order, "H"]
return sum(math.dist(SITES[a], SITES[b]) for a, b in zip(stops, stops[1:]))
best = min(permutations("ABCD"), key=length)
current, left, greedy = "H", set("ABCD"), []
while left:
nxt = min(sorted(left), key=lambda s: math.dist(SITES[current], SITES[s]))
greedy.append(nxt)
left.remove(nxt)
current = nxt
print(f"exhaustive: H-{'-'.join(best)}-H = {length(best):.2f} km")
print(f"nearest neighbour: H-{'-'.join(greedy)}-H = {length(greedy):.2f} km "
f"(+{length(greedy) / length(best) - 1:.0%})")
exhaustive: H-B-D-A-C-H = 13.25 km
nearest neighbour: H-B-A-C-D-H = 17.46 km (+32%)
Nearest neighbour starts well at B but gets stuck at C on the left, then has to fly far across to D on the right, ending about a third longer than the best answer. Heuristics should always be checked against better solutions where possible.
Energy and reserve
Usable energy is the battery capacity times the usable fraction, minus a reserve for the unexpected, such as headwind, waiting to land or turning back mid-route. The team must set the reserve as policy and never cut it to make a flight fit.
Example 2. Energy check and splitting into two trips
Assume 33.3 Wh/km with a 2 kg payload, a 500 Wh battery with 80% usable, and a 20% reserve.
import math
from itertools import combinations, permutations
SITES = {"H": (0, 0), "A": (1.0, 2.5), "B": (1.5, 0.0), "C": (-2.0, 1.0), "D": (4.0, 0.5)}
WH_PER_KM, BATTERY_WH, USABLE, RESERVE = 33.3, 500, 0.8, 0.2
available = BATTERY_WH * USABLE * (1 - RESERVE)
def best_trip(stops):
def km(order):
path = ["H", *order, "H"]
return sum(math.dist(SITES[a], SITES[b]) for a, b in zip(path, path[1:]))
order = min(permutations(stops), key=km)
return order, km(order)
order, km = best_trip("ABCD")
print(f"available {available:.0f} Wh; one trip {km:.2f} km needs {km * WH_PER_KM:.0f} Wh "
f"-> {'OK' if km * WH_PER_KM <= available else 'NOT feasible'}")
plans = []
for pair in combinations("ABCD", 2):
other = "".join(s for s in "ABCD" if s not in pair)
trips = [best_trip(pair), best_trip(other)]
if all(k * WH_PER_KM <= available for _, k in trips):
plans.append((sum(k for _, k in trips), trips))
total, trips = min(plans)
for o, k in trips:
print(f"trip H-{'-'.join(o)}-H: {k:.2f} km, {k * WH_PER_KM:.0f} Wh")
print(f"two trips total {total:.2f} km")
available 320 Wh; one trip 13.25 km needs 441 Wh -> NOT feasible
trip H-A-C-H: 8.28 km, 276 Wh
trip H-B-D-H: 8.08 km, 269 Wh
two trips total 16.36 km
A single trip to all four stops needs more energy than is available, so the work is split into two trips. The best pairing is B with D and A with C. The total distance is about 23.5% longer than one trip, but every trip keeps its full reserve.
Outdoor navigation with GNSS
Outdoors, a delivery drone finds its way with GNSS (Global Navigation Satellite System), the family of satellite systems that includes the US GPS. As GPS.gov explains, a receiver measures its distance to each satellite from the travel time of the radio signal multiplied by the speed of light, then finds the one point that fits all those distances; this is trilateration. Because the receiver’s own clock is not perfect, its clock error is one more unknown, so in practice it needs signals from at least four satellites (Groves, 2013). A mission is a list of waypoints in latitude and longitude, like the stops in Example 1.
How good is the position? The GPS Standard Positioning Service Performance Standard (2020) commits to a global average of 8 m or better horizontally, 95% of the time (13 m vertically), and 15 m at the worst site. These figures cover the satellite signals only; near tall buildings, trees or metal roofs, signals bounce (multipath) or are blocked, and the error grows. RTK (real-time kinematic) adds corrections from a base station on the ground: the PX4 guide describes it as giving centimetre-level accuracy, but it needs the base station and a working data link to the drone.
Two planning tasks follow directly:
- Geofence margin. A geofence is a virtual boundary; ArduPilot, for example, supports circular and polygon fences with a margin parameter and an action on breach, such as return or land. The route must keep far enough from a no-fly zone to cover the position error plus the distance needed to stop, for speed and braking deceleration .
- Hand-over accuracy. If the goods must land or be lowered onto a small pad, an 8 m error is far too large. The options are RTK, or a visual marker such as the AprilTags in module 3 for the final metres.
Example 3. From latitude and longitude to a safe route
Health centre A is at the assumed coordinates below. Convert them into east and north kilometres from the hospital (the kind of coordinates used in Example 1), then check a route that passes 30 m from a no-fly zone at 15 m/s with an assumed braking deceleration of 3 m/s², and a 2 m radius landing pad.
import math
EARTH_R = 6_371_000 # m, mean radius
HOSPITAL, CENTRE_A = (14.0000, 100.6000), (14.0225, 100.6093) # lat, lon in degrees
def local_km(lat, lon, ref=HOSPITAL):
east = math.radians(lon - ref[1]) * EARTH_R * math.cos(math.radians(ref[0])) / 1000
north = math.radians(lat - ref[0]) * EARTH_R / 1000
return east, north
def haversine_km(a, b):
p1, p2 = math.radians(a[0]), math.radians(b[0])
dp, dl = p2 - p1, math.radians(b[1] - a[1])
h = math.sin(dp / 2) ** 2 + math.cos(p1) * math.cos(p2) * math.sin(dl / 2) ** 2
return 2 * EARTH_R * math.asin(math.sqrt(h)) / 1000
east, north = local_km(*CENTRE_A)
print(f"A: east {east:.2f} km, north {north:.2f} km, bearing {math.degrees(math.atan2(east, north)):.0f} deg, "
f"flat {math.hypot(east, north):.3f} km, haversine {haversine_km(HOSPITAL, CENTRE_A):.3f} km")
SPEED, DECEL, GAP_TO_ZONE, PAD_RADIUS = 15.0, 3.0, 30.0, 2.0 # m/s, m/s^2, m, m
stop_m = SPEED ** 2 / (2 * DECEL)
for name, err95 in (("standard GNSS", 8.0), ("RTK", 0.05)):
margin = err95 + stop_m
print(f"{name:<13}: fence margin {margin:.1f} m -> route {'OK' if margin <= GAP_TO_ZONE else 'too close'}; "
f"landing pad {'OK' if err95 <= PAD_RADIUS else 'needs RTK or a visual marker'}")
A: east 1.00 km, north 2.50 km, bearing 22 deg, flat 2.696 km, haversine 2.696 km
standard GNSS: fence margin 45.5 m -> route too close; landing pad needs RTK or a visual marker
RTK : fence margin 37.5 m -> route too close; landing pad OK
Over 2.7 km the flat-Earth conversion agrees with the great-circle (haversine) distance to the metre, so the kilometre coordinates of Example 1 are good enough for routes of this size. The fence check shows that RTK alone does not solve the problem: stopping from 15 m/s takes 37.5 m, more than the 30 m gap. The planner must move the route or slow down near the zone; at 10 m/s the stopping distance is 16.7 m, and with standard GNSS the margin becomes 24.7 m, which fits. For the landing pad, standard GNSS is not enough, so the final approach needs RTK or a visual marker.
Drones working with trucks
Murray and Chu (2015) proposed the flying sidekick TSP, in which a delivery truck drives its route and a drone flies from the truck to nearby stops and back, so the drone never has to fly far from the depot. The review by Macrina and colleagues (2020) gathers many variants, such as multiple drones, multiple trucks and battery constraints. Where health centres are beyond drone range, this idea could use an ambulance or medicine van as a mobile drone base.
Module lab
Lab: planning medical delivery routes
- Find the real coordinates of a hospital and health centres near the university (or use the assumed ones) and convert them to kilometres
- Use Example 1 to find the best route and compare it with nearest neighbour
- Use Example 2 to check the energy and plan trips with an assumed energy per kilometre
- Check routes against restricted areas and communities, set the geofence margin with Example 3, adjust the routes and recompute energy
- Out-of-class extension (in Worksheet 2, when a drone and lab time are available): measure the lab drone’s real energy per kilometre, speed and braking from test flights, then redo steps 3 and 4 with the measured values
- Out-of-class extension (in Worksheet 2): simulate the flights in SITL and record the energy actually used against the plan
Common mistakes
Watch out
- Using straight lines on the map without considering restricted areas and obstacles
- Trusting a heuristic without checking its quality
- Cutting the energy reserve to make the plan fit
- Using a single energy-per-kilometre value when wind and payload vary
- Forgetting take-off, landing and waiting time at stops
- Setting a geofence margin from GNSS error alone, forgetting the distance the drone needs to stop, or expecting standard GNSS to hit a small landing pad
Summary
- Ordering delivery stops is a TSP; the number of orders grows factorially
- Nearest neighbour is fast but can be much longer than the best answer
- Energy available = capacity × usable fraction × (1 − reserve); if it is not enough, split trips
- Drones working with trucks extend service range, as in Murray and Chu’s research
- Outdoors, GNSS gives about 8 m (95%) under the GPS standard, RTK centimetres; route margins must cover position error plus stopping distance
Check your understanding
- How many orders are possible for five stops (counting both directions)?
- A 600 Wh battery with 80% usable and a 25% reserve leaves how much usable energy?
- A drone flies at 12 m/s, brakes at 3 m/s² and uses standard GNSS (8 m, 95%). What is the smallest margin to keep from a no-fly zone?
- Why can the nearest-neighbour method produce long routes?
- What is the flying sidekick TSP?
Answers
- Wh
- m
- It chooses one step at a time without seeing the whole picture, and may leave distant stops to the end, forcing a long flight back
- A delivery truck acts as a moving base, and a drone flies from the truck to nearby stops and back
Key formulas
| Route length | |
| Energy available |
Key references
- Murray, C. C., & Chu, A. G. (2015). The flying sidekick traveling salesman problem: Optimization of drone-assisted parcel delivery. Transportation Research Part C: Emerging Technologies, 54, 86–109. link
- Macrina, G., Di Puglia Pugliese, L., Guerriero, F., & Laporte, G. (2020). Drone-aided routing: A literature review. Transportation Research Part C: Emerging Technologies, 120, 102762. link
- Otto, A., Agatz, N., Campbell, J., Golden, B., & Pesch, E. (2018). Optimization approaches for civil applications of unmanned aerial vehicles (UAVs) or aerial drones: A survey. Networks, 72(4), 411–458. link
- Stolaroff, J. K., Samaras, C., O'Neill, E. R., Lubers, A., Mitchell, A. S., & Ceperley, D. (2018). Energy use and life cycle greenhouse gas emissions of drones for commercial package delivery. Nature Communications, 9, 409. link
- National Coordination Office for Space-Based Positioning, Navigation, and Timing. Trilateration. GPS.gov. link
- Groves, P. D. (2013). Principles of GNSS, inertial, and multisensor integrated navigation systems (2nd ed.). Artech House. link
- U.S. Department of Defense. (2020). Global Positioning System standard positioning service performance standard (5th ed.). link
- PX4 Autopilot. RTK GNSS (GPS). PX4 user guide (main). link
- ArduPilot Dev Team. Geofencing (fences). ArduPilot Copter documentation. link
Further reading
Study the assigned knowledge units in advance, review media and take the module quiz
In class / field
Intensive lab and field practice recorded in a lab notebook
Learning evidence: Lab notebook signed by the instructor