Actin  Version 5.5.3
Software for Robotics Simulation and Control
EcRigidBodyMassProperties Class Reference

Represents rigid body mass properties: mass, first moment, and second moment. The second moment is with respect to the origin of the representation (not with respect to the center of mass). More...

#include <ecRigidBodyMass.h>

Inheritance diagram for EcRigidBodyMassProperties:
[legend]
Collaboration diagram for EcRigidBodyMassProperties:
[legend]

Public Member Functions

 EcRigidBodyMassProperties ()
 default constructor
 
 EcRigidBodyMassProperties (const EcXmlNonNegReal &mass, const EcXmlVector &firstMoment, const EcSecondMoment &secondMoment)
 constructor with all components
 
virtual ~EcRigidBodyMassProperties ()
 destructor
 
 EcRigidBodyMassProperties (const EcRigidBodyMassProperties &orig)
 copy constructor
 
EcRigidBodyMassPropertiesoperator= (const EcRigidBodyMassProperties &orig)
 assignment operator
 
EcBoolean operator== (const EcRigidBodyMassProperties &orig) const
 equality operator
 
virtual EcBoolean xmlInit () EC_OVERRIDE
 initialize XML components for reading and writing
 
virtual EcXmlObjectclone () const EC_OVERRIDE
 clone - a virtual constructor to an EcXmlObject pointer
 
virtual EcBoolean equality (const EcXmlObject *other) const EC_OVERRIDE
 equality - virtual equality to an EcXmlObject pointer
 
virtual EcXmlObjectnewObject () const EC_OVERRIDE
 virtual new that returns an EcXmlObject
 
EcRigidBodyMassPropertiesoperator+= (const EcRigidBodyMassProperties &mp2)
 add another mass properties to this and set this to the result
 
EcRigidBodyMassPropertiesoperator-= (const EcRigidBodyMassProperties &mp2)
 subtract another mass properties from this and set this to the result
 
EcRigidBodyMassProperties operator+ (const EcRigidBodyMassProperties &mp2) const
 add another mass properties to this and return the result
 
EcRigidBodyMassProperties operator- (const EcRigidBodyMassProperties &mp2) const
 subtract another mass properties from this and return the result
 
virtual EcRigidBodyMassPropertiestransformBy (const EcCoordinateSystemTransformation &xform)
 general transformation. Returns the transformed entity.
 
virtual EcRigidBodyMassPropertiestransformBy (const EcOrientation &orientation)
 rotation. Returns the transformed entity
 
virtual EcRigidBodyMassPropertiestransformBy (const EcVector &translation)
 
virtual EcGeneralForce calculateForce (const EcGeneralMotion &vel, const EcGeneralMotion &acc) const
 calculates the force on the rigid body needed to produce the velocity and acceleration
 
virtual EcGeneralForce calculateForce (const EcGeneralMotion &acc) const
 
virtual EcGeneralMotion calculateAcceleration (const EcGeneralMotion &vel, const EcGeneralForce &genForce) const
 calculates the acceleration of the rigid body given the velocity and applied force
 
virtual EcGeneralMotion calculateAcceleration (const EcGeneralForce &genForce) const
 
virtual void registerComponents () EC_OVERRIDE
 register components with the parent
 
virtual const EcNonNegRealmass () const
 gets mass
 
virtual const EcVectorfirstMoment () const
 gets the first moment
 
virtual const EcSecondMomentsecondMoment () const
 
virtual const EcSpatialMatrixinvSecondMoment () const
 
virtual void set (EcNonNegReal mass, const EcVector &firstMoment, const EcSecondMoment &secondMoment, EcBoolean checkValidity=EcTrue)
 sets mass, first moment, and second moment More...
 
virtual void getCenterOfMass (EcVector &centerOfMass) const
 get the center-of-mass vector
 
virtual EcBoolean getPrincipalFrame (EcCoordinateSystemTransformation &principalFrame) const
 
virtual EcBoolean isValid () const
 checks validity.
 
virtual const EcReArrayspatialCholeskyDecomposition () const
 
virtual void getArray (EcReArray &array) const
 get the spatial inertia as a 6x6 array
 
virtual EcBoolean approxEq (const EcRigidBodyMassProperties &sm2, EcReal tol) const
 test for approximate equality
 
virtual void scaleBy (EcReal scaleFactor)
 
virtual void getEllipsoid (EcEllipsoid &ellipsoid, EcReal &massDensity) const
 
virtual void makeValid ()
 make the rigid body mass valid by tweaking its elements. This does nothing if it's already valid.
 
virtual const EcTokentoken () const EC_OVERRIDE
 gets the xml token used for writing out. More...
 
virtual EcBoolean read (EcXmlReader &stream) EC_OVERRIDE
 read this object from an XML stream
 
virtual EcBoolean write (EcXmlWriter &stream) const EC_OVERRIDE
 write this object to an XML stream
 
- Public Member Functions inherited from EcXmlCompoundType
 ECDECLARE_BIGFOUR (EcXmlCompoundType)
 
virtual EcBoolean readAttributes (EcXmlReader &stream)
 read object attributes from an XML stream
 
virtual EcBoolean readElements (EcXmlReader &stream)
 read object elements from an XML stream
 
virtual EcBoolean writeAttributes (EcXmlWriter &stream) const
 write object attributes to an XML stream
 
virtual EcBoolean writeElements (EcXmlWriter &stream) const
 write object elements to an XML stream
 
virtual EcBoolean writeSchema (EcXmlSchema &stream) const EC_OVERRIDE
 write schema
 
virtual EcBoolean writeSchemaAttributes (EcXmlSchema &stream) const
 write schema attributes
 
virtual EcBoolean writeSchemaElements (EcXmlSchema &stream) const
 write schema elements
 
virtual void registerComponent (const EcToken &token, EcXmlObject *obj)
 register a single component More...
 
virtual void registerComponent (EcXmlObject *obj)
 register a single component More...
 
virtual void registerComponentReadOnly (const EcToken &token, EcXmlObject *obj)
 register a single component as read-only More...
 
virtual const EcXmlComponentMapcomponentMap () const
 get a reference to the component map
 
virtual void registerAttributeComponent (const EcToken &AttribToken, EcXmlObject *Obj)
 register a single attribute component More...
 
virtual void registerAttributeComponentReadOnly (const EcToken &AttribToken, EcXmlObject *Obj)
 register a single attribute component read-only More...
 
virtual const EcXmlComponentMapattributeComponentMap ()
 get a reference to the component attribute map
 
virtual const EcXmlSpecialDescriptorMapspecialDescriptorMap ()
 get a reference to the special-descriptor map
 
virtual void registerComponentDescriptor (const EcToken &xmlToken, const EcToken &descriptorToken, const EcString &descriptorString)
 register an XML token-string descriptor More...
 
virtual const EcXmlTokenStringDescriptorMapMaptokenStringDescriptorMap ()
 get a reference to the XML token-string descriptor map
 
virtual EcBoolean hasChildren () const
 return EcTrue if there are children components or EcFalse if an empty element.
 
virtual EcBoolean hasAttributes () const
 return EcTrue if there are attributes in the element.
 
- Public Member Functions inherited from EcXmlObject
 ECDECLARE_BIGFOUR (EcXmlObject)
 
virtual EcBoolean readAttribute (EcXmlReader &stream)
 read this attribute from an XML stream
 
virtual EcBoolean createSchema (const EcString &filename, const EcToken &objectName=EcXml::EcDefaultToken) const
 create schema
 
virtual EcBoolean xmlInitialized () const
 get XML initialized flag. This bit is set on initialization.
 
virtual void setXmlInitialized (EcBoolean val=EcTrue)
 set XML initialized flag. This bit is set on initialization.
 
