PIXELBANKv9.1.0
Menu

Detect potential loop closures based on pose proximity.

Loop closure is one of the most critical components of SLAM. It occurs when a robot returns to a previously visited location, allowing it to correct accumulated drift.

Simple loop closure detection checks if the current pose is close to any past pose:

  • Compute distance to each past pose
  • If distance < threshold, it's a potential loop closure candidate

In practice, loop closure also uses appearance-based methods (comparing images or point clouds), but geometric proximity is a necessary first filter.

Example:

Input:
detect_loop_closure([0, 0, 0], [[10, 0, 0], [0.5, 0.5, 0], [5, 5, 0]], 1.0)
Output:
[1]
Reasoning:
  • Checking distances from (0,0) to past poses:
  • Pose 0 at (10,0): d = sqrt(10² + 0²) = 10 > 1.0 ✗
  • Pose 1 at (0.5,0.5): d = sqrt(0.5² + 0.5²) = 0.707 < 1.0 ✓
  • Pose 2 at (5,5): d = sqrt(5² + 5²) = 7.07 > 1.0 ✗ Only pose 1 is within threshold.

Constraints:

  • current_pose: [x, y, theta] current robot pose
  • past_poses: list of [x, y, theta] previously visited poses
  • distance_thresh: maximum distance for loop closure candidate
  • Return list of indices of potential loop closures
solution.py

Test Results

0/0
Run code to see test results.