Probabilistic roadmaps: sample once, answer many queries
概率路线图
How a probabilistic roadmap (PRM) samples free configurations, links nearby ones with a local planner, and then answers start–goal queries by graph search; why it suits many queries in a fixed world, what probabilistic completeness means, why narrow passages are hard, and which connection rule (PRM*) makes it asymptotically optimal, shown on a synthetic map with one narrow gap.
probabilistic-roadmapsSample once, answer many queries
A probabilistic roadmap (PRM) plans robot motions in two stages. First it builds a roadmap, a graph whose nodes are random collision-free robot positions and whose edges are short moves checked to be collision-free. Then, to answer a query, it connects the start and the goal to the roadmap and searches the graph for a route. Abstract
Think of a robot arm in a fixed welding station that must move between many pre-programmed positions every shift. Building the roadmap is slow, but it is done once. After that, planning each new start-to-goal path takes only a little work. Kavraki and colleagues use point-to-point welding in car assembly as an example. Example tasks
In our synthetic map below, building one roadmap took 2945 edge collision checks. Answering a query then took 20. A collision check is one call to a program that answers “does this position, or this short move, hit an obstacle?”
Why random positions? An arm with six or seven joints has a six- or seven-dimensional configuration space, the space of all its joint settings. Earlier exact roadmap methods either work only in low dimensions or are too complex to be practical. Kavraki and colleagues built their roadmap from random samples instead, aimed at robots with many joints. Given enough time, such a roadmap eventually captures how the free space is connected, though they could not say how long is enough. Earlier roadmaps and connectivity, pp. 6–7
The standard reference is a 1996 paper by Kavraki, Švestka, Latombe and Overmars. It merged earlier work by two research teams, so PRM has no single inventor. A PRM finds a path with probability approaching one as the roadmap grows, if a path exists. It struggles with narrow passages and with environments that change. For a single query in a new environment, the tree-based rapidly-exploring random trees is the usual companion. History of the method Multiple-query planning
Two phases, the original algorithm, and what is guaranteed
This section defines the roadmap, walks through the 1996 algorithm and its later variants, and then explains completeness, narrow passages and the optimal version PRM*. Page numbers for Kavraki et al. are pages of the 40-page manuscript we read, not the journal’s pages 566–580.
The roadmap and the two phases
A configuration is a full description of the robot’s pose, such as the angle of every joint; see robotics overview. The free configuration space is the set of configurations where the robot touches no obstacle. A local planner is a simple, fast routine that tries to join two configurations by a short path, such as a straight line in configuration space. It reports whether that path is collision-free.
LaValle writes the roadmap as an ordinary graph. Basic method
In words: the nodes are free configurations, and two nodes and are joined by an edge when the local planner found a collision-free path between them.
Kavraki et al. call the two stages the learning phase and the query phase. Abstract, p. 1 In the learning phase the roadmap is built and stored. In the query phase the start and goal are joined to two roadmap nodes and the graph is searched. The motion is then rebuilt by recomputing the local paths along the route. Section 3, pp. 8 and 16–17 The search is an ordinary shortest-path search such as uniform-cost search (Dijkstra’s algorithm) or A*.
The two phases need not be strictly separate. If queries fail often, learning can resume and extend the roadmap instead of starting again. Interleaving, pp. 2 and 17 LaValle presents PRM as the main example of multiple-query planning. It assumes that the obstacles stay the same between queries. Multiple-query planning, pp. 237–238
The construction step in the 1996 paper
Kavraki et al. build the roadmap in a construction step followed by an expansion step. The construction step repeats the following. Section 3.1.1, pp. 9–10
- Draw a random configuration by sampling each joint uniformly over its range. If it collides, discard it. Random configurations, pp. 10–11
- Add it as a node .
- Take the existing nodes within a distance threshold as candidate neighbours, nearest first.
- Skip any candidate already in the same connected component as . Otherwise call the local planner, and add an edge if it succeeds.
A connected component is a group of nodes joined to each other by some chain of edges. Because step 4 skips nodes that are already connected, no cycle can form, so the original roadmap is a forest, a set of trees. The authors explain the choice: an edge that closes a cycle never makes a failing query succeed. They also note the cost, query paths that can be needlessly long, and suggest path smoothing as the remedy. Forest, pp. 9–10
The candidate set is capped at a number of neighbours, typically about 30. In the worst case, the cost of each iteration then no longer grows with the size of the roadmap, so local-planner calls grow linearly with the number of nodes. maxneighbors, p. 13
The local planner involves a trade-off. A powerful but slow planner needs fewer nodes; a weak but fast one needs more. Their experiments favoured a very fast deterministic planner, which also means local paths can be recomputed at query time instead of stored. Local planner, pp. 8 and 11–12 Their general planner joins two configurations by a straight segment in configuration space. It checks points along it so closely that no point of the robot moves more than a small constant between checks. Straight-line planner, p. 12 Their distance between two configurations is the largest distance any point of the robot moves, a cheap guess at how likely the local planner is to fail. Distance function, p. 13
The expansion step and the query phase
The expansion step adds nodes where the roadmap is weak. Each node gets a weight that is higher in difficult regions; they used the node’s local-planner failure ratio. A node is picked with probability equal to its normalised weight. A short random-bounce walk from it, moving in random directions and bouncing off obstacles, produces a new node, which is then connected to other components. Small leftover components are discarded at the end. Section 3.1.2, pp. 13–16 LaValle writes the failure statistic as , the number of failed connection attempts over the number of attempts plus one. Failure ratio, p. 243 Kavraki et al. report that splitting learning time about 2 to 1 between construction and expansion worked well over a wide range of problems. Time split, p. 16
In the query phase, roadmap nodes are tried in order of increasing distance from the start until the local planner succeeds. Random-bounce walks are the fallback, and the same is done for the goal. The query fails if start and goal cannot be joined to the same component. With few components this is detected quickly. Section 3.2, pp. 16–17
Later variants: keeping cycles
Many later implementations drop the same-component test, so the roadmap keeps cycles and offers alternative routes. LaValle notes that the test itself takes near-constant time with a union-find structure, which keeps track of components. Implementations that want alternative routes skip it and cap the number of edges per node instead. Union-find and cycles, pp. 239–240 Karaman and Frazzoli call the version that also connects within components the simplified PRM (sPRM). Algorithms 1–2, pp. 11–12
LaValle lists common choices of neighbours. One is the nearest nodes, typically . Another is up to per component. A third is all nodes within a radius , with a cap such as . The last is all nodes, which gives a visibility roadmap. Trying nearer candidates first is wise, because short connections are cheaper to check and more likely to be free. Neighbourhoods, p. 240
LaValle also argues that the “probabilistic” part is not essential. Deterministic, evenly spread samples work too, so he calls the family sampling-based roadmaps. Sampling-based roadmaps, p. 237 and p. 246
What is guaranteed
A complete planner always finds a path if one exists and reports failure otherwise. PRMs are not complete. With random samples they are probabilistically complete: if a path exists, the probability of finding it tends to one as the number of samples grows. Completeness notions, pp. 185–186 Kavraki et al. put it plainly: the roadmap will eventually capture the free space’s connectivity, but they do not know how long that takes. Connectivity, p. 7
For the sPRM, Karaman and Frazzoli state a rate (their Theorem 15). It holds for robustly feasible problems, those with a solution path that keeps some positive clearance from obstacles. They attribute the result to Kavraki et al. (1998), a later paper that we did not read. Theorem 15, p. 17
In words: beyond some sample count , the chance of failure is below , so it falls at least exponentially in the number of samples . The rate depends on the problem.
If a problem is not robustly feasible, for example if every path must touch an obstacle, then the success probability of any sampling-based algorithm stays zero. The only exception is a sampling distribution tailored to that problem. Robust feasibility, p. 17
LaValle describes a related measure called ε-goodness. ε-goodness, eq. (5.41)
In words: for each free configuration , take the share of free space that the local planner can reach from it directly, its visibility set , measured by volume . The worst share over all is . Bounds on the success probability can be written in terms of and the number of nodes. LaValle calls them very conservative, and cannot be computed efficiently. ε-goodness bounds, pp. 241–242
A failed query proves nothing about whether a path exists. With samples of known spacing one can only say that no solution exists at the planner’s resolution. Failed queries, p. 240
Narrow passages
Narrow channels in free space, created by tight clearances, are hard for sampling-based roadmaps. Even one thin corridor is hard, and higher dimensions bring harder versions. Narrow channels, pp. 240–241 A simple calculation shows why. It is our own illustration, not a result from the sources.
In words: a uniform free sample lands in a small region with probability , the share of free space that covers. The chance that none of independent samples lands there is . In our map the gap covers 0.4 of 72.4 square units of free space, so .
Several sampling tricks put more nodes near obstacles, where narrow passages are. LaValle summarises them. Sampling heuristics, pp. 243–245
- Boundary sampling uses binary search from colliding samples toward free space.
- Gaussian sampling draws a pair of nearby points and keeps the free one only when exactly one of the two is free.
- The bridge test keeps the midpoint of a short segment whose two ends both collide.
- Medial-axis sampling places nodes along the middle of free space.
LaValle also describes visibility roadmaps, which keep only “guards” that see no other guard and “connectors” that see guards from two components. They give much smaller roadmaps, but the result depends on sample order. Visibility roadmap, pp. 242–243
Optimal roadmaps: PRM*
Probabilistic completeness says nothing about path length. A planner is asymptotically optimal if, as the number of samples goes to infinity, the cost of its best path converges to the optimal cost with probability one. Karaman and Frazzoli prove four things. The standard PRM is not asymptotically optimal. The sPRM is asymptotically optimal but expensive. Connecting each node to its nearest neighbours is not even probabilistically complete for . And for any fixed it is not asymptotically optimal. Contributions, p. 4
Their fix, PRM*, connects every pair of nodes within a radius that shrinks as the roadmap grows, or to a number of nearest neighbours that grows slowly. The thresholds in Karaman and Frazzoli’s arXiv version are as follows. PRM*, pp. 13–14; Theorems 34–35, p. 28
In words: is the number of nodes, the dimension, the free volume and the volume of a unit ball (). The radius shrinks as the roadmap grows, but slowly enough that each node keeps about neighbours; the -nearest version asks for about neighbours directly.
They add that satisfies the condition for every problem. Theorem 35, p. 28 They also note that uniform random points are spaced on the order of apart, the same rate at which the radius shrinks. Dispersion, p. 14 PRM* costs at most a constant factor more than PRM-type planners that are only probabilistically complete. Abstract, p. 1 The RRT* radius in the same paper uses a different constant, so the two should not be mixed. Like their RRT* results, these assume no differential constraints, meaning straight-line connections for a robot without dynamics. Problem formulation, pp. 4–6
A wall with one narrow gap, by simulation
This section builds roadmaps on a small synthetic map, compares their paths with the exact optimum, and tests narrow passages, sampling tricks and a changed world. The program is original, uses only numpy, and has fixed seeds. All numbers are properties of this toy map and these seeds.
The robot is a point in the square . A wall at has one gap at . Three more blocks are –, – and –. Edges are checked exactly against the rectangles (Liang–Barsky clipping). Exact shortest paths come from a visibility graph of rectangle corners searched with Dijkstra’s algorithm.
Each new node tries its 10 nearest earlier nodes as candidates. The “forest” version skips candidates in the same component, as Kavraki et al. did. The “graph” version tries all 10 and keeps cycles. Queries join the start and the goal to their 10 nearest roadmap nodes. That differs from the 1996 query phase, which stops at the first success.
import heapq
import math
import numpy as np
# Synthetic 2-D world: point robot in the square [0, 10] x [0, 10].
# Obstacles are closed axis-aligned rectangles (xmin, ymin, xmax, ymax).
# A wall at x in [4.5, 5.5] has one narrow gap at y in [4.8, 5.2].
BASE = np.array([
[4.5, 0.0, 5.5, 4.8], # lower part of the wall
[4.5, 5.2, 5.5, 10.0], # upper part of the wall
[1.5, 2.0, 3.0, 8.0], # block on the left
[7.0, 1.0, 8.5, 4.0], # block on the right, low
[7.0, 6.0, 8.5, 9.0], # block on the right, high
])
LO, HI = 0.0, 10.0
QUERIES = [((1.0, 1.0), (9.0, 9.0)), ((0.5, 9.5), (9.5, 0.5)),
((1.0, 5.0), (3.5, 5.0)), ((6.0, 5.0), (9.5, 5.0))]
def points_free(P, rects):
P = np.atleast_2d(P)
x, y = P[:, :1], P[:, 1:]
inside = (rects[:, 0] <= x) & (x <= rects[:, 2]) & (rects[:, 1] <= y) & (y <= rects[:, 3])
return ~inside.any(axis=1)
def segments_free(a, b, rects):
# Exact Liang-Barsky test of segments a[i] -> b[i] against closed rectangles.
a = np.atleast_2d(a)[:, None, :]
d = np.atleast_2d(b)[:, None, :] - a
t0 = np.zeros((a.shape[0], rects.shape[0]))
t1 = np.ones_like(t0)
hit = np.ones(t0.shape, dtype=bool)
for k in range(2):
dk, ak = d[..., k], a[..., k]
lo, hi = rects[None, :, k], rects[None, :, k + 2]
par = np.abs(dk) < 1e-15
hit &= ~(par & ((ak < lo) | (ak > hi)))
with np.errstate(divide="ignore", invalid="ignore"):
ta, tb = (lo - ak) / dk, (hi - ak) / dk
t0 = np.maximum(t0, np.where(par, -np.inf, np.minimum(ta, tb)))
t1 = np.minimum(t1, np.where(par, np.inf, np.maximum(ta, tb)))
hit &= t0 <= t1
return ~hit.any(axis=1)
class DSU:
def __init__(self, n):
self.p = list(range(n))
def find(self, i):
while self.p[i] != i:
self.p[i] = self.p[self.p[i]]
i = self.p[i]
return i
def union(self, i, j):
self.p[self.find(i)] = self.find(j)
def dijkstra(adj, src, n):
dist = [math.inf] * n
dist[src] = 0.0
pq = [(0.0, src)]
while pq:
du, u = heapq.heappop(pq)
if du > dist[u]:
continue
for v, w in adj[u]:
if du + w < dist[v]:
dist[v] = du + w
heapq.heappush(pq, (dist[v], v))
return dist
def visibility_optimum(s, g, rects):
# Exact shortest path for a point robot: visibility graph over start, goal
# and rectangle corners pushed 1e-6 outward, then Dijkstra.
e = 1e-6
C = [s, g]
for x0, y0, x1, y1 in rects:
C += [(x0 - e, y0 - e), (x1 + e, y0 - e), (x0 - e, y1 + e), (x1 + e, y1 + e)]
C = np.array(C, dtype=float)
keep = points_free(C, rects) & (C >= LO).all(1) & (C <= HI).all(1)
keep[:2] = True
C = C[keep]
m = len(C)
I, J = np.triu_indices(m, 1)
ok = segments_free(C[I], C[J], rects)
adj = [[] for _ in range(m)]
for i, j, f in zip(I, J, ok):
if f:
w = float(np.hypot(*(C[i] - C[j])))
adj[i].append((j, w))
adj[j].append((i, w))
return dijkstra(adj, 0, m)[1]
def sample_uniform(rng, n, rects):
pts, draws = [], 0
while len(pts) < n:
q = rng.uniform(LO, HI, size=2)
draws += 1
if points_free(q, rects)[0]:
pts.append(q)
return np.array(pts), draws
def sample_gaussian(rng, n, rects, sigma=0.3):
# Gaussian sampling: draw q1 uniformly and q2 near q1; keep the free one
# only when exactly one of the pair is free (biases nodes to obstacle edges).
pts, draws = [], 0
while len(pts) < n:
q1 = rng.uniform(LO, HI, size=2)
q2 = q1 + rng.normal(0.0, sigma, size=2)
draws += 2
inb = LO <= q2[0] <= HI and LO <= q2[1] <= HI
f1 = points_free(q1, rects)[0]
f2 = inb and points_free(q2, rects)[0]
if f1 != f2:
pts.append(q1 if f1 else q2)
return np.array(pts), draws
def build_prm(V, rects, k=10, forest=True):
# Learning (preprocessing) phase. Node i tries its k nearest earlier nodes
# in order of increasing distance. forest=True skips pairs already in the
# same connected component (Kavraki et al. 1996), so no cycles form;
# forest=False tries every candidate pair, so the graph keeps cycles.
n = len(V)
dsu = DSU(n)
adj = [[] for _ in range(n)]
D = np.hypot(V[:, None, 0] - V[None, :, 0], V[:, None, 1] - V[None, :, 1])
D[np.triu_indices(n)] = np.inf
cand = np.argsort(D, axis=1, kind="stable")[:, :k]
checks = edges = 0
if forest:
for i in range(1, n):
for j in cand[i]:
j = int(j)
if not np.isfinite(D[i, j]) or dsu.find(i) == dsu.find(j):
continue
checks += 1
if segments_free(V[i], V[j], rects)[0]:
adj[i].append((j, float(D[i, j])))
adj[j].append((i, float(D[i, j])))
dsu.union(i, j)
edges += 1
return adj, dsu, checks, edges
I = np.repeat(np.arange(n), k)
J = cand.reshape(-1)
valid = np.isfinite(D[I, J])
I, J = I[valid], J[valid]
checks = len(I)
ok = segments_free(V[I], V[J], rects)
for i, j in zip(I[ok], J[ok]):
i, j = int(i), int(j)
adj[i].append((j, float(D[i, j])))
adj[j].append((i, float(D[i, j])))
dsu.union(i, j)
edges += 1
return adj, dsu, checks, edges
def link(V, q, rects, k=10):
# Connect a query configuration to up to k nearest roadmap nodes.
d = np.hypot(V[:, 0] - q[0], V[:, 1] - q[1])
J = np.argsort(d, kind="stable")[:k]
ok = segments_free(np.repeat(np.array([q], dtype=float), len(J), 0), V[J], rects)
return [(int(j), float(d[j])) for j in J[ok]], len(J)
def query(V, adj, dsu, s, g, rects, k=10, need_length=True):
# Query phase: link s and g to the roadmap, then search the graph once,
# treating s and g as temporary extra nodes n and n + 1.
n = len(V)
ls, cs = link(V, s, rects, k)
lg, cg = link(V, g, rects, k)
checks = cs + cg
if not need_length:
roots = {dsu.find(j) for j, _ in ls}
return (0.0 if any(dsu.find(j) in roots for j, _ in lg) else math.inf), checks
ext = adj + [[(j, w) for j, w in ls], []]
for j, w in lg:
ext[j] = ext[j] + [(n + 1, w)]
return dijkstra(ext, n, n + 2)[n + 1], checks
free_area = 100.0 - float(((BASE[:, 2] - BASE[:, 0]) * (BASE[:, 3] - BASE[:, 1])).sum())
gap_area = 1.0 * 0.4
print("World: [0,10]^2, wall x in [4.5,5.5] with one gap y in [4.8,5.2], 3 more blocks")
print(f"free area = {free_area:.2f}; gap area = {gap_area:.2f}; "
f"P(uniform free sample lands in gap) = {gap_area / free_area:.5f}")
print()
rng = np.random.default_rng(0)
V, draws = sample_uniform(rng, 300, BASE)
print("[1] One roadmap: N=300 uniform free samples, k=10 nearest neighbours")
print(f"draws needed for 300 free samples = {draws}")
results = {}
for forest in (True, False):
adj, dsu, checks, edges = build_prm(V, BASE, forest=forest)
comps = len({dsu.find(i) for i in range(len(V))})
results[forest] = (adj, dsu)
tag = "forest (skip same component)" if forest else "graph (try all k, cycles allowed)"
print(f"{tag}: edges={edges}, components={comps}, edge collision checks={checks}")
print()
print("[2] Queries on the cycle-allowing roadmap vs exact optimum")
adj, dsu = results[False]
adj_f, dsu_f = results[True]
qchecks = []
for s, g in QUERIES:
opt = visibility_optimum(s, g, BASE)
L, c = query(V, adj, dsu, s, g, BASE)
Lf, _ = query(V, adj_f, dsu_f, s, g, BASE)
qchecks.append(c)
print(f"{s}->{g}: optimum={opt:.4f}, PRM graph={L:.4f} ({L / opt:.3f}x), "
f"PRM forest={Lf:.4f} ({Lf / opt:.3f}x), query checks={c}")
print(f"build checks / mean query checks = {build_prm(V, BASE, forest=False)[2]} / {np.mean(qchecks):.0f}")
print()
print("[3] Narrow gap: query (1,1)->(9,9) over 40 seeds, uniform sampling, k=10, graph")
for N in (100, 200, 400, 800):
ok, comps = 0, []
for seed in range(40):
r = np.random.default_rng(1000 + seed)
Vs, _ = sample_uniform(r, N, BASE)
a, ds, _, _ = build_prm(Vs, BASE, forest=False)
L, _ = query(Vs, a, ds, (1.0, 1.0), (9.0, 9.0), BASE, need_length=False)
ok += math.isfinite(L)
comps.append(len({ds.find(i) for i in range(N)}))
expected_in_gap = N * gap_area / free_area
print(f"N={N:3d}: success {ok:2d}/40, mean components={np.mean(comps):.1f}, "
f"expected samples in gap={expected_in_gap:.2f}")
print()
print("[4] Same seeds and budget as [3] at N=200 kept nodes: uniform vs Gaussian sampling (sigma=0.3)")
for name, fn in (("uniform", sample_uniform), ("gaussian", sample_gaussian)):
ok, dr, in_gap = 0, 0, 0
for seed in range(40):
r = np.random.default_rng(1000 + seed)
Vs, dd = fn(r, 200, BASE)
dr += dd
in_gap += int(((Vs[:, 0] >= 4.5) & (Vs[:, 0] <= 5.5) & (Vs[:, 1] > 4.8) & (Vs[:, 1] < 5.2)).sum())
a, ds, _, _ = build_prm(Vs, BASE, forest=False)
L, _ = query(Vs, a, ds, (1.0, 1.0), (9.0, 9.0), BASE, need_length=False)
ok += math.isfinite(L)
print(f"{name:8s}: success {ok:2d}/40, mean nodes inside gap={in_gap / 40:.2f}, "
f"mean collision-checked draws per roadmap={dr / 40:.0f}")
print()
print("[5] PRM* connection rules (Karaman & Frazzoli 2011), d=2")
gamma_star = 2 * (1 + 1 / 2) ** 0.5 * (free_area / math.pi) ** 0.5
k_star = math.e * (1 + 1 / 2)
print(f"gamma*_PRM = {gamma_star:.4f}; k*_PRM = e(1+1/d) = {k_star:.4f}")
for n in (100, 200, 400, 800):
print(f"n={n:3d}: r_min(n) = gamma*(log n/n)^(1/2) = {gamma_star * math.sqrt(math.log(n) / n):.4f}, "
f"k_min(n) = k* log n = {k_star * math.log(n):.2f}")
print()
print("[6] Static-world assumption: add a box (2.5,0.5)-(4,1.5) after building [1]")
new_rects = np.vstack([BASE, [2.5, 0.5, 4.0, 1.5]])
E = [(i, j) for i in range(len(V)) for j, _ in adj[i] if i < j]
Ea = np.array([V[i] for i, _ in E])
Eb = np.array([V[j] for _, j in E])
bad = ~segments_free(Ea, Eb, new_rects)
dead_nodes = int((~points_free(V, new_rects)).sum())
print(f"edges now in collision = {int(bad.sum())} of {len(E)}; nodes now in collision = {dead_nodes}")
The program prints:
World: [0,10]^2, wall x in [4.5,5.5] with one gap y in [4.8,5.2], 3 more blocks
free area = 72.40; gap area = 0.40; P(uniform free sample lands in gap) = 0.00552
[1] One roadmap: N=300 uniform free samples, k=10 nearest neighbours
draws needed for 300 free samples = 417
forest (skip same component): edges=299, components=1, edge collision checks=521
graph (try all k, cycles allowed): edges=2512, components=1, edge collision checks=2945
[2] Queries on the cycle-allowing roadmap vs exact optimum
(1.0, 1.0)->(9.0, 9.0): optimum=12.5749, PRM graph=13.6986 (1.089x), PRM forest=26.6858 (2.122x), query checks=20
(0.5, 9.5)->(9.5, 0.5): optimum=13.8038, PRM graph=14.5737 (1.056x), PRM forest=35.4101 (2.565x), query checks=20
(1.0, 5.0)->(3.5, 5.0): optimum=7.5828, PRM graph=8.3420 (1.100x), PRM forest=10.8356 (1.429x), query checks=20
(6.0, 5.0)->(9.5, 5.0): optimum=3.5000, PRM graph=3.6939 (1.055x), PRM forest=5.7658 (1.647x), query checks=20
build checks / mean query checks = 2945 / 20
[3] Narrow gap: query (1,1)->(9,9) over 40 seeds, uniform sampling, k=10, graph
N=100: success 23/40, mean components=1.4, expected samples in gap=0.55
N=200: success 29/40, mean components=1.3, expected samples in gap=1.10
N=400: success 36/40, mean components=1.1, expected samples in gap=2.21
N=800: success 40/40, mean components=1.0, expected samples in gap=4.42
[4] Same seeds and budget as [3] at N=200 kept nodes: uniform vs Gaussian sampling (sigma=0.3)
uniform : success 29/40, mean nodes inside gap=1.00, mean collision-checked draws per roadmap=276
gaussian: success 37/40, mean nodes inside gap=4.30, mean collision-checked draws per roadmap=2339
[5] PRM* connection rules (Karaman & Frazzoli 2011), d=2
gamma*_PRM = 11.7590; k*_PRM = e(1+1/d) = 4.0774
n=100: r_min(n) = gamma*(log n/n)^(1/2) = 2.5234, k_min(n) = k* log n = 18.78
n=200: r_min(n) = gamma*(log n/n)^(1/2) = 1.9139, k_min(n) = k* log n = 21.60
n=400: r_min(n) = gamma*(log n/n)^(1/2) = 1.4392, k_min(n) = k* log n = 24.43
n=800: r_min(n) = gamma*(log n/n)^(1/2) = 1.0749, k_min(n) = k* log n = 27.26
[6] Static-world assumption: add a box (2.5,0.5)-(4,1.5) after building [1]
edges now in collision = 65 of 2512; nodes now in collision = 2
The map. The obstacles cover , so the free area is . The gap is , so a uniform free sample lands in it with probability .
Part 1: forest versus graph. Getting 300 free samples took 417 draws, so 117 collided and were discarded. The forest has 299 edges and one component. That is a single tree, since a tree on 300 nodes has exactly 299 edges. It needed 521 edge checks. The graph version kept 2512 edges and needed 2945 checks. That count is easy to verify: node has earlier candidates, so the total is .
Part 2: query quality. The table compares path lengths with the exact optimum. Each query used 20 linking checks.
| query | optimum | graph | forest |
|---|---|---|---|
| (1,1) to (9,9) | 12.5749 | 13.6986 (1.089×) | 26.6858 (2.122×) |
| (0.5,9.5) to (9.5,0.5) | 13.8038 | 14.5737 (1.056×) | 35.4101 (2.565×) |
| (1,5) to (3.5,5) | 7.5828 | 8.3420 (1.100×) | 10.8356 (1.429×) |
| (6,5) to (9.5,5) | 3.5000 | 3.6939 (1.055×) | 5.7658 (1.647×) |
The forest is cheaper to build but its paths are 1.429 to 2.565 times optimal, because a tree offers only one route between two nodes. This is the long-path effect Kavraki et al. warned about and proposed to fix by smoothing. Keeping cycles costs more checks (2945 against 521) and gives paths within 1.055 to 1.100 times optimal. The build took 2945 checks against 20 per query, a ratio of about 147. Kavraki et al. report learning that needed 2 to 3 orders of magnitude more checks than queries in their scene. Learning versus query, p. 28
Part 3: the narrow gap. The query to must pass through the gap; we built 40 graph roadmaps per size. Success rose from 23 of 40 at to all 40 at , as the expected number of samples in the gap grew from 0.55 to 4.42. A path exists in every case; only the samples change. This is probabilistic completeness at work.
Part 4: Gaussian sampling. On the same 40 seeds at , Gaussian sampling with put 4.30 nodes in the gap on average, against 1.00 for uniform sampling, and solved 37 queries instead of 29. It needed about 8.5 times as many collision-checked draws (). It helped here, at a price, and one toy map does not show that it helps in general.
Part 5: PRM thresholds.* For this map , and . Even at the minimum is 18.78. Our runs used a fixed , below every printed threshold. It worked well enough here, but it lies outside the theorem.
Part 6: a changed world. Adding one box – after building the Part 1 graph puts 65 of its 2512 edges and 2 of its nodes in collision. They must be removed or rechecked before the next query. The roadmap is only as valid as the assumption that the world stays still.
Where roadmaps struggle
This section lists the main limits of PRMs and of our example.
Static worlds. A roadmap encodes one fixed environment. Kavraki et al. left moving or added obstacles as an open question. Conclusion, p. 34 Part 6 shows the cost of a single new box.
Building costs more than one query. Kavraki et al. found that, once built, the roadmap answered queries much faster than the Randomized Path Planner (RPP), an earlier single-query planner. If learning time is counted, as it should be when planning only once, RPP was faster on many problems. Comparison with RPP, p. 7 and p. 33 LaValle and Kuffner add that PRM does heavy precomputation and tree planners do not, so direct comparisons are not straightforward. Comparison, p. 9
Hard local connections. A PRM must join two given configurations exactly. For nonholonomic robots, such as a car that cannot slide sideways, or robots with dynamics, that can be as hard as designing a controller. Connection problem, p. 3 Kavraki et al. mention a variant for car-like robots that used a different local planner. Nonholonomic variant, p. 33
Narrow passages and no certificate. Probabilistic completeness is not completeness. A failed query does not prove that no path exists. Failed queries, p. 240 Narrow passages need many samples or tailored sampling. LaValle notes that such sampling heuristics are often problem-specific. Heuristics, p. 243
Conservative theory. The ε-goodness bounds are very conservative and cannot be computed. ε-goodness, pp. 241–242 The exponential rate of Theorem 15 is for the sPRM on robustly feasible problems, with constants that depend on the problem. Theorem 15, p. 17
Fixed is a heuristic. Common settings such as are practical defaults. Karaman and Frazzoli show that any fixed gives up asymptotic optimality. Contributions, p. 4
Old timings. The 1996 paper reports results on 1990s workstations with many-joint planar robots. Its customised version answered difficult queries in a fraction of a second, after a few dozen seconds of learning. Its general version took several minutes on the same problems. Abstract and conclusion, pp. 1 and 33 These numbers describe that hardware and those robots only.
The example is a toy. A point robot, rectangular obstacles, exact edge checks and chosen seeds. Real planners check edges at sample points and work in many more dimensions. The failure estimate is our own illustration.
Exercises
These exercises cover the two-phase design, a hand calculation, counterexamples about guarantees, method choice and PRM*.
-
Why does a PRM split its work into a learning phase and a query phase, and when does that pay off?
Answer: Building the roadmap is the expensive part, with most of the collision checks. A query only links two configurations and runs a graph search. In Parts 1–2 the graph roadmap cost 2945 edge checks and each query 20. Kavraki et al. report learning checks 2 to 3 orders of magnitude above query checks. This pays off when many queries share one static environment. For a single query, counting learning time, a single-query planner can be faster: RPP in their comparison, or an rapidly-exploring random trees today.
-
(a) Check the optimum 7.5828 for the query to around the block –. (b) The gap covers of the free area. Compute the probability that none of , 200 or 400 uniform free samples lands in the gap, and compare with the failure rates in Part 3.
Answer: (a) The straight line is blocked. Going over the top: is ; is 1.5; is 3.0414. The total is 7.5828. Going under the bottom corners at gives the same length by symmetry. (b) , so , and . The observed failure rates are , and . They are close but not equal. A node inside the gap is not strictly necessary, because two nodes lined up on either side can see each other through it. Nor is it sufficient, because it must also connect to both sides among its 10 nearest neighbours.
-
“Our PRM query failed after 10 000 samples, so the start and goal are in different parts of free space.” Give two reasons this may be false, and one situation in which no sampling-based planner will ever succeed.
Answer: (i) A PRM is probabilistically complete, not complete. Failure may only mean too few samples in a narrow passage. In Part 3, 17 of 40 roadmaps with failed although a path always exists. (ii) The connection rule matters. A small fixed can leave the graph disconnected, and Karaman and Frazzoli show that with the method is not even probabilistically complete. (iii) Suppose every solution must touch an obstacle, so the problem is not robustly feasible. Then the success probability of any sampling-based planner stays zero, unless the sampling is tailored to that problem.
-
Which planner would you pick? (a) A robot arm in a fixed welding cell that moves between hundreds of taught poses each shift. (b) A car-like robot with dynamics entering a new parking garage once. (c) The welding cell after a fixture is added between two shifts. (d) A 2-D map with one 0.4 m doorway that uniform sampling keeps missing.
Answer: (a) A PRM: many queries in a static cell, the case the method was designed for. (b) A single-query tree planner such as rapidly-exploring random trees. It needs no precomputation and never has to join two given states exactly, which is hard for nonholonomic robots. (c) Reuse the roadmap, but remove or recheck the edges and nodes that now collide. In Part 6 that was 65 of 2512 edges and 2 nodes. Kavraki et al. note that a roadmap can be extended rather than rebuilt, though they left changing scenes as an open question. (d) Bias the sampling toward narrow regions, for example with Gaussian or bridge-test sampling. In Part 4 Gaussian sampling raised success from 29 to 37 of 40 at , but needed about 8.5 times as many collision-checked draws (2339 against 276).
-
For the example map (, free area 72.4), compute the PRM* radius constant and the minimum at . Does our meet it?
Answer: . Then , and , so at least 28 neighbours. Our is far below, so the asymptotic-optimality theorem does not cover our runs, even though on this map the four test queries came within 1.055 to 1.100 times the optimum.
History and further reading
This section summarises where the method came from, as read from the sources, and suggests further reading.
The standard reference is “Probabilistic roadmaps for path planning in high-dimensional configuration spaces” by Lydia Kavraki, Petr Švestka, Jean-Claude Latombe and Mark Overmars. It appeared in IEEE Transactions on Robotics and Automation, volume 12, issue 4, pages 566–580, in 1996. We read a 40-page manuscript version hosted by the Kavraki lab, which carries that citation on its first page; all page numbers in this article refer to that manuscript. First page
The paper says it merges the work of two teams, one at Utrecht and one at Stanford. One team had a single-shot random planner that it later extended to a learning approach. The other had independently introduced a preprocessing scheme that built a probabilistic roadmap for robots with many degrees of freedom. The paper also notes that another similar planner was developed independently. Origins, pp. 7–8 So the 1996 paper is best seen as the combined, standard statement of the idea, not the work of one inventor.
The method targeted robots with many degrees of freedom, roughly five or more, and holonomic robots in general. Scope, pp. 2–3 Earlier roadmap methods, such as visibility graphs, Voronoi diagrams and silhouettes, capture free-space connectivity exactly in one pass. The first two are limited to low-dimensional configuration spaces, and the silhouette method is too complex to be practical. Earlier roadmaps, p. 6
LaValle and Kuffner later observed that starting a tree at every sample and merging trees as they connect reproduces the PRM. Limiting case, p. 9 LaValle’s Planning Algorithms, Chapter 5, treats PRMs as sampling-based roadmaps and is a good next read. Section 5.6 Karaman and Frazzoli’s 2011 paper, read here in its arXiv version, analyses which connection rules give asymptotic optimality. Sections 3.2–3.3
To find candidate neighbours quickly, see approximate nearest-neighbour search and k-nearest neighbours. For the joint spaces in which arms are planned, see robot kinematics and inverse kinematics. Occupancy maps are one source of the collision map, and trajectory optimisation can smooth a roadmap path. Monte Carlo integration uses the same reasoning about how often uniform samples hit a small region. Multi-query arm motions in grasping and manipulation are a typical use.
Make a prediction, then check
In the example map a wall has a single gap covering 0.55% of the free area. With uniform sampling and 10 nearest neighbours per node, roadmaps with N = 100 answered the through-the-wall query for only 23 of 40 seeds, and all 40 at N = 800. Which reading is correct?
Learning objectives
- Describe the two phases of a probabilistic roadmap: sample free configurations, connect nearby nodes with a local planner and track connected components; at query time link start and goal to the roadmap and run a graph search. Explain why it suits many queries in a static environment.
- Explain how narrow passages, the connection rule and environment changes limit a roadmap; distinguish probabilistic completeness from asymptotic optimality, and explain why PRM*'s connection radius or k must change with the number of samples.
Prerequisites & connections
Explore related knowledge →References
- Probabilistic roadmaps for path planning in high-dimensional configuration spaces — scoped
Lydia E. Kavraki; Petr Švestka; Jean-Claude Latombe; Mark H. Overmars · 1996 - Planning Algorithms, Chapter 5: Sampling-Based Motion Planning — scoped
Steven M. LaValle · 2006 - Sampling-based algorithms for optimal motion planning (arXiv v1) — scoped
Sertac Karaman; Emilio Frazzoli · 2011 - Rapidly-exploring random trees: Progress and prospects — scoped
Steven M. LaValle; James J. Kuffner · 2001
Version1 · Editorial status: Recorded technical checks completed
View technical check record (AI)
Claude · 2026-12-03 · Independent AI check (Claude subagent, not the author; not a human or expert review). Research was done by a separate research subagent (facts.md) and the prose by a writer subagent. Gemini app style-only edits had been applied to the English opening (intuition) section before this check; each logged edit was compared with its old text and none changed a fact, hedge or attribution. The Chinese opening had no Gemini pass, so the checker did its own D012 readability pass on it. Ran example.py with the pinned interpreter (numpy 1.26.4): output identical to example.stdout.txt, and the python block in en.mdx and zh.mdx is byte-identical to example.py. Re-derived the free area 72.4, gap probability 0.00552, the 2945-check count, the 7.5828 optimum, (1-p)^N for N = 100, 200, 400, gamma*_PRM = 11.759, k(800) > 27.26 and the 8.47 ratio. Re-opened the sources myself: the Kavraki lab manuscript of Kavraki-Svestka-Latombe-Overmars (OCR of manuscript pp. 1-18, 28, 33, 34; first page carries the IEEE TRA 12(4):566-580 citation), confirming the welding example (p. 3), earlier roadmap methods (p. 6), the 'don't know how long is enough' remark (p. 7), the two-team history and the independent similar planner (pp. 7-8), the forest and smoothing remark (pp. 9-10), the maxneighbors worst-case bound (p. 13), the 2:1 time split (p. 16), resuming construction (p. 17), learning versus query checks (p. 28), timings and the RPP comparison (p. 33) and the open question on changing obstacles (p. 34); Karaman-Frazzoli arXiv:1105.1186v1 via pdftotext (section 1.3 contributions p. 4, PRM* and k-nearest PRM* pp. 13-14 including k_PRM = 2e and the dispersion remark, Theorem 15 p. 17, Theorems 34-35 p. 28, abstract p. 1); LaValle's Planning Algorithms ch. 5 via pdftotext ('probabilistic' not important, pp. 237-238; Further Reading 'sampling-based roadmap', p. 246; neighbourhood options pp. 239-240). Compared zh and en section by section, checked equation parity, citation IDs, MDX safety, links (rrt, grasping and manipulation stay inline code) and data.json catalogue IDs and quiz answer. Not checked: Kavraki manuscript pp. 19-27 and 29-32 beyond skimming, the journal pagination, Karaman-Frazzoli's Theorem 29 proof and the journal version, and the 1998 Kavraki et al. completeness paper (not read; the article says so).
- example.py run with the pinned interpreter (numpy 1.26.4) matches example.stdout.txt; the zh and en code blocks are byte-identical to example.py.
- Hand-checked the free area 72.4, gap probability 0.00552, 2945 checks, optimum 7.5828, (1-p)^N, gamma* = 11.759 and k(800) > 27.26.
- Re-read the Kavraki et al. manuscript by OCR (manuscript pages, not journal pp. 566-580): the welding example is on p. 3, earlier roadmap methods on p. 6, the two-team merger on pp. 7-8, the forest on pp. 9-10 and maxneighbors on p. 13.
- Checked Karaman-Frazzoli arXiv v1 p. 4 (section 1.3 summary of PRM non-optimality and the sPRM/k-nearest results) and the PRM* constants and theorems on pp. 13-14, 17 and 28.
- Checked LaValle's book: the 'probabilistic' part is not important and the family is called sampling-based roadmaps (pp. 237-238 and p. 246).
- zh and en compared section by section: same claims, numbers, exercises, answers and caveats; equations, citation IDs and links match, and the MDX is safe.
Source locations checked:
- Probabilistic roadmaps for path planning in high-dimensional configuration spaces — scoped · Kavraki-lab PDF kavraki-svestka1996probabilistic-roadmaps-for.pdf, 40-page double-spaced manuscript (first page: IEEE Trans. on Robotics and Automation, 12(4), 566-580, 1996). Type-3 fonts; rendered at 200 dpi and OCR'd with tesseract. Locators are manuscript pages, not journal pages. Read in full pp. 1–18: abstract; §1 (two phases, many-dof, interleaving phases, parameter choice, example tasks incl. point-to-point welding, pp. 2–4); §2 related work (potential fields/RPP, earlier roadmap methods, two-team history, pp. 4–8); §3 general method: §3.1.1 construction step pseudocode, forest, smoothing remark, random configurations, local planner trade-off, straight-line planner with eps, maxdist and maxneighbors (~30), distance function eq. (1) (pp. 8–13); §3.1.2 expansion step, weights, failure ratio, random-bounce walk, mincomponent, 2:1 time split (pp. 13–16); §3.2 query phase, several components, extending the roadmap (pp. 16–17); opening of §4 (p. 18). Also read p. 28 (learning checks 2-3 orders of magnitude above query checks; RPP comparison; 7-dof free-base robot) and pp. 32–34 (§7 conclusion, dynamic scenes open). Skimmed only the first lines of pp. 19–27 and 29–31 (planar-robot techniques, experiment tables; tables not used). The OCR garbled the failure-ratio formula on p. 15; the formula n_f/(n_t+1) is taken from LaValle §5.6.3.
- Planning Algorithms, Chapter 5: Sampling-Based Motion Planning — scoped · ch5.pdf via pdftotext (printed pages). Read pp. 185–186 (complete / resolution complete / probabilistically complete); §5.6 pp. 237–245 in full: §5.6.1 two phases, BUILD_ROADMAP Fig. 5.25, union-find and degree cap (pp. 238–240), neighbourhood options nearest K = 15 / component K / radius with K = 20 cap / visibility, increasing-distance order, query phase and what failure implies, narrow channels Fig. 5.27, ε-goodness eq. (5.41) (pp. 240–242); §5.6.2 visibility roadmap guards/connectors (pp. 242–243); §5.6.3 vertex enhancement n_f/(n_t+1), boundary sampling, Gaussian sampling, bridge test, medial axis (pp. 243–245); end of §5.5.3 (PRM as the limit of many trees, p. 237); Further Reading pp. 245–246 ('probabilistic' not critical). Not read: §5.1–5.2, §5.3.1–5.3.3, §5.4 beyond the bug-trap passage.
- Sampling-based algorithms for optimal motion planning (arXiv v1) — scoped · arXiv:1105.1186v1 via pdftotext, arXiv PDF pages. Read pp. 1–6 (abstract; §1.1 PRM as multiple-query with exponential failure decay, p. 3; §1.3 contributions incl. non-optimality of PRM, sPRM AO but expensive, k-nearest sPRM not PC for k = 1 and not AO for fixed k, p. 4; Table 1, p. 5; §2.1, p. 6); pp. 11–17 (§3.1 primitives; §3.2 Algorithm 1 PRM forest, Algorithm 2 sPRM, k-nearest k = 15 and bounded-degree k = 20 typical values, variable radius, p. 12; §3.3 PRM* radius and constant, dispersion remark, k-nearest PRM* with k_PRM > e(1+1/d) and 2e valid, pp. 13–14; §4.1 robust feasibility, Definition 14, Theorem 15, zero success without robust feasibility, p. 17); p. 28 (Theorems 34–35). Theorem 29 (p. 24) seen only as a statement line. Not read: proofs, §4.3 complexity, §5 experiments, appendices; journal version not opened.
- Rapidly-exploring random trees: Progress and prospects — scoped · LavKuf01.pdf via OCR, PDF pp. 1–9 read in full (see the rrt record). Used here: p. 3 (PRM local connection may be as hard as designing a nonlinear controller under differential constraints) and p. 9 (PRM as the limiting case of merging many RRTs; PRM's precomputation is for multiple queries, so direct comparison with RRT planners is not straightforward). Venue (A K Peters 2001) taken from Planning Algorithms bibliography [108].
Related topics