MBody Class Reference

#include <MBody.h>

Inherits MTransformable.

Collaboration diagram for MBody:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 MBody (const string &objectName, const dWorldID &worldID)
virtual ~MBody ()
bool initFromXML (const wxXmlNode &node)
void getAvailableData (map< TLMDataIF::Key, TLMDataIF::DataInfo > &data) const
bool getDataValue (const TLMDataIF::Key &key, string &data) const
bool setDataValue (const TLMDataIF::Key &key, const string &data)
virtual void setMassDistribution (const dMass &massDistribution)
virtual void addMassDistribution (const dMass &massDistribution)
virtual void addMassDistribution (const MGeometry &geom, const double mass)
virtual void setTotalMass (const double mass)
virtual void getTotalMass (double &mass) const
virtual void getMassDistribution (double &m00, double &m01, double &m02, double &m11, double &m12, double &m22) const
virtual void setMassDistribution (const double m00, const double m01, const double m02, const double m11, const double m12, const double m22)
virtual void getCenterOfMass (double &x, double &y, double &z) const
virtual void setCenterOfMass (const double x, const double y, const double z)
virtual void setPosition (const double x, const double y, const double z)
virtual void getPosition (double &x, double &y, double &z) const
virtual void setVelocity (const double vx, const double vy, const double vz)
virtual void getVelocity (double &vx, double &vy, double &vz) const
virtual void getQuaternion (double &angle, double &x, double &y, double &z) const
virtual void setQuaternion (const double angle, const double x, const double y, const double z)
virtual void setRotation (const double phi, const double theta, const double psi)
const string & objectName () const
void objectName (const string &name)
dBodyID bodyID () const

Static Public Member Functions

static MBodygetBodyForID (const dBodyID id)

Protected Member Functions

void cleanup ()
bool parseMassNode (const wxXmlNode &node, dMass &result)
 Handle the <mass> XML node.

Protected Attributes

string myObjectName
 The name of my parent object.
dBodyID myBodyID
 The body id of this object in the physics model.

Detailed Description

A modeled body. A body is something that has mass, position and velocity that the physics model models.
Author:
Chad Weisshaar
Date:
2005

Definition at line 21 of file MBody.h.


Constructor & Destructor Documentation

MBody::MBody const string &  objectName,
const dWorldID &  worldID
 

Create a new model object. This object will be added to the given world. This object doesn't have a shape or a mass until you call the set functions

Definition at line 16 of file MBody.cpp.

References memTraceMsg, and myBodyID.

MBody::~MBody  )  [virtual]
 

Definition at line 27 of file MBody.cpp.

References cleanup(), and memTraceMsg.

Here is the call graph for this function:


Member Function Documentation

void MBody::addMassDistribution const MGeometry geom,
const double  mass
[virtual]
 

Add a mass distribution to this body. This can be called multiple times to build up a mass distribution from a set of simple distributions. The geometry provides the distribution that matches its shape.

Definition at line 420 of file MBody.cpp.

References addMassDistribution(), MGeometry::getMassDistro(), and traceId.

Here is the call graph for this function:

void MBody::addMassDistribution const dMass &  massDistribution  )  [virtual]
 

Add a mass distribution to this body. This can be called multiple times to build up a mass distribution from a set of simple distributions

Definition at line 411 of file MBody.cpp.

References myBodyID, and traceId.

Referenced by addMassDistribution().

dBodyID MBody::bodyID  )  const [inline]
 

Definition at line 178 of file MBody.h.

References myBodyID.

Referenced by MHingeJoint::MHingeJoint().

void MBody::cleanup  )  [protected]
 

Definition at line 561 of file MBody.cpp.

References myBodyID, and traceId.

Referenced by ~MBody().

void MBody::getAvailableData map< TLMDataIF::Key, TLMDataIF::DataInfo > &  data  )  const
 