virtual EcBoolean specified () const
 get specified flag. This bit is set upon reading from an XML file.
 
virtual void setSpecified (EcBoolean val=EcTrue)
 set specified flag. This bit is set upon reading from an XML file.
 
virtual EcBoolean isBasicType () const
 Return true/false for basic type.
 
virtual EcBoolean equalsDefault () const
 tests equality of XML object with default
 

Static Public Member Functions

static EcRigidBodyMassProperties nullObject ()
 get an zero second moment
 
static EcRigidBodyMassProperties defaultObject ()
 standard mass property object
 
static EcRigidBodyMassProperties pointMass (EcReal mass)
 a point mass with zero offset
 
static EcRigidBodyMassProperties uniformSolidSphere (EcReal mass, EcReal radius)
 
static EcRigidBodyMassProperties uniformSolidHemisphere (EcReal mass, EcReal radius)
 
static EcRigidBodyMassProperties uniformSphericalShell (EcReal mass, EcReal radius)
 
static EcRigidBodyMassProperties uniformSolidAxisAlignedEllipsoid (EcReal mass, EcReal semiaxisX, EcReal semiaxisY, EcReal semiaxisZ)
 
static EcRigidBodyMassProperties uniformSolidAxisAlignedRectangularPrism (EcReal mass, EcReal lengthAlongX, EcReal lengthAlongY, EcReal lengthAlongZ)
 
static EcRigidBodyMassProperties uniformSolidAxisAlignedCylinder (EcReal mass, EcReal radius, EcReal length)
 
static EcRigidBodyMassProperties uniformSolidAxisAlignedCone (const EcReal mass, const EcReal radius0, const EcReal radius1, const EcReal length)
 
static EcRigidBodyMassProperties uniformSolidAxisAlignedTorus (EcReal mass, EcReal bigRadius, EcReal littleRadius)
 
static EcRigidBodyMassProperties uniformSolidAxisAlignedCircularLozenge (const EcReal mass, const EcReal circleRadius, const EcReal lozengeRadius)
 a unifor solid circular-lozenge encircling the z-axis
 
static EcRigidBodyMassProperties uniformSolidCapsule (EcReal mass, const EcCapsule &capsule)
 a uniform capsule with a given mass
 
static EcRigidBodyMassProperties uniformSolidLozenge (const EcReal mass, const EcLozenge &lozenge, const EcU32 meshSize=20)
 a uniform lozenge with a given mass
 
static EcRigidBodyMassProperties uniformSolidTriangularLozenge (const EcReal mass, const EcTriangularLozenge &triLozenge, const EcU32 meshSize=100)
 a uniform triangular-lozenge with a given mass
 
static EcRigidBodyMassProperties massPropertiesFromShape (const EcReal mass, const EcShape *shape)
 compute mass properties from shape
 
static EcBoolean isShapeSupported (const EcShape *shape)
 get if computing mass properties from shape is supported
 

Protected Member Functions

virtual void computeSecondMomentInverse () const
 computes the inverse of the second moment of inertia
 
- Protected Member Functions inherited from EcXmlCompoundType
virtual EcBoolean readValueFromToken (const EcToken &token, EcXmlReader &stream)
 
virtual EcBoolean readValueFromSpecialToken (const EcToken &token, EcXmlReader &stream)
 read value from unregistered token
 
virtual EcBoolean readAttributeFromToken (const EcToken &token, EcXmlReader &stream)
 
virtual EcXmlComponentMapnewComponentMap () const
 allocate a new componentMap
 
virtual EcXmlSpecialDescriptorMapnewSpecialDescriptorMap ()
 allocate a new specialDescriptorsMap
 
virtual EcXmlTokenStringDescriptorMapMapnewTokenStringDescriptorMap ()
 allocate a new tokenStringDescriptorsMap
 
virtual void createComponentMap () const
 create component map
 
virtual void createAttributeComponentMap ()
 create attribute component map
 
virtual void createSpecialDescriptorMap ()
 create special-descriptors map
 
