Libcoal: Flexible Collision Library Extension

3.0.2 · active · verified Fri Apr 17

Libcoal is a Python wrapper and extension for the Flexible Collision Library (FCL), a high-performance C++ library for performing collision detection and distance computation between geometric objects. It provides efficient Python bindings to FCL's core functionalities, enabling robotics, simulation, and planning applications to leverage fast collision checks. The current version is 3.0.2, with frequent patch releases addressing build system and compatibility updates.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to create two simple collision geometries (spheres), define their poses using transforms, and perform a collision check using `libcoal_core.collide`. It shows both colliding and non-colliding scenarios.

import libcoal_core

# Create two spheres
sphere_radius = 1.0
s1 = libcoal_core.CollisionGeometry(libcoal_core.CollisionShape_Sphere(sphere_radius))
s2 = libcoal_core.CollisionGeometry(libcoal_core.CollisionShape_Sphere(sphere_radius))

# Define transforms (position and orientation) for the spheres
tf1 = libcoal_core.Transform3d()
# Move the second sphere to partially overlap with the first
tf2 = libcoal_core.Transform3d()
tf2.translation = libcoal_core.Vector3d([sphere_radius * 0.5, 0.0, 0.0]) # Overlap by 0.5 units

# Perform collision checking
req = libcoal_core.CollisionRequest()
res = libcoal_core.CollisionResult()
libcoal_core.collide(s1, tf1, s2, tf2, req, res)

print(f"Are spheres colliding? {res.is_collision}")
print(f"Number of contacts: {res.num_contacts}")

# Adjust position to not collide
tf2.translation = libcoal_core.Vector3d([sphere_radius * 2.5, 0.0, 0.0]) # Separated by 0.5 units
libcoal_core.collide(s1, tf1, s2, tf2, req, res)
print(f"Are spheres colliding (separated)? {res.is_collision}")

view raw JSON →