AGX Dynamics  2.38.0.2
Shovel.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2024. Algoryx Simulation AB.
3 
4 All AGX source code, intellectual property, documentation, sample code,
5 tutorials, scene files and technical white papers, are copyrighted, proprietary
6 and confidential material of Algoryx Simulation AB. You may not download, read,
7 store, distribute, publish, copy or otherwise disseminate, use or expose this
8 material unless having a written signed agreement with Algoryx Simulation AB, or having been
9 advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10 valid commercial license from Algoryx Simulation AB.
11 
12 Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13 from using this software, unless otherwise stated in written agreements with
14 Algoryx Simulation AB.
15 */
16 
17 #pragma once
18 
19 #include <agx/BitState.h>
23 
24 #include <agxStream/Serializable.h>
25 
26 namespace agxCollide
27 {
28  class Geometry;
29  class Shape;
30 }
31 
32 namespace agxTerrain
33 {
34  class Terrain;
35  class TerrainMaterial;
36  class TerrainToolCollection;
37 
51  {
52  public:
53  class ExcavationSettings;
54 
55 
71  Shovel(agx::RigidBody* shovelBody,
72  const agx::Line& topEdge,
73  const agx::Line& cuttingEdge,
74  const agx::Vec3& cuttingDirection,
75  Shovel* connectedShovel=nullptr);
76 
92  {
93  PRIMARY = 0,
94  DEFORM_BACK = 1,
95  DEFORM_RIGHT = 2,
96  DEFORM_LEFT = 3
97  };
98 
102  agx::RigidBody* getRigidBody() const;
103 
107  ExcavationSettings& getExcavationSettings(ExcavationMode mode);
108 
112  agx::Line getTopEdge() const;
113 
117  agx::Line getTopEdgeWorld() const;
118 
122  agx::Line getCuttingEdge() const;
123 
127  agx::Line getCuttingEdgeWorld() const;
128 
132  agx::Vec3 getCuttingDirection() const;
133 
137  agx::Vec3 getCuttingDirectionWorld() const;
138 
142  agx::Real getToothLength() const;
143 
147  agx::Real getToothMinimumRadius() const;
148 
152  agx::Real getToothMaximumRadius() const;
153 
157  agx::UInt getNumberOfTeeth() const;
158 
162  agx::Real computeCuttingEdgeLength() const;
163 
180  void setExcavationSettings( ExcavationMode mode, ExcavationSettings excavationSettings );
181 
186  void setTopEdge(agx::Line topEdge);
187 
192  void setCuttingEdge(agx::Line cuttingEdge);
193 
197  void setCuttingDirection(agx::Vec3 cuttingDirection);
198 
202  void setToothLength(agx::Real length);
203 
207  void setToothMinimumRadius(agx::Real radius);
208 
212  void setToothMaximumRadius(agx::Real radius);
213 
217  void setNumberOfTeeth(agx::UInt count);
218 
222  void setNoMergeExtensionDistance(agx::Real extensionDistance);
223 
227  void setMinimumSubmergedContactLengthFraction(agx::Real minimumSubmergedContactLengthFraction);
228 
232  agx::Plane getCurrentSeparationPlane( Terrain* terrain, ExcavationMode mode ) const;
233 
237  agx::Real getMinimumSubmergedContactLengthFraction() const;
238 
242  agx::Real getNoMergeExtensionDistance() const;
243 
248  void setVerticalBladeSoilMergeDistance(agx::Real verticalSoilBladeMergeDistance);
249 
255  void setSecondarySeparationDeadloadLimit( agx::Real secondarySeparationLimit );
256 
261  agx::Real getVerticalBladeSoilMergeDistance() const;
262 
274  bool getSoilPenetrationModel(agxTerrain::Terrain* terrain, agxTerrain::SoilPenetrationResistance::PenetrationModel& model) const;
275 
285  void setPenetrationDepthThreshold(agx::Real depthThreshold);
286 
298  bool setSoilPenetrationModel(agxTerrain::SoilPenetrationResistance::PenetrationModel model, agxTerrain::Terrain* terrain);
299 
309  agx::Real getPenetrationDepthThreshold() const;
310 
315  void setPenetrationForceScaling(agx::Real penetrationForceScaling);
316 
320  agx::Real getPenetrationForceScaling() const;
321 
328  void setEnableParticleFreeDeformers(bool enable);
329 
333  bool getEnableParticleFreeDeformers() const;
334 
339  void setAlwaysRemoveShovelContacts(bool enable);
340 
344  bool getAlwaysRemoveShovelContacts() const;
345 
350  void setMaxPenetrationForce(agx::Real maxPenetrationForce);
351 
356  agx::Real getMaxPenetrationForce() const;
357 
362  agx::Real getSecondarySeparationDeadloadLimit() const;
363 
367  agx::Vec3 getSecondaryCuttingDirection( Terrain* terrain ) const;
368 
372  agx::Real getSecondarySeparationAngle( Terrain* terrain ) const;
373 
379  agx::Real getDeadLoadFraction() const;
380 
387  agx::Real getInnerContactArea() const;
388 
397  void setContactRegionThreshold( agx::Real contactRegionThreshold );
398 
406  agx::Real getContactRegionThreshold() const;
407 
415  void setContactRegionVerticalLimit( agx::Real verticalLimit );
416 
417  /*
418  Get the maximum vertical distance from the shovel bottom plane where regular geometry
419  contacts between the shovel and the terrain are allowed to be created. Contacts past that distance
420  will be filtered away.
421  \return the maximum vertical distance from the shovel bottom plane where regular geometry
422  contacts between the shovel and the terrain are allowed to be created
423  */
424  agx::Real getContactRegionVerticalLimit() const;
425 
432  void setEnableInnerShapeCreateDynamicMass( bool enable );
433 
439  bool getEnableInnerShapeCreateDynamicMass() const;
440 
447  void setEnableParticleForceFeedback( bool enable );
448 
453  bool getEnableParticleForceFeedback();
454 
460  void setEnable(bool enable);
461 
466  bool getEnable() const;
467 
468 
475  agx::Real getParticleInclusionMultiplier() const;
476 
477  /*
478  Get the radius multiplier for extending the inclusion bound with
479  particle radius during post-excavation with particles in bucket.
480  \param radiusMultiplier - The multiplier for the particle radius
481  extension of the shovel inclusion
482  bound. (Default: 1.0)
483  \note - This will only be active pos-excavation and NOT during excavation
484  when we have active soil wedges.
485  */
486  void setParticleInclusionMultiplier( agx::Real radiusMultiplier );
487 
488  public:
489 
494  {
495  public:
500 
506 
511  void setEnable(bool enable);
512 
517  void setEnableCreateDynamicMass(bool enable);
518 
523  void setEnableForceFeedback(bool enable);
524 
528  bool getEnable() const;
529 
533  bool getEnableForceFeedback() const;
534 
538  bool getEnableCreateDynamicMass() const;
539 
543  agx::UInt32 getState() const;
544 
545  void store( agxStream::OutputArchive& out ) const { m_settings.store( out ); }
546  void restore( agxStream::InputArchive& in ) { m_settings.restore( in ); }
547 
548  private:
549  enum StateFlags : agx::UInt32
550  {
551  ENABLED = 1 << 0,
552  ENABLE_CREATE_DYNAMIC_MASS = 1 << 1,
553  ENABLE_FORCE_FEEDBACK = 1 << 2,
554  };
555  using Flags = agx::BitState<StateFlags, agx::UInt32>;
556  Flags m_settings;
557  };
558 
559  public:
560 
566  agx::Bool initializeCollection( TerrainToolCollection* collection, agxSDK::Simulation* simulation );
567 
572  void uninitializeCollection( TerrainToolCollection* collection, agxSDK::Simulation* simulation );
573 
578  void onPre( TerrainToolCollection* collection );
579 
584  void onPost( TerrainToolCollection* collection );
585 
586  bool getShovelPlanes(TerrainToolCollection* collection,
587  agx::Plane& bottomPlane,
588  agx::Plane& backPlane,
589  agx::Plane& leftPlane,
590  agx::Plane& rightPlane);
591 
592  void removeTerrainShovelContacts(TerrainToolCollection* collection);
593 
594  void removeTerrainShovelContactsDeformer(TerrainToolCollection* collection);
595 
596  bool isEdgeSubmerged(const agx::Line& edge, const Terrain* terrain) const;
597 
598  bool isEdgeSubmergedInSolid(const agx::Line& edge, const Terrain* terrain) const;
599 
600  bool isEdgeSubmergedInHeightfield(const agx::Line& edge, const agxCollide::HeightField* heightfield, const Terrain* terrain) const;
601 
602  agx::Real getSubmergedEdgeLength(const agx::Line& edge, const Terrain* terrain) const;
603 
604  agx::Vec3 getCuttingEdgeVelocity();
605 
606  void correctShovelVectors();
607 
608  void calculateDeadLoadFraction( const Terrain* terrain,
609  const ActiveZone* activeZone,
610  const agx::Physics::GranularBodyPtrVector& innerParticles );
611 
612  void setInnerContactArea( agx::Real contactArea );
613 
614  void setSettingsAreDirty(bool enable);
615 
616  bool getSettingsAreDirty() const;
617 
618  agx::Real computeDefaultContactRegionThreshold() const;
619 
620  Shovel* getConnectedShovel();
621 
624 
625  protected:
629  Shovel();
630 
634  virtual ~Shovel();
635 
636  agxCollide::GeometryRefVector createVoxelCollisionGeometries( agx::Real tessellationLevel ) const;
637 
638  protected:
640  {
644  };
645 
647  {
648  ENABLED = 1 << 0,
649  REMOVE_SHOVEL_CONTACTS = 1 << 1,
650  INNER_SHAPE_CREATE_DYNAMIC_MASS = 1 << 2,
651  ENABLE_PARTICLE_FREE_DEFORMATION = 1 << 3,
652  ENABLE_PARTICLE_FORCE_FEEDBACK = 1 << 4
653  };
654  using Flags = agx::BitState<StateFlags, agx::UInt32>;
655 
671 
672  std::array< ExcavationSettings, 4 > m_excavationSettings;
673 
676 
677  // Caching of dead load
679  // Caching of inner contact area
681 
682  // Geometries used to find shovel-voxel collisions
685 
687  };
688 }
agxTerrain::Shovel::SoilPenetrationParameters::maxForce
agx::Real maxForce
Definition: Shovel.h:643
agx::UInt
uint64_t UInt
Definition: Integer.h:27
agxTerrain::Shovel::m_particleInclusionMultiplier
agx::Real m_particleInclusionMultiplier
Definition: Shovel.h:668
agxTerrain::Shovel::SoilPenetrationParameters::forceScaling
agx::Real forceScaling
Definition: Shovel.h:642
agxTerrain::Terrain
A terrain model based a 3D grid model with overlapping height field that can be deformed by interacti...
Definition: Terrain.h:85
agx::Real
double Real
Definition: Real.h:42
agxTerrain::Shovel::m_flags
Flags m_flags
Definition: Shovel.h:669
agx::Physics::GranularBodyPtrVector
agx::VectorPOD< GranularBodyPtr > GranularBodyPtrVector
Definition: GranularBodyEntity.h:296
agx::Vector< agx::ref_ptr< Geometry > >
PrimaryActiveZone.h
agxStream::out
OutputRef< Serializable > out(const char *name, const Serializable *obj)
Return an object that contain the name and the object that should be serialized to an archive.
Definition: OutputArchive.h:412
BitState.h
agxTerrain
The agxTerrain namespace contains a 3D model for a dynamic deformable Terrain and related classes.
Definition: Geometry.h:58
agx::RigidBody
The rigid body class, combining a geometric model and a frame of reference.
Definition: RigidBody.h:51
agxStream::Serializable
This class is an abstract base class for all classes that can be stored and retrieved from an Archive...
Definition: Serializable.h:44
agxRender::Flags
Flags
Flags for specifying what is enabled in the debug rendering system.
Definition: RenderManager.h:58
DOXYGEN_END_INTERNAL_BLOCK
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: macros.h:97
agxTerrain::Shovel
Definition: Shovel.h:50
DOXYGEN_START_INTERNAL_BLOCK
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: macros.h:96
agxTerrain::Shovel::m_nTeeth
agx::UInt m_nTeeth
Definition: Shovel.h:663
agxTerrain::Shovel::m_noMergeExtensionDistance
agx::Real m_noMergeExtensionDistance
Definition: Shovel.h:664
SoilPenetrationResistance.h
agxTerrain::Shovel::ExcavationMode
ExcavationMode
Enum for describing the different excavation modes of a shovel: PRIMARY - The primary mode of excavat...
Definition: Shovel.h:91
agxTerrain::Shovel::m_voxelCollisionGeometries
agxCollide::GeometryRefVector m_voxelCollisionGeometries
Definition: Shovel.h:683
AGXSTREAM_DECLARE_SERIALIZABLE
#define AGXSTREAM_DECLARE_SERIALIZABLE(T)
Use this in a Serializable class to add the required methods Important: Use full namespace in the dec...
Definition: Serializable.h:207
agx::observer_ptr< RigidBody >
agxTerrain::Shovel::m_toothMinRadius
agx::Real m_toothMinRadius
Definition: Shovel.h:661
agx
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
Definition: AddedMassInteraction.h:22
agxTerrain::Shovel::ExcavationSettings::store
void store(agxStream::OutputArchive &out) const
Definition: Shovel.h:545
agxTerrain::Shovel::ExcavationSettings::restore
void restore(agxStream::InputArchive &in)
Definition: Shovel.h:546
agxStream::in
InputRef< T > in(const char *name, T &obj)
Create an object with a name and a reference to the object that should be restored (usually a pointer...
Definition: InputArchive.h:399
agxTerrain::Shovel::m_contactThreshold
agx::Real m_contactThreshold
Definition: Shovel.h:674
agx::PlaneT
Class representing the mathematical concept of a plane, also called a half- space.
Definition: Plane.h:31
AGX_DECLARE_VECTOR_TYPES
#define AGX_DECLARE_VECTOR_TYPES(type)
Definition: Vector.h:34
agxTerrain::Shovel::SoilPenetrationParameters::depthThreshold
agx::Real depthThreshold
Definition: Shovel.h:641
agx::Vec3
Vec3T< Real > Vec3
The object holding 3 dimensional vectors and providing basic arithmetic.
Definition: Vec3.h:36
agxTerrain::Shovel::m_cuttingDirection
agx::Vec3 m_cuttingDirection
Definition: Shovel.h:659
agxTerrain::Shovel::Flags
agx::BitState< StateFlags, agx::UInt32 > Flags
Definition: Shovel.h:654
agxTerrain::SoilPenetrationResistance::PenetrationModel
PenetrationModel
Definition: SoilPenetrationResistance.h:35
agxTerrain::Shovel::m_soilPenetrationParameters
SoilPenetrationParameters m_soilPenetrationParameters
Definition: Shovel.h:670
agxTerrain::Shovel::ExcavationSettings
Class containing the settings for the different ExcavationModes for a shovel.
Definition: Shovel.h:493
agxTerrain::Shovel::m_toothMaxRadius
agx::Real m_toothMaxRadius
Definition: Shovel.h:662
agxTerrain::Shovel::m_minimumSubmergedContactLengthFraction
agx::Real m_minimumSubmergedContactLengthFraction
Definition: Shovel.h:666
agx::LineT
Definition: Line.h:25
agxStream::OutputArchive
Class for writing serialized data in binary format to a stream.
Definition: OutputArchive.h:56
Serializable.h
agxStream::InputArchive
Class for reading a binary stream of serialized data.
Definition: InputArchive.h:50
agxTerrain::Shovel::m_verticalContactThreshold
agx::Real m_verticalContactThreshold
Definition: Shovel.h:675
agx::Line
LineT< Vec3 > Line
Definition: Line.h:39
agx::Referenced
Base class providing referencing counted objects.
Definition: Referenced.h:119
agxTerrain::Shovel::StateFlags
StateFlags
Definition: Shovel.h:646
AGX_DECLARE_POINTER_TYPES
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
AGXTERRAIN_EXPORT
#define AGXTERRAIN_EXPORT
Definition: agxTerrain/export.h:41
agxCollide
This namespace consists of a set of classes for handling geometric intersection tests including boole...
Definition: ContactForceFilterParticipant.h:22
agxTerrain::Shovel::m_cuttingEdge
agx::Line m_cuttingEdge
Definition: Shovel.h:657
agx::Bool
bool Bool
Definition: Integer.h:40
agxTerrain::Shovel::m_settingsAreDirty
bool m_settingsAreDirty
Definition: Shovel.h:684
agxTerrain::Shovel::SoilPenetrationParameters
Definition: Shovel.h:639
agxTerrain::Shovel::m_topEdge
agx::Line m_topEdge
Definition: Shovel.h:658
agxSDK
The agxSDK namespace contain classes to bridge the collision detection system and the dynamical simul...
Definition: Constraint.h:30
agxTerrain::Shovel::m_connectedShovel
Shovel * m_connectedShovel
Definition: Shovel.h:686
agxTerrain::Shovel::m_shovelBody
agx::RigidBodyObserver m_shovelBody
Definition: Shovel.h:656
agx::Vec3T< Real >
SoilParticleAggregate.h
agxTerrain::Shovel::m_excavationSettings
std::array< ExcavationSettings, 4 > m_excavationSettings
Definition: Shovel.h:672
agx::UInt32
uint32_t UInt32
Definition: Integer.h:32
agxCollide::GeometryRefVector
agx::Vector< agx::ref_ptr< Geometry > > GeometryRefVector
Definition: agxcollide_vector_types.h:38
agxTerrain::Shovel::m_toothLength
agx::Real m_toothLength
Definition: Shovel.h:660
agxTerrain::Shovel::m_secondarySeparationDeadLoadLimit
agx::Real m_secondarySeparationDeadLoadLimit
Definition: Shovel.h:667
agxTerrain::Shovel::m_innerContactArea
agx::Real m_innerContactArea
Definition: Shovel.h:680
agx::Plane
PlaneT< agx::Real > Plane
Definition: Plane.h:121
agxTerrain::Shovel::m_verticalSoilBladeMergeDistance
agx::Real m_verticalSoilBladeMergeDistance
Definition: Shovel.h:665
agxTerrain::Shovel::m_deadLoadFraction
agx::Real m_deadLoadFraction
Definition: Shovel.h:678