Body Class Reference

A generic simulation body. More...

#include <body.h>

Inheritance diagram for Body:
Inheritance graph
[legend]

List of all members.

Public Member Functions

virtual void addContact (Contact *c)
 Adds a contact to this body.
void addIVMat (bool clone=false)
 Adds additional material nodes so we can control the transparency of the body.
virtual void addToIvc (bool ExpectEmpty=false)
 Adds this body to the collision detection system.
virtual void addVirtualContact (Contact *c)
 Adds a virtual contact to this body.
 Body (World *w, const char *name=0)
 Empty body with invalid material and no geometry.
virtual void breakContacts ()
 Removes all the cotacts on this body (usually after a move).
virtual void breakVirtualContacts ()
 Removes all virtual contacts on this body.
ContactcheckContactInheritance (Contact *c)
 Checks if a current contact is the same as a contact from the previous time step.
virtual void cloneFrom (const Body *original)
 Make this body a clone of another body.
virtual void cloneToIvc (const Body *original)
 Adds this body to the collision detection system as a clone of another body.
virtual bool contactsPreventMotion (const transf &motion) const
 Returns true if current contacts prevent motion in the given direction.
int convert2xml (QString filename)
 Convert the body information to xml and link the xml to the given geometry file.
bool frictionConesShown () const
int getBirdNumber ()
 Which bird in the flock controlls this body.
std::list< Contact * > getContacts (Body *b=NULL) const
FlockTransfgetFlockTran ()
 Where on the body the Flock of Birds sensor is mounted.
void getGeometryTriangles (std::vector< Triangle > *triangles) const
void getGeometryVertices (std::vector< position > *vertices) const
SoSeparator * getIVContactIndicators () const
SoSeparator * getIVGeomRoot () const
SoMaterial * getIVMat () const
SoTransform * getIVTran () const
int getMaterial () const
int getNumContacts (Body *b=NULL) const
int getNumVirtualContacts () const
virtual WorldElementgetOwner ()
 Individual bodies belong to themselves. Links override this and return their robot.
bool getRenderGeometry () const
 Gets the current rendering requests state.
transf const & getTran () const
float getTransparency () const
 Returns the transparency of this body for rendering.
std::list< Contact * > getVirtualContacts () const
double getYoungs ()
 Returns the Young's modulus for this body.
virtual bool isDynamic () const
 Determines whether instance is dynamic (overridden in DynamicBody).
bool isElastic ()
 Returns whether this body is soft (elastic) or not. Affect contact models.
virtual int load (const QString &filename)
 Load the body information from a file.
virtual int loadContactData (QString fn)
 Load in virtual contacts specified in file fn.
virtual int loadFromXml (const TiXmlElement *root, QString rootPath)
 Loads the body information from an XML structure.
int loadGeometryIV (const QString &filename)
 Loads the geometry of the body from an Inventor file that can be read by Coin (IV or VRML).
int loadGeometryMemory (const std::vector< position > &vertices, const std::vector< int > &triangles)
 Loads the geometry from a vector of vertices and one of triangles.
int loadGeometryOFF (const QString &filename)
 Loads the geometry of the body from an .off file.
int loadGeometryPLY (const QString &filename)
 Loads the geometry of the body from a .ply file.
virtual void redrawFrictionCones ()
 Asks all contacts to recompute their friction cones.
virtual void removeContact (Contact *c)
 Removed a contact from this body.
virtual void removePrevContact (Contact *c)
 Removes a contact from the list of contacts at the previous time step.
virtual void resetContactList ()
 Moves all current contacts to the list of previous contacts.
virtual int saveToXml (QTextStream &xml)
 Saves the body information to an XML structure.
void setBVGeometry (const std::vector< BoundingBox > &bvs)
virtual void setDefaultViewingParameters ()
 Default parameters for transparency, show friction cones, etc.
void setMaterial (int mat)
 Sets the material of this body.
void setRenderGeometry (bool s)
 Enables / disabled automatic render requests when this body is moved.
virtual int setTran (transf const &newTr)
 Sets the body to another location in the world. Collisions are not checked.