Get all the available data/telemetry elements that this class can provide. Each of the returned keys can be passed to the get/set functions to get/set that member data.

Reimplemented from MTransformable.

Definition at line 241 of file MBody.cpp.

References TLMDataIF::DOUBLE, MTransformable::getAvailableData(), and traceId.

Here is the call graph for this function:

MBody * MBody::getBodyForID const dBodyID  id  )  [static]
 

Get the MBody for a particular physics model body ID.

Definition at line 10 of file MBody.cpp.

References traceId.

void MBody::getCenterOfMass double &  x,
double &  y,
double &  z
const [virtual]
 

Get the center of mass

Definition at line 475 of file MBody.cpp.

References myBodyID, and traceId.

Referenced by getDataValue(), and setDataValue().

bool MBody::getDataValue const TLMDataIF::Key key,
string &  data
const [virtual]
 

Get the value of a particular data/telemetry element.

Parameters:
key A valid key as returned by the getAvailableData function
data The returned data. All data is returned as a string regardless of the actual type.
Returns:
true if the data was found in this class and the data parameter was set to its value. false otherwise

Reimplemented from MTransformable.

Definition at line 274 of file MBody.cpp.

References getCenterOfMass(), MTransformable::getDataValue(), getMassDistribution(), getTotalMass(), getVelocity(), and traceId.

Here is the call graph for this function:

void MBody::getMassDistribution double &  m00,
double &  m01,
double &  m02,
double &  m11,
double &  m12,
double &  m22
const [virtual]
 

Get the mass distribution of the body The inertia matrix is defined as ( m00, m01, m02 ) ( m10, m11, m12 ) ( m20, m21, m22 ) However, you only specify the upper right and diagonal portion of the matrix since it is symetric

Definition at line 446 of file MBody.cpp.

References myBodyID, and traceId.

Referenced by getDataValue(), and setDataValue().

void MBody::getPosition double &  x,
double &  y,
double &  z
const [virtual]
 

Get the position of the center of mass of the body.

Implements MTransformable.

Definition at line 502 of file MBody.cpp.

References myBodyID, and traceId.

void MBody::getQuaternion double &  angle,
double &  x,
double &  y,
double &  z
const [virtual]
 

Get the quaternion. A quaternion is a vector and a rotation about that vector.

Parameters:
angle The amount of rotation

Implements MTransformable.

Definition at line 542 of file MBody.cpp.

References myBodyID, and traceId.

void MBody::getTotalMass double &  mass  )  const [virtual]
 

Get the total mass of the body

Definition at line 438 of file MBody.cpp.

References myBodyID, and traceId.

Referenced by getDataValue().

void MBody::getVelocity double &  vx,
double &  vy,
double &  vz
const [virtual]
 

Get the velocity of the body

Definition at line 517 of file MBody.cpp.

References myBodyID, and traceId.

Referenced by getDataValue(), and setDataValue().

bool MBody::initFromXML const wxXmlNode &  node  ) 
 

Initialize this body from the <body> XML node. This will setup the mass distribution of the body.

Definition at line 33 of file MBody.cpp.

References myBodyID, myObjectName, parseMassNode(), traceId, and verboseMsg.

Here is the call graph for this function:

void MBody::objectName const string &  name  )  [inline]
 

Definition at line 176 of file MBody.h.

References myObjectName.

const string& MBody::objectName  )  const [inline]
 

Definition at line 175 of file MBody.h.

References myObjectName.

Referenced by MJoint::getDataValue().

bool MBody::parseMassNode const wxXmlNode &  massNode,
dMass &  result
[protected]
 

Handle the <mass> XML node.

Todo:
cylinder mass_shapes

Definition at line 64 of file MBody.cpp.

References myObjectName, traceId, and verboseMsg.

Referenced by initFromXML().

void MBody::setCenterOfMass const double  x,
const double  y,
const double  z
[virtual]
 

Set the center of mass

