Skip to content

feat: add collision checking option to IK solver#1

Merged
jimsynz merged 1 commit intomainfrom
collision-avoidance
Dec 30, 2025
Merged

feat: add collision checking option to IK solver#1
jimsynz merged 1 commit intomainfrom
collision-avoidance

Conversation

@jimsynz
Copy link
Contributor

@jimsynz jimsynz commented Dec 30, 2025

Summary

Adds optional self-collision detection to reject IK solutions that would cause the robot to collide with itself.

New Options

Option Type Default Description
:check_collisions boolean false Enable collision checking after IK converges
:collision_margin float 0.0 Safety margin in metres for collision detection

Usage

# Basic collision checking
DLS.solve(robot, positions, :tip, target, check_collisions: true)

# With safety margin (detects near-misses)
DLS.solve(robot, positions, :tip, target,
  check_collisions: true,
  collision_margin: 0.01
)

Error Handling

When a collision is detected, returns:

{:error, %BB.Error.Kinematics.SelfCollision{
  link_a: :forearm,
  link_b: :base,
  joint_positions: %{shoulder: 1.2, elbow: -2.1}
}}

Dependencies

Requires bb ~> 0.11 with collision detection support (beam-bots/bb#25).

Test plan

  • Default behaviour unchanged (no collision checking)
  • Collision-free solutions accepted when checking enabled
  • Self-collision returns SelfCollision error
  • Collision margin parameter respected
  • New CollisionArm test robot with collision geometry

Add optional self-collision detection to reject IK solutions that would
cause the robot to collide with itself.

New options for `DLS.solve/5`:
- `:check_collisions` - enable collision checking (default: false)
- `:collision_margin` - safety margin in metres (default: 0.0)

When enabled, solutions are validated against `BB.Collision` after
convergence. If a collision is detected, returns `{:error, %SelfCollision{}}`
with the offending link pair and joint positions.

Requires bb ~> 0.11 (collision detection feature).
@jimsynz jimsynz force-pushed the collision-avoidance branch from 73c9f27 to 21ed73f Compare December 30, 2025 06:05
@jimsynz jimsynz merged commit 9c47ef9 into main Dec 30, 2025
12 checks passed
@jimsynz jimsynz deleted the collision-avoidance branch December 30, 2025 06:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant