AGX Dynamics 2.42.1.1
Loading...
Searching...
No Matches
SuctionGripper.h
Go to the documentation of this file.
1/*
2Copyright 2007-2025. 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 <agxModel/export.h>
20
21#include <agx/Real.h>
22#include <agx/Frame.h>
23#include <agx/Vec2.h>
24#include <agx/Constraint.h>
25#include <agx/Referenced.h>
26#include <agxUtil/agxUtil.h>
29#include <agxSDK/Assembly.h>
30#include <agxCollide/Line.h>
31#include <agxCollide/Sphere.h>
32#include <agxCollide/Mesh.h>
33#include <agx/LockJoint.h>
34
35namespace agxSDK
36{
37 class Simulation;
38}
39
40
41namespace agxModel
42{
43
44
53 {
54 public:
55
57 {}
58
60 {
62 }
63
65 {
67 }
68
70 virtual bool match(const agxCollide::Geometry* g0, const agxCollide::Geometry* g1) const override
71 {
72 const agxCollide::Geometry* geos[] = { g0, g1 };
73
74 for (size_t j = 0; j < 2; ++j)
75 {
76 for (size_t i = 0; i < m_collisionGeometries.size(); ++i)
77 {
78 if (geos[j] == m_collisionGeometries[i])
79 return true;
80 }
81 }
82 return false;
83 }
84
85 using ExecuteFilter::match;
86
87 protected:
89 {
91 };
92
93
94 protected:
97 };
98
99
100
103
106
120 {
121 public:
127
128
132 size_t getSealCount() const;
133
137 bool getCentered() const;
138
145
152
159
166
173
178
183
188
193
194
195 protected:
197
198 friend class SuctionCup;
199 friend class SuctionGripper;
200
201 /*
202 Update the latest position found for where to apply the cvacuum force
203 */
205
210
217
223
229
230 void updateInteractedSeals(size_t sealIndex, agx::Real depth);
231
234
235 agx::Real getSealDepth(size_t sealIndex) const;
236
237 bool hasSealInteraction(size_t sealIndex) const;
238
246 virtual bool updateVacuumForce(const SuctionCup* cup, const VacuumSystem* vacuumSystem, agx::Real fraction);
247
248 void reset();
249
251
253
264 };
265
266
269
280 {
281 public:
290 VacuumSystem(agx::Real desiredVacuum);
291
297
303
309 virtual void step(agx::Real dt, const SuctionGripper* gripper);
310
314 void setEnablePump(const bool& enable);
315
319 bool getEnablePump() const;
320
325
331 void setDesiredVacuum(agx::Real vacuumLevel);
332
337
342
347
352
357
362
364
365 protected:
366 virtual ~VacuumSystem();
380 };
381
382
419 {
420 public:
433 agx::Real lipRadius = agx::Real(0.025),
434 agx::Real lipHeight = agx::Real(0.01),
435 size_t sealResolution = size_t(0),
436 agx::Vec3 localLineSensorVector = agx::Vec3(0,0,-0.1),
437 agx::Real sealSensorReach = agx::Real(0.01));
438
439
444
450
455
460
465
473
478
482 bool isValid() const;
483
488
492 size_t getSealResolution() const;
493
498
503
512
517
522 agx::Vector < agxModel::SuctionCupInteraction*> getActiveInteractionsVector() const;
523
527 virtual void updateLeakageArea();
528
532 void applyVacuumForces(const VacuumSystem* vacuumSystem);
533
534
541 void updateVacuumForces(const VacuumSystem* vacuumSystem);
542
543
545
546 protected:
548
549 virtual ~SuctionCup();
550
551 // Contact events.
553
554 friend class SuctionGripper;
555
557
562
564
566
574
582
583
584 friend class SuctionGripper;
585
588
591
593 const agx::TimeStamp&, agxCollide::GeometryPair&);
594
597
602
604 agx::Vec3 pointAtSurface,
605 bool& success);
606
608
610
611 protected:
629 // Implementation dependent temporary variables, only valid per time step.
632
633 };
634
652 {
653 public:
661
666
671
676
681
686
693
695 bool isValid() const;
696
701
706
711
715 void setVacuumSystem(VacuumSystem* vacuumSystem);
716
719 agx::Vec3 holderLocalTranslate,
720 agx::Vec3 cupLocalTranslate);
721
723
724 protected:
726
727 virtual void updateValid();
728
730
731 // Adding to/removing from simulation.
732 virtual void addNotification( agxSDK::Simulation* simulation ) override;
733
735
736 virtual void removeNotification( agxSDK::Simulation* simulation )override;
737
739
740
741 // Step events.
743
744 virtual void preCollide(const agx::TimeStamp&);
745 virtual void pre(const agx::TimeStamp&);
746 virtual void post(const agx::TimeStamp&);
747 virtual void last(const agx::TimeStamp&);
748
749
750
751 protected:
752 // More persistent variables, will be serialized.
758
759 };
760
764 {
765 public:
785 SingleCupSuctionGripper(size_t sealResolution,
786 agx::Real gripperRadius = agx::Real(0.025),
787 agx::Real gripperHeight = agx::Real(0.01),
788 agx::Real cupHeight = agx::Real(0.05),
789 agx::Real lipHeight = agx::Real(0.01),
790 agxCollide::Trimesh* deformableMesh = nullptr,
791 agx::Material* cupMaterial = nullptr,
792 agx::RigidBody* holderBody = nullptr,
793 agx::RigidBody* cupBody = nullptr);
794
799
804
809
814
816
817 protected:
820
823
828
829 };
830}
831
#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 AGXMODEL_EXPORT
#define AGX_DECLARE_VECTOR_TYPES(type)
Definition: agx/Vector.h:34
A contact between two geometries.
Definition: Contacts.h:354
The geometry representation used by the collision detection engine.
Definition: Geometry.h:92
Base class for a shape.
Definition: Shape.h:58
Triangle mesh for geometric intersection tests.
Definition: Trimesh.h:40
agxUtil::TrimeshDeformerRef m_trimeshDeformer
agxUtil::TrimeshDeformer * getTrimeshDeformer() const
agxCollide::TrimeshRef m_trimesh
agxCollide::GeometryRef m_trimeshGeometry
SingleCupSuctionGripper(size_t sealResolution, agx::Real gripperRadius=agx::Real(0.025), agx::Real gripperHeight=agx::Real(0.01), agx::Real cupHeight=agx::Real(0.05), agx::Real lipHeight=agx::Real(0.01), agxCollide::Trimesh *deformableMesh=nullptr, agx::Material *cupMaterial=nullptr, agx::RigidBody *holderBody=nullptr, agx::RigidBody *cupBody=nullptr)
Create a SuctionGripper with one holder body and one suction cup.
agxCollide::Trimesh * getDeformableTrimesh() const
void setupDeformableTrimesh(SuctionCup *cup, agx::Frame *holderFrame)
agx::LockJoint * getLockJoint() const
agxCollide::Geometry * getTrimeshGeometry() const
agx::RigidBody * createDefaultHolderBody(agx::Real radius, agx::Real height) const
agx::ref_ptr< agx::LockJoint > m_lock
virtual bool updateVacuumForce(const SuctionCup *cup, const VacuumSystem *vacuumSystem, agx::Real fraction)
Function responsible for updating the force from the vacuum.
void renderInteraction(const SuctionCup *cup)
agx::Real getCurrentRelativeVelocity() const
bool hasSealInteraction(size_t sealIndex) const
SuctionCupInteraction()
A class for collecting and computing information for one RigidBody nearby a suction cup.
agx::Real getCalculatedScalarForce() const
agx::HashVector< size_t, agx::Real > m_interactedSealDepth
void setCalculatedForce(agx::Vec3 force)
agx::Vec3 getCurrentFrictionForce() const
void updateInteractedSeals(size_t sealIndex, agx::Real depth)
void setRigidBody(agx::RigidBody *body)
agx::Real getSealDepth(size_t sealIndex) const
void setFoundSurfacePositionWorld(agx::Vec3 worldPosition)
agx::Real getCenterDistance() const
agx::Vec3 getFoundSurfacePositionWorld() const
agx::RigidBody * getRigidBody()
agx::Vec3 getCalculatedForce() const
void updateEstimatedForcePosition(const SuctionCup *cup, agx::Real depth)
Updates the surface position of an interacting object where to apply the force.
agx::Vec3 getCurrentContactNormalForce() const
agx::RigidBodyObserver m_body
agx::Vec3 getCenterNormalWorld() const
void setCenterDistance(agx::Real distance)
Set distance to object along a vector considered positioned at the center of the suction cup,...
void setCenterNormalWorld(agx::Vec3 normal)
Set the surface normal of the object at the point at the center under the suction cup.
void setCalculatedScalarForce(agx::Real scalarForce)
void addTemporaryGeometryContact(agxCollide::GeometryContact *gc)
agxCollide::GeometryContactPtrVector m_tempContacts
Class for filtering objects of interest nearby a suction cup.
agxCollide::GeometryRefVector m_sensors
const agxCollide::GeometryRefVector & getGeometries() const
void addGeometry(agxCollide::Geometry *geometry)
virtual bool match(const agxCollide::Geometry *g0, const agxCollide::Geometry *g1) const override
Inherited from agxSDK::ExecuteFilter.
agxCollide::GeometryRefVector m_collisionGeometries
SuctionCupSensorFilter * getSensorFilter()
const SuctionCupInteractionRefVector & getDisabledInteractions() const
agxCollide::Geometry * createSealSensor(agx::RigidBody *body, agx::Vec3 bodyLocalPosition)
agx::Real getArea() const
agx::Vec3 findSurfaceNormal(agxCollide::Shape *collidedShape, agx::Vec3 pointAtSurface, bool &success)
const agxCollide::GeometryRefSetVector & getSealSensors() const
const agx::RigidBody * getRigidBody() const
agx::Vec3 m_localLineSensorVector
SuctionCupSensorFilterRef m_collisionFilter
agx::RigidBody * createDefaultCupBody()
SuctionCupInteraction * getActiveInteraction(agx::RigidBody *rigidBody)
agx::Real getLipRadius() const
agx::ref_ptr< agxUtil::GeneralContactEventListener< SuctionCup > > m_contactCallback
agx::Vec3 calculateLineP2() const
agx::Vector< agxModel::SuctionCupInteraction * > getActiveInteractionsVector() const
agx::Real m_calculatedAvailableVacuumForce
agx::Real getSensorDistance() const
void setMountingRadius(agx::Real radius)
Set the mounting radius.
agx::HashVector< agx::RigidBody *, SuctionCupInteractionRef > m_activeInteractions
agx::Real getCurrentLeakageArea() const
agx::Real getMountingRadius() const
agx::AffineMatrix4x4 m_miniSphereTransform
void addNotification(agxSDK::Simulation *simulation)
Makes sure all suction cup bodies and constraints are given to the simulation.
SuctionCupInteractionRefVector m_interactionsPool
agx::RigidBodyRef m_body
void applyVacuumForces(const VacuumSystem *vacuumSystem)
Responsible for applying forces to rigid bodies of the cup interactions.
SuctionCup(agx::RigidBody *cupBody, agx::Real lipRadius=agx::Real(0.025), agx::Real lipHeight=agx::Real(0.01), size_t sealResolution=size_t(0), agx::Vec3 localLineSensorVector=agx::Vec3(0, 0,-0.1), agx::Real sealSensorReach=agx::Real(0.01))
The SuctionCup contains a rigid body with a local attachment frame which will be used to position it ...
agx::Vec3 getNormal() const
virtual agxModel::SuctionCupInteraction * createInteraction()
Function creating an interaction.
virtual void updateLeakageArea()
Calculates the leakage area.
agx::Real m_currentLeakageArea
agxCollide::GeometryRef m_lineSensor
agx::ref_ptr< agxCollide::Line > m_line
size_t getSealResolution() const
void separation(const agx::TimeStamp &, agxCollide::GeometryPair &)
agx::RigidBody * getRigidBody()
void removeNotification(agxSDK::Simulation *simulation)
void collectCollisionGeometries()
agx::Real getAvailableVacuumForce() const
The available vacuum force is a pre calculated value by the virtual VacuumSystem::calculateAvailableV...
agxSDK::ContactEventListener::KeepContactPolicy contact(const agx::TimeStamp &, agxCollide::GeometryContact *gc)
agxSDK::ContactEventListener::KeepContactPolicy impact(const agx::TimeStamp &, agxCollide::GeometryContact *gc)
agx::RealVector m_sealDepthMeasurements
agxCollide::GeometryRefSetVector m_sealSensors
agxCollide::SphereRef m_miniSphere
const agx::HashVector< agx::RigidBody *, SuctionCupInteractionRef > & getActiveInteractions() const
agxSDK::ContactEventListener::KeepContactPolicy handleContacts(const agx::TimeStamp &, agxCollide::GeometryContact *gc)
void updateVacuumForces(const VacuumSystem *vacuumSystem)
Will call the virtual function VacuumSystem::calculateAvailableVacuumForce; then apply the vacuum for...
bool isValid() const
Verify if the cup is valid.
This should be considered a template class used as a base for Suction Gripper simulation models.
agx::RigidBody * getHolderRigidBody()
void addSuctionCup(SuctionCup *cup)
Add one suction cup to the gripper.
SuctionCupRefVector & getSuctionCups()
virtual void last(const agx::TimeStamp &)
agxModel::SuctionCupRefVector m_suctionCups
VacuumSystem * getVacuumSystem()
VacuumSystemRef m_vacuumSystem
SuctionGripper(agx::RigidBody *holderBody)
The SuctionGripper must be initialized with a holder body.
agx::Real getCurrentLeakage() const
void setVacuumSystem(VacuumSystem *vacuumSystem)
Set a new vacuum system to the gripper.
static agx::LockJoint * positionAndLockSuctionCup(agxModel::SuctionGripper *gripper, agxModel::SuctionCup *cup, agx::Vec3 holderLocalTranslate, agx::Vec3 cupLocalTranslate)
virtual void pre(const agx::TimeStamp &)
virtual void preCollide(const agx::TimeStamp &)
const agx::RigidBody * getHolderRigidBody() const
virtual void addNotification(agxSDK::Simulation *simulation) override
Called when this assembly is added to a simulation (given that it not already is in the simulation).
agx::RigidBodyRef m_holderBody
virtual void updateValid()
const VacuumSystem * getVacuumSystem() const
bool setHolderRigidBody(agx::RigidBody *holderBody)
Set the rigid body of the holder.
virtual void post(const agx::TimeStamp &)
const SuctionCupRefVector & getSuctionCups() const
agx::ref_ptr< agxUtil::GeneralStepListener< SuctionGripper > > m_stepCallback
Basic model for a vacuum system used by a SuctionGripper.
agx::Real m_timeOfPumpStateToggled
void setEnablePump(const bool &enable)
agx::Real getOutsideGasDensity() const
Get the gas density outside the vacuum system [kg / m^3].
agx::Real getOutsidePressure() const
Get the pressure outside the vacuum system in Pascal[Pa].
agx::Real getDesiredVacuum() const
Set the desired vacuum level (0-1) for the system.
void setDesiredVacuum(agx::Real vacuumLevel)
Set the current vacuum level (0-1) for the system If set outside the valid range, the value is clampe...
void setCurrentVacuum(agx::Real vacuum)
Set the current vacuum for the system.
virtual agx::Real calculateAvailableVacuumForce(SuctionCup *cup) const
A virtual function which is responsible to calculate the actual force a suction cup can apply to obje...
virtual void step(agx::Real dt, const SuctionGripper *gripper)
A virtual function for updating the vacuum system.
agx::Real calculateGasSpeedAtLip(const SuctionCup *cup) const
agx::Real getCurrentVacuum() const
void setOutsidePressure(agx::Real pressure)
Set the pressure outside the vacuum system in Pascal [Pa].
bool getEnablePump() const
void setOutsideGasDensity(agx::Real density)
Set the gas density outside the vacuum system [kg / m^3].
VacuumSystem(agx::Real desiredVacuum)
Create a vacuum system with a constant desired vacuum level.
agx::Real calculateMaximumSuctionForce(SuctionCup *cup) const
An assembly is a collection of basic simulation objects, such as rigid bodies, constraints,...
Definition: Assembly.h:70
virtual void removeNotification(agxSDK::Simulation *)
Called when this assembly is removed from a simulation.
Definition: Assembly.h:778
virtual void addNotification(agxSDK::Simulation *)
Called when this assembly is added to a simulation (given that it not already is in the simulation).
Definition: Assembly.h:773
KeepContactPolicy
Defines whether contact should be kept or removed after contact/impact methods returns.
Abstract base class that implements a filter that selects which events should trigger a Listener.
Definition: ExecuteFilter.h:34
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition: Simulation.h:131
This class is an abstract base class for all classes that can be stored and retrieved from an Archive...
Definition: Serializable.h:44
Utility class to get contact event callbacks to any class having the methods implemented.
Definition: agxUtil.h:632
Utility class to get step event callbacks to any class having the methods implemented.
Definition: agxUtil.h:584
size_t size() const
Definition: Container.h:134
The object defining a frame of reference and providing transformations operations.
Definition: agx/Frame.h:68
Inheritance with partial specialization due to bug with ref_ptr containers.
Definition: agx/HashSet.h:670
This class is a combined container which has the find complexity of a HashTable, deterministic iterat...
Definition: HashVector.h:41
Constraint that removes all 6 DOF between two bodies, or one body and the world.
Definition: LockJoint.h:31
Main material class which acts as a holder of a Surface Material and a Bulk material.
Definition: Material.h:378
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:49
void clear(ClearPolicy policy=SHRINK_BUFFER_AVERAGED)
Remove all elements, optionally with maintained buffer allocation.
Definition: agx/Vector.h:491
void push_back(const T2 &value)
Definition: agx/Vector.h:715
Contain classes for higher level modeling primitives, such as Tree, Terrain etc.
Definition: Space.h:63
agx::HashSet< SuctionCupRef > SuctionCupRefSet
The SuctionCup model owns a body which is mean to be attached somewhere on a SuctionGripper holder.
The agxSDK namespace contain classes to bridge the collision detection system and the dynamical simul...
Definition: Constraint.h:31
double Real
Definition: Real.h:41
agx::Real TimeStamp
Definition: TimeStamp.h:26