Definition at line 485 of file MBody.cpp.

References myBodyID, and traceId.

Referenced by setDataValue().

bool MBody::setDataValue const TLMDataIF::Key key,
const string &  data
[virtual]
 

Set the value of a particular data/telemetry element.

Parameters:
key A valid key as returned by the getAvailableData function
data The data to set. All data is provided as a string regardless of the actual type.
Returns:
true if the data was found in this class and the data parameter was set to its value. false otherwise

Reimplemented from MTransformable.

Definition at line 341 of file MBody.cpp.

References getCenterOfMass(), getMassDistribution(), getVelocity(), setCenterOfMass(), MTransformable::setDataValue(), setMassDistribution(), setTotalMass(), setVelocity(), and traceId.

Here is the call graph for this function:

void MBody::setMassDistribution const double  m00,
const double  m01,
const double  m02,
const double  m11,
const double  m12,
const double  m22
[virtual]
 

Definition at line 460 of file MBody.cpp.

References myBodyID, and traceId.

void MBody::setMassDistribution const dMass &  massDistribution  )  [virtual]
 

Setup the mass distribution for this object. If this function isn't called, the object defaults to a mass zero particle

Definition at line 405 of file MBody.cpp.

References myBodyID, and traceId.

Referenced by setDataValue(), and setTotalMass().

void MBody::setPosition const double  x,
const double  y,
const double  z
[virtual]
 

Set the position of the body. This will set the positions of the associcated geometries too. Be careful when using this on a body currently being simulated. This can mess up joints. Certainly don't call this every frame to move an object. Instead provide forces and let the physics engine move the objects.

Implements MTransformable.

Definition at line 511 of file MBody.cpp.

References myBodyID, and traceId.

void MBody::setQuaternion const double  angle,
const double  x,
const double  y,
const double  z
[virtual]
 

Get the quaternion. A quaternion is a vector and a rotation about that vector.

Parameters:
angle The amount of rotation

Implements MTransformable.

Definition at line 532 of file MBody.cpp.

References myBodyID, and traceId.

void MBody::setRotation const double  phi,
const double  theta,
const double  psi
[virtual]
 

Set the rotation rotation. These are euler angles.

Parameters:
phi rotation about the x axis
theta rotation about the y axis
psi rotation about the z axis

Implements MTransformable.

Definition at line 553 of file MBody.cpp.

References myBodyID, and traceId.

void MBody::setTotalMass const double  mass  )  [virtual]
 

Adjust the mass disribution of this object so that the total mass is the given mass

Definition at line 429 of file MBody.cpp.

References myBodyID, setMassDistribution(), and traceId.

Referenced by setDataValue().

Here is the call graph for this function:

void MBody::setVelocity const double  vx,
const double  vy,
const double  vz
[virtual]
 

Set the velocity of the body. Be careful when using this on a body currently being simulated. This can mess up joints. Certainly don't call this every frame to move an object. Instead provide forces and let the physics engine move the objects.

Definition at line 526 of file MBody.cpp.

References myBodyID, and traceId.

Referenced by setDataValue().


Member Data Documentation

dBodyID MBody::myBodyID [protected]
 

The body id of this object in the physics model.

Definition at line 188 of file MBody.h.

Referenced by addMassDistribution(), bodyID(), cleanup(), getCenterOfMass(), getMassDistribution(), getPosition(), getQuaternion(), getTotalMass(), getVelocity(), initFromXML(), MBody(), setCenterOfMass(), setMassDistribution(), setPosition(), setQuaternion(), setRotation(), setTotalMass(), and setVelocity().

string MBody::myObjectName [protected]
 

The name of my parent object.

Definition at line 186 of file MBody.h.

Referenced by initFromXML(), objectName(), and parseMassNode().


The documentation for this class was generated from the following files:
Generated on Sat Dec 3 10:48:04 2005 for Robotics by  doxygen 1.4.5