Description

Geometric model for the custom multicore Chrono collision system.

#include <ChCollisionModelChrono.h>

Inheritance diagram for chrono::collision::ChCollisionModelChrono:
Collaboration diagram for chrono::collision::ChCollisionModelChrono:

Public Member Functions

virtual ChCollisionSystemType GetType () const override
 Return the type of this collision model.
 
virtual int ClearModel () override
 Deletes all inserted geometries. More...
 
virtual int BuildModel () override
 Builds the BV hierarchy. More...
 
virtual void SyncPosition () override
 Sets the position and orientation of the collision model as the rigid body current position.
 
virtual void SetContactable (ChContactable *mc) override
 Sets the pointer to the contactable object.
 
virtual bool AddSphere (std::shared_ptr< ChMaterialSurface > material, double radius, const ChVector<> &pos=ChVector<>()) override
 Add a sphere shape to this collision model. More...
 
virtual bool AddEllipsoid (std::shared_ptr< ChMaterialSurface > material, double axis_x, double axis_y, double axis_z, const ChVector<> &pos=ChVector<>(), const ChMatrix33<> &rot=ChMatrix33<>(1)) override
 Add an ellipsoid shape to this collision model. More...
 
virtual bool AddBox (std::shared_ptr< ChMaterialSurface > material, double size_x, double size_y, double size_z, const ChVector<> &pos=ChVector<>(), const ChMatrix33<> &rot=ChMatrix33<>(1)) override
 Add a box shape to this collision model. More...
 
virtual bool AddRoundedBox (std::shared_ptr< ChMaterialSurface > material, double size_x, double size_y, double size_z, double sphere_r, const ChVector<> &pos=ChVector<>(), const ChMatrix33<> &rot=ChMatrix33<>(1)) override
 Add a rounded box shape to this collision model. More...
 
virtual bool AddTriangle (std::shared_ptr< ChMaterialSurface > material, ChVector<> A, ChVector<> B, ChVector<> C, const ChVector<> &pos=ChVector<>(), const ChMatrix33<> &rot=ChMatrix33<>(1))
 Add a triangle shape to this model, for collision purposes. More...
 
virtual bool AddCylinder (std::shared_ptr< ChMaterialSurface > material, double radius, double height, const ChVector<> &pos=ChVector<>(), const ChMatrix33<> &rot=ChMatrix33<>(1)) override
 Add a cylinder to this collision model (axis in Z direction). More...
 
virtual bool AddCylindricalShell (std::shared_ptr< ChMaterialSurface > material, double radius, double height, const ChVector<> &pos=ChVector<>(), const ChMatrix33<> &rot=ChMatrix33<>(1)) override
 Add a cylindrical shell to this collision model (axis in Z direction). More...
 
virtual bool AddRoundedCylinder (std::shared_ptr< ChMaterialSurface > material, double radius, double height, double sphere_r, const ChVector<> &pos=ChVector<>(), const ChMatrix33<> &rot=ChMatrix33<>(1)) override
 Add a rounded cylinder to this collision model (axis in Z direction). More...
 
virtual bool AddCone (std::shared_ptr< ChMaterialSurface > material, double radius, double height, const ChVector<> &pos=ChVector<>(), const ChMatrix33<> &rot=ChMatrix33<>(1)) override
 Add a cone to this collision model (axis in Z direction). More...
 
virtual bool AddCapsule (std::shared_ptr< ChMaterialSurface > material, double radius, double height, const ChVector<> &pos=ChVector<>(), const ChMatrix33<> &rot=ChMatrix33<>(1)) override
 Add a capsule to this collision model (axis in Z direction). More...
 
virtual bool AddConvexHull (std::shared_ptr< ChMaterialSurface > material, const std::vector< ChVector< double >> &pointlist, const ChVector<> &pos=ChVector<>(), const ChMatrix33<> &rot=ChMatrix33<>(1)) override
 Add a convex hull to this collision model. More...
 
virtual bool AddTriangleMesh (std::shared_ptr< ChMaterialSurface > material, std::shared_ptr< geometry::ChTriangleMesh > trimesh, bool is_static, bool is_convex, const ChVector<> &pos=ChVector<>(), const ChMatrix33<> &rot=ChMatrix33<>(1), double sphereswept_thickness=0.0) override
 Add a triangle mesh to this collision model. More...
 