void setTransparency (float t)
 Sets the transparency of this body for rendering.
void showFrictionCones (bool on, int vc=0)
 Shows or hides the friction cones for this body.
bool usesFlock ()
 Tells us if this body's position is controlled by the Flock of Birds.
virtual ~Body ()
 Breaks all contacts; does not remove body from collision detection or scene graph.

Static Public Attributes

static const float CONE_HEIGHT = 20.0
 Parameter to control the height of friction cones.

Protected Member Functions

 Body (const Body &b)
 Copy constructor.
void createAxesGeometry ()
 Creates the axes for display.
virtual void getBodyList (std::vector< Body * > *bodies)
 Adds itself to the given vector of Bodies.
void initializeIV ()
 Initialize an empty scene graph structure with just the needed roots.

Protected Attributes

SoScale * axesScale
 Inventor scale for axes so that they extend outside the body.
SoTranslation * axesTranToCOG
 Inventor transform from body frame to center of gravity.
std::list< Contact * > contactList
 The current contacts on the body.
SoSwitch * IVAxes
 Inventor root of the axes in the body subtree.
SoSeparator * IVBVRoot
 A pointer to a node that can hold the geometry of the bounding volume struture.
SoSeparator * IVContactIndicators
 A pointer to the root of the friction cones on this body.
SoSeparator * IVGeomRoot
 A pointer to the root node of the geometry of this model.
SoMaterial * IVMat
 A pointer to the material node that controls this body's transparency.
SoTransform * IVTran
 A pointer to the Inventor transform for the body.
SoSeparator * IVWorstCase
 Inventor root of the worst case disturbance wrench indicator.
int material
 The surface material of the body specified as an index to the world material list.
int mBirdNumber
 This tells us which bird in the flock the object is using.
FlockTransf mFlockTran
 The relative tranform used for the Flock of Birds.
QString mGeometryFilename
 The file that geometry was loaded from, if any.
QString mGeometryFileType
 Type of geometry file, for now either "Inventor" or "off".
bool mIsElastic
 Tells us whether this is a rigid body or not (affects friction models).
bool mRenderGeometry
 When this is un-checked, changing the transform of this body will not trigger a redraw.
bool mUsesFlock
 This flag tells us if this body follows the Flock of Birds tracker.
int numContacts
 The number of contacts on the body.
std::list< Contact * > prevContactList
 The contacts on the body at the previous time step.
bool showFC
 This flag determines whether the body's friction cones should be shown.
bool showVC
 This flag determines whether the body's virtual contacts should be shown.
transf Tran
 The body's world position (translations are in mm).
std::list< Contact * > virtualContactList
 Virtual Contacts on this body. See the Virtual Contact class for explanation.
double youngMod
 The Young's Modulus of the material, it describes its elasticity.

Friends

QTextStream & operator<< (QTextStream &os, const Body &b)
 Prints the name and material of this body to a stream.

Detailed Description

A generic simulation body.

A generic body is defined by its geometry, its material, and a transform. Body instances are considered obstacles--they can form contacts with other objects but are not part of of the dynamics system.

Definition at line 76 of file body.h.


Constructor & Destructor Documentation

Body::Body ( const Body b  )  [protected]

Copy constructor.

Copy constructor remains protected (should not be called by user)

Definition at line 132 of file body.cpp.

Body::Body ( World w,
const char *  name = 0 
)

Empty body with invalid material and no geometry.

Constructs an empty body with its material set to invalid, and the geometry pointer set to NULL. Use load() to initialize the body from a model file.

Definition at line 106 of file body.cpp.

Body::~Body (  )  [virtual]

Breaks all contacts; does not remove body from collision detection or scene graph.

Breaks all contacts; it is up to the world to also remove it from the collision detection system or the scene graph. In general, do not delete bodies directly, but use World::removeElement(...)instead which can also delete them.

Definition at line 161 of file body.cpp.


Member Function Documentation

void Body::addContact ( Contact c  )  [virtual]

Adds a contact to this body.

Adds contact c to the body's contact list. Assumes the contact is not already in the list.

See also:
removeContact()

