Choreonoid  1.8
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
cnoid::Body Class Reference

#include <Body.h>

Inheritance diagram for cnoid::Body:
cnoid::ClonableReferenced cnoid::Referenced cnoid::DyBody

Classes

class  ContainerWrapper
 

Public Member Functions

 Body ()
 
 Body (const std::string &name)
 
 Body (const Body &org)=delete
 
virtual ~Body ()
 
void copyFrom (const Body *org, CloneMap *cloneMap=nullptr)
 
Bodyclone () const
 
Bodyclone (CloneMap &cloneMap) const
 
virtual LinkcreateLink (const Link *org=nullptr) const
 
const std::string & name () const
 
void setName (const std::string &name)
 
const std::string & modelName () const
 
void setModelName (const std::string &name)
 
void setRootLink (Link *link)
 
void expandLinkOffsetRotations ()
 
void updateLinkTree ()
 
void initializePosition ()
 
virtual void initializeState ()
 
BodyparentBody () const
 
LinkparentBodyLink () const
 
void setParent (Link *parentBodyLink)
 
void resetParent ()
 
void syncPositionWithParentBody (bool doForwardKinematics=true)
 
int numLinks () const
 
Linklink (int index) const
 
Linklink (const std::string &name) const
 
const LinkTraverselinkTraverse () const
 
const std::vector< Link * > & links () const
 
LinkrootLink () const
 
LinkfindUniqueEndLink () const
 
LinklastSerialLink () const
 
int numJoints () const
 
int numVirtualJoints () const
 
int numAllJoints () const
 
Linkjoint (int id) const
 
Linkjoint (const std::string &name) const
 
ContainerWrapper< std::vector< LinkPtr > > joints ()
 
const std::vector< LinkPtr > & allJoints () const
 
int numDevices () const
 
Devicedevice (int index) const
 
const DeviceListdevices () const
 
template<class DeviceType >
DeviceList< DeviceType > devices () const
 
template<class DeviceType >
DeviceType * findDevice (const std::string &name) const
 
template<class DeviceType >
DeviceType * findDevice () const
 
DevicefindDevice (const std::string &name) const
 
void addDevice (Device *device, Link *link)
 
void addDevice (Device *device)
 
void removeDevice (Device *device)
 
void clearDevices ()
 
void sortDevicesByLinkOrder ()
 
void initializeDeviceStates ()
 
bool isStaticModel () const
 
bool isFixedRootModel () const
 
void resetDefaultPosition (const Isometry3 &T)
 
const Isometry3defaultPosition () const
 
double mass () const
 
const Vector3calcCenterOfMass ()
 
const Vector3centerOfMass () const
 
void calcTotalMomentum (Vector3 &out_P, Vector3 &out_L)
 
void calcForwardKinematics (bool calcVelocity=false, bool calcAcceleration=false)
 
void clearExternalForces ()
 
int numExtraJoints () const
 
ExtraJointextraJoint (int index)
 
const ExtraJointextraJoint (int index) const
 
void addExtraJoint (const ExtraJoint &extraJoint)
 
void clearExtraJoints ()
 
const Mappinginfo () const
 
Mappinginfo ()
 
template<typename T >
info (const std::string &key) const
 
template<typename T >
info (const std::string &key, const T &defaultValue) const
 
template<typename T >
void setInfo (const std::string &key, const T &value)
 
void resetInfo (Mapping *info)
 
void cloneShapes (CloneMap &cloneMap)
 
template<class T >
T * findCache (const std::string &name)
 
template<class T >
const T * findCache (const std::string &name) const
 
template<class T >
T * getOrCreateCache (const std::string &name)
 
void setCache (const std::string &name, Referenced *cache)
 
bool getCaches (PolymorphicReferencedArrayBase<> &out_caches, std::vector< std::string > &out_names) const
 
void removeCache (const std::string &name)
 
void setCurrentTimeFunction (std::function< double()> func)
 
double currentTime () const
 
bool addHandler (BodyHandler *handler, bool isTopPriority=false)
 
template<class BodyHandlerType >
BodyHandlerType * findHandler ()
 
int numHandlers () const
 
BodyHandlerhandler (int index)
 
BodyCustomizerHandle customizerHandle () const
 
BodyCustomizerInterfacecustomizerInterface () const
 
bool installCustomizer ()
 
bool installCustomizer (BodyCustomizerInterface *customizerInterface)
 
bool hasVirtualJointForces () const
 
void setVirtualJointForces (double timeStep=0.0)
 
void resetLinkName (Link *link, const std::string &name)
 
void resetJointSpecificName (Link *link)
 
void resetJointSpecificName (Link *link, const std::string &name)
 
template<>
double info (const std::string &key) const
 
template<>
double info (const std::string &key, const double &defaultValue) const
 
template<>
bool info (const std::string &key, const bool &defaultValue) const
 
template<>
void setInfo (const std::string &key, const double &value)
 
template<>
void setInfo (const std::string &key, const bool &value)
 
- Public Member Functions inherited from cnoid::Referenced
virtual ~Referenced ()
 

Static Public Member Functions

static void addCustomizerDirectory (const std::string &path)
 
static BodyInterfacebodyInterface ()
 

Protected Member Functions

 Body (Link *rootLink)
 
virtual ReferenceddoClone (CloneMap *cloneMap) const override
 
- Protected Member Functions inherited from cnoid::Referenced
 Referenced ()
 
 Referenced (const Referenced &)
 
int refCount () const
 

Constructor & Destructor Documentation

◆ Body() [1/4]

Body::Body ( )

◆ Body() [2/4]

Body::Body ( const std::string &  name)

◆ Body() [3/4]

cnoid::Body::Body ( const Body org)
delete

◆ ~Body()

Body::~Body ( )
virtual

◆ Body() [4/4]

Body::Body ( Link rootLink)
protected

Member Function Documentation

◆ addCustomizerDirectory()

void Body::addCustomizerDirectory ( const std::string &  path)
static

◆ addDevice() [1/2]

void Body::addDevice ( Device device)

◆ addDevice() [2/2]

void Body::addDevice ( Device device,
Link link 
)

◆ addExtraJoint()

void cnoid::Body::addExtraJoint ( const ExtraJoint extraJoint)
inline

◆ addHandler()

bool Body::addHandler ( BodyHandler handler,
bool  isTopPriority = false 
)

◆ allJoints()

const std::vector<LinkPtr>& cnoid::Body::allJoints ( ) const
inline

◆ bodyInterface()

BodyInterface * Body::bodyInterface ( )
static

◆ calcCenterOfMass()

const Vector3 & Body::calcCenterOfMass ( )

◆ calcForwardKinematics()

void cnoid::Body::calcForwardKinematics ( bool  calcVelocity = false,
bool  calcAcceleration = false 
)
inline

◆ calcTotalMomentum()

void Body::calcTotalMomentum ( Vector3 out_P,
Vector3 out_L 
)

assuming Link::v,w is already computed by calcForwardKinematics(true); assuming Link::wc is already computed by calcCenterOfMass();

◆ centerOfMass()

const Vector3 & Body::centerOfMass ( ) const

◆ clearDevices()

void Body::clearDevices ( )

◆ clearExternalForces()

void Body::clearExternalForces ( )

◆ clearExtraJoints()

void cnoid::Body::clearExtraJoints ( )
inline

◆ clone() [1/2]

Body* cnoid::Body::clone ( ) const
inline

◆ clone() [2/2]

Body* cnoid::Body::clone ( CloneMap cloneMap) const
inline

◆ cloneShapes()

void Body::cloneShapes ( CloneMap cloneMap)

◆ copyFrom()

void Body::copyFrom ( const Body org,
CloneMap cloneMap = nullptr 
)

◆ createLink()

Link * Body::createLink ( const Link org = nullptr) const
virtual

Reimplemented in cnoid::DyBody.

◆ currentTime()

double cnoid::Body::currentTime ( ) const
inline

◆ customizerHandle()

BodyCustomizerHandle Body::customizerHandle ( ) const

◆ customizerInterface()

BodyCustomizerInterface * Body::customizerInterface ( ) const

◆ defaultPosition()

const Isometry3& cnoid::Body::defaultPosition ( ) const
inline

◆ device()

Device* cnoid::Body::device ( int  index) const
inline

◆ devices() [1/2]

const DeviceList& cnoid::Body::devices ( ) const
inline

