Description

Class defining the geometric model for collision detection.

#include <ChCollisionModel.h>

Public Types

typedef std::pair< std::shared_ptr< ChCollisionShape >, ChFrame<> > ShapeInstance
 A ShapeInstance is a pair of a collision shape and its position in the model.
 

Public Member Functions

 ChCollisionModel (const ChCollisionModel &other)
 
void Clear ()
 Delete all inserted collision shapes.
 
void AddShape (std::shared_ptr< ChCollisionShape > shape, const ChFrame<> &frame=ChFrame<>())
 Add a collision shape with specified position within the model. More...
 
void AddCylinder (std::shared_ptr< ChContactMaterial > material, double radius, const ChVector3d &p1, const ChVector3d &p2)
 Convenience function to add a cylinder collision shape specified through a radius and end points. More...
 
void AddShapes (std::shared_ptr< ChCollisionModel > model, const ChFrame<> &frame=ChFrame<>())
 Add copies of the collision shapes in the provided model to this collision model. More...
 
void SetContactable (ChContactable *contactable)
 Set the pointer to the contactable object.
 
ChContactableGetContactable ()
 Get the pointer to the contactable object.
 
ChPhysicsItemGetPhysicsItem ()
 Get the pointer to the client owner ChPhysicsItem. More...
 
void SyncPosition ()
 Synchronize the position and orientation of the collision model to the associated contactable.
 
void SetFamily (int family)
 Set the collision family for this model (0...15). More...
 
int GetFamily ()
 Return the collision family for this model.
 
void DisallowCollisionsWith (int family)
 By default, family mask is all turned on, so all families can collide with this object, but you can turn on-off some bytes of this mask so that some families do not collide. More...
 
void AllowCollisionsWith (int family)
 
bool CollidesWith (int family)
 Return true if this model is allowed to collide with objects in the specified collision family.
 
short int GetFamilyGroup () const
 [INTERNAL USE] Return the collision family group of this model. More...
 
void SetFamilyGroup (short int group)
 [INTERNAL USE] Set the collision family group of this model. More...
 
short int GetFamilyMask () const
 [INTERNAL USE] Return the collision mask for this model. More...
 
void SetFamilyMask (short int mask)
 [INTERNAL USE] Set the collision mask for this model. More...
 
void SetSafeMargin (float margin)
 Set the suggested collision 'inward safe margin' for the shapes to be added from now on. More...
 
float GetSafeMargin ()
 Return the inward safe margin (see SetSafeMargin).
 
void SetEnvelope (float envelope)
 Set the suggested collision outward 'envelope' used from shapes added from now on. More...
 
float GetEnvelope ()
 Return the outward safe margin (see SetEnvelope).
 
ChAABB GetBoundingBox (bool local=false) const
 Return the axis aligned bounding box (AABB) of the collision model. More...
 
void ArchiveOut (ChArchiveOut &archive_out)
 Method to allow serialization of transient data to archives.
 
void ArchiveIn (ChArchiveIn &archive_in)
 Method to allow de-serialization of transient data from archives.
 
unsigned int GetNumShapes () const
 Return the number of collision shapes in this model.
 
const std::vector< ShapeInstance > & GetShapeInstances () const
 Get the list of collision shapes in this model.
 
const ShapeInstanceGetShapeInstance (int index) const
 Get the collision shape with specified index.
 
void SetAllShapesMaterial (std::shared_ptr< ChContactMaterial > mat)
 Set the contact material for all collision shapes in the model (all shapes will share the material). More...
 
bool HasImplementation () const
 
ChCollisionModelImpl * GetImplementation () const
 
void RemoveImplementation ()
 

Static Public Member Functions

static void SetDefaultSuggestedEnvelope (double envelope)
 Set the default envelope value. More...
 
static void SetDefaultSuggestedMargin (double margin)
 Set the default margin (inward penetration). More...
 
static double GetDefaultSuggestedEnvelope ()
 
static double GetDefaultSuggestedMargin ()
 

Friends

class ChCollisionModelImpl
 

Member Function Documentation

◆ AddCylinder()

void chrono::ChCollisionModel::AddCylinder ( std::shared_ptr< ChContactMaterial material,
double  radius,
const ChVector3d p1,
const ChVector3d p2 
)

Convenience function to add a cylinder collision shape specified through a radius and end points.

Parameters
materialsurface contact material
radiusradius
p1first end point
p2second end point

◆ AddShape()

void chrono::ChCollisionModel::AddShape ( std::shared_ptr< ChCollisionShape shape,
const ChFrame<> &  frame = ChFrame<>() 
)

Add a collision shape with specified position within the model.

Parameters
shapecollision shape
frameshape frame in model

◆ AddShapes()