Definition at line 995 of file body.cpp.

void Body::addIVMat ( bool  clone = false  ) 

Adds additional material nodes so we can control the transparency of the body.

After the geometry has been set, this function adds a new Material node after any Material node already present so we can change the transparency of this object. Does not work on bodies loaded from VRML files, as they have different types of material nodes. I have tried also searching for SoVRMLMaterial nodes, but the search fails even if those nodes exist; I suppose that is a bug in Coin.

Definition at line 580 of file body.cpp.

void Body::addToIvc ( bool  ExpectEmpty = false  )  [virtual]

Adds this body to the collision detection system.

Adds the body to the world's collision detection system

Definition at line 625 of file body.cpp.

void Body::addVirtualContact ( Contact c  )  [virtual]

Adds a virtual contact to this body.

Adds a virtual contacts to this body

Definition at line 1040 of file body.cpp.

void Body::breakContacts (  )  [virtual]

Removes all the cotacts on this body (usually after a move).

Breaks all contacts on the body, deleting entire contact list, and removes all friction cones if necessary. Also clears the list of contacts from the previous time step.

Definition at line 895 of file body.cpp.

void Body::breakVirtualContacts (  )  [virtual]

Removes all virtual contacts on this body.

Removes all virtual contacts. This only removes the virtual contacts.

Definition at line 948 of file body.cpp.

Contact * Body::checkContactInheritance ( Contact c  ) 

Checks if a current contact is the same as a contact from the previous time step.

Checks if this contact inherits some other contact from the prevContactList. The check looks of contact points are close, normals agree and the second body is the same. If inheritance is found, some properites of the contact are passed from the previous contact to this one.

Definition at line 1055 of file body.cpp.

void Body::cloneFrom ( const Body original  )  [virtual]

Make this body a clone of another body.

Clones this body from an original. This means that the two bodies have independent transform, materials, properties, etc, BUT they share the scene graph geometry and the collision detection geometry. They can still be used for collision detection independently as they can have different transforms.

WARNING: cloning mechanism is incomplete. If the original is deleted, the clone becomes unpredicateble and can cause the system to crash

Definition at line 176 of file body.cpp.

void Body::cloneToIvc ( const Body original  )  [virtual]

Adds this body to the collision detection system as a clone of another body.

Clones the original's body geometry for the world collision detection system. The new body only gets its own IVC transform.

Definition at line 636 of file body.cpp.

bool Body::contactsPreventMotion ( const transf motion  )  const [virtual]

Returns true if current contacts prevent motion in the given direction.

Given a motion relative to body coordinates, this determines whether the current contacts allow that motion.

Implements WorldElement.

Definition at line 875 of file body.cpp.

int Body::convert2xml ( QString  filename  ) 

Convert the body information to xml and link the xml to the given geometry file.

void Body::createAxesGeometry (  )  [protected]

Creates the axes for display.

Creates the geometry of the axes which show this body's local coordinate system. The axes are usually shown centered at the c.o.m

Definition at line 1212 of file body.cpp.

bool Body::frictionConesShown (  )  const [inline]

Returns the value of the flag determining whether friction cones are shown on this body

Definition at line 301 of file body.h.

int Body::getBirdNumber (  )  [inline]

Which bird in the flock controlls this body.

Definition at line 235 of file body.h.

virtual void Body::getBodyList ( std::vector< Body * > *  bodies  )  [inline, protected, virtual]

Adds itself to the given vector of Bodies.

Implements WorldElement.

Definition at line 173 of file body.h.

std::list< Contact * > Body::getContacts ( Body b = NULL  )  const

Returns a copy of the body's contact list against a given body.

Returns a list of the contacts on this body. if b is not NULL, it returns only contacts against the body b. If b is NULL, it returns all the contacts.

Definition at line 1027 of file body.cpp.

FlockTransf* Body::getFlockTran (  )  [inline]

Where on the body the Flock of Birds sensor is mounted.

Definition at line 238 of file body.h.

void Body::getGeometryTriangles ( std::vector< Triangle > *  triangles  )  const

Returns all the triangles of the scene graph geometry of this object

