AGXDynamics  2.31.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
agxVehicle::Wheel Class Reference

Abstraction of a wheel of arbitrary geometry. More...

#include <Wheel.h>

+ Inheritance diagram for agxVehicle::Wheel:

Public Types

using ConstraintContainer = agx::Vector< agx::ConstraintRef >
 

Public Member Functions

 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 rigid body frame. More...
 
 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 the rigid body frame. More...
 
template<typename T >
T * as ()
 Subclass casting. More...
 
template<typename T >
const T * as () const
 
template<typename T >
T * asSafe ()
 Safe subclass casting, return nullptr if template type does not match. More...
 
template<typename T >
const T * asSafe () const
 
template<typename T >
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. More...
 
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. More...
 
agx::Vec3 getCenterPosition () const
 
const char * getClassName () const override
 
agx::Constraint * getConstraint () const
 
agx::Constraint * getConstraint (const agx::Name &name) const
 
const ConstraintContainer & getConstraints () const
 
bool getEnableSerialization () const
 
bool getEnableUuidGeneration ()
 
agx::UInt32 getIndex () const
 This index is given at creation of this object. More...
 
agx::Frame * getLocalFrame () const
 
agx::Real getRadius () const
 
int getReferenceCount () const
 
agx::RigidBody * getRigidBody () const
 
agx::Vec3 getRotationAxis () const
 
agx::Plane getRotationAxisPlane () const
 
agxStream::StorageAgent * getStorageAgent () const override
 
agx::AffineMatrix4x4 getTransform () const
 
agx::Vec3 getUpAxis () const
 
agx::Uuid getUuid () const
 
template<typename T >
bool is () const
 Subclass test. More...
 
bool isFinished () const
 
void reference (void *ptr=nullptr) const
 Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it. More...
 
virtual void restore (agxStream::InputArchive &in) override
 
void setEnableSerialization (bool flag)
 Set to false to disable serialization of this object. More...
 
void setFinished ()
 Tells this class that it is restored correctly and should not be deleted during destruction of an Archive. More...
 
void setUuid (const agx::Uuid &uuid)
 Explicitly set a Uuid on a serializable object. More...
 
virtual void store (agxStream::OutputArchive &out) const override
 
void unreference (void *ptr=nullptr) const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
void unreference_nodelete () const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 

Static Public Member Functions

static agxStream::Serializable * create ()
 
static agxStream::Serializable * create (agxStream::InputArchive &)
 
static const char * getConstructClassId ()
 
static void setEnableUuidGeneration (bool flag)
 Specify if there should be UUID:s generated for each new Serializable object. By default it is enabled. More...
 
template<typename T >
static bool ValidateCast (const Referenced *object)
 

Protected Member Functions

 Wheel ()
 Default constructor used only when this object is restored. More...
 
virtual ~Wheel ()
 Reference counted object - protected destructor. More...
 
void allocateObserverVector () const
 
void deleteUsingDeleteHandler () const
 
void generateUuid ()
 

Static Protected Member Functions

static DeleteHandler * getDeleteHandler ()
 
static void setDeleteHandler (DeleteHandler *handler)
 Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to. More...
 

Protected Attributes

Mutex m_mutex
 
ObserverContainer m_observers
 
AtomicValue m_refCount
 

Detailed Description

Abstraction of a wheel of arbitrary geometry.

The wheel has a well defined center, rotation axis and radius.

Definition at line 37 of file Wheel.h.

Member Typedef Documentation

Constructor & Destructor Documentation

agxVehicle::Wheel::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 rigid body frame.

Rotation axis is by definition the y axis in rbRelFrame (if given, otherwise y axis of rb).

Up axis is by definition the z axis in rbRelFrame (if given, otherwise z axis of rb).

Parameters
radius- radius of the wheel
rb- wheel body
rbRelFrame- relative frame defining center and rotation axis of this wheel, given in rb frame.
agxVehicle::Wheel::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 the rigid body frame.

Rotation axis is by definition the y axis in rbRelFrame (if given, otherwise y axis of rb).

Up axis is by definition the z axis in rbRelFrame (if given, otherwise z axis of rb).

Parameters
radius- radius of the wheel
rb- wheel body
rbRelTransform- relative transform defining center and rotation axis of this wheel, given in rb frame.
agxVehicle::Wheel::Wheel ( )
protected

