Calculator D3

Collision Detection Algorithms: GJK, EPA & BVH Optimization

Collision detection algorithms are math tricks robots use to figure out if two moving objects—like a robotic arm and a machine part—are about to bump into each other.

Industry Applications
Automotive assembly, semiconductor wafer handling, surgical robotics, collaborative palletizing
Key Standards
ISO/TS 15066:2016 (safety for collaborative robots), ROS 2 Real-Time Working Group guidelines
Typical Scale
Workcells with 5–20 robots, 10⁴–10⁶ mesh primitives, sub-millisecond latency budgets
Computational Budget
≤800 µs per collision query (at 125 Hz control rate)

⚠️ Why It Matters

1
Inaccurate collision prediction
2
Unplanned robot stoppages or emergency stops
3
Reduced cycle time and throughput
4
Increased wear on joints and actuators
5
Safety system overrides triggering false positives
6
Non-compliance with ISO/TS 15066 human-robot collaboration requirements

📘 Definition

Collision detection is the computational process of determining whether two or more geometric objects intersect in 3D space, typically using convex decomposition, support functions, and hierarchical spatial partitioning. The Gilbert–Johnson–Keerthi (GJK) algorithm computes the minimum distance between convex shapes via iterative simplex reduction; the Expanding Polytope Algorithm (EPA) refines GJK’s result to extract penetration depth and normal vector; and Bounding Volume Hierarchies (BVHs) accelerate broad-phase culling by recursively organizing object volumes into tree structures for efficient overlap queries.

🎨 Concept Diagram

Support mappingGJK CoreEPA Refinement

AI-generated illustration for visual understanding

💡 Engineering Insight

GJK is not a 'black box'—its convergence behavior is highly sensitive to numerical conditioning. In practice, always initialize the search direction using the relative velocity vector between objects; this reduces average iteration count by 30–50% and prevents pathological oscillation near grazing contacts. EPA should never be called unless GJK returns a degenerate simplex (volume < 1e−9 m³)—a common mistake that cripples real-time performance.

📖 Detailed Explanation

At its core, collision detection answers a binary question: 'Are these two objects touching?' Early approaches used brute-force triangle-triangle tests, which scale quadratically and fail catastrophically beyond ~1000 primitives. GJK solves this by operating in 'configuration space': instead of checking geometry directly, it iteratively builds a simplex (point, line, triangle, tetrahedron) inside the Minkowski difference of two convex sets—where intersection corresponds to the origin lying within that simplex.

GJK’s elegance lies in its reliance solely on a support function—the farthest point on a shape in a given direction. This makes it agnostic to mesh representation and enables exact computation for primitives like ellipsoids, capsules, and convex polyhedra. However, GJK alone cannot quantify how *deeply* objects interpenetrate; that’s where EPA comes in. EPA expands the final GJK simplex into a polytope that approximates the Minkowski difference boundary, then walks its faces to locate the closest point to the origin—yielding both depth and normal.

BVHs address the scalability bottleneck. Industrial workcells contain thousands of static and dynamic objects; testing all pairs is O(n²). A well-constructed BVH reduces this to O(n log n) by pruning entire subtrees when their bounding volumes don’t overlap. Critically, BVH quality depends less on tree depth than on 'tightness' of bounds—loose AABBs cause excessive false positives. For dynamic scenes, incremental updates (e.g., SAH-rebuilding every 10 frames) strike the best balance between fidelity and CPU cost in real-time PLC-integrated systems.

🔄 Engineering Workflow

Step 1
Step 1: Geometric preprocessing — convex decomposition of non-convex CAD parts using V-HACD or HACD
Step 2
Step 2: BVH construction — build axis-aligned bounding box (AABB) tree with surface-area heuristic (SAH) optimization
Step 3
Step 3: GJK initialization — compute initial simplex using cached support points and temporal coherence from prior frame
Step 4
Step 4: Narrow-phase verification — run GJK to determine separation/intersection; if intersecting, invoke EPA to extract contact manifold
Step 5
Step 5: Physics integration — feed penetration depth and normal into compliant contact model (e.g., Hunt–Crossley) for force estimation
Step 6
Step 6: Motion planner feedback — adjust trajectory waypoints or velocity profiles based on collision risk score (distance-to-collision < threshold)
Step 7
Step 7: Runtime validation — log GJK iteration count, EPA face resolution, and BVH traversal depth for performance auditing

📋 Decision Guide

Rock/Field Condition Recommended Design Action
High-fidelity CAD model (>50k triangles) with tight clearance (<2 mm) and 125 Hz motion control Use BVH + GJK/EPA hybrid: BVH for broad-phase culling (AABB), GJK for narrow-phase on convex decompositions; precompute support function LUTs for critical parts.
Dynamic workcell with moving conveyors and humans (ISO/TS 15066 compliant) Deploy GJK with conservative safety margin (≥3× sensor noise floor); run EPA only on GJK 'collision' results; enforce strict temporal coherence via warm-started simplex initialization.
Resource-constrained embedded controller (ARM Cortex-R5F, <100 kB RAM) Replace full EPA with Johnson–Sekhon linear approximation for penetration depth; use sphere-tree BVH with fixed-depth truncation (depth ≤ 6); limit convex decomposition to ≤8 primitives per component.