Returns all the triangle that make up the geometry of this body

Definition at line 1187 of file body.cpp.

void Body::getGeometryVertices ( std::vector< position > *  vertices  )  const

Returns all the vertices of the scene graph geometry of this object

Returns all the vertices that make up the geometry of this body. This function will return duplicates, as vertices are reported once for each triangle that they are part of

Definition at line 1199 of file body.cpp.

SoSeparator* Body::getIVContactIndicators (  )  const [inline]

Returns a pointer to the root of the Inventor subtree containing the friction cones.

Definition at line 276 of file body.h.

SoSeparator* Body::getIVGeomRoot (  )  const [inline]

Returns a pointer to the root of the Inventor geometry that was loaded.

Definition at line 263 of file body.h.

SoMaterial* Body::getIVMat (  )  const [inline]

Returns the Inventor material for the body.

Definition at line 257 of file body.h.

SoTransform* Body::getIVTran (  )  const [inline]

Returns a pointer to the Inventor transform node for the body.

Definition at line 271 of file body.h.

int Body::getMaterial (  )  const [inline]

Returns the current material of the body.

See also:
setMaterial()

Definition at line 252 of file body.h.

int Body::getNumContacts ( Body b = NULL  )  const

Returns the number of contacts on the body, against another given body.

The number of contacts on this body. If b is not null, it only counts contacts against b. If it is null, is returns all contacts on this body, regardless of who they are against.

Definition at line 1011 of file body.cpp.

int Body::getNumVirtualContacts (  )  const [inline]

Returns the number of virtual contacts on the body.

Definition at line 290 of file body.h.

virtual WorldElement* Body::getOwner (  )  [inline, virtual]

Individual bodies belong to themselves. Links override this and return their robot.

Reimplemented in Link.

Definition at line 241 of file body.h.

bool Body::getRenderGeometry (  )  const [inline]

Gets the current rendering requests state.

Definition at line 229 of file body.h.

transf const& Body::getTran (  )  const [inline, virtual]

Returns the current pose of the body.

Implements WorldElement.

Definition at line 284 of file body.h.

float Body::getTransparency (  )  const

Returns the transparency of this body for rendering.

Returns the current transparency value for the body (between 0 and 1).

See also:
setTransparency()

Definition at line 749 of file body.cpp.

std::list<Contact *> Body::getVirtualContacts (  )  const [inline]

Returns a copy of the body's virtual contact list.

Definition at line 296 of file body.h.

double Body::getYoungs (  )  [inline]

Returns the Young's modulus for this body.

Definition at line 260 of file body.h.

void Body::initializeIV (  )  [protected]

Initialize an empty scene graph structure with just the needed roots.

Initialized the empty scene graph structure that we will use in the future to render this body

Definition at line 654 of file body.cpp.

virtual bool Body::isDynamic (  )  const [inline, virtual]

Determines whether instance is dynamic (overridden in DynamicBody).

Reimplemented in DynamicBody.

Definition at line 244 of file body.h.

bool Body::isElastic (  )  [inline]

Returns whether this body is soft (elastic) or not. Affect contact models.

Definition at line 247 of file body.h.

int Body::load ( const QString &  filename  )  [virtual]

Load the body information from a file.

Opens and loads a body information file. filename is the complete path to the body file, which should be in XML format (with a .xml extension) and can contain a number of Graspit-specific properties as XML tags, as well as a pointer to a different file which contains the geometry itself.

Alternatively, filename can also point directly to the geometry file.The type of the file will be detected by its extension (.iv, .wrl, .off or .ply) in which case GraspIt will use the default values for all the properties that normally come from the XML tags.

Definition at line 348 of file body.cpp.

int Body::loadContactData ( QString  fn  )  [virtual]

Load in virtual contacts specified in file fn.

Load in all virtual contacts from file fn

Definition at line 923 of file body.cpp.

int Body::loadFromXml ( const TiXmlElement root,
QString  rootPath 
) [virtual]

Loads the body information from an XML structure.

Parses the root node of an XML structure containing information for a body. It looks for all the relevant properties. Some of the properties are optional and if they are not found, they will be set to default values. Others will cause a failure if they are not present.