virtual bool AddBarrel (std::shared_ptr< ChMaterialSurface > material, double Y_low, double Y_high, double axis_vert, double axis_hor, double R_offset, const ChVector<> &pos=ChVector<>(), const ChMatrix33<> &rot=ChMatrix33<>(1)) override
 Add a barrel-like shape to this collision model (main axis on Y direction). More...
 
virtual bool AddCopyOfAnotherModel (ChCollisionModel *another) override
 Add all shapes already contained in another model.
 
virtual void GetAABB (ChVector<> &bbmin, ChVector<> &bbmax) const override
 Return the axis aligned bounding box for this collision model.
 
virtual ChCoordsys GetShapePos (int index) const override
 Return the position and orientation of the collision shape with specified index, relative to the model frame.
 
virtual std::vector< double > GetShapeDimensions (int index) const override
 Return shape characteristic dimensions. More...
 
ChBodyGetBody () const
 Return a pointer to the associated body.
 
void SetBody (ChBody *body)
 Set the pointer to the owner rigid body.
 
- Public Member Functions inherited from chrono::collision::ChCollisionModel
bool AddCylinder (std::shared_ptr< ChMaterialSurface > material, double radius, const ChVector<> &p1, const ChVector<> &p2)
 Add a cylinder specified through a radius and end points. More...
 
virtual bool Add2Dpath (std::shared_ptr< ChMaterialSurface > material, std::shared_ptr< geometry::ChLinePath > mpath, const ChVector<> &pos=ChVector<>(), const ChMatrix33<> &rot=ChMatrix33<>(1), const double thickness=0.001)
 Add a 2D closed line, defined on the XY plane passing by pos and aligned as rot, that defines a 2D collision shape that will collide with another 2D line of the same type if aligned on the same plane. More...
 
virtual bool AddPoint (std::shared_ptr< ChMaterialSurface > material, double radius=0, const ChVector<> &pos=ChVector<>())
 Add a point-like sphere, that will collide with other geometries, but won't ever create contacts between them. More...
 
virtual bool AddConvexHullsFromFile (std::shared_ptr< ChMaterialSurface > material, ChStreamInAscii &mstream, const ChVector<> &pos=ChVector<>(), const ChMatrix33<> &rot=ChMatrix33<>(1))
 Add a cluster of convex hulls specified in a '.chulls' file description. More...
 
ChContactableGetContactable ()
 Get the pointer to the contactable object.
 
virtual ChPhysicsItemGetPhysicsItem ()
 Get the pointer to the client owner ChPhysicsItem. More...
 
virtual void SetFamily (int mfamily)
 By default, all collision objects belong to family n.0, but you can set family in range 0..15. More...
 
virtual int GetFamily ()
 
virtual void SetFamilyMaskNoCollisionWithFamily (int mfamily)
 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...
 
virtual void SetFamilyMaskDoCollisionWithFamily (int mfamily)
 
virtual bool GetFamilyMaskDoesCollisionWithFamily (int mfamily)
 Tells if the family mask of this collision object allows for the collision with another collision object belonging to a given family. More...
 
virtual short int GetFamilyGroup () const
 Return the collision family group of this model. More...
 
virtual void SetFamilyGroup (short int group)
 Set the collision family group of this model. More...
 
virtual short int GetFamilyMask () const
 Return the collision mask for this model. More...
 
virtual void SetFamilyMask (short int mask)
 Set the collision mask for this model. More...
 
virtual void SetSafeMargin (double amargin)
 Set the suggested collision 'inward safe margin' for the shapes to be added from now on. More...
 
virtual float GetSafeMargin ()
 Returns the inward safe margin (see SetSafeMargin() )
 
virtual void SetEnvelope (double amargin)
 Set the suggested collision outward 'envelope' used from shapes added from now on. More...
 
virtual float GetEnvelope ()
 Return the outward safe margin (see SetEnvelope() )
 
virtual void ArchiveOut (ChArchiveOut &marchive)
 Method to allow serialization of transient data to archives.
 