Example: DeviceList<ForceSensor> forceSensors(body->devices()); or forceSensors << body->devices();

◆ devices() [2/2]

template<class DeviceType >
DeviceList<DeviceType> cnoid::Body::devices ( ) const
inline

◆ doClone()

Referenced * Body::doClone ( CloneMap cloneMap) const
overrideprotectedvirtual

Implements cnoid::ClonableReferenced.

Reimplemented in cnoid::DyBody.

◆ expandLinkOffsetRotations()

void cnoid::Body::expandLinkOffsetRotations ( )
inline

◆ extraJoint() [1/2]

ExtraJoint& cnoid::Body::extraJoint ( int  index)
inline

◆ extraJoint() [2/2]

const ExtraJoint& cnoid::Body::extraJoint ( int  index) const
inline

◆ findCache() [1/2]

template<class T >
T* cnoid::Body::findCache ( const std::string &  name)
inline

◆ findCache() [2/2]

template<class T >
const T* cnoid::Body::findCache ( const std::string &  name) const
inline

◆ findDevice() [1/3]

template<class DeviceType >
DeviceType* cnoid::Body::findDevice ( ) const
inline

◆ findDevice() [2/3]

template<class DeviceType >
DeviceType* cnoid::Body::findDevice ( const std::string &  name) const
inline

◆ findDevice() [3/3]

Device* cnoid::Body::findDevice ( const std::string &  name) const
inline

◆ findHandler()

template<class BodyHandlerType >
BodyHandlerType* cnoid::Body::findHandler ( )
inline

◆ findUniqueEndLink()

Link * Body::findUniqueEndLink ( ) const

◆ getCaches()

bool Body::getCaches ( PolymorphicReferencedArrayBase<> &  out_caches,
std::vector< std::string > &  out_names 
) const

◆ getOrCreateCache()

template<class T >
T* cnoid::Body::getOrCreateCache ( const std::string &  name)
inline

◆ handler()

BodyHandler * Body::handler ( int  index)

◆ hasVirtualJointForces()

bool Body::hasVirtualJointForces ( ) const

◆ info() [1/7]

Mapping* cnoid::Body::info ( )

◆ info() [2/7]

Mapping * Body::info ( ) const

◆ info() [3/7]

template<typename T >
T cnoid::Body::info ( const std::string &  key) const

◆ info() [4/7]

template<>
CNOID_EXPORT double cnoid::Body::info ( const std::string &  key) const

◆ info() [5/7]

template<>
CNOID_EXPORT bool cnoid::Body::info ( const std::string &  key,
const bool &  defaultValue 
) const

◆ info() [6/7]

template<>
CNOID_EXPORT double cnoid::Body::info ( const std::string &  key,
const double &  defaultValue 
) const

◆ info() [7/7]

template<typename T >
T cnoid::Body::info ( const std::string &  key,
const T &  defaultValue 
) const

◆ initializeDeviceStates()

void Body::initializeDeviceStates ( )

◆ initializePosition()

void Body::initializePosition ( )

◆ initializeState()

void Body::initializeState ( )
virtual

◆ installCustomizer() [1/2]

bool Body::installCustomizer ( )

The function installs the pre-loaded customizer corresponding to the model name.

◆ installCustomizer() [2/2]

bool Body::installCustomizer ( BodyCustomizerInterface customizerInterface)

◆ isFixedRootModel()

bool cnoid::Body::isFixedRootModel ( ) const
inline

◆ isStaticModel()

bool cnoid::Body::isStaticModel ( ) const
inline

This function returns true when the whole body is a static, fixed object like a floor.

◆ joint() [1/2]

Link * Body::joint ( const std::string &  name) const

This function returns a link object whose joint name matches a given name. A nullptr is returned when the corresponding link is not found.

◆ joint() [2/2]

Link* cnoid::Body::joint ( int  id) const
inline

This function returns the link object that has a given joint ID. If there is no corresponding link, the function returns a dummy link object whose ID is minus one. If the body has virtual joints, this function returns them by giving the ids over the last one.

◆ joints()

ContainerWrapper<std::vector<LinkPtr> > cnoid::Body::joints ( )
inline

◆ lastSerialLink()

Link * Body::lastSerialLink ( ) const

◆ link() [1/2]