virtual void createTokenStringDescriptorMap ()
 create token-string descriptor map
 
virtual EcBoolean isReadOnlyComponent (const EcToken token) const
 check to see if the token corresponds to a read-only component
 
virtual EcBoolean isReadOnlyAttribute (const EcToken token) const
 check to see if the token corresponds to a read-only attribute
 
virtual EcXmlObjectlibraryAttribute ()
 

Protected Attributes

EcXmlNonNegReal m_Mass
 scalar mass
 
EcXmlVector m_FirstMoment
 vector first moment
 
EcSecondMoment m_SecondMoment
 
EcSpatialMatrix m_InverseSecondMoment
 the inverse of the moment of inertia, added here for speed
 
EcBoolean m_InverseSecondMomentValid
 flag indicating if the inverse second moment matrix is valid
 
EcReArray m_SpatialCholeskyDecomposition
 The spatial Cholesky decomposition.
 
EcBoolean m_IsSpatialCholeskyDecompositionValid
 The spatial Cholesky decomposition valid flag.
 
- Protected Attributes inherited from EcXmlCompoundType
EcXmlComponentMapm_pComponentMap
 
EcXmlComponentMapm_pAttributeComponentMap
 
EcXmlSpecialDescriptorMapm_pSpecialDescriptorMap
 
EcXmlTokenStringDescriptorMapMapm_pComponentMapTokenStringDescriptor
 
- Protected Attributes inherited from EcXmlObject
EcU8 m_State
 the state of the object - eight boolean flags
 

Additional Inherited Members

- Public Types inherited from EcXmlCompoundType
enum  {
  READONLYCOMPONENT = 0,
  READONLYATTRIBUTE
}
 special-descriptor codes More...
 
- Static Protected Attributes inherited from EcXmlObject
static const EcU8 m_theXmlInitializedBit
 the bit used to describe xml initialization
 
static const EcU8 m_theSpecifiedBit
 the bit used to describe specification
 

Detailed Description

Represents rigid body mass properties: mass, first moment, and second moment. The second moment is with respect to the origin of the representation (not with respect to the center of mass).

Holds rigid body mass properties. The mass properties is a set of 10 unique values: mass, first moment of inertia, and second moment of inertia.

Definition at line 35 of file ecRigidBodyMass.h.

Member Function Documentation

virtual EcGeneralMotion EcRigidBodyMassProperties::calculateAcceleration ( const EcGeneralForce genForce) const
virtual

calculates the acceleration produced by the specified force when there is no velocity

virtual EcGeneralForce EcRigidBodyMassProperties::calculateForce ( const EcGeneralMotion acc) const
virtual

calculates the force on the rigid body needed to produce the acceleration with no velocity

virtual void EcRigidBodyMassProperties::getEllipsoid ( EcEllipsoid ellipsoid,
EcReal massDensity 
) const
virtual

return an approximating ellipsoid and the corresponding mass density

virtual EcBoolean EcRigidBodyMassProperties::getPrincipalFrame ( EcCoordinateSystemTransformation principalFrame) const
virtual

get the principal frame this frame is centered at the center of mass and is oriented along the principal axes of ineria, with the x-axis having the maximum moment of ineria, and the z-axis having the minimum.

virtual const EcSpatialMatrix& EcRigidBodyMassProperties::invSecondMoment ( ) const
virtual

gets the inverse of the second moment expressed at the center of mass, not at the point of application.

virtual void EcRigidBodyMassProperties::scaleBy ( EcReal  scaleFactor)
virtual

scale the mass properties by a distance scale factor this assumes constant density, so that mass scales with the cube of the scale factor, for example

virtual const EcSecondMoment& EcRigidBodyMassProperties::secondMoment ( ) const
virtual

gets the second moment expressed at the point of application, not at the center of mass.

virtual void EcRigidBodyMassProperties::set ( EcNonNegReal  mass,
const EcVector firstMoment,
const EcSecondMoment secondMoment,
EcBoolean  checkValidity = EcTrue 
)
virtual

