AGX Dynamics 2.42.1.1
Loading...
Searching...
No Matches
TwoBodyTire.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 <agxModel/Tire.h>
22#include <agx/Vec2.h>
23#include <agx/Hinge.h>
24#include <agxUtil/agxUtil.h>
25
26namespace agxSDK
27{
28 class Simulation;
29}
30
31
32namespace agxModel
33{
35 // Class for allowing contacts as long as any of the bodies is involved.
37 {
38 public:
39
41 {}
42
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
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
179
184
189
194
199
204
206 virtual bool isValid() const;
207
210
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
251
259 virtual bool setDampingCoefficient(const agx::Real dampingCoefficient, DeformationMode mode);
260
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
299
309
310 enum Flags
311 {
313 CONTACT_FILTER = 1 << 0,
314 CONSTRAINT = 1 << 1,
315 DEFAULT=CONTACT_FILTER | CONSTRAINT
316 };
317
324 void setEnable(Flags flags);
325
326
331
333
334 protected:
336
337 void initBodies(agx::Real outerRadius, agx::Real innerRadius);
338
339 virtual ~TwoBodyTire();
340
341 // Adding to/removing from simulation.
342 virtual void addNotification( agxSDK::Simulation* simulation ) override;
343
345
346 virtual void removeNotification( agxSDK::Simulation* simulation )override;
347
349
350 // Contact events.
352
355
358
360 const agx::TimeStamp&, agxCollide::GeometryPair& );
361
364
366
368
369 void reduceContacts(agxCollide::LocalGeometryContact& gc);
370
371 // Step events.
373
374 virtual void preCollide( const agx::TimeStamp& );
375 virtual void pre( const agx::TimeStamp& );
376 virtual void post( const agx::TimeStamp& );
377 virtual void last( const agx::TimeStamp& );
378
379
380 protected:
381 // More persistent variables, will be serialized.
390 // Implementation dependent temporary variables, only valid per simulation.
394 // Implementation dependent temporary variables, only valid per time step.
397 };
398}
399
#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
virtual bool match(const agxCollide::Geometry *g0, const agxCollide::Geometry *g1) const override
Inherited from agxSDK::ExecuteFilter.
Definition: TwoBodyTire.h:49
void addBody(agx::RigidBody *body)
Definition: TwoBodyTire.h:43
virtual ~TireFilter()
Definition: TwoBodyTire.h:65
agx::RigidBodyRefVector m_bodies
Definition: TwoBodyTire.h:69
Friction model that follows a tire's orientation in the world, based on the tire's frame.
Definition: TwoBodyTire.h:82
virtual void calculateTangentPlane(const agxCollide::Geometry *geometry1, const agxCollide::Geometry *geometry2, const agx::Vec3 &point, const agx::Vec3 &normal, const agx::Real depth, agx::Vec3 &ret_u, agx::Vec3 &ret_v) const override
Inherited from IterativeProjectedConeFriction, the only change.
TireFriction(const agx::Frame *referenceFrame)
Constructor given frame.
agx::FrameConstObserver m_refFrame
Definition: TwoBodyTire.h:104
agx::Vec3 getTireCenterWorld() const
void setImplicitFrictionMultiplier(const agx::Vec2 &implicitFrictionMultiplier)
Set the implicit friction multiplier in order to get different behavior for different friction direct...
agx::ref_ptr< agxUtil::GeneralStepListener< TwoBodyTire > > m_stepCallback
Definition: TwoBodyTire.h:393
static TwoBodyTirePtrVector findAll(const agxSDK::Simulation *simulation, const agx::Name &name)
Find all TwoBodyTires with given name.
agx::Real getOuterRadius() const
agx::Vec2 m_implicitFrictionMultiplier
Definition: TwoBodyTire.h:385
Flags getEnable() const
Get current enabled flags.
virtual void pre(const agx::TimeStamp &)
virtual agx::Real getLoadedRadius() const override
Gets the current loaded radius.
agx::Vec2 getImplicitFrictionMultiplier() const
agx::ref_ptr< agxUtil::GeneralContactEventListener< TwoBodyTire > > m_contactCallback
Definition: TwoBodyTire.h:392
void setEnable(Flags flags)
Set flags for this tire to enable or disable certain features.
agx::RigidBody * getHubRigidBody()
agx::FrameRef m_refFrame
Definition: TwoBodyTire.h:387
virtual bool isValid() const
agx::Hinge * getHinge()
Gets the hinge (with active Lock1D) connecting the tire to the hub.
agx::Real getInnerRadius() const
agx::RigidBody * getTireRigidBody()
const agx::RigidBody * getTireRigidBody() const
void separation(const agx::TimeStamp &, agxCollide::GeometryPair &)
@ NONE
No flags set.
Definition: TwoBodyTire.h:312
virtual agx::Real getStiffness(DeformationMode mode)
Gets the stiffness for a deformation mode.
TwoBodyTire(agx::RigidBody *tireBody, agx::Real outerRadius, agx::RigidBody *hubBody, agx::Real innerRadius, const agx::AffineMatrix4x4 &localTransform=agx::AffineMatrix4x4())
Construct tire given rigid body (with wheel geometry/geometries) and radius.
agx::Vec3 getTireAxisWorld() const
virtual bool setDampingCoefficient(const agx::Real dampingCoefficient, DeformationMode mode)
Sets the damping coefficient for a deformation mode.
static TwoBodyTire * find(agxSDK::Simulation *simulation, const agx::Name &name)
Search the given simulation for a TwoBodyTire with the given name.
const agx::RigidBody * getHubRigidBody() const
virtual bool setStiffness(const agx::Real stiffness, DeformationMode mode)
Sets the stiffness for a deformation mode.
agx::Real m_loadedRadius
Definition: TwoBodyTire.h:389
virtual void post(const agx::TimeStamp &)
agxSDK::ContactEventListener::KeepContactPolicy contact(const agx::TimeStamp &, agxCollide::GeometryContact *gc)
static TwoBodyTirePtrVector findAll(const agxSDK::Simulation *simulation)
Finds all TwoBodyTire in the given simulation.
agxSDK::ContactEventListener::KeepContactPolicy handleContacts(const agx::TimeStamp &, agxCollide::GeometryContact *gc)
static TwoBodyTire * find(agxSDK::Assembly *assembly, const agx::Name &name)
Search the given assembly for a TwoBodyTire with the given name.
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).
agxSDK::ContactEventListener::KeepContactPolicy impact(const agx::TimeStamp &, agxCollide::GeometryContact *gc)
agx::HingeRef m_hinge
Definition: TwoBodyTire.h:386
const agx::Frame * getReferenceFrame() const
virtual void preCollide(const agx::TimeStamp &)
virtual void last(const agx::TimeStamp &)
agx::Vector< agx::ContactMaterialRef > m_contactMaterials
Definition: TwoBodyTire.h:396
agx::RigidBodyObserver m_hubBody
Definition: TwoBodyTire.h:383
agx::Vector< agxCollide::LocalGeometryContact > m_contacts
Definition: TwoBodyTire.h:395
agx::UInt32 m_collisionGroup
Definition: TwoBodyTire.h:391
virtual agx::Real getDampingCoefficient(DeformationMode mode)
Gets the damping coefficient for a deformation mode.
agx::RigidBodyObserver m_tireBody
Definition: TwoBodyTire.h:382
void initBodies(agx::Real outerRadius, agx::Real innerRadius)
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
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
The hinge constraint between two rigid bodies or one rigid body and the world.
Definition: Hinge.h:104
Iterative Projected Cone Friction (IPC friction) model.
Representation of a name string.
Definition: Name.h:33
The rigid body class, combining a geometric model and a frame of reference.
Definition: RigidBody.h:49
Vector containing 'raw' data.
Definition: agx/Vector.h:246
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
The agxSDK namespace contain classes to bridge the collision detection system and the dynamical simul...
Definition: Constraint.h:31
uint32_t UInt32
Definition: Integer.h:32
double Real
Definition: Real.h:41
agx::Real TimeStamp
Definition: TimeStamp.h:26