NTRT Simulator  Version: Master
 All Classes Namespaces Files Functions Variables Typedefs Friends Pages
tgBulletContactSpringCable Class Reference

#include <tgBulletContactSpringCable.h>

Inheritance diagram for tgBulletContactSpringCable:
Collaboration diagram for tgBulletContactSpringCable:

Public Member Functions

 tgBulletContactSpringCable (btPairCachingGhostObject *ghostObject, tgWorld &world, const std::vector< tgBulletSpringCableAnchor * > &anchors, double coefK, double dampingCoefficient, double pretension=0.0, double thickness=0.001, double resolution=0.1)
 
virtual ~tgBulletContactSpringCable ()
 
virtual void step (double dt)
 
virtual const btScalar getActualLength () const
 
virtual const double getTension () const
 
virtual const std::vector
< const tgSpringCableAnchor * > 
getAnchors () const
 
virtual const double getRestLength () const
 
virtual void setRestLength (const double newRestLength)
 
virtual const double getCoefK () const
 
virtual const double getCoefD () const
 
virtual const double getVelocity () const
 
virtual const double getDamping () const
 

Protected Attributes

btPairCachingGhostObject * m_ghostObject
 
const double m_thickness
 
const double m_resolution
 
std::vector
< tgBulletSpringCableAnchor * > 
m_anchors
 
tgBulletSpringCableAnchor *const anchor1
 
tgBulletSpringCableAnchor *const anchor2
 
double m_damping
 
double m_velocity
 
const double m_coefK
 
const double m_dampingCoefficient
 
double m_restLength
 
double m_prevLength
 

Detailed Description

An extension of tgBulletSpringCable that places a ghostObject into the bullet world and then uses that object to generate collision dynamics. The ghost object is updated every time step to account for the new shape of the string. Anchors track their associated btPersistentManifold to determine whether they are still in contact with the rigid object. The string is massless, but collision handling should conserve momentum (see unit tests)

This could eventually be merged with Corde for a massive, low node string. Merging with Corde could also address some of the current issues with rotational energy

Definition at line 60 of file tgBulletContactSpringCable.h.

Constructor & Destructor Documentation

tgBulletContactSpringCable::tgBulletContactSpringCable ( btPairCachingGhostObject *  ghostObject,
tgWorld world,
const std::vector< tgBulletSpringCableAnchor * > &  anchors,
double  coefK,
double  dampingCoefficient,
double  pretension = 0.0,
double  thickness = 0.001,
double  resolution = 0.1 
)

The only constructor. Requires a number of parameters typically provided by the builder tools, in this case tgMultiPointStringInfo

Parameters
[in]ghostObject- the btPairCashingGhostObject that this interacts with
[in]world- the tgWorld - we need to keep access to the bullet dynamics world's broadphase so that we can determine collisions and contact points
[in]anchors- a reference to a list of anchors. Will be passed to tgBulletSpringCable and form the initial (likely permanent) anchor list. Size must be 2 or greater (enforced in tgBulletSpringCable)
[in]coefK- The stiffness of this cable. Units are mass / sec^2, sets a member variable of tgBulletSpringCable
[in]dampingCofefficient- The damping coefficient of the force application equation. Units are mass / sec, sets a member variable of tgBulletSpringCable
[in]Thepretension on the string, units are force. Must be small enough (based on stiffness) such that rest length > 0;
[in]thickness,theradius of the cylinder used for the btCollisionObject
[in]resolution,thespatial resultion used to prune new contacts. also affects runtime (lower corresponds to longer runtime)

Definition at line 57 of file tgBulletContactSpringCable.cpp.

tgBulletContactSpringCable::~tgBulletContactSpringCable ( )
virtual

The destructor. Removes the ghost object from the world, deletes its collision shape, and then deletes the object. tgBulletSpringCable ensures all anchors are deleted

Definition at line 74 of file tgBulletContactSpringCable.cpp.

Here is the call graph for this function:

Member Function Documentation

const btScalar tgBulletContactSpringCable::getActualLength ( ) const
virtual
Returns
a btScalar of the string's actual length - the sum of the lengths between the anchors.

Reimplemented from tgBulletSpringCable.

Definition at line 84 of file tgBulletContactSpringCable.cpp.

Here is the caller graph for this function:

const std::vector< const tgSpringCableAnchor * > tgBulletSpringCable::getAnchors ( ) const
virtualinherited

Returns a const vector of const anchors. Currently casts from tgBulletSpringCableAnchors, which makes it impossible to return a reference

