Description
Class containing the geometric model ready for collision detection.
Each rigid body will have a ChCollisionModel. A ChCollisionModel will contain all the geometric description(s) of the shape of the rigid body, for collision purposes.
#include <ChCCollisionModel.h>
Public Member Functions | |
virtual int | ClearModel ()=0 |
Deletes all inserted geometries. More... | |
virtual int | BuildModel ()=0 |
Builds the BV hierarchy. More... | |
virtual bool | AddSphere (double radius, const ChVector<> &pos=ChVector<>())=0 |
Add a sphere shape to this model, for collision purposes. More... | |
virtual bool | AddEllipsoid (double rx, double ry, double rz, const ChVector<> &pos=ChVector<>(), const ChMatrix33<> &rot=ChMatrix33<>(1))=0 |
Add an ellipsoid shape to this model, for collision purposes. More... | |
virtual bool | AddBox (double hx, double hy, double hz, const ChVector<> &pos=ChVector<>(), const ChMatrix33<> &rot=ChMatrix33<>(1))=0 |
Add a box shape to this model, for collision purposes. More... | |
virtual bool | AddCylinder (double rx, double rz, double hy, const ChVector<> &pos=ChVector<>(), const ChMatrix33<> &rot=ChMatrix33<>(1))=0 |
Add a cylinder to this model (default axis on Y direction), for collision purposes. | |
virtual bool | AddCone (double rx, double rz, double hy, const ChVector<> &pos=ChVector<>(), const ChMatrix33<> &rot=ChMatrix33<>(1))=0 |
Add a cone to this model (default axis on Y direction), for collision purposes. | |
virtual bool | AddCapsule (double radius, double hlen, const ChVector<> &pos=ChVector<>(), const ChMatrix33<> &rot=ChMatrix33<>(1))=0 |
Add a capsule to this model (default axis in Y direction), for collision purposes. More... | |
virtual bool | AddRoundedBox (double hx, double hy, double hz, double sphere_r, const ChVector<> &pos=ChVector<>(), const ChMatrix33<> &rot=ChMatrix33<>(1))=0 |
Add a rounded box shape to this model, for collision purposes. | |
virtual bool | AddRoundedCylinder (double rx, double rz, double hy, double sphere_r, const ChVector<> &pos=ChVector<>(), const ChMatrix33<> &rot=ChMatrix33<>(1))=0 |
Add a rounded cylinder to this model (default axis on Y direction), for collision purposes. | |
virtual bool | AddRoundedCone (double rx, double rz, double hy, double sphere_r, const ChVector<> &pos=ChVector<>(), const ChMatrix33<> &rot=ChMatrix33<>(1))=0 |
Add a rounded cone to this model (default axis on Y direction), for collision purposes. | |
virtual bool | AddConvexHull (const std::vector< ChVector< double > > &pointlist, const ChVector<> &pos=ChVector<>(), const ChMatrix33<> &rot=ChMatrix33<>(1))=0 |
Add a convex hull to this model. More... | |
virtual bool | AddTriangleMesh (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)=0 |
Add a triangle mesh to this model, passing a triangle mesh. More... | |
virtual bool | AddBarrel (double Y_low, double Y_high, double R_vert, double R_hor, double R_offset, const ChVector<> &pos=ChVector<>(), const ChMatrix33<> &rot=ChMatrix33<>(1))=0 |
Add a barrel-like shape to this model (main axis on Y direction), for collision purposes. More... | |
virtual bool | Add2Dpath (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 (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 | AddCopyOfAnotherModel (ChCollisionModel *another)=0 |
Add all shapes already contained in another model. More... | |
virtual bool | AddConvexHullsFromFile (ChStreamInAscii &mstream, const ChVector<> &pos=ChVector<>(), const ChMatrix33<> &rot=ChMatrix33<>(1)) |
Add a cluster of convex hulls by a '.chulls' file description. More... | |
ChContactable * | GetContactable () |
Gets the pointer to the contactable object. | |
virtual void | SetContactable (ChContactable *mc) |
Sets the pointer to the contactable object. More... | |
virtual ChPhysicsItem * | GetPhysicsItem () |
Gets the pointer to the client owner ChPhysicsItem. More... | |
virtual void | SyncPosition ()=0 |
Sets the position and orientation of the collision model as the rigid body current position. 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) |
Sets the suggested collision 'inward safe margin' for the shapes to be added from now on, using the AddBox, AddCylinder etc (where, if this margin is too high for some thin or small shapes, it may be clamped). More... | |
virtual float | GetSafeMargin () |
Returns the inward safe margin (see SetSafeMargin() ) | |
virtual void | SetEnvelope (double amargin) |
Sets the suggested collision outward 'envelope' (used from shapes added, from now on, to this collision model). More... | |
virtual float | GetEnvelope () |
Returns the outward safe margin (see SetEnvelope() ) | |
virtual void | GetAABB (ChVector<> &bbmin, ChVector<> &bbmax) const =0 |
Returns the axis aligned bounding box (AABB) of the collision model, i.e. More... | |
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. | |
Static Public Member Functions | |
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 | |
virtual float | GetSuggestedFullMargin () |
Protected Attributes | |
float | model_envelope |
float | model_safe_margin |
ChContactable * | mcontactable |
short int | family_group |
short int | family_mask |
Member Function Documentation
◆ Add2Dpath()
|
inlinevirtual |
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.
This is useful for mechanisms that work on a plane, and that require more precise collision that is not possible with current 3D shapes. For example, the line can contain concave or convex round fillets. Requirements:
- the line must be clockwise for inner material, (counterclockwise=hollow, material outside)
- the line must contain only ChLineSegment and ChLineArc sub-lines
- the sublines must follow in the proper order, with coincident corners, and must be closed.
Reimplemented in chrono::collision::ChModelBullet.
◆ AddBarrel()
|
pure virtual |
Add a barrel-like shape to this model (main axis on Y direction), for collision purposes.
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 radii of the ellipse are R_vert (for the vertical direction, i.e. the axis parallel to Y) and R_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.
Implemented in chrono::collision::ChModelBullet, and chrono::collision::ChCollisionModelParallel.
◆ AddBox()
|
pure virtual |
Add a box shape to this model, for collision purposes.
- Parameters
-
hx the halfsize on x axis hy the halfsize on y axis hz the halfsize on z axis pos the position of the box COG rot the rotation of the box - matrix must be orthogonal
Implemented in chrono::collision::ChCollisionModelParallel, chrono::collision::ChModelBullet, and chrono::collision::ChCollisionModelDistributed.
◆ AddCapsule()
|
pure virtual |
Add a capsule to this model (default axis in Y direction), for collision purposes.
- Parameters
-
radius capsule radius hlen half-length of capsule axis pos the position of the ellipsoid rot the matrix defining rotation (orthogonal)
Implemented in chrono::collision::ChCollisionModelParallel, and chrono::collision::ChModelBullet.
◆ AddConvexHull()
|
pure virtual |
Add a convex hull to this 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, that is instantly copied into the model.
Implemented in chrono::collision::ChCollisionModelParallel.
◆ AddConvexHullsFromFile()
|
virtual |
Add a cluster of convex hulls by a '.chulls' file description.
The file is an ascii text that contains many lines with "[x] [y] [z]" coordinates of the convex hulls. Hulls are separated by lines with "hull". Inherited classes should not need to implement/overload this, because this base implementation basically calls AddConvexHull() n times while parsing the file, that is enough.
◆ AddCopyOfAnotherModel()
|
pure virtual |
Add all shapes already contained in another model.
If possible, child classes implement this so that underlying shapes are shared (not copied) among the models.
Implemented in chrono::collision::ChModelBullet, and chrono::collision::ChCollisionModelParallel.
◆ AddEllipsoid()
|
pure virtual |
Add an ellipsoid shape to this model, for collision purposes.
- Parameters
-
rx the rad on x axis ry the rad on y axis rz the rad on z axis pos the position of the ellipsoid rot the matrix defining rotation (orthogonal)
Implemented in chrono::collision::ChCollisionModelParallel, and chrono::collision::ChModelBullet.
◆ AddPoint()
|
inlinevirtual |
Add a point-like sphere, that will collide with other geometries, but won't ever create contacts between them.
- Parameters
-
radius the radius of the node pos the position of the node in model coordinates
Reimplemented in chrono::collision::ChModelBullet.
◆ AddSphere()
|
pure virtual |
Add a sphere shape to this model, for collision purposes.
- Parameters
-
radius the radius of the sphere pos the position of the sphere in model coordinates
Implemented in chrono::collision::ChCollisionModelParallel, chrono::collision::ChModelBullet, and chrono::collision::ChCollisionModelDistributed.
◆ AddTriangleMesh()
|
pure virtual |
Add a triangle mesh to this model, passing a triangle mesh.
Note: if possible, for better performance, avoid triangle meshes and prefer simplified representations as compounds of primitive convex shapes (boxes, sphers, etc).
- Parameters
-
trimesh the triangle mesh is_static true if model doesn't move. May improve performance. is_convex if true, a convex hull is used. May improve robustness. pos displacement respect to COG rot the rotation of the mesh sphereswept_thickness outward sphere-swept layer (when supported)
Implemented in chrono::collision::ChCollisionModelParallel, and chrono::collision::ChModelBullet.
◆ BuildModel()
|
pure virtual |
Builds the BV hierarchy.
Call this function AFTER adding the geometric description. MUST be inherited by child classes! (ex for building BV hierarchies)
Implemented in chrono::collision::ChCollisionModelParallel, and chrono::collision::ChModelBullet.
◆ ClearModel()
|
pure virtual |
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)
Implemented in chrono::collision::ChCollisionModelParallel, chrono::collision::ChModelBullet, and chrono::collision::ChCollisionModelDistributed.
◆ GetAABB()
|
pure virtual |
Returns the axis aligned bounding box (AABB) of the collision model, i.e.
max-min along the x,y,z world axes. Remember that SyncPosition() should be invoked before calling this. MUST be implemented by child classes!
Implemented in chrono::collision::ChModelBullet, chrono::collision::ChCollisionModelParallel, and chrono::collision::ChCollisionModelDistributed.
◆ GetFamilyGroup()
|
inlinevirtual |
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()
|
inlinevirtual |
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).
◆ GetFamilyMaskDoesCollisionWithFamily()
|
virtual |
Tells if the family mask of this collision object allows for the collision with another collision object belonging to a given family.
NOTE: this function has NO effect if used before you add the body to a ChSystem, using AddBody(). Use after AddBody(). This default implementation uses the family mask.
Reimplemented in chrono::collision::ChModelBullet.
◆ GetPhysicsItem()
|
virtual |
Gets the pointer to the client owner ChPhysicsItem.
Default: just casts GetContactable(). Just for backward compatibility. It might return null if contactable not inherited by ChPhysicsItem. TODO remove the need of ChPhysicsItem*, just use ChContactable* in all code
◆ SetContactable()
|
inlinevirtual |
Sets the pointer to the contactable object.
A derived class may override this, but should always invoke this base class implementation.
Reimplemented in chrono::collision::ChCollisionModelParallel.
◆ SetDefaultSuggestedEnvelope()
|
static |
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.
Easier than calling SetEnvelope() all the times.
◆ SetDefaultSuggestedMargin()
|
static |
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.
If you call it again later, it will have no effect, except for shapes created later. Easier than calling SetMargin() all the times.
◆ SetEnvelope()
|
inlinevirtual |
Sets the suggested collision outward 'envelope' (used from shapes added, from now on, to this collision model).
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()
|
virtual |
By default, all collision objects belong to family n.0, but you can set family in range 0..15.
This is used when the objects collided with another: the contact is created only if the family is within the 'family mask' of the other, and viceversa. NOTE: these functions have NO effect if used before you add the body to a ChSystem, using AddBody(). Use after AddBody(). These default implementations use the family group.
Reimplemented in chrono::collision::ChModelBullet.
◆ SetFamilyGroup()
|
virtual |
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.
Reimplemented in chrono::collision::ChModelBullet.
◆ SetFamilyMask()
|
virtual |
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.
Reimplemented in chrono::collision::ChModelBullet.
◆ SetFamilyMaskNoCollisionWithFamily()
|
virtual |
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. NOTE: these functions have NO effect if used before you add the body to a ChSystem, using AddBody(). Use after AddBody(). These default implementations use the family mask.
Reimplemented in chrono::collision::ChModelBullet.
◆ SetSafeMargin()
|
inlinevirtual |
Sets the suggested collision 'inward safe margin' for the shapes to be added from now on, using the AddBox, AddCylinder etc (where, if this margin is too high for some thin or small shapes, it may be clamped).
If dist<0 and interpretation occurs (ex.for 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 at the margin as a radius of a 'smoothing' fillet on all corners of the shapes - that's why you cannot exceed with this.
◆ SyncPosition()
|
pure virtual |
Sets the position and orientation of the collision model as the rigid body current position.
By default it uses GetCsysForCollisionModel
Implemented in chrono::collision::ChModelBullet, and chrono::collision::ChCollisionModelParallel.
The documentation for this class was generated from the following files:
- /builds/uwsbel/chrono/src/chrono/collision/ChCCollisionModel.h
- /builds/uwsbel/chrono/src/chrono/collision/ChCCollisionModel.cpp