void chrono::ChCollisionModel::AddShapes ( std::shared_ptr< ChCollisionModel model,
const ChFrame<> &  frame = ChFrame<>() 
)

Add copies of the collision shapes in the provided model to this collision model.

Parameters
modelcollision model
framemodel frame in model

◆ DisallowCollisionsWith()

void chrono::ChCollisionModel::DisallowCollisionsWith ( int  family)

By default, family mask is all turned on, so all families can collide with this object, but you can turn on-off some bytes of this mask so that some families do not collide.

When two objects collide, the contact is created only if the family is within the 'family mask' of the other, and viceversa.

◆ GetBoundingBox()

ChAABB chrono::ChCollisionModel::GetBoundingBox ( bool  local = false) const

Return the axis aligned bounding box (AABB) of the collision model.

If local=true, return the AABB expressed in the local frame of the owner contactable. Otherwise, return the AABB expressed in the absolute coordinate frame (in this case, SyncPosition() should be invoked first).

◆ GetFamilyGroup()

short int chrono::ChCollisionModel::GetFamilyGroup ( ) const
inline

[INTERNAL USE] Return the collision family group of this model.

The collision family of this model is the position of the single set bit in the return value.

◆ GetFamilyMask()

short int chrono::ChCollisionModel::GetFamilyMask ( ) const
inline

[INTERNAL USE] Return the collision mask for this model.

A bit in the mask indicates if this model collides with the corresponding family (bit set) or not (bit unset).

◆ GetPhysicsItem()

ChPhysicsItem * chrono::ChCollisionModel::GetPhysicsItem ( )

Get the pointer to the client owner ChPhysicsItem.

TODO OBSOLETE

◆ SetAllShapesMaterial()

void chrono::ChCollisionModel::SetAllShapesMaterial ( std::shared_ptr< ChContactMaterial mat)

Set the contact material for all collision shapes in the model (all shapes will share the material).

This function is useful in adjusting contact material properties for objects imported from outside (e.g., from SolidWorks).

◆ SetDefaultSuggestedEnvelope()

void chrono::ChCollisionModel::SetDefaultSuggestedEnvelope ( double  envelope)
static

Set the default envelope value.

All collision shapes in all collision models created after the call to this function will use this value. A particular collision system may ignore this suggested value.

◆ SetDefaultSuggestedMargin()

void chrono::ChCollisionModel::SetDefaultSuggestedMargin ( double  margin)
static

Set the default margin (inward penetration).

All collision shapes in all collision models created after the call to this function will use this value. A particular collision system may ignore this suggested value.

◆ SetEnvelope()

void chrono::ChCollisionModel::SetEnvelope ( float  envelope)
inline

Set the suggested collision outward 'envelope' used from shapes added from now on.

This 'envelope' is a surrounding invisible volume which extends outward from the surface, and it is used to detect contacts a bit before shapes come into contact, i.e. when dist>0. However contact points will stay on the true surface of the geometry, not on the external surface of the envelope. Call this BEFORE adding the shapes into the model. Side effect: AABB are 'expanded' outward by this amount, so if you exaggerate with this value, CD might be slower and too sensible. On the other hand, if you set this value to 0, contacts are detected only for dist<=0, thus causing unstable simulation.

◆ SetFamily()

void chrono::ChCollisionModel::SetFamily ( int  family)

Set the collision family for this model (0...15).

By default, all collision objects belong to family 0.

◆ SetFamilyGroup()

void chrono::ChCollisionModel::SetFamilyGroup ( short int  group)

[INTERNAL USE] Set the collision family group of this model.

This is an alternative way of specifying the collision family for this object. The group must have a single set bit; its position represents the collision family.

◆ SetFamilyMask()

void chrono::ChCollisionModel::SetFamilyMask ( short int  mask)

[INTERNAL USE] Set the collision mask for this model.

A set bit in the mask indicates that this model collides with the family equal to the bit position.

◆ SetSafeMargin()

void chrono::ChCollisionModel::SetSafeMargin ( float  margin)
inline

Set the suggested collision 'inward safe margin' for the shapes to be added from now on.

If this margin is too high for some thin or small shapes, it may be clamped. If dist<0 and inter-penetration occurs (e.g. due to numerical errors) within this 'safe margin' inward range, collision detection is still fast and reliable (beyond this, for deep penetrations, CD still works, but might be slower and less reliable) Call this BEFORE adding the shapes into the model. Side effect: think of the margin as a radius of a 'smoothing' fillet on all corners of the shapes - that's why you cannot exceed with this.


The documentation for this class was generated from the following files:
  • /builds/uwsbel/chrono/src/chrono/collision/ChCollisionModel.h
  • /builds/uwsbel/chrono/src/chrono/collision/ChCollisionModel.cpp