AGX Dynamics  2.35.0.1
SuctionGripper.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2021. 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 
34 namespace agxSDK
35 {
36  class Simulation;
37 }
38 
39 
40 namespace agxModel
41 {
42 
43 
52  {
53  public:
54 
56  {}
57 
59  {
61  }
62 
64  {
65  return m_collisionGeometries;
66  }
67 
69  virtual bool match(const agxCollide::Geometry* g0, const agxCollide::Geometry* g1) const override
70  {
71  const agxCollide::Geometry* geos[] = { g0, g1 };
72 
73  for (size_t j = 0; j < 2; ++j)
74  {
75  for (size_t i = 0; i < m_collisionGeometries.size(); ++i)
76  {
77  if (geos[j] == m_collisionGeometries[i])
78  return true;
79  }
80  }
81  return false;
82  }
83 
84  using ExecuteFilter::match;
85 
86  protected:
88  {
90  };
91 
92 
93  protected:
96  };
97 
98 
99 
102 
105 
119  {
120  public:
126 
127 
131  size_t getSealCount() const;
132 
136  bool getCentered() const;
137 
144 
151 
158 
165 
172 
177 
182 
187 
192 
193 
194  protected:
196 
197  friend class SuctionCup;
198  friend class SuctionGripper;
199 
200  /*
201  Update the latest position found for where to apply the cvacuum force
202  */
204 
209 
216 
221  void setCenterDistance(agx::Real distance);
222 
228 
229  void updateInteractedSeals(size_t sealIndex, agx::Real depth);
230 
233 
234  agx::Real getSealDepth(size_t sealIndex) const;
235 
236  bool hasSealInteraction(size_t sealIndex) const;
237 
245  virtual bool updateVacuumForce(const SuctionCup* cup, const VacuumSystem* vacuumSystem, agx::Real fraction);
246 
247  void reset();
248 
250 
251  void renderInteraction(const SuctionCup* cup);
252 
263  };
264 
265 
268 
279  {
280  public:
289  VacuumSystem(agx::Real desiredVacuum);
290 
296 
302 
308  virtual void step(agx::Real dt, const SuctionGripper* gripper);
309 
313  void setEnablePump(const bool& enable);
314 
318  bool getEnablePump() const;
319 
324 
330  void setDesiredVacuum(agx::Real vacuumLevel);
331 
336 
341 
346 
351 
356 
361 
363 
364  protected:
365  virtual ~VacuumSystem();
379  };
380 
381 
417  class AGXMODEL_EXPORT SuctionCup : public virtual agx::Referenced, public virtual agxStream::Serializable
418  {
419  public:
432  agx::Real lipRadius = agx::Real(0.025),
433  agx::Real lipHeight = agx::Real(0.01),
434  size_t sealResolution = size_t(0),
435  agx::Vec3 localLineSensorVector = agx::Vec3(0,0,-0.1),
436  agx::Real sealSensorReach = agx::Real(0.01));
437 
438 
443 
449 
453  const agx::RigidBody* getRigidBody() const;
454 
459 
464 
472 
477 
481  bool isValid() const;
482 
487 
491  size_t getSealResolution() const;
492 
497 
502 
511 
516 
522 
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 
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 
729  virtual ~SuctionGripper();
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.
754  bool m_valid;
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:
819  void setupDeformableTrimesh(SuctionCup* cup, agx::Frame* holderFrame);
820 
823 
828 
829  };
830 }
831 
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:248
#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:270
The geometry representation used by the collision detection engine.
Definition: Geometry.h:93
Base class for a shape.
Definition: Shape.h:54
Triangle mesh for geometric intersection tests.
Definition: Trimesh.h:43
agxUtil::TrimeshDeformerRef m_trimeshDeformer
agx::RigidBody * createDefaultHolderBody(agx::Real radius, agx::Real height) const
agxUtil::TrimeshDeformer * getTrimeshDeformer() const
agxCollide::Geometry * getTrimeshGeometry() 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
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::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::RigidBody * getRigidBody()
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
agx::Real getArea() const
agx::Vec3 findSurfaceNormal(agxCollide::Shape *collidedShape, agx::Vec3 pointAtSurface, bool &success)
SuctionCupInteraction * getActiveInteraction(agx::RigidBody *rigidBody)
agx::Vec3 m_localLineSensorVector
SuctionCupSensorFilterRef m_collisionFilter
agx::Vector< agxModel::SuctionCupInteraction * > getActiveInteractionsVector() const
agxCollide::Geometry * createSealSensor(agx::RigidBody *body, agx::Vec3 bodyLocalPosition)
const agx::HashVector< agx::RigidBody *, SuctionCupInteractionRef > & getActiveInteractions() const
agx::Real getLipRadius() const
agx::ref_ptr< agxUtil::GeneralContactEventListener< SuctionCup > > m_contactCallback
agx::Vec3 calculateLineP2() const
agx::RigidBody * createDefaultCupBody()
agx::Real m_calculatedAvailableVacuumForce
agx::Real getSensorDistance() const
void setMountingRadius(agx::Real radius)
Set the mounting radius.
const SuctionCupInteractionRefVector & getDisabledInteractions() const
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
const agx::RigidBody * getRigidBody() const
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
agx::RigidBody * getRigidBody()
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 &)
void removeNotification(agxSDK::Simulation *simulation)
void collectCollisionGeometries()
SuctionCupSensorFilter * getSensorFilter()
const agxCollide::GeometryRefSetVector & getSealSensors() const
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
virtual agxModel::SuctionCupInteraction * createInteraction()
Function creating an interaction.
agxCollide::GeometryRefSetVector m_sealSensors
agxCollide::SphereRef m_miniSphere
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.
const agx::RigidBody * getHolderRigidBody() const
void addSuctionCup(SuctionCup *cup)
Add one suction cup to the gripper.
const SuctionCupRefVector & getSuctionCups() const
virtual void last(const agx::TimeStamp &)
SuctionCupRefVector & getSuctionCups()
agxModel::SuctionCupRefVector m_suctionCups
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 &)
VacuumSystem * getVacuumSystem()
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()
agx::RigidBody * getHolderRigidBody()
bool setHolderRigidBody(agx::RigidBody *holderBody)
Set the rigid body of the holder.
virtual void post(const agx::TimeStamp &)
const VacuumSystem * getVacuumSystem() 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:67
virtual void removeNotification(agxSDK::Simulation *)
Called when this assembly is removed from a simulation.
Definition: Assembly.h:618
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:613
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:35
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition: Simulation.h:127
This class is an abstract base class for all classes that can be stored and retrieved from an Archive...
Definition: Serializable.h:45
Utility class to get contact event callbacks to any class having the methods implemented.
Definition: agxUtil.h:573
Utility class to get step event callbacks to any class having the methods implemented.
Definition: agxUtil.h:525
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:666
Constraint that removes all 6 DOF between two bodies, or one body and the world.
Definition: LockJoint.h:29
Main material class which acts as a holder of a Surface Material and a Bulk material.
Definition: Material.h:388
Base class providing referencing counted objects.
Definition: Referenced.h:114
The rigid body class, combining a geometric model and a frame of reference.
Definition: RigidBody.h:55
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
agx::SymmetricPair< agx::Physics::GeometryPtr > GeometryPair
Definition: Geometry.h:66
Contain classes for higher level modeling primitives, such as Tree, Terrain etc.
Definition: FlowUnit.h:37
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:42
agx::Real TimeStamp
Definition: TimeStamp.h:26