virtual 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< std::shared_ptr< ChCollisionShape > > & GetShapes () const
 Get the list of collision shapes in this model.
 
std::shared_ptr< ChCollisionShapeGetShape (int index)
 Get the collision shape with specified index.
 
void SetShapeMaterial (int index, std::shared_ptr< ChMaterialSurface > mat)
 Set the contact material for 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...
 

Public Attributes

std::vector< real3local_convex_data
 
ChVector aabb_min
 
ChVector aabb_max
 

Protected Attributes

ChBodymbody
 
- Protected Attributes inherited from chrono::collision::ChCollisionModel
float model_envelope
 Maximum envelope: surrounding volume from surface to the exterior.
 
float model_safe_margin
 Maximum margin value to be used for fast penetration contact detection.
 
ChContactablemcontactable
 Pointer to the contactable object.
 
short int family_group
 Collision family group.
 
short int family_mask
 Collision family mask.
 
std::vector< std::shared_ptr< ChCollisionShape > > m_shapes
 list of collision shapes in model
 

Additional Inherited Members

- Static Public Member Functions inherited from chrono::collision::ChCollisionModel
static void SetDefaultSuggestedEnvelope (double menv)
 Using this function BEFORE you start creating collision shapes, it will make all following collision shapes to take this collision envelope (safe outward layer) as default. More...
 
static void SetDefaultSuggestedMargin (double mmargin)
 Using this function BEFORE you start creating collision shapes, it will make all following collision shapes to take this collision margin (inward penetration layer) as default. More...
 
static double GetDefaultSuggestedEnvelope ()
 
static double GetDefaultSuggestedMargin ()
 
- Protected Member Functions inherited from chrono::collision::ChCollisionModel
void CopyShapes (ChCollisionModel *other)
 Copy the collision shapes from another model.
 
virtual float GetSuggestedFullMargin ()
 

Member Function Documentation

◆ AddBarrel()

bool chrono::collision::ChCollisionModelChrono::AddBarrel ( std::shared_ptr< ChMaterialSurface material,
double  Y_low,
double  Y_high,
double  axis_vert,
double  axis_hor,
double  R_offset,
const ChVector<> &  pos = ChVector<>(),
const ChMatrix33<> &  rot = ChMatrix33<>(1) 
)
overridevirtual

Add a barrel-like shape to this collision model (main axis on Y direction).

The barrel shape is made by lathing an arc of an ellipse around the vertical Y axis. The center of the ellipse is on Y=0 level, and it is offsetted by R_offset from the Y axis in radial direction. The two axes of the ellipse are axis_vert (for the vertical direction, i.e. the axis parallel to Y) and axis_hor (for the axis that is perpendicular to Y). Also, the solid is clamped with two discs on the top and the bottom, at levels Y_low and Y_high. Currently not supported.

Parameters
materialsurface contact material
Y_lowbottom level
Y_hightop level
axis_vertellipse axis in vertical direction
axis_horellipse axis in horizontal direction
R_offsetlateral offset (radius at top and bottom)
poscenter position in model coordinates
rotrotation in model coordinates

Implements chrono::collision::ChCollisionModel.

◆ AddBox()

bool chrono::collision::ChCollisionModelChrono::AddBox ( std::shared_ptr< ChMaterialSurface material,
double  size_x,
double  size_y,
double  size_z,
const ChVector<> &  pos = ChVector<>(),
const ChMatrix33<> &  rot = ChMatrix33<>(1) 
)
overridevirtual

Add a box shape to this collision model.

Parameters
materialsurface contact material
size_xx dimension
size_yy dimension
size_zz dimension
poscenter position in model coordinates
rotrotation in model coordinates

Implements chrono::collision::ChCollisionModel.

Reimplemented in chrono::collision::ChCollisionModelDistributed.

◆ AddCapsule()

bool chrono::collision::ChCollisionModelChrono::AddCapsule ( std::shared_ptr< ChMaterialSurface material,
double  radius,
double  height,
const ChVector<> &  pos = ChVector<>(),
const ChMatrix33<> &  rot = ChMatrix33<>(1) 
)
overridevirtual