Reimplemented in DynamicBody.

Definition at line 214 of file body.cpp.

int Body::loadGeometryIV ( const QString &  filename  ) 

Loads the geometry of the body from an Inventor file that can be read by Coin (IV or VRML).

Loads only the geometry part of this object, without any other GraspIt specific information such as mass, material etc. The file must be in a format that is readable by Coin, which for now means either Inventor (.iv) or VRML.

Definition at line 405 of file body.cpp.

int Body::loadGeometryMemory ( const std::vector< position > &  vertices,
const std::vector< int > &  triangles 
)

Loads the geometry from a vector of vertices and one of triangles.

Definition at line 549 of file body.cpp.

int Body::loadGeometryOFF ( const QString &  filename  ) 

Loads the geometry of the body from an .off file.

Loads the geometry of this object from an .off file. This was primarily created for loading models from the Princeton Shape Benchmark, allowing GraspIt to interact with the Columbia Grasp Database.

Definition at line 471 of file body.cpp.

int Body::loadGeometryPLY ( const QString &  filename  ) 

Loads the geometry of the body from a .ply file.

Loads the geometry of this body from a .ply file. Uses ply loading code from ROS by Willow Garage, which in turn uses code from Greg Turk, Georgia Institute of Technology. PLY loading seems to be fairly complex, as the ply format is very extensible. Right now, this will only load vertices and triangles and nothing else, not even other types of faces. Could be extended in the future.

Definition at line 531 of file body.cpp.

void Body::redrawFrictionCones (  )  [virtual]

Asks all contacts to recompute their friction cones.

Recomputes all the friction cones on the body

Definition at line 805 of file body.cpp.

void Body::removeContact ( Contact c  )  [virtual]

Removed a contact from this body.

Removes contact c from the body's contact list. Assumes the contact is in the list.

See also:
addContact()

Definition at line 1086 of file body.cpp.

void Body::removePrevContact ( Contact c  )  [virtual]

Removes a contact from the list of contacts at the previous time step.

Removes a contact c from the prevContactList

Definition at line 1110 of file body.cpp.

void Body::resetContactList (  )  [virtual]

Moves all current contacts to the list of previous contacts.

Moves all contacts to the prevContactList and clears the contactList for new contacts Old contacts from prevContactList are deleted.

Definition at line 966 of file body.cpp.

int Body::saveToXml ( QTextStream &  xml  )  [virtual]

Saves the body information to an XML structure.

Reimplemented in DynamicBody.

Definition at line 324 of file body.cpp.

void Body::setBVGeometry ( const std::vector< BoundingBox > &  bvs  ) 

Asks the body to display a number of bounding boxes as part of its collision detection bbox hierarchy. Used only for debugging purposes.

Shows a bounding box hierarchy for this body. Used for debug purposes.

Definition at line 683 of file body.cpp.

void Body::setDefaultViewingParameters (  )  [virtual]

Default parameters for transparency, show friction cones, etc.

Reimplemented in DynamicBody, and GraspableBody.

Definition at line 643 of file body.cpp.

void Body::setMaterial ( int  mat  ) 

Sets the material of this body.

Set the current material of the body to mat

See also:
getMaterial()

Definition at line 772 of file body.cpp.

void Body::setRenderGeometry ( bool  s  ) 

Enables / disabled automatic render requests when this body is moved.

Sets whether a change of this body's transform should automatically trigger a redraw. This seems to not always work...

Definition at line 824 of file body.cpp.

int Body::setTran ( transf const &  tr  )  [virtual]

Sets the body to another location in the world. Collisions are not checked.

Sets the current world pose of the body to tr. Collisions are not checked.

Implements WorldElement.

Reimplemented in DynamicBody.

Definition at line 853 of file body.cpp.

void Body::setTransparency ( float  t  ) 

Sets the transparency of this body for rendering.

Set the current transparency value for the body. t is a value between 0 and 1, where 0 is opaque, 1 is transparent.

See also:
getTransparency()

Definition at line 761 of file body.cpp.