Default constructor used only when this object is restored.

virtual agxVehicle::Wheel::~Wheel ( )
protectedvirtual

Reference counted object - protected destructor.

Member Function Documentation

void agx::Referenced::allocateObserverVector ( ) const
protectedinherited
template<typename T >
T* agx::Referenced::as ( )
inherited

Subclass casting.

Template type must match actual type, dynamic_cast assertion will fail otherwise.

Referenced by agx::InternalData::get(), agxVehicle::Track::getNode(), and agx::InternalData::getOrCreate().

template<typename T >
const T* agx::Referenced::as ( ) const
inherited
template<typename T >
T* agx::Referenced::asSafe ( )
inherited

Safe subclass casting, return nullptr if template type does not match.

Referenced by agxUtil::CollectBodiesAndWiresVisitor::visit().

template<typename T >
const T* agx::Referenced::asSafe ( ) const
inherited
template<typename T >
agx::ref_ptr< T > agxVehicle::Wheel::attachConstraint ( const agx::Name &  name,
agx::RigidBody *  other,
agx::Real  wheelCenterOffset 
)

Create constraint with this wheel and some other rigid body.

The constraint axis will point along the rotation axis and it's possible to offset the center along that same axis.

The constraint is stored and accessible through the given name. The constraint will be added to the simulation when this wheel is used in an agxVehicle object.

Parameters
name- name of the constraint
other- other rigid body
wheelCenterOffset- offset along the rotation axis (from center of this wheel)
Returns
constraint with this wheel body as first and other as second body in the constraint

Definition at line 181 of file Wheel.h.

References getCenterPosition(), getRotationAxis(), agx::RigidBody::getTransform(), getUpAxis(), agx::AffineMatrix4x4T< T >::inverse(), agx::Vec3T< T >::x(), agx::Vec3T< T >::y(), and agx::Vec3T< T >::z().

agx::Hinge* agxVehicle::Wheel::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.

See Also
attachConstraint
Parameters
name- name of the hinge
other- other rigid body
wheelCenterOffset- offset along the rotation axis (from center if this wheel)
Returns
hinge with this wheel body as first and other as second body in the hinge
static agxStream::Serializable* agxVehicle::Wheel::create ( )
inlinestatic

Definition at line 157 of file Wheel.h.

static agxStream::Serializable* agxVehicle::Wheel::create ( agxStream::InputArchive &  )
inlinestatic

Definition at line 157 of file Wheel.h.

void agx::Referenced::deleteUsingDeleteHandler ( ) const
protectedinherited
void agxStream::Serializable::generateUuid ( )
protectedinherited
agx::Vec3 agxVehicle::Wheel::getCenterPosition ( ) const
Returns
center position of this wheel, in world coordinate system

Referenced by attachConstraint().

const char* agxVehicle::Wheel::getClassName ( ) const
inlineoverridevirtual
Returns
the class name of this class.

Reimplemented from agxStream::Serializable.

Definition at line 157 of file Wheel.h.

agx::Constraint* agxVehicle::Wheel::getConstraint ( ) const
Returns
first constraint (null if no constraints has been attached with attachConstraint)
agx::Constraint* agxVehicle::Wheel::getConstraint ( const agx::Name &  name) const
Parameters
name- name of the constraint to find
Returns
constraint with the given name
const ConstraintContainer& agxVehicle::Wheel::getConstraints ( ) const
Returns
vector with attached constraints created with attachConstraint
static const char* agxVehicle::Wheel::getConstructClassId ( )
inlinestatic

Definition at line 157 of file Wheel.h.

static DeleteHandler* agx::Referenced::getDeleteHandler ( )
staticprotectedinherited
Returns
a DeleteHandler.
bool agxStream::Serializable::getEnableSerialization ( ) const
inherited
Returns
true if serialization is enabled for this object

Definition at line 273 of file Serializable.h.

bool agxStream::Serializable::getEnableUuidGeneration ( )
inherited
Returns
true if Uuid:s should be generated for each new Serializable object
agx::UInt32 agxStream::Serializable::getIndex ( ) const
inherited

This index is given at creation of this object.

It is guaranteed to be unique for the lifetime of this library instance. As long as the application is running. This value is not serialized or restored. A new object will always get a new index no matter how it is created.

