Simbody  3.7
SimTK::ContactTracker Class Referenceabstract

A ContactTracker implements an algorithm for detecting overlaps or potential overlaps between pairs of ContactGeometry objects, and managing Contact objects that track individual contacts as they evolve through time. More...

+ Inheritance diagram for SimTK::ContactTracker:

Classes

class  ConvexImplicitPair
 This ContactTracker handles contacts between two smooth, convex objects by using their implicit functions. More...
 
class  GeneralImplicitPair
 (TODO: not implemented yet) This ContactTracker handles contacts between two arbitrary smooth surfaces by using their implicit functions, with no shape restrictions. More...
 
class  HalfSpaceBrick
 This ContactTracker handles contacts between a ContactGeometry::HalfSpace and a ContactGeometry::Sphere, in that order. More...
 
class  HalfSpaceConvexImplicit
 This ContactTracker handles contacts between a ContactGeometry::HalfSpace and any ContactGeometry that can be considered a convex, implicit surface, in that order. More...
 
class  HalfSpaceEllipsoid
 This ContactTracker handles contacts between a ContactGeometry::HalfSpace and a ContactGeometry::Ellipsoid, in that order. More...
 
class  HalfSpaceSphere
 This ContactTracker handles contacts between a ContactGeometry::HalfSpace and a ContactGeometry::Sphere, in that order. More...
 
class  HalfSpaceTriangleMesh
 This ContactTracker handles contacts between a ContactGeometry::HalfSpace and a ContactGeometry::TriangleMesh, in that order. More...
 
class  SphereSphere
 This ContactTracker handles contacts between two ContactGeometry::Sphere objects. More...
 
class  SphereTriangleMesh
 This ContactTracker handles contacts between a ContactGeometry::Sphere and a ContactGeometry::TriangleMesh, in that order. More...
 
class  TriangleMeshTriangleMesh
 This ContactTracker handles contacts between two ContactGeometry::TriangleMesh surfaces. More...
 

Public Member Functions

 ContactTracker (ContactGeometryTypeId typeOfSurface1, ContactGeometryTypeId typeOfSurface2)
 Base class constructor for use by the concrete classes. More...
 
const std::pair< ContactGeometryTypeId, ContactGeometryTypeId > & getContactGeometryTypeIds () const
 Return the pair of contact geometry type ids handled by this tracker, in the order that they must be presented to the tracker's methods. More...
 
virtual ~ContactTracker ()
 
virtual bool trackContact (const Contact &priorStatus, const Transform &X_GS1, const ContactGeometry &surface1, const Transform &X_GS2, const ContactGeometry &surface2, Real cutoff, Contact &currentStatus) const =0
 The ContactTrackerSubsystem will invoke this method for any pair of contact surfaces that is already being tracked, or for which the static broad phase analysis indicated that they might be in contact now. More...
 

Static Public Member Functions

static bool refineImplicitPair (const ContactGeometry &shapeA, Vec3 &pointP_A, const ContactGeometry &shapeB, Vec3 &pointQ_B, const Transform &X_AB, Real accuracyRequested, Real &accuracyAchieved, int &numIterations)
 Given two shapes for which implicit functions are known, and a rough-guess contact point for each shape (each measured and expressed in its own surface's frame), refine those contact points to obtain the nearest pair that satisfies contact conditions to a requested accuracy. More...
 
static Vec6 findImplicitPairError (const ContactGeometry &shapeA, const Vec3 &pointP, const ContactGeometry &shapeB, const Vec3 &pointQ, const Transform &X_AB)
 Calculate the error function described in refineImplicitPair(). More...
 
static Mat66 calcImplicitPairJacobian (const ContactGeometry &shapeA, const Vec3 &pointP, const ContactGeometry &shapeB, const Vec3 &pointQ, const Transform &X_AB, const Vec6 &err0)
 Calculate the partial derivatives of the findImplicitPairError() error function with respect to the locations of the two points in their own surface's frame. More...
 
static bool estimateConvexImplicitPairContactUsingMPR (const ContactGeometry &shapeA, const ContactGeometry &shapeB, const Transform &X_AB, Vec3 &pointP_A, Vec3 &pointQ_B, UnitVec3 &dirInA, int &numIterations)
 Use Minkowski Portal Refinement (XenoCollide method by G. More...
 

Detailed Description

A ContactTracker implements an algorithm for detecting overlaps or potential overlaps between pairs of ContactGeometry objects, and managing Contact objects that track individual contacts as they evolve through time.

This class is used internally by ContractTrackerSubsystem and there usually is no reason to access it directly. The exception is if you are defining a new ContactGeometry subclass. In that case, you will also need to define one or more ContactTrackers to detect collisions with your new geometry type, then register it with the ContactTrackerSubsystem.

The result of a ContactTracker when applied to a pair of contact surfaces, is either a determination that the surfaces are not in contact, or a Contact object describing their contact interaction. There are different types of these Contact objects (for example, PointContact, LineContact, MeshContact) and the same algorithm may result in different kinds of Contact under different circumstances. At each evaluation, the caller passes in the previous Contact object, if any, that was associated with two ContactSurfaces, then receives an update from the algorithm.

Note that ContactTrackers that manage dissimilar geometry type pairs expect the two types in a particular order, e.g. (halfspace,sphere) rather than (sphere,halfspace) but are used for all contacts involving that pair of types. It is up to the ContactTrackerSubsystem to ensure that the contact surfaces are presented in the correct order regardless of how they are encountered. The Contact objects that are created and managed by trackers always have their (surface1,surface2) pairs in the order required by the tracker that handles those types.

Constructor & Destructor Documentation

◆ ContactTracker()

SimTK::ContactTracker::ContactTracker ( ContactGeometryTypeId  typeOfSurface1,
ContactGeometryTypeId  typeOfSurface2 
)
inline

Base class constructor for use by the concrete classes.

◆ ~ContactTracker()

virtual SimTK::ContactTracker::~ContactTracker ( )
inlinevirtual

Member Function Documentation

◆ getContactGeometryTypeIds()

const std::pair<ContactGeometryTypeId,ContactGeometryTypeId>& SimTK::ContactTracker::getContactGeometryTypeIds ( ) const
inline

Return the pair of contact geometry type ids handled by this tracker, in the order that they must be presented to the tracker's methods.

◆ trackContact()

virtual bool SimTK::ContactTracker::trackContact ( const Contact priorStatus,
const Transform X_GS1,
const ContactGeometry surface1,
const Transform X_GS2,
const ContactGeometry surface2,
Real  cutoff,
Contact currentStatus 
) const
pure virtual

The ContactTrackerSubsystem will invoke this method for any pair of contact surfaces that is already being tracked, or for which the static broad phase analysis indicated that they might be in contact now.

Only position information is available. Note that the arguments and Contact object surfaces must be ordered by geometry type id as required by this tracker.

Implemented in SimTK::ContactTracker::GeneralImplicitPair, SimTK::ContactTracker::ConvexImplicitPair, SimTK::ContactTracker::HalfSpaceConvexImplicit, SimTK::ContactTracker::TriangleMeshTriangleMesh, SimTK::ContactTracker::SphereTriangleMesh, SimTK::ContactTracker::HalfSpaceTriangleMesh, SimTK::ContactTracker::SphereSphere, SimTK::ContactTracker::HalfSpaceBrick, SimTK::ContactTracker::HalfSpaceEllipsoid, and SimTK::ContactTracker::HalfSpaceSphere.

◆ refineImplicitPair()

static bool SimTK::ContactTracker::refineImplicitPair ( const ContactGeometry shapeA,
Vec3 pointP_A,
const ContactGeometry shapeB,
Vec3 pointQ_B,
const Transform X_AB,
Real  accuracyRequested,
Real accuracyAchieved,
int &  numIterations 
)
static

Given two shapes for which implicit functions are known, and a rough-guess contact point for each shape (each measured and expressed in its own surface's frame), refine those contact points to obtain the nearest pair that satisfies contact conditions to a requested accuracy.

For separated objects, these will be the points of closest approach between the surfaces; for contacting objects these are the points of maximum penetration.

In implicit form there are six unknowns (spatial coordinates of the contact points). The six contact conditions we use are:

  • 2 equations: Point P is on the surface of shape A and point Q is on the surface of shape B (that is, the implicit functions both return zero).
  • 2 equations: The normal vector at point P is perpendicular to the tangent plane at point Q.
  • 2 equations: The separation vector (P-Q) is zero or perpendicular to the tangent plane at P.

Note that these equations could be satisfied by incorrect points that have the opposite normals because the perpendicularity conditions can't distinguish n from -n. We are depending on having an initial guess that is good enough so that we find the correct solution by going downhill from there. Don't try to use this if you don't have a reasonably good guess already. For convex implicit surfaces you can use estimateConvexImplicitPairContactUsingMPR() to get a good start if the surfaces are in contact.

Returns
true if the requested accuracy is achieved but returns its best attempt at the refined points regardless.

◆ findImplicitPairError()

static Vec6 SimTK::ContactTracker::findImplicitPairError ( const ContactGeometry shapeA,
const Vec3 pointP,
const ContactGeometry shapeB,
const Vec3 pointQ,
const Transform X_AB 
)
static

Calculate the error function described in refineImplicitPair().

◆ calcImplicitPairJacobian()

static Mat66 SimTK::ContactTracker::calcImplicitPairJacobian ( const ContactGeometry shapeA,
const Vec3 pointP,
const ContactGeometry shapeB,
const Vec3 pointQ,
const Transform X_AB,
const Vec6 err0 
)
static

Calculate the partial derivatives of the findImplicitPairError() error function with respect to the locations of the two points in their own surface's frame.

This might be an approximation of the derivative; it needs only to be good enough for refineImplicitPair() to get usable directional information.

◆ estimateConvexImplicitPairContactUsingMPR()

static bool SimTK::ContactTracker::estimateConvexImplicitPairContactUsingMPR ( const ContactGeometry shapeA,
const ContactGeometry shapeB,
const Transform X_AB,
Vec3 pointP_A,
Vec3 pointQ_B,
UnitVec3 dirInA,
int &  numIterations 
)
static

Use Minkowski Portal Refinement (XenoCollide method by G.

Snethen) to generate a reasonably good starting estimate of the contact points between two convex implicit shapes that may be in contact. MPR cannot find those points if the surfaces are separated. Returns false if the two shapes are definitely not in contact (MPR found a separating plane); in that case the returned direction is the separating plane normal and the points are the support points that prove separation. Otherwise, there might be contact and the points are estimates of the contact point on each surface, determined roughly to the requested accuracy. You still have to refine these and it might turn out there is no contact after all.


The documentation for this class was generated from the following file: