Drake
MultibodyTreeTopology Class Reference

Data structure to store the topological information associated with an entire MultibodyTree. More...

#include <multibody/multibody_tree/multibody_tree_topology.h>

## Public Member Functions

MultibodyTreeTopology ()
Default constructor creates an empty, invalid topology. More...

bool operator== (const MultibodyTreeTopology &other) const
Returns true if all members of this topology are exactly equal to the members of other. More...

int get_num_bodies () const
Returns the number of bodies in the multibody tree. More...

int get_num_frames () const
Returns the number of physical frames in the multibody tree. More...

int get_num_mobilizers () const
Returns the number of mobilizers in the multibody tree. More...

int get_num_body_nodes () const
Returns the number of tree nodes. This must equal the number of bodies. More...

int get_num_force_elements () const
Returns the number of force elements in the multibody tree. More...

int get_tree_height () const
Returns the number of tree levels in the topology. More...

const FrameTopologyget_frame (FrameIndex index) const
Returns a constant reference to the corresponding FrameTopology given the FrameIndex. More...

const BodyTopologyget_body (BodyIndex index) const
Returns a constant reference to the corresponding BodyTopology given a BodyIndex. More...

const MobilizerTopologyget_mobilizer (MobilizerIndex index) const
Returns a constant reference to the corresponding BodyTopology given a BodyIndex. More...

const BodyNodeTopologyget_body_node (BodyNodeIndex index) const
Returns a constant reference to the corresponding BodyNodeTopology given a BodyNodeIndex. More...

std::pair< BodyIndex, FrameIndexadd_body ()
Creates and adds a new BodyTopology to this MultibodyTreeTopology. More...

FrameIndex add_frame (BodyIndex body_index)
Creates and adds a new FrameTopology, associated with the given body_index, to this MultibodyTreeTopology. More...

MobilizerIndex add_mobilizer (FrameIndex in_frame, FrameIndex out_frame, int num_positions, int num_velocities)
Creates and adds a new MobilizerTopology connecting the inboard and outboard multibody frames identified by indexes in_frame and out_frame, respectively. More...

ForceElementIndex add_force_element ()
Creates and adds a new ForceElementTopology, associated with the given force_index, to this MultibodyTreeTopology. More...

void Finalize ()
This method must be called by MultibodyTree::Finalize() after all topological elements in the tree (corresponding to joints, bodies, force elements, constraints) were added and before any computations are performed. More...

bool is_valid () const
Returns true if Finalize() was already called on this topology. More...

int get_num_positions () const
Returns the total number of generalized positions in the model. More...

int get_num_velocities () const
Returns the total number of generalized velocities in the model. More...

int get_num_states () const
Returns the total size of the state vector in the model. More...

void GetKinematicPathToWorld (BodyNodeIndex from, std::vector< BodyNodeIndex > *path_to_world) const
Given a node in this topology, specified by its BodyNodeIndex from, this method computes the kinematic path formed by all the nodes in the tree that connect from with the root (corresponding to the world). More...

Implements CopyConstructible, CopyAssignable, MoveConstructible, MoveAssignable
MultibodyTreeTopology (const MultibodyTreeTopology &)=default

MultibodyTreeTopologyoperator= (const MultibodyTreeTopology &)=default

MultibodyTreeTopology (MultibodyTreeTopology &&)=default

MultibodyTreeTopologyoperator= (MultibodyTreeTopology &&)=default

## Detailed Description

Data structure to store the topological information associated with an entire MultibodyTree.

## Constructor & Destructor Documentation

 MultibodyTreeTopology ( const MultibodyTreeTopology & )
default
 MultibodyTreeTopology ( MultibodyTreeTopology && )
default
 MultibodyTreeTopology ( )
inline

Default constructor creates an empty, invalid topology.

The minimum valid topology for a minimum valid MultibodyTree contains at least the BodyTopology for the world. The topology for the world body does not get added until MultibodyTree construction, which creates a world body and adds it to the tree.

## Member Function Documentation

 std::pair add_body ( )
inline

Creates and adds a new BodyTopology to this MultibodyTreeTopology.

The BodyTopology will be assigned a new, unique BodyIndex and FrameIndex values.

Exceptions
 std::logic_error if Finalize() was already called on this topology.
Returns
a std::pair<BodyIndex, FrameIndex> containing the indexes assigned to the new BodyTopology.

Here is the caller graph for this function:

 ForceElementIndex add_force_element ( )
inline

Creates and adds a new ForceElementTopology, associated with the given force_index, to this MultibodyTreeTopology.

Exceptions
 std::logic_error if Finalize() was already called on this topology.
Returns
The ForceElementIndex assigned to the new ForceElementTopology.

Here is the caller graph for this function:

 FrameIndex add_frame ( BodyIndex body_index )
inline

Creates and adds a new FrameTopology, associated with the given body_index, to this MultibodyTreeTopology.

Exceptions
 std::logic_error if Finalize() was already called on this topology.
Returns
The FrameIndex assigned to the new FrameTopology.

