Drake
MultibodyTreeElement< ElementType< T >, ElementIndexType > Class Template Referenceabstract

Detailed Description

template<template< typename > class ElementType, typename T, typename ElementIndexType>
class drake::multibody::MultibodyTreeElement< ElementType< T >, ElementIndexType >

A class representing an element or component of a MultibodyTree.

Examples of multibody tree elements are bodies, joints, force elements, and constraints. Multibody tree elements are owned and managed by a parent MultibodyTree. At MultibodyTree::Finalize() stage, they get assigned an index that uniquely identifies them within their parent MultibodyTree. A generic multibody tree element MultibodyComponent is derived from this class as:

template <typename T>
class MultibodyComponent :
public MultibodyTreeElement<MultibodyComponent<T>,
MultibodyComponentIndex> {
...
};
Template Parameters
ElementTypeThe type of the specific multibody element, for instance, a body or a mobilizer. It must be a template class on the scalar type T.
TThe underlying scalar type. Must be a valid Eigen scalar. With the signature below the scalar type is automatically deduced from the ElementType template argument.
ElementIndexTypeThe type-safe index used for this element type.

As an example of usage, consider the definition of a ForceElement class as a multibody tree element. This would be accomplished with:

template <typename T>
class ForceElement :
public MultibodyTreeElement<ForceElement<T>, ForceElementIndex>;

Notice that with the signature below the scalar type is automatically deduced from the template arguments.

#include <drake/multibody/tree/multibody_tree_element.h>

Public Member Functions

virtual ~MultibodyTreeElement ()
 
const internal::MultibodyTree< T > & get_parent_tree () const
 Returns a constant reference to the parent MultibodyTree that owns this element. More...
 
ElementIndexType index () const
 Returns this element's unique index in its parent MultibodyTree. More...
 
ModelInstanceIndex model_instance () const
 Returns this element's model instance index in its parent MultibodyTree. More...
 
void HasParentTreeOrThrow () const
 Checks whether this MultibodyTreeElement has been registered into a MultibodyTree. More...
 
template<template< typename > class OtherElementType, typename OtherElementIndexType >
void HasSameParentTreeOrThrow (const MultibodyTreeElement< OtherElementType< T >, OtherElementIndexType > &other) const
 Checks whether this element has the same parent tree as other. More...
 
void HasThisParentTreeOrThrow (const internal::MultibodyTree< T > *tree) const
 Checks whether this MultibodyTreeElement belongs to the provided MultibodyTree tree. More...
 
Does not allow copy, move, or assignment
 MultibodyTreeElement (const MultibodyTreeElement &)=delete
 
MultibodyTreeElementoperator= (const MultibodyTreeElement &)=delete
 
 MultibodyTreeElement (MultibodyTreeElement &&)=delete
 
MultibodyTreeElementoperator= (MultibodyTreeElement &&)=delete
 

Protected Member Functions

 MultibodyTreeElement ()
 Default constructor made protected so that sub-classes can still declare their default constructors if they need to. More...
 
 MultibodyTreeElement (ModelInstanceIndex model_instance)
 Constructor which allows specifying a model instance. More...
 
void SetTopology (const internal::MultibodyTreeTopology &tree)
 Gives MultibodyTree elements the opportunity to retrieve their topology when MultibodyTree::Finalize() is invoked. More...
 
virtual void DoSetTopology (const internal::MultibodyTreeTopology &tree)=0
 Implementation of the NVI SetTopology(). More...
 

Friends

class internal::MultibodyTree< T >
 

Constructor & Destructor Documentation

◆ MultibodyTreeElement() [1/4]

MultibodyTreeElement ( const MultibodyTreeElement< ElementType< T >, ElementIndexType > &  )
delete

◆ MultibodyTreeElement() [2/4]

MultibodyTreeElement ( MultibodyTreeElement< ElementType< T >, ElementIndexType > &&  )
delete

◆ ~MultibodyTreeElement()

virtual ~MultibodyTreeElement ( )
virtual

◆ MultibodyTreeElement() [3/4]

MultibodyTreeElement ( )
protected

Default constructor made protected so that sub-classes can still declare their default constructors if they need to.

◆ MultibodyTreeElement() [4/4]

MultibodyTreeElement ( ModelInstanceIndex  model_instance)
explicitprotected

Constructor which allows specifying a model instance.

Member Function Documentation

◆ DoSetTopology()

virtual void DoSetTopology ( const internal::MultibodyTreeTopology tree)
protectedpure virtual

Implementation of the NVI SetTopology().

For advanced use only for developers implementing new MultibodyTree components.

◆ get_parent_tree()

const internal::MultibodyTree<T>& get_parent_tree ( ) const

Returns a constant reference to the parent MultibodyTree that owns this element.

Sub-classes of MultibodyTreeElement will have a set of Create() methods that, when successful, will create and add a MultibodyTreeElement to a valid MultibodyTree. Therefore, on success, the result of a Create() method is a properly initialized MultibodyTreeElement with a valid MultibodyTree parent.

See also
RigidBody::Create() for an example of a Create() method.

◆ HasParentTreeOrThrow()

void HasParentTreeOrThrow ( ) const

Checks whether this MultibodyTreeElement has been registered into a MultibodyTree.

If not, it throws an exception of type std::logic_error.

◆ HasSameParentTreeOrThrow()

void HasSameParentTreeOrThrow ( const MultibodyTreeElement< OtherElementType< T >, OtherElementIndexType > &  other) const

Checks whether this element has the same parent tree as other.

If not, it throws an exception of type std::logic_error. A std::logic_error exception is thrown if either or both elements do not have a parent tree.

◆ HasThisParentTreeOrThrow()

void HasThisParentTreeOrThrow ( const internal::MultibodyTree< T > *  tree) const

Checks whether this MultibodyTreeElement belongs to the provided MultibodyTree tree.

If not, it throws a std::logic_error.

◆ index()

ElementIndexType index ( ) const

Returns this element's unique index in its parent MultibodyTree.

◆ model_instance()

ModelInstanceIndex model_instance ( ) const

Returns this element's model instance index in its parent MultibodyTree.

◆ operator=() [1/2]

MultibodyTreeElement& operator= ( const MultibodyTreeElement< ElementType< T >, ElementIndexType > &  )
delete

◆ operator=() [2/2]

MultibodyTreeElement& operator= ( MultibodyTreeElement< ElementType< T >, ElementIndexType > &&  )
delete

◆ SetTopology()

void SetTopology ( const internal::MultibodyTreeTopology tree)
protected

Gives MultibodyTree elements the opportunity to retrieve their topology when MultibodyTree::Finalize() is invoked.

NVI to pure virtual method DoSetTopology().

Friends And Related Function Documentation

◆ internal::MultibodyTree< T >

friend class internal::MultibodyTree< T >
friend

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