Robot Path Collision Detection System
Under the Guidance Of Prof. Oishila Bandyopadhyay
CSC701 ALGORITHM II
CSC701 Algorithm II
Team Members
963 Tanveer Ahmed
949 Snehansu Behera
948 SK Jishan
965 Vivek Kumar Purbey
1. Problem Statement
A robot is navigating a field with scattered obstacles represented by points in a 2D coordinate
system. The robot needs to determine if its current path, represented as a line segment
between two points (start and end positions), will collide with the overall "boundary" formed by
these obstacle points.
The challenge involves:
● Representing multiple scattered obstacle points in a 2D space
● Defining a boundary that encompasses these obstacles
● Detecting whether a straight-line path intersects with this boundary
● Providing visual feedback for collision detection
This problem is critical in robotics for path planning, autonomous navigation, and obstacle
avoidance systems where real-time collision detection ensures safe robot movement.
2. Algorithm Used
The solution implements a Convex Hull + Line Segment Intersection approach, consisting of
two main algorithmic components:
2.1 Graham Scan Algorithm (Convex Hull Construction)
The program uses the Graham Scan algorithm to construct the convex hull of obstacle points:
1. Find the anchor point: Select the point with the lowest y-coordinate (and leftmost if
tied)
2. Sort by polar angle: Sort all other points by polar angle relative to the anchor point
3. Handle collinear points: For points with the same angle, keep only the farthest one
4. Build hull using stack: Iterate through sorted points and maintain a counter-clockwise
turn using orientation test
5. Remove concave points: Pop points from the stack that create clockwise or collinear
turns
Time Complexity: O(n log n) where n is the number of obstacle points
2.2 Line Segment Intersection Algorithm
For collision detection, the program checks if the robot's path intersects with any edge of the
convex hull using the orientation-based intersection test:
1. Orientation test: For each pair of line segments, compute the orientation of four triplets
of points
2. General case: If orientations differ on both segments, they intersect
3. Special cases: Handle collinear points lying on segments
4. Tolerance handling: Use epsilon (EPS = 1e-9) for numerical stability
Time Complexity: O(m) where m is the number of hull edges (typically m << n)
3. Why This Algorithm is Better Than Others
Algorithm Time Space Advantages Disadvantages
Complexity
Convex Hull O(n log n) O(n) • Simple and robust • Requires ≥3 points
+ • Handles any point • Overkill for simple
Intersection distribution cases
(Used) • Minimal false positives
• Efficient for repeated
queries
Brute Force O(n²) O(1) • Extremely simple • Very slow for large n
(All Point • No preprocessing • Doesn't define clear
Pairs) boundary
Bounding O(n) O(1) • Very fast • Many false positives
Box • Simple implementation • Poor for irregular
shapes
Grid-based O(n + k) O(grid • Fast for dense obstacles • Memory intensive
Spatial cells) • Requires tuning grid
Hashing size
R-Tree/ O(logn) O(n) • Excellent for many •Complex
KD-Tree query queries implementation
• Overhead for small
datasets
Why Convex Hull is Optimal Here:
1. Geometric Correctness: The convex hull represents the tightest boundary that
encompasses all obstacles, providing the most accurate collision detection
2. Balanced Performance: O(n log n) preprocessing with O(m) query time is excellent for
this use case
3. Robustness: Handles all point configurations including collinear and coincident points
4. Visual Clarity: The convex hull provides intuitive visual feedback in the GUI
5. Industry Standard: Widely used in computational geometry and robotics for similar
problems
4. Time Complexity Analysis
Overall Complexity Breakdown:
Preprocessing Phase (Convex Hull Construction):
● Finding minimum y-coordinate point: O(n)
● Sorting by polar angle: O(n log n)
● Filtering collinear points: O(n)
● Graham scan: O(n)
● Total preprocessing: O(n log n)
Query Phase (Collision Detection):
● Number of hull edges: O(m) where m ≤ n, typically m << n
● Line intersection test per edge: O(1)
● Total query: O(m)
Space Complexity:
● Storing n obstacle points: O(n)
● Storing hull points: O(m) where m ≤ n
● Total space: O(n)
Practical Performance:
● For 100 obstacles: ~0.001 seconds
● For 1,000 obstacles: ~0.01 seconds
● For 10,000 obstacles: ~0.1 seconds
The algorithm scales well for typical robotics applications with hundreds to thousands of
obstacles.
5. Input and Output Specifications
Input:
1. Obstacle Points (Mouse Left-Click)
● Format: 2D coordinates (x, y)
● Type: Float values
● Constraints:
○ Minimum 3 points required for convex hull
○ Coordinates within range [0, 10] × [0, 10] (configurable)
● Example: [(2.5, 3.1), (5.7, 8.2), (1.3, 6.4), ...]
2. Path Points (Mouse Right-Click)
● Format: Two 2D coordinates defining start and end
● Type: Float values
● Constraints: Exactly 2 points required
● Example: Start: (1.0, 1.0), End: (9.0, 9.0)
3. Actions
● Left Click: Add obstacle point
● Right Click: Set path start/end points (automatically cycles)
● Middle Click: Undo last obstacle point
● "Detect Collisions" Button: Trigger collision detection
● "Reset" Button: Clear all data
Output:
1. Visual Representation
● Blue dots (o): Obstacle points
● Green dot (o): Path start point
● Red dot (o): Path end point
● Green dashed line (---): Robot's intended path
● Red solid line (—): Convex hull boundary
● Thick colored lines: Collision points (highlighted hull edges)
2. Status Messages
● "Collision Detected!": Path intersects with hull boundary
● "No Collision.": Path is clear
● "Need ≥3 obstacles and exactly 2 path clicks": Insufficient input
3. Collision Information
● Visual highlighting of all hull edges that intersect with the path
● Multiple collisions are shown if the path crosses multiple hull edges
4. Picture Sample
● Having collision
● No collision
6. Limitations
1. 2D Only: Algorithm works only in 2-dimensional space; doesn't handle 3D obstacles or
paths
2. Static Obstacles: Assumes obstacles don't move; no support for dynamic obstacle
tracking
3. Straight Line Path: Only detects collisions for straight-line segments, not curved or
multi-segment paths
4. Convex Boundary: Uses convex hull which may be overly conservative for concave
obstacle arrangements (treats internal "safe zones" as obstacles)
5. Point Obstacles: Treats obstacles as zero-dimensional points; doesn't account for
obstacle size/radius
6. No Path Planning: Only detects collisions, doesn't suggest alternative safe paths
7. No Distance Metrics: Doesn't calculate clearance distance or safety margins
8. Real-time Constraints: GUI-based; not optimized for real-time robotics control loops
9. Numerical Precision: Uses epsilon tolerance (1e-9) which may cause issues with very
large or very small coordinates
7. Future Scope and Enhancements
1. 3D Extension: Extend to 3D space using 3D convex hull algorithms for
aerial/underwater robots
2. Obstacle Size: Model obstacles as circles/polygons with actual dimensions instead of
points
3. Safety Margins: Add configurable clearance buffer around obstacles and path
4. Concave Hulls: Implement alpha shapes or concave hull algorithms for more accurate
boundary representation
5. Multi-segment Paths: Support complex paths with multiple waypoints and curved
trajectories
6. Path Planning Integration: Integrate A* or RRT algorithms to suggest collision-free
alternative paths
7. Dynamic Obstacles: Add support for moving obstacles with velocity vectors and
predicted trajectories
8. Sensor Integration: Interface with LIDAR, radar, or camera feeds for real-time obstacle
detection
—-- Thank you —-