Here is the caller graph for this function:

 MobilizerIndex add_mobilizer ( FrameIndex in_frame, FrameIndex out_frame, int num_positions, int num_velocities )
inline

Creates and adds a new MobilizerTopology connecting the inboard and outboard multibody frames identified by indexes in_frame and out_frame, respectively.

The created topology will correspond to that of a Mobilizer with num_positions and num_velocities.

Exceptions
 std::runtime_error if either in_frame or out_frame do not index frame topologies in this MultibodyTreeTopology. a std::runtime_error if in_frame == out_frame. a std::runtime_error if in_frame and out_frame already are connected by another mobilizer. More than one mobilizer between two frames is not allowed. std::logic_error if Finalize() was already called on this topology.
Returns
The MobilizerIndex assigned to the new MobilizerTopology.

Here is the call graph for this function:

Here is the caller graph for this function:

 void Finalize ( )
inline

This method must be called by MultibodyTree::Finalize() after all topological elements in the tree (corresponding to joints, bodies, force elements, constraints) were added and before any computations are performed.

It essentially compiles all the necessary "topological information", i.e. how bodies, joints and, any other elements connect with each other, and performs all the required pre-processing to perform computations at a later stage. This preprocessing includes:

• sorting in BFT order for fast recursions through the tree,
• computation of state sizes and of pool sizes within cache entries,
• computation of index maps to retrieve either state or cache entries for each multibody element.

If the finalize stage is successful, the this topology is validated, meaning it is up-to-date after this call. No more multibody tree elements can be added after a call to Finalize().

Exceptions
 std::logic_error If users attempt to call this method on an already finalized topology.
See also
is_valid()

Here is the call graph for this function:

 const BodyTopology& get_body ( BodyIndex index ) const
inline

Returns a constant reference to the corresponding BodyTopology given a BodyIndex.

 const BodyNodeTopology& get_body_node ( BodyNodeIndex index ) const
inline

Returns a constant reference to the corresponding BodyNodeTopology given a BodyNodeIndex.

Here is the caller graph for this function:

 const FrameTopology& get_frame ( FrameIndex index ) const
inline

Returns a constant reference to the corresponding FrameTopology given the FrameIndex.

Here is the caller graph for this function:

 const MobilizerTopology& get_mobilizer ( MobilizerIndex index ) const
inline

Returns a constant reference to the corresponding BodyTopology given a BodyIndex.

Here is the caller graph for this function:

 int get_num_bodies ( ) const
inline

Returns the number of bodies in the multibody tree.

This includes the "world" body and therefore the minimum number of bodies after MultibodyTree::Finalize() will always be one, not zero.

Here is the caller graph for this function:

 int get_num_body_nodes ( ) const
inline

Returns the number of tree nodes. This must equal the number of bodies.

 int get_num_force_elements ( ) const
inline

Returns the number of force elements in the multibody tree.

 int get_num_frames ( ) const
inline

Returns the number of physical frames in the multibody tree.

 int get_num_mobilizers ( ) const
inline

Returns the number of mobilizers in the multibody tree.

Since the "world" body does not have a mobilizer, the number of mobilizers will always equal the number of bodies minus one.

 int get_num_positions ( ) const
inline

Returns the total number of generalized positions in the model.

Here is the caller graph for this function:

 int get_num_states ( ) const
inline

Returns the total size of the state vector in the model.

Here is the caller graph for this function:

 int get_num_velocities ( ) const
inline

Returns the total number of generalized velocities in the model.

Here is the caller graph for this function:

 int get_tree_height ( ) const
inline

Returns the number of tree levels in the topology.

Here is the caller graph for this function:

 void GetKinematicPathToWorld ( BodyNodeIndex from, std::vector< BodyNodeIndex > * path_to_world ) const
inline

Given a node in this topology, specified by its BodyNodeIndex from, this method computes the kinematic path formed by all the nodes in the tree that connect from with the root (corresponding to the world).

Parameters
 [in] from A node in the tree topology to which the path to the root (world) is to be computed. [out] path_to_world A std::vector of body node indexes that on output will contain the path to the root of the tree. Forward iteration (from element 0 to element size()-1) of path_to_world will traverse all nodes in the tree starting at the root along the path to from. That is, forward iteration starts with the root of the tree at path_to_world[0] and ends with from at path_to_world.back(). On input, path_to_world must be a valid pointer. On output this vector will be resized, only if needed, to store as many elements as the level (BodyNodeTopology::level) of body node from plus one (so that we can include the root node in the path).
 bool is_valid ( ) const
inline

Returns true if Finalize() was already called on this topology.

See also
Finalize()

Here is the caller graph for this function:

 MultibodyTreeTopology& operator= ( MultibodyTreeTopology && )
default
 MultibodyTreeTopology& operator= ( const MultibodyTreeTopology & )
default
 bool operator== ( const MultibodyTreeTopology & other ) const
inline

Returns true if all members of this topology are exactly equal to the members of other.

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