Returns
an instance index of this object. This is unique for the lifetime of this library instance.

Definition at line 247 of file Serializable.h.

agx::Frame* agxVehicle::Wheel::getLocalFrame ( ) const
Returns
the local frame to the wheel body
agx::Real agxVehicle::Wheel::getRadius ( ) const
Returns
the radius of this wheel
int agx::Referenced::getReferenceCount ( ) const
inherited
Returns
the number pointers currently referencing this object.
agx::RigidBody* agxVehicle::Wheel::getRigidBody ( ) const
Returns
the wheel rigid body
agx::Vec3 agxVehicle::Wheel::getRotationAxis ( ) const
Returns
wheel axis in world coordinate system

Referenced by attachConstraint().

agx::Plane agxVehicle::Wheel::getRotationAxisPlane ( ) const
Returns
the plane defined by the rotation axis
agxStream::StorageAgent* agxVehicle::Wheel::getStorageAgent ( ) const
inlineoverridevirtual
Returns
the storage agent

Implements agxStream::Serializable.

Definition at line 157 of file Wheel.h.

agx::AffineMatrix4x4 agxVehicle::Wheel::getTransform ( ) const
Returns
the transform of this wheel
agx::Vec3 agxVehicle::Wheel::getUpAxis ( ) const
Returns
wheel up axis in world coordinate system

Referenced by attachConstraint().

agx::Uuid agxStream::Serializable::getUuid ( ) const
inherited
Returns
a unique id for this instance.

Definition at line 268 of file Serializable.h.

template<typename T >
bool agx::Referenced::is ( ) const
inherited
bool agxStream::Serializable::isFinished ( ) const
inherited
Returns
true if this class is restored correctly and should not be deleted during destruction of an Archive.

Definition at line 252 of file Serializable.h.

void agx::Referenced::reference ( void *  ptr = nullptr) const
inherited

Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it.

This method should be used with care, always balanced with the same number of calls to unreference.

Referenced by agxData::Val< UInt >::Val().

virtual void agxVehicle::Wheel::restore ( agxStream::InputArchive &  in)
overridevirtual
static void agx::Referenced::setDeleteHandler ( DeleteHandler *  handler)
staticprotectedinherited

Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to.

void agxStream::Serializable::setEnableSerialization ( bool  flag)
inherited

Set to false to disable serialization of this object.

It will just be ignored during serialization (writing). It is still possible to restore TO this object.

static void agxStream::Serializable::setEnableUuidGeneration ( bool  flag)
staticinherited

Specify if there should be UUID:s generated for each new Serializable object. By default it is enabled.

void agxStream::Serializable::setFinished ( )
inherited

Tells this class that it is restored correctly and should not be deleted during destruction of an Archive.

void agxStream::Serializable::setUuid ( const agx::Uuid &  uuid)
inherited

Explicitly set a Uuid on a serializable object.

Use this method with great care, as it can result in non-unique identifiers in the system!

virtual void agxVehicle::Wheel::store ( agxStream::OutputArchive &  out) const
overridevirtual
void agx::Referenced::unreference ( void *  ptr = nullptr) const
inherited

Decrement the reference count by one, indicating that a pointer to this object is referencing it.

If the reference count goes to zero, it is assumed that this object is no longer referenced and is automatically deleted.

This method should be used with care, always balanced with the same number of calls to reference.

void agx::Referenced::unreference_nodelete ( ) const
inherited

Decrement the reference count by one, indicating that a pointer to this object is referencing it.

However, do not delete it, even if ref count goes to 0. Warning, unref_nodelete() should only be called if the user knows exactly who will be responsible for, one should prefer unref() over unref_nodelete() as the later can lead to memory leaks.

template<typename T >
static bool agx::Referenced::ValidateCast ( const Referenced *  object)
staticinherited

Member Data Documentation

Mutex agx::Referenced::m_mutex
mutableprotectedinherited

Definition at line 240 of file Referenced.h.

ObserverContainer agx::Referenced::m_observers
mutableprotectedinherited

Definition at line 239 of file Referenced.h.

AtomicValue agx::Referenced::m_refCount
mutableprotectedinherited

Definition at line 241 of file Referenced.h.


The documentation for this class was generated from the following file: