newton.CollisionPipeline#
- class newton.CollisionPipeline(shape_count, particle_count, shape_pairs_filtered, rigid_contact_max=None, rigid_contact_max_per_pair=10, rigid_contact_margin=0.01, soft_contact_max=None, soft_contact_margin=0.01, edge_sdf_iter=10, iterate_mesh_vertices=True, requires_grad=False, device=None)[source]#
Bases:
object
CollisionPipeline manages collision detection and contact generation for a simulation.
This class is responsible for allocating and managing buffers for collision detection, generating rigid and soft contacts between shapes and particles, and providing an interface for running the collision pipeline on a given simulation state.
- classmethod from_model(model, rigid_contact_max_per_pair=None, rigid_contact_margin=0.01, soft_contact_max=None, soft_contact_margin=0.01, edge_sdf_iter=10, iterate_mesh_vertices=True, requires_grad=None)#
Create a CollisionPipeline instance from a Model.
- Parameters:
model (Model) – The simulation model.
rigid_contact_max_per_pair (int | None, optional) – Maximum number of contact points per shape pair. If None, uses model.rigid_contact_max and sets per-pair to 0.
rigid_contact_margin (float, optional) – Margin for rigid contact generation. Defaults to 0.01.
soft_contact_max (int | None, optional) – Maximum number of soft contacts to allocate.
soft_contact_margin (float, optional) – Margin for soft contact generation. Defaults to 0.01.
edge_sdf_iter (int, optional) – Number of iterations for edge SDF collision. Defaults to 10.
iterate_mesh_vertices (bool, optional) – Whether to iterate mesh vertices for collision. Defaults to True.
requires_grad (bool | None, optional) – Whether to enable gradient computation. If None, uses model.requires_grad.
- Returns:
The constructed collision pipeline.
- Return type:
- __init__(shape_count, particle_count, shape_pairs_filtered, rigid_contact_max=None, rigid_contact_max_per_pair=10, rigid_contact_margin=0.01, soft_contact_max=None, soft_contact_margin=0.01, edge_sdf_iter=10, iterate_mesh_vertices=True, requires_grad=False, device=None)#
Initialize the CollisionPipeline.
- Parameters:
shape_count (int) – Number of shapes in the simulation.
particle_count (int) – Number of particles in the simulation.
shape_pairs_filtered (wp.array) – Array of filtered shape pairs to consider for collision.
rigid_contact_max (int | None, optional) – Maximum number of rigid contacts to allocate. If None, computed as shape_pairs_max * rigid_contact_max_per_pair.
rigid_contact_max_per_pair (int, optional) – Maximum number of contact points per shape pair. Defaults to 10.
rigid_contact_margin (float, optional) – Margin for rigid contact generation. Defaults to 0.01.
soft_contact_max (int | None, optional) – Maximum number of soft contacts to allocate. If None, computed as shape_count * particle_count.
soft_contact_margin (float, optional) – Margin for soft contact generation. Defaults to 0.01.
edge_sdf_iter (int, optional) – Number of iterations for edge SDF collision. Defaults to 10.
iterate_mesh_vertices (bool, optional) – Whether to iterate mesh vertices for collision. Defaults to True.
requires_grad (bool, optional) – Whether to enable gradient computation. Defaults to False.
device (Devicelike, optional) – The device on which to allocate arrays and perform computation.
- collide(model, state)#
Run the collision pipeline for the given model and state, generating contacts.
This method allocates or clears the contact buffer as needed, then generates soft and rigid contacts using the current simulation state.
- property device#
Returns the device on which the collision pipeline’s buffers are allocated.
- Returns:
The device associated with the pipeline’s buffers.