AGX Dynamics 2.38.0.0
Loading...
Searching...
No Matches
Shovel.h
Go to the documentation of this file.
1/*
2Copyright 2007-2024. Algoryx Simulation AB.
3
4All AGX source code, intellectual property, documentation, sample code,
5tutorials, scene files and technical white papers, are copyrighted, proprietary
6and confidential material of Algoryx Simulation AB. You may not download, read,
7store, distribute, publish, copy or otherwise disseminate, use or expose this
8material unless having a written signed agreement with Algoryx Simulation AB, or having been
9advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10valid commercial license from Algoryx Simulation AB.
11
12Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13from using this software, unless otherwise stated in written agreements with
14Algoryx Simulation AB.
15*/
16
17#pragma once
18
19#include <agx/BitState.h>
23
25
26namespace agxCollide
27{
28 class Geometry;
29 class Shape;
30}
31
32namespace agxTerrain
33{
34 class Terrain;
35 class TerrainMaterial;
36 class TerrainToolCollection;
37
51 {
52 public:
54
55
68 const agx::Line& topEdge,
69 const agx::Line& cuttingEdge,
70 const agx::Vec3& cuttingDirection,
71 Shovel* connectedShovel=nullptr);
72
88 {
89 PRIMARY = 0,
90 DEFORM_BACK = 1,
91 DEFORM_RIGHT = 2,
92 DEFORM_LEFT = 3
93 };
94
99
104
109
114
119
124
129
134
139
144
149
154
159
177
182 void setTopEdge(agx::Line topEdge);
183
188 void setCuttingEdge(agx::Line cuttingEdge);
189
193 void setCuttingDirection(agx::Vec3 cuttingDirection);
194
199
204
209
214
218 void setNoMergeExtensionDistance(agx::Real extensionDistance);
219
223 void setMinimumSubmergedContactLengthFraction(agx::Real minimumSubmergedContactLengthFraction);
224
229
234
239
244 void setVerticalBladeSoilMergeDistance(agx::Real verticalSoilBladeMergeDistance);
245
251 void setSecondarySeparationDeadloadLimit( agx::Real secondarySeparationLimit );
252
258
271
282
295
306
311 void setPenetrationForceScaling(agx::Real penetrationForceScaling);
312
317
325
330
336
341
346 void setMaxPenetrationForce(agx::Real maxPenetrationForce);
347
353
359
364
369
376
384
393 void setContactRegionThreshold( agx::Real contactRegionThreshold );
394
403
412
413 /*
414 Get the maximum vertical distance from the shovel bottom plane where regular geometry
415 contacts between the shovel and the terrain are allowed to be created. Contacts past that distance
416 will be filtered away.
417 \return the maximum vertical distance from the shovel bottom plane where regular geometry
418 contacts between the shovel and the terrain are allowed to be created
419 */
421
429
436
444
450
456 void setEnable(bool enable);
457
462 bool getEnable() const;
463
464
472
473 /*
474 Get the radius multiplier for extending the inclusion bound with
475 particle radius during post-excavation with particles in bucket.
476 \param radiusMultiplier - The multiplier for the particle radius
477 extension of the shovel inclusion
478 bound. (Default: 1.0)
479 \note - This will only be active pos-excavation and NOT during excavation
480 when we have active soil wedges.
481 */
483
484 public:
485
490 {
491 public:
496
502
507 void setEnable(bool enable);
508
513 void setEnableCreateDynamicMass(bool enable);
514
519 void setEnableForceFeedback(bool enable);
520
524 bool getEnable() const;
525
530
535
540
541 void store( agxStream::OutputArchive& out ) const { m_settings.store( out ); }
542 void restore( agxStream::InputArchive& in ) { m_settings.restore( in ); }
543
544 private:
546 {
547 ENABLED = 1 << 0,
548 ENABLE_CREATE_DYNAMIC_MASS = 1 << 1,
549 ENABLE_FORCE_FEEDBACK = 1 << 2,
550 };
551 using Flags = agx::BitState<StateFlags, agx::UInt32>;
552 Flags m_settings;
553 };
554
555 public:
556
562 agx::Bool initializeCollection( TerrainToolCollection* collection, agxSDK::Simulation* simulation );
563
568 void uninitializeCollection( TerrainToolCollection* collection, agxSDK::Simulation* simulation );
569
574 void onPre( TerrainToolCollection* collection );
575
580 void onPost( TerrainToolCollection* collection );
581
582 bool getShovelPlanes(TerrainToolCollection* collection,
583 agx::Plane& bottomPlane,
584 agx::Plane& backPlane,
585 agx::Plane& leftPlane,
586 agx::Plane& rightPlane);
587
588 void removeTerrainShovelContacts(TerrainToolCollection* collection);
589
590 void removeTerrainShovelContactsDeformer(TerrainToolCollection* collection);
591
592 bool isEdgeSubmerged(const agx::Line& edge, const Terrain* terrain) const;
593
594 bool isEdgeSubmergedInSolid(const agx::Line& edge, const Terrain* terrain) const;
595
596 bool isEdgeSubmergedInHeightfield(const agx::Line& edge, const agxCollide::HeightField* heightfield, const Terrain* terrain) const;
597
598 agx::Real getSubmergedEdgeLength(const agx::Line& edge, const Terrain* terrain) const;
599
600 agx::Vec3 getCuttingEdgeVelocity();
601
602 void correctShovelVectors();
603
604 void calculateDeadLoadFraction( const Terrain* terrain,
605 const ActiveZone* activeZone,
606 const agx::Physics::GranularBodyPtrVector& innerParticles );
607
608 void setInnerContactArea( agx::Real contactArea );
609
610 void setSettingsAreDirty(bool enable);
611
612 bool getSettingsAreDirty() const;
613
614 agx::Real computeDefaultContactRegionThreshold() const;
615
616 Shovel* getConnectedShovel();
617
620
621 protected:
626
630 virtual ~Shovel();
631
632 agxCollide::GeometryRefVector createVoxelCollisionGeometries( agx::Real tessellationLevel ) const;
633
634 protected:
636 {
640 };
641
643 {
644 ENABLED = 1 << 0,
645 REMOVE_SHOVEL_CONTACTS = 1 << 1,
646 INNER_SHAPE_CREATE_DYNAMIC_MASS = 1 << 2,
647 ENABLE_PARTICLE_FREE_DEFORMATION = 1 << 3,
648 ENABLE_PARTICLE_FORCE_FEEDBACK = 1 << 4
649 };
650 using Flags = agx::BitState<StateFlags, agx::UInt32>;
651
667
668 std::array< ExcavationSettings, 4 > m_excavationSettings;
669
672
673 // Caching of dead load
675 // Caching of inner contact area
677
678 // Geometries used to find shovel-voxel collisions
681
683 };
684}
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
#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
#define AGXTERRAIN_EXPORT
#define AGX_DECLARE_VECTOR_TYPES(type)
Definition: agx/Vector.h:34
Class for reading a binary stream of serialized data.
Definition: InputArchive.h:52
Class for writing serialized data in binary format to a stream.
Definition: OutputArchive.h:57
This class is an abstract base class for all classes that can be stored and retrieved from an Archive...
Definition: Serializable.h:45
Class containing the settings for the different ExcavationModes for a shovel.
Definition: Shovel.h:490
ExcavationSettings()
Default constructor.
void setEnable(bool enable)
Set whether the excavation mode should be enabled, creating dynamic mass and generating force feedbac...
ExcavationSettings(agx::UInt32 state)
Constructor taking an internal state variable from another excavation setting object.
void store(agxStream::OutputArchive &out) const
Definition: Shovel.h:541
void setEnableForceFeedback(bool enable)
Set true/false if the excavation mode should generate force feedback from created aggregates.
void restore(agxStream::InputArchive &in)
Definition: Shovel.h:542
void setEnableCreateDynamicMass(bool enable)
Set true/false if the excavation mode should create dynamic mass.
bool getEnableParticleFreeDeformers() const
agx::Real m_toothLength
Definition: Shovel.h:656
void setToothMinimumRadius(agx::Real radius)
void setMinimumSubmergedContactLengthFraction(agx::Real minimumSubmergedContactLengthFraction)
Set the minimum submerged cutting edge length fraction (0-1) that generates submerged cutting.
agx::Real getNoMergeExtensionDistance() const
Get the margin outside the shovel bonding box where soil particle merging is forbidden.
agx::Real m_particleInclusionMultiplier
Definition: Shovel.h:664
agx::Line getCuttingEdge() const
agx::UInt m_nTeeth
Definition: Shovel.h:659
agx::Plane getCurrentSeparationPlane(Terrain *terrain, ExcavationMode mode) const
agx::Real getMaxPenetrationForce() const
Set the maximum limit on penetration force (N) that the terrain will generate on this shovel.
agx::Real m_verticalContactThreshold
Definition: Shovel.h:671
agx::RigidBodyObserver m_shovelBody
Definition: Shovel.h:652
agx::Line m_topEdge
Definition: Shovel.h:654
agx::Real getVerticalBladeSoilMergeDistance() const
Get the vertical distance under the blade cutting edge that the soil is allowed to instantly merge up...
void setCuttingDirection(agx::Vec3 cuttingDirection)
agx::Real getToothLength() const
agx::Real getContactRegionVerticalLimit() const
agx::Real m_contactThreshold
Definition: Shovel.h:670
agx::Real getPenetrationDepthThreshold() const
Get the vertical penetration depth threshold for when the shovel tooth for penetration resistance sho...
bool getAlwaysRemoveShovelContacts() const
agx::Vec3 m_cuttingDirection
Definition: Shovel.h:655
void setEnableParticleForceFeedback(bool enable)
Set whenever the excavation force feedback during PRIMARY excavation should be generated from particl...
agx::UInt getNumberOfTeeth() const
agx::Real getParticleInclusionMultiplier() const
void setToothMaximumRadius(agx::Real radius)
Shovel * m_connectedShovel
Definition: Shovel.h:682
bool getEnableParticleForceFeedback()
agx::Real m_noMergeExtensionDistance
Definition: Shovel.h:660
void setNumberOfTeeth(agx::UInt count)
agx::Real m_deadLoadFraction
Definition: Shovel.h:674
bool setSoilPenetrationModel(agxTerrain::SoilPenetrationResistance::PenetrationModel model, agxTerrain::Terrain *terrain)
Set the soil penetration model used for the specified shovel in the given terrain.
bool m_settingsAreDirty
Definition: Shovel.h:680
void setContactRegionThreshold(agx::Real contactRegionThreshold)
Set the starting distance threshold from the shovel planes where regular geometry contacts between th...
void setContactRegionVerticalLimit(agx::Real verticalLimit)
Set the maximum vertical distance from the shovel bottom plane where regular geometry contacts betwee...
void setToothLength(agx::Real length)
void setEnableParticleFreeDeformers(bool enable)
Set true/false if the shovel deformers should make particle free deformations.
void setTopEdge(agx::Line topEdge)
Set the top edge in local space.
void setMaxPenetrationForce(agx::Real maxPenetrationForce)
Set a maximum limit on penetration force (N) that the terrain will generate on this shovel.
agx::Real m_toothMaxRadius
Definition: Shovel.h:658
agx::Real m_minimumSubmergedContactLengthFraction
Definition: Shovel.h:662
agx::BitState< StateFlags, agx::UInt32 > Flags
Definition: Shovel.h:650
bool getEnable() const
Access the state enable flag.
agx::Vec3 getCuttingDirectionWorld() const
agxCollide::GeometryRefVector m_voxelCollisionGeometries
Definition: Shovel.h:679
agx::Real getDeadLoadFraction() const
Get the last computed dead load fraction of the shovel, i.e how much of it's inner volume that is fil...
void setNoMergeExtensionDistance(agx::Real extensionDistance)
Set the extension outside the shovel bounding box where soil particle merging is forbidden.
agx::Vec3 getCuttingDirection() const
agx::Real getMinimumSubmergedContactLengthFraction() const
Get the minimum submerged cutting edge length fraction (0-1) that generates submerged cutting.
agx::Real m_verticalSoilBladeMergeDistance
Definition: Shovel.h:661
void setEnableInnerShapeCreateDynamicMass(bool enable)
Set if inner shape alone should always create dynamic mass.
agx::Real getSecondarySeparationDeadloadLimit() const
agx::Line getTopEdgeWorld() const
std::array< ExcavationSettings, 4 > m_excavationSettings
Definition: Shovel.h:668
bool getEnableInnerShapeCreateDynamicMass() const
Get if inner shape alone should always create dynamic mass.
void setEnable(bool enable)
Change state enable of this shovel Default: true.
bool getSoilPenetrationModel(agxTerrain::Terrain *terrain, agxTerrain::SoilPenetrationResistance::PenetrationModel &model) const
Get the soil penetration model used for the specified shovel in the given terrain.
agx::Real getSecondarySeparationAngle(Terrain *terrain) const
void setParticleInclusionMultiplier(agx::Real radiusMultiplier)
agx::Line getCuttingEdgeWorld() const
agx::Real getToothMinimumRadius() const
void setSecondarySeparationDeadloadLimit(agx::Real secondarySeparationLimit)
Sets the dead-load limit where secondary separation will start to activate where the forward directio...
void setExcavationSettings(ExcavationMode mode, ExcavationSettings excavationSettings)
Set a settings object for an ExcavationMode of the shovel.
Shovel(agx::RigidBody *shovelBody, const agx::Line &topEdge, const agx::Line &cuttingEdge, const agx::Vec3 &cuttingDirection, Shovel *connectedShovel=nullptr)
Basic constructor.
void setPenetrationForceScaling(agx::Real penetrationForceScaling)
Set the linear scaling coefficient for the penetration force (Default: 1.0)
agx::Real getInnerContactArea() const
Get the last computed inner contact area of the shovel, i.e the estimated cross-section area of the i...
void setPenetrationDepthThreshold(agx::Real depthThreshold)
Set the vertical penetration depth threshold for when the shovel tooth for penetration resistance sho...
agx::Real getToothMaximumRadius() const
agx::Real m_secondarySeparationDeadLoadLimit
Definition: Shovel.h:663
agx::Vec3 getSecondaryCuttingDirection(Terrain *terrain) const
void setAlwaysRemoveShovelContacts(bool enable)
Set to true/false if shovel <-> terrain contacts should always be removed param enable - set to true/...
agx::Line m_cuttingEdge
Definition: Shovel.h:653
void setVerticalBladeSoilMergeDistance(agx::Real verticalSoilBladeMergeDistance)
Sets the vertical distance under the blade cutting edge that the soil is allowed to instantly merge u...
agx::Real getPenetrationForceScaling() const
agx::RigidBody * getRigidBody() const
SoilPenetrationParameters m_soilPenetrationParameters
Definition: Shovel.h:666
agx::Real m_innerContactArea
Definition: Shovel.h:676
ExcavationSettings & getExcavationSettings(ExcavationMode mode)
ExcavationMode
Enum for describing the different excavation modes of a shovel: PRIMARY - The primary mode of excavat...
Definition: Shovel.h:88
void setCuttingEdge(agx::Line cuttingEdge)
Set the cutting edge in local space.
agx::Real computeCuttingEdgeLength() const
agx::Real m_toothMinRadius
Definition: Shovel.h:657
agx::Line getTopEdge() const
agx::Real getContactRegionThreshold() const
Get the starting distance threshold from the shovel planes where regular geometry contacts between th...
A terrain model based a 3D grid model with overlapping height field that can be deformed by interacti...
Definition: Terrain.h:85
Class representing the mathematical concept of a plane, also called a half- space.
Definition: agx/Plane.h:32
Base class providing referencing counted objects.
Definition: Referenced.h:120
The rigid body class, combining a geometric model and a frame of reference.
Definition: RigidBody.h:52
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: macros.h:97
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: macros.h:96
This namespace consists of a set of classes for handling geometric intersection tests including boole...
The agxSDK namespace contain classes to bridge the collision detection system and the dynamical simul...
Definition: Constraint.h:31
The agxTerrain namespace contains a 3D model for a dynamic deformable Terrain and related classes.
Definition: Geometry.h:59
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
uint32_t UInt32
Definition: Integer.h:40
uint32_t UInt
Definition: Integer.h:34
double Real
Definition: Real.h:42