AGX Dynamics 2.42.3.1
Loading...
Searching...
No Matches
Wheel.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
20
21#include <agx/Constraint.h>
22#include <agx/Plane.h>
23
24namespace agx
25{
26 class Hinge;
27}
28
29namespace agxSDK
30{
31 class Simulation;
32}
33
34namespace agxVehicle
35{
37
43 {
44 public:
46
47 public:
62 Wheel( agx::Real radius, agx::RigidBody* rb, agx::Frame* rbRelFrame = nullptr );
63
78 Wheel( agx::Real radius, agx::RigidBody* rb, agx::AffineMatrix4x4 rbRelTransform );
79
84
89
94
99
104
109
114
119
132 template<typename T>
133 agx::ref_ptr<T> attachConstraint( const agx::Name& name, agx::RigidBody* other, agx::Real wheelCenterOffset );
134
143 agx::Hinge* attachHinge( const agx::Name& name, agx::RigidBody* other, agx::Real wheelCenterOffset );
144
149
154
160
168 agx::Real offsetFromSurface = 0.0,
169 agx::Real wrapSign = -1.0 ) const;
170
180 agx::Real offsetFromSurface = 0.0,
181 agx::Real wrapSign = -1.0 ) const;
182
192 agx::Real offsetFromSurface = 0.0,
193 agx::Real wrapSign = -1.0 ) const;
194
211 const agx::Hinge* hinge,
212 agx::Real sign = 1.0);
213
225 const agx::Vec3 &rotationAxis );
226
227 public:
229
230 protected:
235
239 virtual ~Wheel();
240
241 private:
242 void addConstraint( const agx::Name& name, agx::Constraint* constraint );
243
244 private:
245 agx::Real m_radius;
247 agx::FrameRef m_rbRelFrame;
248 ConstraintContainer m_constraints;
249 };
250
251 template<typename T>
253 {
254 if ( m_rb == nullptr )
255 return agx::ref_ptr<T>( nullptr );
256
257 // x y z
258 const auto xAxis = getRotationAxis() ^ getUpAxis();
259 agx::OrthoMatrix3x3 rotation( getUpAxis().x(), getUpAxis().y(), getUpAxis().z(),
260 xAxis.x(), xAxis.y(), xAxis.z(),
261 getRotationAxis().x(), getRotationAxis().y(), getRotationAxis().z() );
262
263 const auto constraintFrame = agx::AffineMatrix4x4( rotation,
264 getCenterPosition() + wheelCenterOffset * getRotationAxis() );
265 agx::FrameRef wheelFrame = new agx::Frame( constraintFrame * m_rb->getTransform().inverse() );
266 agx::FrameRef otherFrame = new agx::Frame( constraintFrame * ( other != nullptr ? other->getTransform().inverse() : agx::AffineMatrix4x4() ) );
267
268 agx::ref_ptr<T> constraint = new T( m_rb, wheelFrame, other, otherFrame );
269 addConstraint( name, constraint );
270
271 return constraint;
272 }
273}
#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 AGXVEHICLE_EXPORT
This class is an abstract base class for all classes that can be stored and retrieved from an Archive...
Definition: Serializable.h:44
Abstraction of a wheel of arbitrary geometry.
Definition: Wheel.h:43
agx::Constraint * getConstraint() const
agx::Constraint * getConstraint(const agx::Name &name) const
virtual ~Wheel()
Reference counted object - protected destructor.
WheelTangentData tangentFrom(const agx::Vec3 &point, agx::Real offsetFromSurface=0.0, agx::Real wrapSign=-1.0) const
Calculates tangent from the given world point to wheel.
WheelTangentData tangentTo(const Wheel &other, agx::Real offsetFromSurface=0.0, agx::Real wrapSign=-1.0) const
static agx::AffineMatrix4x4 findRelativeTransform(const agx::RigidBody *wheelBody, const agx::Hinge *hinge, agx::Real sign=1.0)
Calculates a transformation such that, when applied to a wheel with the given rigid body,...
agx::Vec3 getCenterPosition() const
agx::RigidBody * getRigidBody() const
agx::Hinge * attachHinge(const agx::Name &name, agx::RigidBody *other, agx::Real wheelCenterOffset)
Specialized version of attachConstraint to create a hinge with this wheel body and other.
Wheel(agx::Real radius, agx::RigidBody *rb, agx::Frame *rbRelFrame=nullptr)
Construct wheel given radius, wheel body and frame defining wheel center, up and rotation axes in the...
agx::Frame * getLocalFrame() const
static agx::AffineMatrix4x4 findRelativeTransform(const agx::RigidBody *wheelBody, const agx::Vec3 &rotationAxis)
Calculates a transformation such that, when applied to a wheel with the given rigid body,...
agx::Plane getRotationAxisPlane() const
agx::Real getRadius() const
Wheel()
Default constructor used only when this object is restored.
agx::Vec3 getRotationAxis() const
const ConstraintContainer & getConstraints() const
agx::Vec3 getUpAxis() const
agx::AffineMatrix4x4 getTransform() const
agx::ref_ptr< T > attachConstraint(const agx::Name &name, agx::RigidBody *other, agx::Real wheelCenterOffset)
Create constraint with this wheel and some other rigid body.
Definition: Wheel.h:252
WheelTangentData tangentTo(const agx::Vec3 &point, agx::Real offsetFromSurface=0.0, agx::Real wrapSign=-1.0) const
Calculates tangent from this wheel to a world point.
Wheel(agx::Real radius, agx::RigidBody *rb, agx::AffineMatrix4x4 rbRelTransform)
Construct wheel given radius, wheel body and transform defining wheel center, up and rotation axes in...
AffineMatrix4x4T< T > inverse() const
Quick inverse, transpose rotation part, and change sign of translation part.
The base class for a constraint.
Definition: Constraint.h:89
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
Representation of a name string.
Definition: Name.h:33
Specialized types of matrices for holding orthogonal transformation matrices.
Class representing the mathematical concept of a plane, also called a half- space.
Definition: agx/Plane.h:32
Base class providing referencing counted objects.
Definition: Referenced.h:120
The rigid body class, combining a geometric model and a frame of reference.
Definition: RigidBody.h:49
const agx::AffineMatrix4x4 & getTransform() const
Current model frame transform, given in world coordinate frame.
Definition: RigidBody.h:1253
Smart pointer for handling referenced counted objects.
Definition: ref_ptr.h:30
The agxSDK namespace contain classes to bridge the collision detection system and the dynamical simul...
Definition: Constraint.h:31
This namespace contains classes related to vehicles dynamics.
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
double Real
Definition: Real.h:41
AffineMatrix4x4T< Real > AffineMatrix4x4
Data for an external tangent between two wheels.