Karana.Collision#
Models and classes for collision detection and contact force calculation.
Classes#
Package Contents#
- class Karana.Collision.ContactForceBase#
Bases:
Karana.Core.Base- applyForce(arg0: FrameContact, arg1: Karana.Dynamics.SubTree) None#
Apply the contact force for the associated contact.
This first calls computeForce to get the contact force. Then, it applies it to frames if those frames belong to a body.
- Parameters:
contact – The contact to apply the force for.
st – The SubTree we are computing forces for.
- getLastNodePair() tuple[Karana.Dynamics.Node, Karana.Dynamics.Node]#
Get the pair of nodes from the most recent contact. :returns: The node pair (may be null)
- resetLastNodePair() None#
Reset the most recent contact node pair to nullptr
- class Karana.Collision.ContactForceManager(name: str)#
Bases:
ContactForceBase- static create(name: str) ContactForceManager#
Create an instance of ContactForceManager.
- Parameters:
name – The name for the ContactForceManager instance.
- Returns:
A ks_ptr to the newly created ContactForceManager.
- clearDelegates() None#
Clear out all registered ContactForceBase instances
- getDelegate(contact: FrameContact) ContactForceBase#
- getDelegate() ContactForceBase
- getDelegate(frame1: Karana.Frame.Frame, frame2: Karana.Frame.Frame, strict: bool = False) ContactForceBase
Get the most specific matching ContactForceBase
- Parameters:
contact – The contact to get the delegate for.
- Returns:
The ContactForceBase (may be nullptr)
- setDelegate(force: ContactForceBase = None) None#
- setDelegate(frame1: Karana.Frame.Frame, frame2: Karana.Frame.Frame, force: ContactForceBase = None) None
Set the ContactForceBase used by default
- Parameters:
force – The ContactForceBase (may be nullptr)
- class Karana.Collision.FrameCollider(proxy_scene: Karana.Scene.ProxyScene, collision_scene: Karana.Scene.CollisionScene)#
- clearIgnoredFramePairs() None#
Stop ignoring any frame-pair collisions
- collide(col_func: collections.abc.Callable[[FrameContact], None], filter_func: collections.abc.Callable[[Karana.Scene.CollisionScenePart, Karana.Scene.CollisionScenePart], bool] = None) None#
Process all collisions
Sweeps through all contacts between geometries attached to Frames, calling the collision handler for each unfiltered contact.
- Parameters:
collision_handler –
Callback to handle a contact
filter –
Callback to skip potential collisions in the broadphase.
- ignoreAllCurrentlyTouchingPairs() None#
Call ignoreFramePair for each pair with a collision
- ignoreFramePair(frame1: Karana.Frame.Frame, frame2: Karana.Frame.Frame) None#
Ignore collisions between a pair of frames :param frame1: The first frame in the pair :param frame2: The second frame in the pair
- lookupPartFrame(part: Karana.Scene.CollisionScenePart) Karana.Frame.Frame#
- lookupPartFrame(id: SupportsInt) Karana.Frame.Frame
Get the Frame that a CollisionScenePart is attached to :param part:
A CollisionScenePart managed by ProxyScene
- Returns:
The ancestor Frame for the part.
- unignoreFramePair(frame1: Karana.Frame.Frame, frame2: Karana.Frame.Frame) None#
Stop ignoring collisions between a pair of frames :param frame1: The first frame in the pair :param frame2: The second frame in the pair
- class Karana.Collision.FrameContact#
- property frame_1: Karana.Frame.Frame#
The first Frame involved in the contact
- property frame_2: Karana.Frame.Frame#
The second Frame involved in the contact
- property location_1: Annotated[numpy.typing.NDArray[numpy.float64], [3, 1]]#
Contact location on the first Frame relative to the first Frame and expressed in the first frame
- property location_2: Annotated[numpy.typing.NDArray[numpy.float64], [3, 1]]#
Contact location on the second Frame relative to the second Frame and expressed in the second frame
- property normal_1: Annotated[numpy.typing.NDArray[numpy.float64], [3, 1]]#
Contact normal expressed first Frame
- property normal_2: Annotated[numpy.typing.NDArray[numpy.float64], [3, 1]]#
Contact normal expressed second Frame
- property penetration: float#
Maximum penetration distance
- class Karana.Collision.HuntCrossley(name: str)#
Bases:
ContactForceBase- static create(name: str) HuntCrossley#
Create an instance of the HuntCrossley contact force model.
- Parameters:
name – The name for the HuntCrossley instance.
- Returns:
A ks_ptr to the newly created HuntCrossley contact force model.
- property params: HuntCrossleyParams#
Parameters used for the contact model.
- property scratch: HuntCrossleyScratch#
Scratch values
- class Karana.Collision.HuntCrossleyParams#
- property kc: float#
Normal penetration restitution/damping coefficient
- property kp: float#
Normal penetration stiffness coefficient
- property linear_region_tol: float#
Tolerance at which friction is linearly interpolated between the real value and 0.
To avoid jittering for cases like rolling without friction, near zero, the friction force uses a linear interpolation between the full friction force and zero. This avoids rapid, large changes in the friction force as the velocity changes sign, and instead, smoothly, linearly interpolates between these large forces over a region of linear_region_tol * 2.
- property mu: float#
Friction coefficient
- property n: float#
Exponent