Coal Library

raw JSON →
3.0.1 verified Fri May 01 auth: no python

An extension of the Flexible Collision Library (FCL) for collision detection and distance computation. Supports convex primitives, meshes, octrees, and BVH. Version 3.0.1, with recent patch 3.0.2.c1. Release cadence: irregular.

pip install coal-library
error ModuleNotFoundError: No module named 'coal_library'
cause Trying to import using the PyPI package name instead of the Python import name.
fix
Install with pip install coal-library but import as import coal.
error AttributeError: module 'coal' has no attribute 'Box'
cause In older versions (pre-3.0), shapes were in a different location or named differently.
fix
Upgrade to coal-library >=3.0 and use from coal import Box or coal.Box.
breaking In coal-library v3.x, the main module is imported as `import coal` not `import coal_library`. The PyPI package name differs from the import name.
fix Use `import coal` and `from coal import ...` for all symbols.
gotcha Collision objects require explicit transform updates; transformations are not automatically applied after creation.
fix Set the transformation using `obj.setTransform(transform)` before calling collide or distance.
deprecated The `CollisionRequest` and `DistanceRequest` constructors now require keyword arguments for flags and settings; positional arguments are deprecated.
fix Use `coal.CollisionRequest(enable_contact=True)` instead of `coal.CollisionRequest(True)` .

Simple collision check between two identical boxes.

import coal

# Create a box collision object
box = coal.Box(1, 2, 3)
obj = coal.CollisionObject(box)

# Perform collision check
res = coal.collide(obj, obj, coal.CollisionRequest())
print(res.is_collision)