AGX Dynamics  2.37.2.0
SuctionGripper.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 <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>
28 #include <agxStream/Serializable.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 
35 namespace agxSDK
36 {
37  class Simulation;
38 }
39 
40 
41 namespace agxModel
42 {
43 
44 
53  {
54  public:
55 
57  {}
58 
60  {
61  m_collisionGeometries.push_back(geometry);
62  }
63 
65  {
66  return m_collisionGeometries;
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 
86 
87  protected:
89  {
90  m_collisionGeometries.clear();
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 
144  agx::Real getCenterDistance() const;
145 
151  agx::Vec3 getCenterNormalWorld() const;
152 
158  agx::Real getCalculatedScalarForce() const;
159 
165  agx::Vec3 getCalculatedForce() const;
166 
172  agx::Vec3 getFoundSurfacePositionWorld() const;
173 
177  agx::RigidBody* getRigidBody();
178 
182  agx::Vec3 getCurrentFrictionForce() const;
183 
187  agx::Vec3 getCurrentContactNormalForce() const;
188 
192  agx::Real getCurrentRelativeVelocity() const;
193 
194 
195  protected:
196  virtual ~SuctionCupInteraction();
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  */
204  void setFoundSurfacePositionWorld(agx::Vec3 worldPosition);
205 
209  void setRigidBody(agx::RigidBody* body);
210 
216  void updateEstimatedForcePosition(const SuctionCup* cup, agx::Real depth);
217 
222  void setCenterDistance(agx::Real distance);
223 
228  void setCenterNormalWorld(agx::Vec3 normal);
229 
230  void updateInteractedSeals(size_t sealIndex, agx::Real depth);
231 
232  void setCalculatedForce(agx::Vec3 force);
233  void setCalculatedScalarForce(agx::Real scalarForce);
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 
250  void addTemporaryGeometryContact(agxCollide::GeometryContact* gc);
251 
252  void renderInteraction(const SuctionCup* cup);
253 
264  };
265 
266 
269 
280  {
281  public:
290  VacuumSystem(agx::Real desiredVacuum);
291 
296  agx::Real calculateMaximumSuctionForce(SuctionCup* cup) const;
297 
302  virtual agx::Real calculateAvailableVacuumForce(SuctionCup* cup) const;
303 
309  virtual void step(agx::Real dt, const SuctionGripper* gripper);
310 
314  void setEnablePump(const bool& enable);
315 
319  bool getEnablePump() const;
320 
324  agx::Real getCurrentVacuum() const;
325 
331  void setDesiredVacuum(agx::Real vacuumLevel);
332 
336  agx::Real getDesiredVacuum() const;
337 
341  void setOutsidePressure(agx::Real pressure);
342 
346  agx::Real getOutsidePressure() const;
347 
351  agx::Real calculateGasSpeedAtLip(const SuctionCup* cup) const;
352 
356  void setOutsideGasDensity(agx::Real density);
357 
361  agx::Real getOutsideGasDensity() const;
362 
364 
365  protected:
366  virtual ~VacuumSystem();
367  VacuumSystem();
372  void setCurrentVacuum(agx::Real vacuum);
380  };
381 
382 
418  class AGXMODEL_EXPORT SuctionCup : public virtual agx::Referenced, public virtual agxStream::Serializable
419  {
420  public:
432  SuctionCup(agx::RigidBody* cupBody,
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 
443  agx::Vec3 getNormal() const;
444 
449  agx::Real getArea() const;
450 
454  const agx::RigidBody* getRigidBody() const;
455 
459  agx::RigidBody* getRigidBody();
460 
464  agx::Real getLipRadius() const;
465 
472  void setMountingRadius(agx::Real radius);
473 
477  agx::Real getMountingRadius() const;
478 
482  bool isValid() const;
483 
487  agx::Real getCurrentLeakageArea() const;
488 
492  size_t getSealResolution() const;
493 
497  agx::Real getSensorDistance() const;
498 
502  SuctionCupSensorFilter* getSensorFilter();
503 
511  agx::Real getAvailableVacuumForce() const;
512 
516  const agxCollide::GeometryRefSetVector& getSealSensors() const;
517 
522  agx::Vector < agxModel::SuctionCupInteraction*> getActiveInteractionsVector() const;
523 
528  virtual void updateLeakageArea();
529 
533  void applyVacuumForces(const VacuumSystem* vacuumSystem);
534 
535 
542  void updateVacuumForces(const VacuumSystem* vacuumSystem);
543 
544 
546 
547  protected:
548  SuctionCup();
549 
550  virtual ~SuctionCup();
551 
552  // Contact events.
554 
555  friend class SuctionGripper;
556 
557  void invalidateInteractions();
558 
562  agx::RigidBody* createDefaultCupBody();
563 
564  const agx::HashVector<agx::RigidBody*, SuctionCupInteractionRef>& getActiveInteractions() const;
565 
566  const SuctionCupInteractionRefVector& getDisabledInteractions() const;
567 
574  virtual agxModel::SuctionCupInteraction* createInteraction();
575 
581  void addNotification(agxSDK::Simulation* simulation);
582  void removeNotification(agxSDK::Simulation* simulation);
583 
584 
585  friend class SuctionGripper;
586 
589 
592 
593  void separation(
595 
598 
599  agx::Vec3 calculateLineP2() const;
600  void createLineSensor();
601  agxCollide::Geometry* createSealSensor(agx::RigidBody* body, agx::Vec3 bodyLocalPosition);
602  void createCupSealSensors();
603 
604  agx::Vec3 findSurfaceNormal(agxCollide::Shape* collidedShape,
605  agx::Vec3 pointAtSurface,
606  bool& success);
607 
608  SuctionCupInteraction* getActiveInteraction(agx::RigidBody* rigidBody);
609 
610  void collectCollisionGeometries();
611 
612  protected:
630  // Implementation dependent temporary variables, only valid per time step.
633 
634  };
635 
653  {
654  public:
661  SuctionGripper( agx::RigidBody* holderBody );
662 
666  bool setHolderRigidBody(agx::RigidBody* holderBody);
667 
671  agx::RigidBody* getHolderRigidBody();
672 
676  const agx::RigidBody* getHolderRigidBody() const;
677 
681  const SuctionCupRefVector& getSuctionCups() const;
682 
686  SuctionCupRefVector& getSuctionCups();
687 
693  void addSuctionCup(SuctionCup* cup);
694 
696  bool isValid() const;
697 
701  agx::Real getCurrentLeakage() const;
702 
706  const VacuumSystem* getVacuumSystem() const;
707 
711  VacuumSystem* getVacuumSystem();
712 
716  void setVacuumSystem(VacuumSystem* vacuumSystem);
717 
718  static agx::LockJoint* positionAndLockSuctionCup( agxModel::SuctionGripper* gripper,
720  agx::Vec3 holderLocalTranslate,
721  agx::Vec3 cupLocalTranslate);
722 
724 
725  protected:
726  SuctionGripper();
727 
728  virtual void updateValid();
729 
730  virtual ~SuctionGripper();
731 
732  // Adding to/removing from simulation.
733  virtual void addNotification( agxSDK::Simulation* simulation ) override;
734 
736 
737  virtual void removeNotification( agxSDK::Simulation* simulation )override;
738 
740 
741 
742  // Step events.
744 
745  virtual void preCollide(const agx::TimeStamp&);
746  virtual void pre(const agx::TimeStamp&);
747  virtual void post(const agx::TimeStamp&);
748  virtual void last(const agx::TimeStamp&);
749 
750 
751 
752  protected:
753  // More persistent variables, will be serialized.
755  bool m_valid;
759 
760  };
761 
765  {
766  public:
786  SingleCupSuctionGripper(size_t sealResolution,
787  agx::Real gripperRadius = agx::Real(0.025),
788  agx::Real gripperHeight = agx::Real(0.01),
789  agx::Real cupHeight = agx::Real(0.05),
790  agx::Real lipHeight = agx::Real(0.01),
791  agxCollide::Trimesh* deformableMesh = nullptr,
792  agx::Material* cupMaterial = nullptr,
793  agx::RigidBody* holderBody = nullptr,
794  agx::RigidBody* cupBody = nullptr);
795 
799  agx::LockJoint* getLockJoint() const;
800 
804  agxCollide::Geometry* getTrimeshGeometry() const;
805 
809  agxCollide::Trimesh* getDeformableTrimesh() const;
810 
814  agxUtil::TrimeshDeformer* getTrimeshDeformer() const;
815 
817 
818  protected:
819  agx::RigidBody* createDefaultHolderBody(agx::Real radius, agx::Real height) const;
820  void setupDeformableTrimesh(SuctionCup* cup, agx::Frame* holderFrame);
821 
823  virtual ~SingleCupSuctionGripper();
824 
829 
830  };
831 }
832 
const agxCollide::GeometryRefVector & getGeometries() const
agx::HashVector< agx::RigidBody *, SuctionCupInteractionRef > m_activeInteractions
agx::Vec3 m_localLineSensorVector
Inheritance with partial specialization due to bug with ref_ptr containers.
Definition: HashSet.h:669
agxCollide::GeometryRefVector m_sensors
agxCollide::SphereRef m_miniSphere
Utility class to get step event callbacks to any class having the methods implemented.
Definition: agxUtil.h:524
agx::ref_ptr< agxUtil::GeneralStepListener< SuctionGripper > > m_stepCallback
Base class for a shape.
Definition: Shape.h:53
agx::SymmetricPair< agx::Physics::GeometryPtr > GeometryPair
Definition: Geometry.h:66
agxCollide::GeometryContactPtrVector m_tempContacts
agx::Real m_timeOfPumpStateToggled
Abstract base class that implements a filter that selects which events should trigger a Listener...
Definition: ExecuteFilter.h:33
virtual void removeNotification(agxSDK::Simulation *)
Called when this assembly is removed from a simulation.
Definition: Assembly.h:621
A contact between two geometries.
Definition: Contacts.h:270
This should be considered a template class used as a base for Suction Gripper simulation models...
agxCollide::GeometryRef m_trimeshGeometry
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
virtual bool match(const agxCollide::GeometryContact &gc) const
Called when narrow phase tests have determined overlap (when we have detailed intersection between th...
agxUtil::TrimeshDeformerRef m_trimeshDeformer
agx::Real TimeStamp
Definition: TimeStamp.h:26
agxCollide::TrimeshRef m_trimesh
agx::RigidBodyObserver m_body
agxCollide::GeometryRef m_lineSensor
agx::Real m_currentLeakageArea
virtual bool match(const agxCollide::Geometry *g0, const agxCollide::Geometry *g1) const override
Inherited from agxSDK::ExecuteFilter.
Base class providing referencing counted objects.
Definition: Referenced.h:119
Contain classes for higher level modeling primitives, such as Tree, Terrain etc.
Definition: FlowUnit.h:36
The geometry representation used by the collision detection engine.
Definition: Geometry.h:92
Class for filtering objects of interest nearby a suction cup.
agx::ref_ptr< agxCollide::Line > m_line
agx::RealVector m_sealDepthMeasurements
agx::AffineMatrix4x4 m_miniSphereTransform
Constraint that removes all 6 DOF between two bodies, or one body and the world.
Definition: LockJoint.h:28
Vector containing &#39;raw&#39; data.
Definition: Vector.h:245
virtual void last(const agx::TimeStamp &time)
Called after a step is taken in the simulation Implement this method in the derived class to get call...
agxModel::SuctionCupRefVector m_suctionCups
virtual void post(const agx::TimeStamp &time)
Called after a step is taken in the simulation Implement this method in the derived class to get call...
KeepContactPolicy
Defines whether contact should be kept or removed after contact/impact methods returns.
agx::HashSet< SuctionCupRef > SuctionCupRefSet
The SuctionCup model owns a body which is mean to be attached somewhere on a SuctionGripper holder...
void addGeometry(agxCollide::Geometry *geometry)
The rigid body class, combining a geometric model and a frame of reference.
Definition: RigidBody.h:54
Main material class which acts as a holder of a Surface Material and a Bulk material.
Definition: Material.h:375
SuctionCupInteractionRefVector m_interactionsPool
agx::RigidBodyRef m_body
agx::ref_ptr< agxUtil::GeneralContactEventListener< SuctionCup > > m_contactCallback
VacuumSystemRef m_vacuumSystem
agxCollide::GeometryRefSetVector m_sealSensors
The object defining a frame of reference and providing transformations operations.
Definition: Frame.h:67
#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_calculatedAvailableVacuumForce
This class is an abstract base class for all classes that can be stored and retrieved from an Archive...
Definition: Serializable.h:44
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:616
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition: Simulation.h:126
SuctionCupSensorFilterRef m_collisionFilter
Basic model for a vacuum system used by a SuctionGripper.
agx::RigidBodyRef m_holderBody
#define AGXMODEL_EXPORT
agx::ref_ptr< agx::LockJoint > m_lock
double Real
Definition: Real.h:42
#define AGX_DECLARE_VECTOR_TYPES(type)
Definition: Vector.h:34
agx::HashVector< size_t, agx::Real > m_interactedSealDepth
Triangle mesh for geometric intersection tests.
Definition: Trimesh.h:42
virtual void pre(const agx::TimeStamp &time)
Called before a step is taken in the simulation Implement this method in the derived class to get cal...
The agxSDK namespace contain classes to bridge the collision detection system and the dynamical simul...
Definition: Constraint.h:30
virtual void preCollide(const agx::TimeStamp &time)
Called before collision detection is performed in the simulation Implement this method in the derived...
An assembly is a collection of basic simulation objects, such as rigid bodies, constraints, geometries.
Definition: Assembly.h:66
agxCollide::GeometryRefVector m_collisionGeometries
Utility class to get contact event callbacks to any class having the methods implemented.
Definition: agxUtil.h:572