sets mass, first moment, and second moment

Parameters
[in]massThe mass.
[in]firstMomentThe first moment of inertia.
[in]secondMomentThe second moment of inertia. It is expressed at the point of application, not the center of mass.
[in]checkValidityIf true, the validity of the second moment is checked and if it's invalid, an attempt will be made to make it valid. This is the default. If checkValidity is false, then there'll be no attempt to make the mass properties valid. The supplied values will be used as is.
virtual const EcReArray& EcRigidBodyMassProperties::spatialCholeskyDecomposition ( ) const
virtual

the Cholesky decomposition of the spatial inertia matrix. (i.e., lower-triangular L such that L*L^T=|mI H^T| |H J |

virtual const EcToken& EcRigidBodyMassProperties::token ( ) const
virtual

gets the xml token used for writing out.

Implements EcXmlObject.

virtual EcRigidBodyMassProperties& EcRigidBodyMassProperties::transformBy ( const EcVector translation)
virtual

offset. Returns the transformed entity Note that this takes mass properties represented at the tip of the transformation vector and expresses it at the origin.

static EcRigidBodyMassProperties EcRigidBodyMassProperties::uniformSolidAxisAlignedCone ( const EcReal  mass,
const EcReal  radius0,
const EcReal  radius1,
const EcReal  length 
)
static

a uniform solid cone frustum with axis the z-axis with 2 radii and end-to-end length as specified centered at the origin (Point 0)

static EcRigidBodyMassProperties EcRigidBodyMassProperties::uniformSolidAxisAlignedCylinder ( EcReal  mass,
EcReal  radius,
EcReal  length 
)
static

a uniform solid cylinder with axis the z-axis with radius and end-to-end length as specified centered at the origin

static EcRigidBodyMassProperties EcRigidBodyMassProperties::uniformSolidAxisAlignedEllipsoid ( EcReal  mass,
EcReal  semiaxisX,
EcReal  semiaxisY,
EcReal  semiaxisZ 
)
static

a uniform elipsoid aligned with the axes, with given semiaxes along x, y, and z centered at the origin

static EcRigidBodyMassProperties EcRigidBodyMassProperties::uniformSolidAxisAlignedRectangularPrism ( EcReal  mass,
EcReal  lengthAlongX,
EcReal  lengthAlongY,
EcReal  lengthAlongZ 
)
static

a uniform rectangular prism aligned with the axes, with given lengths along x, y, and z. centered at the origin

static EcRigidBodyMassProperties EcRigidBodyMassProperties::uniformSolidAxisAlignedTorus ( EcReal  mass,
EcReal  bigRadius,
EcReal  littleRadius 
)
static

a uniform solid torus encircling the z-axis centered at the origin

static EcRigidBodyMassProperties EcRigidBodyMassProperties::uniformSolidHemisphere ( EcReal  mass,
EcReal  radius 
)
static

a uniform hemisphere with a given mass and radius, with axis along the z axis and flat portion aligned with the x-y plane. The hemisphere protrudes in the direction of the positive z-axis.

static EcRigidBodyMassProperties EcRigidBodyMassProperties::uniformSolidSphere ( EcReal  mass,
EcReal  radius 
)
static

a uniform sphere with a given mass and radius centered at the origin

Examples:
ecCollisionAvoidanceExample.cpp, and ecProgrammaticConstructionMain.cpp.
static EcRigidBodyMassProperties EcRigidBodyMassProperties::uniformSphericalShell ( EcReal  mass,
EcReal  radius 
)
static

a uniform shell with a given mass and radius centered at the origin

Member Data Documentation

EcSecondMoment EcRigidBodyMassProperties::m_SecondMoment
protected

second moment (equivalent to a symmectric 3x3 matrix) expressed at the point of application, not at the center of mass.

Definition at line 439 of file ecRigidBodyMass.h.


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