Link * Body::link ( const std::string &  name) const

This function returns the link object whose name matches a given name. A nullptr is returned when the corresponding link is not found.

◆ link() [2/2]

Link* cnoid::Body::link ( int  index) const
inline

This function returns the link object of a given index in the whole link sequence. The order of the sequence corresponds to a link-tree traverse from the root link. The size of the sequence can be obtained by numLinks().

◆ links()

const std::vector<Link*>& cnoid::Body::links ( ) const
inline

◆ linkTraverse()

const LinkTraverse& cnoid::Body::linkTraverse ( ) const
inline

LinkTraverse object that traverses all the links from the root link

◆ mass()

double Body::mass ( ) const

◆ modelName()

const std::string & Body::modelName ( ) const

◆ name()

const std::string & Body::name ( ) const

◆ numAllJoints()

int cnoid::Body::numAllJoints ( ) const
inline

The number of all the joints including both the actual and virtual joints.

◆ numDevices()

int cnoid::Body::numDevices ( ) const
inline

◆ numExtraJoints()

int cnoid::Body::numExtraJoints ( ) const
inline

◆ numHandlers()

int Body::numHandlers ( ) const

◆ numJoints()

int cnoid::Body::numJoints ( ) const
inline

The number of the links that are actual joints. The joints given joint ids are recognized as such joints. Note that the acutal value is the maximum joint ID plus one. Thus there may be a case where the value does not correspond to the actual number of the joints with ids. In other words, the value represents the size of the link sequence obtained by joint() function.

◆ numLinks()

int cnoid::Body::numLinks ( ) const
inline

The number of all the links the body has. The value corresponds to the size of the sequence obtained by link() function.

◆ numVirtualJoints()

int cnoid::Body::numVirtualJoints ( ) const
inline

The number of the joints without joint ids. For example, a joint for simulating a spring is usually handled as such a joint. You can get the joints by giving the index after the last joint id to the joint() function.

◆ parentBody()

Body* cnoid::Body::parentBody ( ) const
inline

◆ parentBodyLink()

Link* cnoid::Body::parentBodyLink ( ) const
inline

◆ removeCache()

void Body::removeCache ( const std::string &  name)

◆ removeDevice()

void Body::removeDevice ( Device device)

◆ resetDefaultPosition()

void Body::resetDefaultPosition ( const Isometry3 T)

◆ resetInfo()

void Body::resetInfo ( Mapping info)

◆ resetJointSpecificName() [1/2]

void Body::resetJointSpecificName ( Link link)

◆ resetJointSpecificName() [2/2]

void Body::resetJointSpecificName ( Link link,
const std::string &  name 
)

◆ resetLinkName()

void Body::resetLinkName ( Link link,
const std::string &  name 
)

◆ resetParent()

void Body::resetParent ( )

◆ rootLink()

Link* cnoid::Body::rootLink ( ) const
inline

The root link of the body

◆ setCache()

void cnoid::Body::setCache ( const std::string &  name,
Referenced cache 
)
inline

◆ setCurrentTimeFunction()

void Body::setCurrentTimeFunction ( std::function< double()>  func)

◆ setInfo() [1/3]

template<>
CNOID_EXPORT void cnoid::Body::setInfo ( const std::string &  key,
const bool &  value 
)

◆ setInfo() [2/3]

template<>
CNOID_EXPORT void cnoid::Body::setInfo ( const std::string &  key,
const double &  value 
)

◆ setInfo() [3/3]

template<typename T >
void cnoid::Body::setInfo ( const std::string &  key,
const T &  value 
)

◆ setModelName()

void Body::setModelName ( const std::string &  name)

◆ setName()

void Body::setName ( const std::string &  name)

◆ setParent()

void Body::setParent ( Link parentBodyLink)

◆ setRootLink()

void Body::setRootLink ( Link link)

◆ setVirtualJointForces()

void Body::setVirtualJointForces ( double  timeStep = 0.0)

◆ sortDevicesByLinkOrder()

void Body::sortDevicesByLinkOrder ( )

◆ syncPositionWithParentBody()

void Body::syncPositionWithParentBody ( bool  doForwardKinematics = true)

◆ updateLinkTree()

void Body::updateLinkTree ( )

This function must be called when the structure of the link tree is changed.


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