AGX Dynamics  2.37.2.0
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 
67  Shovel(agx::RigidBody* shovelBody,
68  const agx::Line& topEdge,
69  const agx::Line& cuttingEdge,
70  const agx::Vec3& cuttingDirection);
71 
87  {
88  PRIMARY = 0,
89  DEFORM_BACK = 1,
90  DEFORM_RIGHT = 2,
91  DEFORM_LEFT = 3
92  };
93 
97  agx::RigidBody* getRigidBody() const;
98 
102  ExcavationSettings& getExcavationSettings(ExcavationMode mode);
103 
107  agx::Line getTopEdge() const;
108 
112  agx::Line getTopEdgeWorld() const;
113 
117  agx::Line getCuttingEdge() const;
118 
122  agx::Line getCuttingEdgeWorld() const;
123 
127  agx::Vec3 getCuttingDirection() const;
128 
132  agx::Vec3 getCuttingDirectionWorld() const;
133 
137  agx::Real getToothLength() const;
138 
142  agx::Real getToothMinimumRadius() const;
143 
147  agx::Real getToothMaximumRadius() const;
148 
152  agx::UInt getNumberOfTeeth() const;
153 
157  agx::Real computeCuttingEdgeLength() const;
158 
175  void setExcavationSettings( ExcavationMode mode, ExcavationSettings excavationSettings );
176 
181  void setTopEdge(agx::Line topEdge);
182 
187  void setCuttingEdge(agx::Line cuttingEdge);
188 
192  void setCuttingDirection(agx::Vec3 cuttingDirection);
193 
197  void setToothLength(agx::Real length);
198 
202  void setToothMinimumRadius(agx::Real radius);
203 
207  void setToothMaximumRadius(agx::Real radius);
208 
212  void setNumberOfTeeth(agx::UInt count);
213 
217  void setNoMergeExtensionDistance(agx::Real extensionDistance);
218 
222  void setMinimumSubmergedContactLengthFraction(agx::Real minimumSubmergedContactLengthFraction);
223 
227  agx::Plane getCurrentSeparationPlane( Terrain* terrain, ExcavationMode mode ) const;
228 
232  agx::Real getMinimumSubmergedContactLengthFraction() const;
233 
237  agx::Real getNoMergeExtensionDistance() const;
238 
243  void setVerticalBladeSoilMergeDistance(agx::Real verticalSoilBladeMergeDistance);
244 
250  void setSecondarySeparationDeadloadLimit( agx::Real secondarySeparationLimit );
251 
256  agx::Real getVerticalBladeSoilMergeDistance() const;
257 
269  bool getSoilPenetrationModel(agxTerrain::Terrain* terrain, agxTerrain::SoilPenetrationResistance::PenetrationModel& model) const;
270 
280  void setPenetrationDepthThreshold(agx::Real depthThreshold);
281 
293  bool setSoilPenetrationModel(agxTerrain::SoilPenetrationResistance::PenetrationModel model, agxTerrain::Terrain* terrain);
294 
304  agx::Real getPenetrationDepthThreshold() const;
305 
310  void setPenetrationForceScaling(agx::Real penetrationForceScaling);
311 
315  agx::Real getPenetrationForceScaling() const;
316 
323  void setEnableParticleFreeDeformers(bool enable);
324 
328  bool getEnableParticleFreeDeformers() const;
329 
334  void setAlwaysRemoveShovelContacts(bool enable);
335 
339  bool getAlwaysRemoveShovelContacts() const;
340 
345  void setMaxPenetrationForce(agx::Real maxPenetrationForce);
346 
351  agx::Real getMaxPenetrationForce() const;
352 
357  agx::Real getSecondarySeparationDeadloadLimit() const;
358 
362  agx::Vec3 getSecondaryCuttingDirection( Terrain* terrain ) const;
363 
367  agx::Real getSecondarySeparationAngle( Terrain* terrain ) const;
368 
374  agx::Real getDeadLoadFraction() const;
375 
382  agx::Real getInnerContactArea() const;
383 
392  void setContactRegionThreshold( agx::Real contactRegionThreshold );
393 
401  agx::Real getContactRegionThreshold() const;
402 
410  void setContactRegionVerticalLimit( agx::Real verticalLimit );
411 
412  /*
413  Get the maximum vertical distance from the shovel bottom plane where regular geometry
414  contacts between the shovel and the terrain are allowed to be created. Contacts past that distance
415  will be filtered away.
416  \return the maximum vertical distance from the shovel bottom plane where regular geometry
417  contacts between the shovel and the terrain are allowed to be created
418  */
419  agx::Real getContactRegionVerticalLimit() const;
420 
427  void setEnableInnerShapeCreateDynamicMass( bool enable );
428 
434  bool getEnableInnerShapeCreateDynamicMass() const;
435 
442  void setEnableParticleForceFeedback( bool enable );
443 
448  bool getEnableParticleForceFeedback();
449 
455  void setEnable(bool enable);
456 
461  bool getEnable() const;
462 
463 
470  agx::Real getParticleInclusionMultiplier() const;
471 
472  /*
473  Get the radius multiplier for extending the inclusion bound with
474  particle radius during post-excavation with particles in bucket.
475  \param radiusMultiplier - The multiplier for the particle radius
476  extension of the shovel inclusion
477  bound. (Default: 1.0)
478  \note - This will only be active pos-excavation and NOT during excavation
479  when we have active soil wedges.
480  */
481  void setParticleInclusionMultiplier( agx::Real radiusMultiplier );
482 
483  public:
484 
489  {
490  public:
495 
501 
506  void setEnable(bool enable);
507 
512  void setEnableCreateDynamicMass(bool enable);
513 
518  void setEnableForceFeedback(bool enable);
519 
523  bool getEnable() const;
524 
528  bool getEnableForceFeedback() const;
529 
533  bool getEnableCreateDynamicMass() const;
534 
538  agx::UInt32 getState() const;
539 
540  void store( agxStream::OutputArchive& out ) const { m_settings.store( out ); }
541  void restore( agxStream::InputArchive& in ) { m_settings.restore( in ); }
542 
543  private:
544  enum StateFlags : agx::UInt32
545  {
546  ENABLED = 1 << 0,
547  ENABLE_CREATE_DYNAMIC_MASS = 1 << 1,
548  ENABLE_FORCE_FEEDBACK = 1 << 2,
549  };
550  using Flags = agx::BitState<StateFlags, agx::UInt32>;
551  Flags m_settings;
552  };
553 
554  public:
555 
561  agx::Bool initializeCollection( TerrainToolCollection* collection, agxSDK::Simulation* simulation );
562 
567  void uninitializeCollection( TerrainToolCollection* collection, agxSDK::Simulation* simulation );
568 
573  void onPre( TerrainToolCollection* collection );
574 
579  void onPost( TerrainToolCollection* collection );
580 
581  bool getShovelPlanes(TerrainToolCollection* collection,
582  agx::Plane& bottomPlane,
583  agx::Plane& backPlane,
584  agx::Plane& leftPlane,
585  agx::Plane& rightPlane);
586 
587  void removeTerrainShovelContacts(TerrainToolCollection* collection);
588 
589  void removeTerrainShovelContactsDeformer(TerrainToolCollection* collection);
590 
591  bool isEdgeSubmerged(const agx::Line& edge, const Terrain* terrain) const;
592 
593  bool isEdgeSubmergedInSolid(const agx::Line& edge, const Terrain* terrain) const;
594 
595  bool isEdgeSubmergedInHeightfield(const agx::Line& edge, const agxCollide::HeightField* heightfield, const Terrain* terrain) const;
596 
597  agx::Real getSubmergedEdgeLength(const agx::Line& edge, const Terrain* terrain) const;
598 
599  agx::Vec3 getCuttingEdgeVelocity();
600 
601  void correctShovelVectors();
602 
603  void calculateDeadLoadFraction( const Terrain* terrain,
604  const ActiveZone* activeZone,
605  const agx::Physics::GranularBodyPtrVector& innerParticles );
606 
607  void setInnerContactArea( agx::Real contactArea );
608 
609  void setSettingsAreDirty(bool enable);
610 
611  bool getSettingsAreDirty() const;
612 
613  agx::Real computeDefaultContactRegionThreshold() const;
614 
617 
618  protected:
622  Shovel();
623 
627  virtual ~Shovel();
628 
629  agxCollide::GeometryRefVector createVoxelCollisionGeometries( agx::Real tessellationLevel ) const;
630 
631  protected:
633  {
637  };
638 
640  {
641  ENABLED = 1 << 0,
642  REMOVE_SHOVEL_CONTACTS = 1 << 1,
643  INNER_SHAPE_CREATE_DYNAMIC_MASS = 1 << 2,
644  ENABLE_PARTICLE_FREE_DEFORMATION = 1 << 3,
645  ENABLE_PARTICLE_FORCE_FEEDBACK = 1 << 4
646  };
647  using Flags = agx::BitState<StateFlags, agx::UInt32>;
648 
664 
665  std::array< ExcavationSettings, 4 > m_excavationSettings;
666 
669 
670  // Caching of dead load
672  // Caching of inner contact area
674 
675  // Geometries used to find shovel-voxel collisions
678  };
679 }
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:400
agx::Real m_contactThreshold
Definition: Shovel.h:667
agx::Real m_toothLength
Definition: Shovel.h:653
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...
agx::Real m_particleInclusionMultiplier
Definition: Shovel.h:661
A terrain model based a 3D grid model with overlapping height field that can be deformed by interacti...
agx::Real m_secondarySeparationDeadLoadLimit
Definition: Shovel.h:660
bool Bool
Definition: Integer.h:48
agx::BitState< StateFlags, agx::UInt32 > Flags
Definition: Shovel.h:647
This namespace consists of a set of classes for handling geometric intersection tests including boole...
agx::Real m_noMergeExtensionDistance
Definition: Shovel.h:657
The agxTerrain namespace contains a 3D model for a dynamic deformable Terrain and related classes...
Definition: Geometry.h:59
bool m_settingsAreDirty
Definition: Shovel.h:677
Collection of terrain tool (currently Shovel) related objects which are terrain instance specific...
ExcavationMode
Enum for describing the different excavation modes of a shovel: PRIMARY - The primary mode of excavat...
Definition: Shovel.h:86
Class representing the mathematical concept of a plane, also called a half- space.
Definition: Plane.h:31
agxCollide::GeometryRefVector m_voxelCollisionGeometries
Definition: Shovel.h:676
agx::Real m_minimumSubmergedContactLengthFraction
Definition: Shovel.h:659
Base class providing referencing counted objects.
Definition: Referenced.h:119
agx::Real m_innerContactArea
Definition: Shovel.h:673
Class containing the settings for the different ExcavationModes for a shovel.
Definition: Shovel.h:488
agx::Vec3 m_cuttingDirection
Definition: Shovel.h:652
uint32_t UInt
Definition: Integer.h:34
SoilPenetrationParameters m_soilPenetrationParameters
Definition: Shovel.h:663
Vector containing &#39;raw&#39; data.
Definition: Vector.h:245
agx::UInt m_nTeeth
Definition: Shovel.h:656
std::array< ExcavationSettings, 4 > m_excavationSettings
Definition: Shovel.h:665
agx::Real m_toothMaxRadius
Definition: Shovel.h:655
agx::Real m_verticalContactThreshold
Definition: Shovel.h:668
void restore(agxStream::InputArchive &in)
Definition: Shovel.h:541
agx::Line m_cuttingEdge
Definition: Shovel.h:650
#define AGXTERRAIN_EXPORT
The rigid body class, combining a geometric model and a frame of reference.
Definition: RigidBody.h:54
Class for reading a binary stream of serialized data.
Definition: InputArchive.h:51
agx::Line m_topEdge
Definition: Shovel.h:651
#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::Real m_deadLoadFraction
Definition: Shovel.h:671
This class is an abstract base class for all classes that can be stored and retrieved from an Archive...
Definition: Serializable.h:44
Class for writing serialized data in binary format to a stream.
Definition: OutputArchive.h:56
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition: Simulation.h:126
void store(agxStream::OutputArchive &out) const
Definition: Shovel.h:540
double Real
Definition: Real.h:42
#define AGX_DECLARE_VECTOR_TYPES(type)
Definition: Vector.h:34
agx::RigidBodyObserver m_shovelBody
Definition: Shovel.h:649
agx::Real m_verticalSoilBladeMergeDistance
Definition: Shovel.h:658
A HeightField is a collision shape that can be created from a grid structure, like an image...
uint32_t UInt32
Definition: Integer.h:40
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: Object.h:98
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: Object.h:97
AGX_DECLARE_POINTER_TYPES(SpaceListener)
agx::Real m_toothMinRadius
Definition: Shovel.h:654