Add a capsule to this collision model (axis in Z direction).

Parameters
materialsurface contact material
radiusradius
heightheight of cylindrical portion
poscenter position in model coordinates
rotrotation in model coordinates

Implements chrono::collision::ChCollisionModel.

◆ AddCone()

bool chrono::collision::ChCollisionModelChrono::AddCone ( std::shared_ptr< ChMaterialSurface material,
double  radius,
double  height,
const ChVector<> &  pos = ChVector<>(),
const ChMatrix33<> &  rot = ChMatrix33<>(1) 
)
overridevirtual

Add a cone to this collision model (axis in Z direction).

Parameters
materialsurface contact material
radiusradius
heightheight
posbase center position in model coordinates
rotrotation in model coordinates

Implements chrono::collision::ChCollisionModel.

◆ AddConvexHull()

bool chrono::collision::ChCollisionModelChrono::AddConvexHull ( std::shared_ptr< ChMaterialSurface material,
const std::vector< ChVector< double >> &  pointlist,
const ChVector<> &  pos = ChVector<>(),
const ChMatrix33<> &  rot = ChMatrix33<>(1) 
)
overridevirtual

Add a convex hull to this collision model.

A convex hull is simply a point cloud that describe a convex polytope. Connectivity between the vertexes, as faces/edges in triangle meshes is not necessary. Points are passed as a list which is then copied into the model.

Parameters
materialsurface contact material
pointlistlist of hull points
posorigin position in model coordinates
rotrotation in model coordinates

Implements chrono::collision::ChCollisionModel.

◆ AddCylinder()

bool chrono::collision::ChCollisionModelChrono::AddCylinder ( std::shared_ptr< ChMaterialSurface material,
double  radius,
double  height,
const ChVector<> &  pos = ChVector<>(),
const ChMatrix33<> &  rot = ChMatrix33<>(1) 
)
overridevirtual

Add a cylinder to this collision model (axis in Z direction).

Parameters
materialsurface contact material
radiusradius
heightheight
poscenter position in model coordinates
rotrotation in model coordinates

Implements chrono::collision::ChCollisionModel.

◆ AddCylindricalShell()

bool chrono::collision::ChCollisionModelChrono::AddCylindricalShell ( std::shared_ptr< ChMaterialSurface material,
double  radius,
double  height,
const ChVector<> &  pos = ChVector<>(),
const ChMatrix33<> &  rot = ChMatrix33<>(1) 
)
overridevirtual

Add a cylindrical shell to this collision model (axis in Z direction).

Parameters
materialsurface contact material
radiusradius
heightheight
poscenter position in model coordinates
rotrotation in model coordinates

Implements chrono::collision::ChCollisionModel.

◆ AddEllipsoid()

bool chrono::collision::ChCollisionModelChrono::AddEllipsoid ( std::shared_ptr< ChMaterialSurface material,
double  axis_x,
double  axis_y,
double  axis_z,
const ChVector<> &  pos = ChVector<>(),
const ChMatrix33<> &  rot = ChMatrix33<>(1) 
)
overridevirtual

Add an ellipsoid shape to this collision model.

Parameters
materialsurface contact material
axis_xx axis length
axis_yy axis length
axis_zz axis length
poscenter position in model coordinates
rotrotation in model coordinates

Implements chrono::collision::ChCollisionModel.

◆ AddRoundedBox()

bool chrono::collision::ChCollisionModelChrono::AddRoundedBox ( std::shared_ptr< ChMaterialSurface material,
double  size_x,
double  size_y,
double  size_z,
double  sphere_r,
const ChVector<> &  pos = ChVector<>(),
const ChMatrix33<> &  rot = ChMatrix33<>(1) 
)
overridevirtual

Add a rounded box shape to this collision model.

Parameters
materialsurface contact material
size_xx dimension
size_yy dimension
size_zz dimension
sphere_rradius of sweeping sphere
poscenter position in model coordinates
rotrotation in model coordinates

Implements chrono::collision::ChCollisionModel.

◆ AddRoundedCylinder()

