AGXDynamics  2.31.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TwoBodyTire.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 #ifndef AGXMODEL_TWO_BODY_TIRE_H
18 #define AGXMODEL_TWO_BODY_TIRE_H
19 
20 #include <agxModel/export.h>
21 
22 #include <agxModel/Tire.h>
23 #include <agx/Vec2.h>
24 #include <agx/Hinge.h>
25 #include <agxUtil/agxUtil.h>
26 
27 namespace agxSDK
28 {
29  class Simulation;
30 }
31 
32 
33 namespace agxModel
34 {
36  // Class for allowing contacts as long as any of the bodies is involved.
38  {
39  public:
40 
42  {}
43 
44  void addBody(agx::RigidBody* body)
45  {
46  m_bodies.push_back(body);
47  }
48 
50  virtual bool match(const agxCollide::Geometry* g0, const agxCollide::Geometry* g1) const override
51  {
52  const agxCollide::Geometry* geos[] = { g0, g1 };
53 
54  for (size_t j = 0; j < 2; ++j)
55  if (geos[j]->getRigidBody())
56  for (size_t i = 0; i < m_bodies.size(); ++i)
57  if (geos[j]->getRigidBody() == m_bodies[i])
58  return true;
59 
60  return false;
61  }
62 
63  using ExecuteFilter::match;
64 
65  protected:
66  virtual ~TireFilter() {};
67 
68 
69  protected:
70  agx::RigidBodyRefVector m_bodies;
71  };
72 
73 
83  {
84  public:
89  TireFriction( const agx::Frame* referenceFrame );
90 
92  virtual void calculateTangentPlane(
93  const agxCollide::Geometry* geometry1,
94  const agxCollide::Geometry* geometry2,
95  const agx::Vec3& point,
96  const agx::Vec3& normal,
97  const agx::Real depth,
98  agx::Vec3& ret_u,
99  agx::Vec3& ret_v ) const override;
100 
101  protected:
102  virtual ~TireFriction();
103 
104  protected:
106  };
107 
108 
145  {
146  public:
160  TwoBodyTire( agx::RigidBody* tireBody, agx::Real outerRadius,
161  agx::RigidBody* hubBody, agx::Real innerRadius,
162  const agx::AffineMatrix4x4& localTransform = agx::AffineMatrix4x4() );
163 
165  RADIAL, // Translation orthogonal to rotation axis.
166  LATERAL, // Translation in rotation axis.
167  BENDING, // Rotation orthogonal to rotation axis.
168  TORSIONAL // Rotation in rotation axis.
169  };
170 
174  agx::RigidBody* getTireRigidBody();
175 
179  const agx::RigidBody* getTireRigidBody() const;
180 
184  agx::RigidBody* getHubRigidBody();
185 
189  const agx::RigidBody* getHubRigidBody() const;
190 
194  agx::Real getOuterRadius() const;
195 
199  agx::Real getInnerRadius() const;
200 
202  bool isValid() const;
203 
205  const agx::Frame* getReferenceFrame() const;
206 
211  agx::Vec2 getImplicitFrictionMultiplier() const;
212 
220  void setImplicitFrictionMultiplier(const agx::Vec2& implicitFrictionMultiplier);
221 
229  virtual agx::Real getLoadedRadius() const override;
230 
238  virtual bool setStiffness(const agx::Real stiffness, DeformationMode mode);
239 
246  virtual agx::Real getStiffness(DeformationMode mode);
247 
255  virtual bool setDampingCoefficient(const agx::Real dampingCoefficient, DeformationMode mode);
256 
263  virtual agx::Real getDampingCoefficient(DeformationMode mode);
264 
271  static TwoBodyTire* find( agxSDK::Simulation* simulation, const agx::Name& name );
272 
279  static TwoBodyTire* find( agxSDK::Assembly* assembly, const agx::Name& name );
280 
287  static TwoBodyTirePtrVector findAll( const agxSDK::Simulation* simulation, const agx::Name& name );
288 
294  static TwoBodyTirePtrVector findAll( const agxSDK::Simulation* simulation );
295 
304  agx::Hinge* getHinge();
305 
307 
308  protected:
309  TwoBodyTire();
310 
311  virtual void updateValid();
312 
313  void initBodies(agx::Real outerRadius, agx::Real innerRadius);
314 
315  virtual ~TwoBodyTire();
316 
317  // Adding to/removing from simulation.
318  virtual void addNotification( agxSDK::Simulation* simulation ) override;
319 
321 
322  virtual void removeNotification( agxSDK::Simulation* simulation )override;
323 
325 
326  // Contact events.
328 
331 
334 
335  void separation(
337 
340 
341  agx::Vec3 getTireCenterWorld() const;
342 
343  agx::Vec3 getTireAxisWorld() const;
344 
345  void reduceContacts(agxCollide::LocalGeometryContact& gc);
346 
347  // Step events.
349 
350  virtual void preCollide( const agx::TimeStamp& );
351  virtual void pre( const agx::TimeStamp& );
352  virtual void post( const agx::TimeStamp& );
353  virtual void last( const agx::TimeStamp& );
354 
355 
356  protected:
357  // More persistent variables, will be serialized.
364  bool m_valid;
366  // Implementation dependent temporary variables, only valid per simulation.
370  // Implementation dependent temporary variables, only valid per time step.
373  };
374 }
375 
376 #endif // AGXMODEL_TWO_BODY_TIRE_H
agx::RigidBodyRefVector m_bodies
Definition: TwoBodyTire.h:66
Utility class to get step event callbacks to any class having the methods implemented.
Definition: agxUtil.h:445
agx::Vec2 m_implicitFrictionMultiplier
Definition: TwoBodyTire.h:361
agx::SymmetricPair< agx::Physics::GeometryPtr > GeometryPair
Definition: Geometry.h:63
agx::ref_ptr< agxUtil::GeneralStepListener< TwoBodyTire > > m_stepCallback
Definition: TwoBodyTire.h:369
Abstract base class that implements a filter that selects which events should trigger a Listener...
Definition: ExecuteFilter.h:34
virtual void removeNotification(agxSDK::Simulation *)
Called when this assembly is removed from a simulation.
Definition: Assembly.h:584
A contact between two geometries.
Definition: Contacts.h:270
agx::ref_ptr< agxUtil::GeneralContactEventListener< TwoBodyTire > > m_contactCallback
Definition: TwoBodyTire.h:368
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:248
Representation of a name string.
Definition: Name.h:32
agx::Real TimeStamp
Definition: TimeStamp.h:26
agx::RigidBodyObserver m_hubBody
Definition: TwoBodyTire.h:359
void addBody(agx::RigidBody *body)
Definition: TwoBodyTire.h:44
The geometry representation used by the collision detection engine.
Definition: Geometry.h:88
AGX_DECLARE_VECTOR_TYPES(Deformable1DComponent)
agx::Real m_loadedRadius
Definition: TwoBodyTire.h:365
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...
agx::RigidBodyObserver m_tireBody
Definition: TwoBodyTire.h:358
agx::Vector< agx::ContactMaterialRef > m_contactMaterials
Definition: TwoBodyTire.h:372
agx::HingeRef m_hinge
Definition: TwoBodyTire.h:362
virtual KeepContactPolicy impact(const agx::TimeStamp &time, agxCollide::GeometryContact *geometryContact)
Called upon impact event if getFilter() contain IMPACT.
agx::FrameConstObserver m_refFrame
Definition: TwoBodyTire.h:105
Smart pointer for handling referenced counted objects.
Definition: ref_ptr.h:29
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.
The hinge constraint between two rigid bodies or one rigid body and the world.
Definition: Hinge.h:103
The rigid body class, combining a geometric model and a frame of reference.
Definition: RigidBody.h:52
agx::UInt32 m_collisionGroup
Definition: TwoBodyTire.h:367
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:206
agx::FrameRef m_refFrame
Definition: TwoBodyTire.h:363
Iterative Projected Cone Friction (IPC friction) model.
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:579
agx::Vector< agxCollide::LocalGeometryContact > m_contacts
Definition: TwoBodyTire.h:371
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition: Simulation.h:121
#define AGXMODEL_EXPORT
Friction model that follows a tire&#39;s orientation in the world, based on the tire&#39;s frame...
Definition: TwoBodyTire.h:82
virtual bool match(const agxCollide::Geometry *g0, const agxCollide::Geometry *g1) const override
Inherited from agxSDK::ExecuteFilter.
Definition: TwoBodyTire.h:50
double Real
Definition: Real.h:42
virtual ~TireFilter()
Definition: TwoBodyTire.h:66
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...
virtual void preCollide(const agx::TimeStamp &time)
Called before collision detection is performed in the simulation Implement this method in the derived...
uint32_t UInt32
Definition: Integer.h:40
An assembly is a collection of basic simulation objects, such as rigid bodies, constraints, geometries.
Definition: Assembly.h:73
virtual void separation(const agx::TimeStamp &t, agxCollide::GeometryPair &gp)
Called upon separation event if getFilter() contain SEPARATION.
Definition: agxUtil.h:516
virtual KeepContactPolicy contact(const agx::TimeStamp &time, agxCollide::GeometryContact *geometryContact)
Called upon contact event if getFilter() contain CONTACT.
Utility class to get contact event callbacks to any class having the methods implemented.
Definition: agxUtil.h:493