AGX Dynamics  2.38.0.2
TwoBodyTire.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 <agxModel/Tire.h>
22 #include <agx/Vec2.h>
23 #include <agx/Hinge.h>
24 #include <agxUtil/agxUtil.h>
25 
26 namespace agxSDK
27 {
28  class Simulation;
29 }
30 
31 
32 namespace agxModel
33 {
35  // Class for allowing contacts as long as any of the bodies is involved.
37  {
38  public:
39 
41  {}
42 
43  void addBody(agx::RigidBody* body)
44  {
45  m_bodies.push_back(body);
46  }
47 
49  virtual bool match(const agxCollide::Geometry* g0, const agxCollide::Geometry* g1) const override
50  {
51  const agxCollide::Geometry* geos[] = { g0, g1 };
52 
53  for (size_t j = 0; j < 2; ++j)
54  if (geos[j]->getRigidBody())
55  for (size_t i = 0; i < m_bodies.size(); ++i)
56  if (geos[j]->getRigidBody() == m_bodies[i])
57  return true;
58 
59  return false;
60  }
61 
62  using ExecuteFilter::match;
63 
64  protected:
65  virtual ~TireFilter() {};
66 
67 
68  protected:
70  };
71 
72 
82  {
83  public:
88  TireFriction( const agx::Frame* referenceFrame );
89 
91  virtual void calculateTangentPlane(
92  const agxCollide::Geometry* geometry1,
93  const agxCollide::Geometry* geometry2,
94  const agx::Vec3& point,
95  const agx::Vec3& normal,
96  const agx::Real depth,
97  agx::Vec3& ret_u,
98  agx::Vec3& ret_v ) const override;
99 
100  protected:
101  virtual ~TireFriction();
102 
103  protected:
105  };
106 
107 
148  {
149  public:
164  TwoBodyTire( agx::RigidBody* tireBody, agx::Real outerRadius,
165  agx::RigidBody* hubBody, agx::Real innerRadius,
166  const agx::AffineMatrix4x4& localTransform = agx::AffineMatrix4x4() );
167 
169  RADIAL, // Translation orthogonal to rotation axis.
170  LATERAL, // Translation in rotation axis.
171  BENDING, // Rotation orthogonal to rotation axis.
172  TORSIONAL // Rotation in rotation axis.
173  };
174 
178  agx::RigidBody* getTireRigidBody();
179 
183  const agx::RigidBody* getTireRigidBody() const;
184 
188  agx::RigidBody* getHubRigidBody();
189 
193  const agx::RigidBody* getHubRigidBody() const;
194 
198  agx::Real getOuterRadius() const;
199 
203  agx::Real getInnerRadius() const;
204 
206  virtual bool isValid() const;
207 
209  const agx::Frame* getReferenceFrame() const;
210 
215  agx::Vec2 getImplicitFrictionMultiplier() const;
216 
224  void setImplicitFrictionMultiplier(const agx::Vec2& implicitFrictionMultiplier);
225 
233  virtual agx::Real getLoadedRadius() const override;
234 
242  virtual bool setStiffness(const agx::Real stiffness, DeformationMode mode);
243 
250  virtual agx::Real getStiffness(DeformationMode mode);
251 
259  virtual bool setDampingCoefficient(const agx::Real dampingCoefficient, DeformationMode mode);
260 
267  virtual agx::Real getDampingCoefficient(DeformationMode mode);
268 
275  static TwoBodyTire* find( agxSDK::Simulation* simulation, const agx::Name& name );
276 
283  static TwoBodyTire* find( agxSDK::Assembly* assembly, const agx::Name& name );
284 
291  static TwoBodyTirePtrVector findAll( const agxSDK::Simulation* simulation, const agx::Name& name );
292 
298  static TwoBodyTirePtrVector findAll( const agxSDK::Simulation* simulation );
299 
308  agx::Hinge* getHinge();
309 
311 
312  protected:
313  TwoBodyTire();
314 
315  void initBodies(agx::Real outerRadius, agx::Real innerRadius);
316 
317  virtual ~TwoBodyTire();
318 
319  // Adding to/removing from simulation.
320  virtual void addNotification( agxSDK::Simulation* simulation ) override;
321 
323 
324  virtual void removeNotification( agxSDK::Simulation* simulation )override;
325 
327 
328  // Contact events.
330 
333 
336 
337  void separation(
339 
342 
343  agx::Vec3 getTireCenterWorld() const;
344 
345  agx::Vec3 getTireAxisWorld() const;
346 
347  void reduceContacts(agxCollide::LocalGeometryContact& gc);
348 
349  // Step events.
351 
352  virtual void preCollide( const agx::TimeStamp& );
353  virtual void pre( const agx::TimeStamp& );
354  virtual void post( const agx::TimeStamp& );
355  virtual void last( const agx::TimeStamp& );
356 
357 
358  protected:
359  // More persistent variables, will be serialized.
368  // Implementation dependent temporary variables, only valid per simulation.
372  // Implementation dependent temporary variables, only valid per time step.
375  };
376 }
377 
agxModel::TwoBodyTire::BENDING
@ BENDING
Definition: TwoBodyTire.h:171
agxSDK::StepEventListener::pre
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...
Definition: StepEventListener.h:106
agxUtil::GeneralContactEventListener::separation
agxCollide::GeometryContact *virtual void separation(const agx::TimeStamp &t, agxCollide::GeometryPair &gp)
Called upon separation event if getFilter() contain SEPARATION.
Definition: agxUtil.h:595
agxModel::TireFilter
Definition: TwoBodyTire.h:36
agx::Real
double Real
Definition: Real.h:42
agxModel
Contain classes for higher level modeling primitives, such as Tree, Terrain etc.
Definition: FlowUnit.h:36
agxData::GeometryPair
agx::SymmetricPair< agx::Physics::GeometryPtr > GeometryPair
Definition: Geometry.h:65
agxUtil::GeneralStepListener
Utility class to get step event callbacks to any class having the methods implemented.
Definition: agxUtil.h:524
agxModel::TwoBodyTire::LATERAL
@ LATERAL
Definition: TwoBodyTire.h:170
Hinge.h
agx::Vector< RigidBodyRef >
agx::Container::size
size_t size() const
Definition: Container.h:134
agx::RigidBody
The rigid body class, combining a geometric model and a frame of reference.
Definition: RigidBody.h:51
agx::IterativeProjectedConeFriction
Iterative Projected Cone Friction (IPC friction) model.
Definition: FrictionModel.h:303
agxCollide::LocalGeometryContact
Definition: LocalContactPoint.h:209
export.h
agxModel::TireFilter::m_bodies
agx::RigidBodyRefVector m_bodies
Definition: TwoBodyTire.h:65
agx::AffineMatrix4x4T< Real >
agxSDK::ExecuteFilter
Abstract base class that implements a filter that selects which events should trigger a Listener.
Definition: ExecuteFilter.h:33
agxSDK::StepEventListener::post
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...
Definition: StepEventListener.h:107
agxModel::TwoBodyTire::m_initialized
bool m_initialized
Definition: TwoBodyTire.h:366
agxModel::TwoBodyTire::m_contactCallback
agx::ref_ptr< agxUtil::GeneralContactEventListener< TwoBodyTire > > m_contactCallback
Definition: TwoBodyTire.h:370
agxModel::TwoBodyTire::m_implicitFrictionMultiplier
agx::Vec2 m_implicitFrictionMultiplier
Definition: TwoBodyTire.h:363
agxModel::TwoBodyTire::m_stepCallback
agx::ref_ptr< agxUtil::GeneralStepListener< TwoBodyTire > > m_stepCallback
Definition: TwoBodyTire.h:371
AGXSTREAM_DECLARE_SERIALIZABLE
#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::VectorPOD
Vector containing 'raw' data.
Definition: Vector.h:245
agxModel::TwoBodyTire::m_loadedRadius
agx::Real m_loadedRadius
Definition: TwoBodyTire.h:367
agxUtil::GeneralContactEventListener
Utility class to get contact event callbacks to any class having the methods implemented.
Definition: agxUtil.h:572
agx::observer_ptr< const Frame >
agxModel::TwoBodyTire::m_tireBody
agx::RigidBodyObserver m_tireBody
Definition: TwoBodyTire.h:360
agxSDK::StepEventListener::last
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...
Definition: StepEventListener.h:108
agxModel::TwoBodyTire::m_contactMaterials
agx::Vector< agx::ContactMaterialRef > m_contactMaterials
Definition: TwoBodyTire.h:374
AGX_DECLARE_VECTOR_TYPES
#define AGX_DECLARE_VECTOR_TYPES(type)
Definition: Vector.h:34
Vec2.h
agxSDK::Assembly
An assembly is a collection of basic simulation objects, such as rigid bodies, constraints,...
Definition: Assembly.h:67
agx::ref_ptr< Hinge >
agxSDK::Simulation
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition: Simulation.h:125
agxModel::TwoBodyTire::m_hubBody
agx::RigidBodyObserver m_hubBody
Definition: TwoBodyTire.h:361
agxModel::TwoBodyTire::DeformationMode
DeformationMode
Definition: TwoBodyTire.h:168
agxSDK::ContactEventListener::KeepContactPolicy
KeepContactPolicy
Defines whether contact should be kept or removed after contact/impact methods returns.
Definition: ContactEventListener.h:59
Tire.h
agxCollide::Geometry
The geometry representation used by the collision detection engine.
Definition: Geometry.h:91
agx::Vec2T< Real >
agx::Name
Representation of a name string.
Definition: Name.h:32
agxModel::TireFilter::~TireFilter
virtual ~TireFilter()
Definition: TwoBodyTire.h:65
agxModel::TwoBodyTire::m_contacts
agx::Vector< agxCollide::LocalGeometryContact > m_contacts
Definition: TwoBodyTire.h:373
agxModel::TwoBodyTire::m_collisionGroup
agx::UInt32 m_collisionGroup
Definition: TwoBodyTire.h:369
agxSDK::ContactEventListener::contact
virtual KeepContactPolicy contact(const agx::TimeStamp &time, agxCollide::GeometryContact *geometryContact)
Called upon contact event if getFilter() contain CONTACT.
Definition: ContactEventListener.h:147
AGX_DECLARE_POINTER_TYPES
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
agxSDK::ContactEventListener::impact
virtual KeepContactPolicy impact(const agx::TimeStamp &time, agxCollide::GeometryContact *geometryContact)
Called upon impact event if getFilter() contain IMPACT.
Definition: ContactEventListener.h:142
agxModel::TireFilter::match
virtual bool match(const agxCollide::Geometry *g0, const agxCollide::Geometry *g1) const override
Inherited from agxSDK::ExecuteFilter.
Definition: TwoBodyTire.h:49
agxCollide::GeometryContact
A contact between two geometries.
Definition: Contacts.h:270
agxModel::TwoBodyTire::m_hinge
agx::HingeRef m_hinge
Definition: TwoBodyTire.h:364
agx::TimeStamp
agx::Real TimeStamp
Definition: TimeStamp.h:26
agxModel::TireFilter::addBody
void addBody(agx::RigidBody *body)
Definition: TwoBodyTire.h:43
agxModel::TwoBodyTire::m_innerRadius
agx::Real m_innerRadius
Definition: TwoBodyTire.h:362
AGXMODEL_EXPORT
#define AGXMODEL_EXPORT
Definition: agxModel/export.h:42
agx::Hinge
The hinge constraint between two rigid bodies or one rigid body and the world.
Definition: Hinge.h:103
agxSDK
The agxSDK namespace contain classes to bridge the collision detection system and the dynamical simul...
Definition: Constraint.h:30
agxModel::TwoBodyTire::m_refFrame
agx::FrameRef m_refFrame
Definition: TwoBodyTire.h:365
agxModel::TireFilter::TireFilter
TireFilter()
Definition: TwoBodyTire.h:40
agx::Vec3T< Real >
agxModel::TireFriction
Friction model that follows a tire's orientation in the world, based on the tire's frame.
Definition: TwoBodyTire.h:81
agx::UInt32
uint32_t UInt32
Definition: Integer.h:32
agxModel::TwoBodyTire
Definition: TwoBodyTire.h:147
agx::Frame
The object defining a frame of reference and providing transformations operations.
Definition: Frame.h:67
agxSDK::Assembly::removeNotification
virtual void removeNotification(agxSDK::Simulation *)
Called when this assembly is removed from a simulation.
Definition: Assembly.h:657
agxSDK::StepEventListener::preCollide
virtual void preCollide(const agx::TimeStamp &time)
Called before collision detection is performed in the simulation Implement this method in the derived...
Definition: StepEventListener.h:105
agxModel::TwoBodyTire::RADIAL
@ RADIAL
Definition: TwoBodyTire.h:169
agxModel::TireFriction::m_refFrame
agx::FrameConstObserver m_refFrame
Definition: TwoBodyTire.h:104
agxModel::Tire
Definition: Tire.h:36
agxUtil.h
agx::Vector::push_back
void push_back(const T2 &value)
Definition: Vector.h:715
agxSDK::Assembly::addNotification
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:652