📊 Key Properties & Parameters

Minimum Separation Distance

0.001–5.0 mm (industrial robotics)

Smallest Euclidean distance between two non-interpenetrating convex objects, computed by GJK.

⚡ Engineering Impact:

Directly governs motion planning safety margins and determines whether a path is kinematically feasible under real-time control latency.

Penetration Depth

0.01–10.0 mm (for compliant industrial grippers and fixtures)

Magnitude of interpenetration between overlapping convex objects, computed by EPA after GJK detects intersection.

⚡ Engineering Impact:

Used to compute corrective forces in physics-based controllers and to trigger recovery logic before mechanical damage occurs.

BVH Tree Depth

4–12 levels (for workcell models with 500–10,000 mesh primitives)

Maximum number of levels in a bounding volume hierarchy used for broad-phase collision culling.

⚡ Engineering Impact:

Shallow trees reduce memory footprint but increase false positives; deep trees improve culling accuracy but raise traversal latency—critical for sub-8 ms control loops.

Support Function Evaluation Time

50–500 ns per evaluation (on x86-64 @ 3 GHz, optimized SIMD)

CPU cycles required to evaluate the support point of a convex shape in a given direction—a core GJK operation.

⚡ Engineering Impact:

Dominates GJK runtime; dictates feasibility of real-time execution at 125 Hz+ control rates in safety-critical applications.

📐 Key Formulas

Minkowski Difference Support Function

S_{A⊖B}(d) = S_A(d) − S_B(−d)

Support function of the Minkowski difference of convex sets A and B, used in GJK to generate simplex vertices.

Variables:
Symbol Name Unit Description
S_{A⊖B}(d) Support function of Minkowski difference m Value of the support function for the Minkowski difference A ⊖ B in direction d
S_A(d) Support function of set A m Value of the support function for convex set A in direction d
S_B(−d) Support function of set B in opposite direction m Value of the support function for convex set B in direction −d
d Direction vector dimensionless Unit vector specifying the query direction for the support function
Typical Ranges:
Industrial robot link vs. fixture
−0.15 to +0.25 m
⚠️ Must be numerically stable to ±1e−9 m under IEEE-754 double precision

GJK Simplex Volume Threshold

V = |(b−a) ⋅ ((c−a) × (d−a))| / 6

Volume of tetrahedral simplex in 3D GJK; near-zero volume indicates degeneracy and triggers restart or EPA fallback.

Variables:
Symbol Name Unit Description
V Simplex Volume Volume of the tetrahedral simplex formed by points a, b, c, d in 3D space
a Vertex A m 3D position vector of first simplex vertex
b Vertex B m 3D position vector of second simplex vertex
c Vertex C m 3D position vector of third simplex vertex
d Vertex D m 3D position vector of fourth simplex vertex
Typical Ranges:
Converged GJK (separated)
1e−6 to 1e−3 m³
Near-contact grazing
1e−9 to 1e−7 m³
⚠️ Restart if V < 1e−9 m³ and iteration count > 10

🏭 Engineering Example

BMW Plant Leipzig – Body Shop Line 4

N/A (robotic workcell; material context replaced with industrial components)
BVH Tree Depth
8
EPA Face Resolution
12 faces
GJK Avg. Iterations
3.1
Control Loop Frequency
125 Hz
Minimum Separation Distance
0.32 mm
Penetration Depth (max observed)
1.8 mm

🏗️ Applications

  • Real-time path validation for UR10e collaborative arms
  • Digital twin collision verification in Siemens Tecnomatix
  • Force-limited contact modeling in KUKA Sunrise.OS

📋 Real Project Case

Palletizing Robot Path Optimization for High-Speed E-Commerce Fulfillment

Automated fulfillment center serving Amazon Prime logistics in Ohio

Challenge: Vibration-induced misalignment causing 8% pallet collapse rate at 120 cycles/hour
Palletizing Robot Path Optimization High-Speed E-Commerce Fulfillment Challenge 8% pallet collapse @ 120 c/h Vibration-induced misalignment Design Approach Quintic spline interpolation Jerk-limited acceleration ramping Real-time load sensing → TCP adaptation Key Parameters t = √(2·aₘₐₓ/jₘₐₓ) = 0.12 s θₘₐₓ = arctan(d/L) = ±0.8° ±0.8° Load Sensor Challenge Design Parameter Adaptation
Read full case study →

🎨 Technical Diagrams

GJK distance query
BVH Level 0 (root)Level 1Level 2Leaves

📚 References

[1]
[2]
ISO/TS 15066:2016 Robots and robotic devices — Collaborative robots — International Organization for Standardization
[3]