Todo:
figure out how to cast and pass by reference

Implements tgSpringCable.

Definition at line 157 of file tgBulletSpringCable.cpp.

virtual const double tgSpringCable::getCoefD ( ) const
inlinevirtualinherited

Get the coefficent of damping

Definition at line 103 of file tgSpringCable.h.

virtual const double tgSpringCable::getCoefK ( ) const
inlinevirtualinherited

Get the coefficent of stiffness

Definition at line 95 of file tgSpringCable.h.

Here is the caller graph for this function:

virtual const double tgSpringCable::getDamping ( ) const
inlinevirtualinherited

Get the last value of the damping force

Definition at line 119 of file tgSpringCable.h.

const double tgSpringCable::getRestLength ( ) const
virtualinherited

Returns m_restLength

Definition at line 66 of file tgSpringCable.cpp.

const double tgBulletSpringCable::getTension ( ) const
virtualinherited

Returns the tension currently in the string by multiplying the difference between the actual length and the rest length by the stiffness coefficient

Implements tgSpringCable.

Definition at line 150 of file tgBulletSpringCable.cpp.

Here is the call graph for this function:

virtual const double tgSpringCable::getVelocity ( ) const
inlinevirtualinherited

Get the last change in length / time

Definition at line 111 of file tgSpringCable.h.

Here is the caller graph for this function:

void tgSpringCable::setRestLength ( const double  newRestLength)
virtualinherited

Sets m_restLength to newRestLength.

Parameters
[in]newRestLength,mustbe non-negative

Definition at line 71 of file tgSpringCable.cpp.

Here is the caller graph for this function:

void tgBulletContactSpringCable::step ( double  dt)
virtual

The "update" function for tgBulletContactSpringCable. In addition to calculating and applying the force, this calls: updateManifolds() pruneAnchors() updateAnchorList() pruneAnchors() calculateAndApplyForce(dt) finally updateCollisionObject()

Reimplemented from tgBulletSpringCable.

Definition at line 97 of file tgBulletContactSpringCable.cpp.

Here is the call graph for this function:

Member Data Documentation

tgBulletSpringCableAnchor* const tgBulletSpringCable::anchor1
protectedinherited

The first attachement point for this spring cable. Storing it seperately makes a number of functions easier

Definition at line 111 of file tgBulletSpringCable.h.

tgBulletSpringCableAnchor* const tgBulletSpringCable::anchor2
protectedinherited

The other permanent attachment for this spring cable.

Definition at line 116 of file tgBulletSpringCable.h.

std::vector<tgBulletSpringCableAnchor*> tgBulletSpringCable::m_anchors
protectedinherited

The list of contact points. tgBulletSpringCable typically has two whereas tgBulletContactSpringCable will have more. Needs to be stored here for consistent rendering. Vector has the convienence of tgCast functions, and we used to need a random iterator to sort

Definition at line 105 of file tgBulletSpringCable.h.

const double tgSpringCable::m_coefK
protectedinherited

The stiffness coefficient Units of mass / sec ^2 Must be positive

Definition at line 149 of file tgSpringCable.h.

double tgSpringCable::m_damping
protectedinherited

The previous value of the damping force. Stored so we can get it without passing a dt

Definition at line 136 of file tgSpringCable.h.

const double tgSpringCable::m_dampingCoefficient
protectedinherited

The damping coefficient. Units of mass / sec. Must be non-negative

Definition at line 156 of file tgSpringCable.h.

btPairCachingGhostObject* tgBulletContactSpringCable::m_ghostObject
protected

A btPairCachingGhostObject that exists in the dynamics world and provides us information about what it collides with. We own this.

Definition at line 247 of file tgBulletContactSpringCable.h.

double tgSpringCable::m_prevLength
protectedinherited

The previous actual length of the string. Used when calculating force and velocity

Definition at line 168 of file tgSpringCable.h.

const double tgBulletContactSpringCable::m_resolution
protected

The spatial resolution used in collision detection Units of length

Definition at line 259 of file tgBulletContactSpringCable.h.

double tgSpringCable::m_restLength
protectedinherited

The rest length of the string. Must be non negative

Definition at line 162 of file tgSpringCable.h.

const double tgBulletContactSpringCable::m_thickness
protected

The radius of the ghost object Units of length

Definition at line 253 of file tgBulletContactSpringCable.h.

double tgSpringCable::m_velocity
protectedinherited

The velocity of the string at the last update step. Stored so we can get it without passing a dt

Definition at line 142 of file tgSpringCable.h.


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