AGX Dynamics 2.38.0.2
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
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
103
108
113
118
123
128
133
138
143
148
153
158
163
181
186 void setTopEdge(agx::Line topEdge);
187
192 void setCuttingEdge(agx::Line cuttingEdge);
193
197 void setCuttingDirection(agx::Vec3 cuttingDirection);
198
203
208
213
218
222 void setNoMergeExtensionDistance(agx::Real extensionDistance);
223
227 void setMinimumSubmergedContactLengthFraction(agx::Real minimumSubmergedContactLengthFraction);
228
233
238
243
248 void setVerticalBladeSoilMergeDistance(agx::Real verticalSoilBladeMergeDistance);
249
255 void setSecondarySeparationDeadloadLimit( agx::Real secondarySeparationLimit );
256
262
275
286
299
310
315 void setPenetrationForceScaling(agx::Real penetrationForceScaling);
316
321
329
334
340
345
350 void setMaxPenetrationForce(agx::Real maxPenetrationForce);
351
357
363
368
373
380
388
397 void setContactRegionThreshold( agx::Real contactRegionThreshold );
398
407
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 */
425
433
440
448
454
460 void setEnable(bool enable);
461
466 bool getEnable() const;
467
468
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 */
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
534
539
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:
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:
630
634 virtual ~Shovel();
635
636 agxCollide::GeometryRefVector createVoxelCollisionGeometries( agx::Real tessellationLevel ) const;
637
638 protected:
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}
#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...
#define AGXTERRAIN_EXPORT
#define AGX_DECLARE_VECTOR_TYPES(type)
Definition agx/Vector.h:34
Class for reading a binary stream of serialized data.
Class for writing serialized data in binary format to a stream.
This class is an abstract base class for all classes that can be stored and retrieved from an Archive...
Class containing the settings for the different ExcavationModes for a shovel.
Definition Shovel.h:494
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:545
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:546
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:660
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:668
agx::Line getCuttingEdge() const
agx::UInt m_nTeeth
Definition Shovel.h:663
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:675
agx::RigidBodyObserver m_shovelBody
Definition Shovel.h:656
agx::Line m_topEdge
Definition Shovel.h:658
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:674
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:659
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:686
bool getEnableParticleForceFeedback()
agx::Real m_noMergeExtensionDistance
Definition Shovel.h:664
void setNumberOfTeeth(agx::UInt count)
agx::Real m_deadLoadFraction
Definition Shovel.h:678
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:684
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:662
agx::Real m_minimumSubmergedContactLengthFraction
Definition Shovel.h:666
agx::BitState< StateFlags, agx::UInt32 > Flags
Definition Shovel.h:654
bool getEnable() const
Access the state enable flag.
agx::Vec3 getCuttingDirectionWorld() const
agxCollide::GeometryRefVector m_voxelCollisionGeometries
Definition Shovel.h:683
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:665
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:672
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:667
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:657
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:670
agx::Real m_innerContactArea
Definition Shovel.h:680
ExcavationSettings & getExcavationSettings(ExcavationMode mode)
ExcavationMode
Enum for describing the different excavation modes of a shovel: PRIMARY - The primary mode of excavat...
Definition Shovel.h:92
void setCuttingEdge(agx::Line cuttingEdge)
Set the cutting edge in local space.
agx::Real computeCuttingEdgeLength() const
agx::Real m_toothMinRadius
Definition Shovel.h:661
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:86
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:32
uint64_t UInt
Definition Integer.h:27
double Real
Definition Real.h:42