void Body::showFrictionCones ( bool  on,
int  vc = 0 
)

Shows or hides the friction cones for this body.

Sets whether friction cones should be shown for this body.

Definition at line 792 of file body.cpp.

bool Body::usesFlock (  )  [inline]

Tells us if this body's position is controlled by the Flock of Birds.

Definition at line 232 of file body.h.


Friends And Related Function Documentation

QTextStream& operator<< ( QTextStream &  os,
const Body b 
) [friend]

Prints the name and material of this body to a stream.

Output method for writing body data to a text world configuration file.

Definition at line 1121 of file body.cpp.


Member Data Documentation

SoScale* Body::axesScale [protected]

Inventor scale for axes so that they extend outside the body.

Definition at line 161 of file body.h.

SoTranslation* Body::axesTranToCOG [protected]

Inventor transform from body frame to center of gravity.

Definition at line 158 of file body.h.

const float Body::CONE_HEIGHT = 20.0 [static]

Parameter to control the height of friction cones.

Definition at line 80 of file body.h.

std::list<Contact *> Body::contactList [protected]

The current contacts on the body.

Definition at line 108 of file body.h.

SoSwitch* Body::IVAxes [protected]

Inventor root of the axes in the body subtree.

Definition at line 152 of file body.h.

SoSeparator* Body::IVBVRoot [protected]

A pointer to a node that can hold the geometry of the bounding volume struture.

Definition at line 126 of file body.h.

SoSeparator* Body::IVContactIndicators [protected]

A pointer to the root of the friction cones on this body.

Definition at line 140 of file body.h.

SoSeparator* Body::IVGeomRoot [protected]

A pointer to the root node of the geometry of this model.

Definition at line 123 of file body.h.

SoMaterial* Body::IVMat [protected]

A pointer to the material node that controls this body's transparency.

Definition at line 137 of file body.h.

SoTransform* Body::IVTran [protected]

A pointer to the Inventor transform for the body.

Definition at line 134 of file body.h.

SoSeparator* Body::IVWorstCase [protected]

Inventor root of the worst case disturbance wrench indicator.

Definition at line 155 of file body.h.

int Body::material [protected]

The surface material of the body specified as an index to the world material list.

Definition at line 84 of file body.h.

int Body::mBirdNumber [protected]

This tells us which bird in the flock the object is using.

Definition at line 146 of file body.h.

The relative tranform used for the Flock of Birds.

Definition at line 149 of file body.h.

QString Body::mGeometryFilename [protected]

The file that geometry was loaded from, if any.

Definition at line 93 of file body.h.

QString Body::mGeometryFileType [protected]

Type of geometry file, for now either "Inventor" or "off".

Definition at line 96 of file body.h.

bool Body::mIsElastic [protected]

Tells us whether this is a rigid body or not (affects friction models).

Definition at line 87 of file body.h.

bool Body::mRenderGeometry [protected]

When this is un-checked, changing the transform of this body will not trigger a redraw.

Definition at line 102 of file body.h.

bool Body::mUsesFlock [protected]

This flag tells us if this body follows the Flock of Birds tracker.

Definition at line 143 of file body.h.

int Body::numContacts [protected]

The number of contacts on the body.

Definition at line 105 of file body.h.

std::list<Contact *> Body::prevContactList [protected]

The contacts on the body at the previous time step.

Definition at line 111 of file body.h.

bool Body::showFC [protected]

This flag determines whether the body's friction cones should be shown.

Definition at line 117 of file body.h.

bool Body::showVC [protected]

This flag determines whether the body's virtual contacts should be shown.

Definition at line 120 of file body.h.

transf Body::Tran [protected]

The body's world position (translations are in mm).

Definition at line 99 of file body.h.

std::list<Contact *> Body::virtualContactList [protected]

Virtual Contacts on this body. See the Virtual Contact class for explanation.

Definition at line 114 of file body.h.

double Body::youngMod [protected]

The Young's Modulus of the material, it describes its elasticity.

Definition at line 90 of file body.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines


graspit
Author(s):
autogenerated on Wed Jan 25 11:00:19 2012