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< ChMaterialSurface > material, double radius, const ChVector<> &p1, const ChVector<> &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 ()
 
void SetFamilyMaskNoCollisionWithFamily (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 SetFamilyMaskDoCollisionWithFamily (int family)
 
bool GetFamilyMaskDoesCollisionWithFamily (int family)
 Indicate if the family mask of this collision object allows for the collision with another collision object belonging to a given family.
 
short int GetFamilyGroup () const
 Return the collision family group of this model. More...
 
void SetFamilyGroup (short int group)
 Set the collision family group of this model. More...
 
short int GetFamilyMask () const
 Return the collision mask for this model. More...
 
void SetFamilyMask (short int mask)
 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).
 
geometry::ChAABB GetBoundingBox () const
 Return the current axis aligned bounding box (AABB) of the collision model. More...
 
void ArchiveOut (ChArchiveOut &marchive)
 Method to allow serialization of transient data to archives.
 
void ArchiveIn (ChArchiveIn &marchive)
 Method to allow de-serialization of transient data from archives.
 
int GetNumShapes () const
 Return the number of collision shapes in this model.
 
const std::vector< ShapeInstance > & GetShapes () const
 Get the list of collision shapes in this model.
 
const ShapeInstanceGetShape (int index) const
 Get the collision shape with specified index.
 
void SetAllShapesMaterial (std::shared_ptr< ChMaterialSurface > 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< ChMaterialSurface material,
double  radius,
const ChVector<> &  p1,
const ChVector<> &  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

◆ GetBoundingBox()

geometry::ChAABB chrono::ChCollisionModel::GetBoundingBox ( ) const

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

Note that SyncPosition() should be invoked before calling this.

◆ GetFamilyGroup()

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

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

Return the collision mask for this model.

Each bit of the return value indicates whether 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< ChMaterialSurface 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)

Set the collision family group of this model.

This is an alternative way of specifying the collision family for this object. The value family_group must have a single bit set (i.e. it must be a power of 2). The corresponding family is then the bit position.

◆ SetFamilyMask()

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

Set the collision mask for this model.

Any set bit in the specified mask indicates that this model collides with all objects whose family is equal to the bit position.

◆ SetFamilyMaskNoCollisionWithFamily()

void chrono::ChCollisionModel::SetFamilyMaskNoCollisionWithFamily ( 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.

◆ 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