Official implementation for Robust Differentiable Collision Detection for General Objects.
DiffCollision is a robust and efficient differentiable collision detection framework for general 3D objects, supporting both convex and concave geometries.
It builds on the high-performance Coal library for forward collision queries and integrates with PyTorch autograd for gradient computation, enabling seamless use in optimization and learning pipelines.
- Parallel multi-mesh batching — Efficiently handles multiple mesh pairs and batches in parallel, supporting up to around 0.5 billion convex piece pairs on a single 24 GB RTX 4090 GPU.
- Unified plug-and-play API — A single PyTorch interface with multiple differentiable backends:
RS1Dist(ours, recommended),RS1Dir,RS0,FD,Analytical. - Strong performance — Achieves >90% mm-level accuracy for convex and >70% for concave objects (DexGraspNet & Objaverse) in our main optimization benchmark.
import torch
from diffcollision import DiffCollision, DCMesh
# Load meshes and define mesh pairs for collision detection
meshes = [DCMesh.from_file(f"obj{i}.obj", scale=0.1) for i in range(7)]
collision_pairs = [[0, 1], [0, 3], [3, 2], [1, 6], [6, 5]] # total 5 mesh pairs
# Initialize differentiable collision module
diffcoll = DiffCollision(meshes, collision_pairs, method="RS1Dist")
# Batched transformation matrices for each mesh, shape (batch, n_mesh, 4, 4)
transforms = torch.eye(4, requires_grad=True)[None, None].expand(13, 7, 4, 4)
# Forward & backward. wp1/wp2: witness points, shape (batch, n_pair, 3)
result = diffcoll.forward(transforms) # including wp1/wp2, normal, sdf, etc.
((result.wp1 - result.wp2) ** 2).sum().backward() For more examples:
tests/test_sphere.py— basic usage & installation verificationtests/test_multi_mesh.py— dynamic updates of collision pairs at runtime
Create and activate a Conda environment with the coal dependency
conda create -n dcd python=3.10 coal -c conda-forge
conda activate dcdThen install DiffCollision:
pip install -e . # Core library only
pip install -e '.[examples]' # Include dependencies for examplesDownload the preprocessed assets from Hugging Face:
DGN_5k_processed.zipobjaverse_5k_processed.zip
Unzip and organize as:
examples/assets/object
├── DGN_5k/processed_data
│ ├── core_bottle_1a7ba1f4c892e2da30711cdbdbc73924
│ └── ...
└── objaverse_5k/processed_data
├── 0a3d04fec6544bb697e14d0c473077ed
└── ...
CUDA_VISIBLE_DEVICES=0 bash examples/scripts/baseline/ours.shTo debug and visualization,
python examples/main.py exp=debug n_tp=10 vis=True n_prob=1 prob_rand=None 'obj=[core_jar_5a4af043ba70f9682db9fca4b68095, sem_TissueBox_fd9c40cd2ff2aab4a843bb865a04c01a]' 'scale=[0.08238040130667001, 0.04604694495201166]' python examples/grasp.py exp=grasp vis=TrueThis work is licensed under CC BY-NC 4.0.
If you find this work useful, please consider to cite:
@article{chen2025robust,
title={Robust Differentiable Collision Detection for General Objects},
author={Chen, Jiayi and Zhao, Wei and Ruan, Liangwang and Chen, Baoquan and Wang, He},
journal={arXiv preprint arXiv:2511.06267},
year={2025}
}