bool chrono::collision::ChCollisionModelChrono::AddRoundedCylinder ( std::shared_ptr< ChMaterialSurface material,
double  radius,
double  height,
double  sphere_r,
const ChVector<> &  pos = ChVector<>(),
const ChMatrix33<> &  rot = ChMatrix33<>(1) 
)
overridevirtual

Add a rounded cylinder to this collision model (axis in Z direction).

Parameters
materialsurface contact material
radiusradius
heightheight
sphere_rradius of sweeping sphere
poscenter position in model coordinates
rotrotation in model coordinates

Implements chrono::collision::ChCollisionModel.

◆ AddSphere()

bool chrono::collision::ChCollisionModelChrono::AddSphere ( std::shared_ptr< ChMaterialSurface material,
double  radius,
const ChVector<> &  pos = ChVector<>() 
)
overridevirtual

Add a sphere shape to this collision model.

Parameters
materialsurface contact material
radiussphere radius
poscenter position in model coordinates

Implements chrono::collision::ChCollisionModel.

Reimplemented in chrono::collision::ChCollisionModelDistributed.

◆ AddTriangle()

bool chrono::collision::ChCollisionModelChrono::AddTriangle ( std::shared_ptr< ChMaterialSurface material,
ChVector<>  A,
ChVector<>  B,
ChVector<>  C,
const ChVector<> &  pos = ChVector<>(),
const ChMatrix33<> &  rot = ChMatrix33<>(1) 
)
virtual

Add a triangle shape to this model, for collision purposes.

Parameters
materialsurface contact material
Atriangle vertex A
Btriangle vertex B
Ctriangle vertex C
poscenter position in model coordinates
rotrotation in model coordinates

Reimplemented in chrono::collision::ChCollisionModelDistributed.

◆ AddTriangleMesh()

bool chrono::collision::ChCollisionModelChrono::AddTriangleMesh ( std::shared_ptr< ChMaterialSurface material,
std::shared_ptr< geometry::ChTriangleMesh trimesh,
bool  is_static,
bool  is_convex,
const ChVector<> &  pos = ChVector<>(),
const ChMatrix33<> &  rot = ChMatrix33<>(1),
double  sphereswept_thickness = 0.0 
)
overridevirtual

Add a triangle mesh to this collision model.

Add a triangle mesh to this model.

Note: if possible, for better performance, avoid triangle meshes and prefer simplified representations as compounds of primitive convex shapes (boxes, sphers, etc).

Parameters
materialsurface contact material
trimeshthe triangle mesh
is_statictrue if model doesn't move. May improve performance.
is_convexif true, a convex hull is used. May improve robustness.
posorigin position in model coordinates
rotrotation in model coordinates
sphereswept_thicknessoutward sphere-swept layer (when supported)

Implements chrono::collision::ChCollisionModel.

◆ BuildModel()

int chrono::collision::ChCollisionModelChrono::BuildModel ( )
overridevirtual

Builds the BV hierarchy.

Call this function AFTER adding the geometric description. MUST be inherited by child classes! (ex for bulding BV hierarchies)

Implements chrono::collision::ChCollisionModel.

◆ ClearModel()

int chrono::collision::ChCollisionModelChrono::ClearModel ( )
overridevirtual

Deletes all inserted geometries.

Also, if you begin the definition of a model, AFTER adding the geometric description, remember to call the ClearModel(). MUST be inherited by child classes! (ex for resetting also BV hierarchies)

Implements chrono::collision::ChCollisionModel.

Reimplemented in chrono::collision::ChCollisionModelDistributed.

◆ GetShapeDimensions()

std::vector< double > chrono::collision::ChCollisionModelChrono::GetShapeDimensions ( int  index) const
overridevirtual

Return shape characteristic dimensions.

The following collision shapes are supported:

SPHERE       radius
BOX          x-halfdim y-halfdim z-halfdim
ELLIPSOID    x-radius y-radius z-radius
CYLINDER     x-radius z-radius halflength
CYLSHELL     radius halflength
CONE         x-radius z-radius halfheight
CAPSULE      radius halflength
ROUNDEDBOX   x-halfdim y-halfdim z-halfdim sphere_rad
ROUNDEDCYL   x-radius z-radius halflength sphere_rad

Implements chrono::collision::ChCollisionModel.


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