A class representing an element (subcomponent) of a MultibodyPlant or (internally) a MultibodyTree.
Examples of multibody elements are bodies, joints, force elements, and actuators. After a Finalize() call, multibody elements get assigned a type-specific index that uniquely identifies them. By convention, every subclass of MultibodyElement provides an index()
member function that returns the assigned index, e.g.,
Some multibody elements are added during Finalize() and are not part of the user-specified model. These are called "ephemeral" elements and can be identified using the is_ephemeral()
function here. Examples include
T | The scalar type, which must be one of the default scalars. |
#include <drake/multibody/tree/multibody_tree_system.h>
Public Member Functions | |
virtual | ~MultibodyElement () |
ModelInstanceIndex | model_instance () const |
Returns the ModelInstanceIndex of the model instance to which this element belongs. More... | |
template<typename = void> | |
const MultibodyPlant< T > & | GetParentPlant () const |
Returns the MultibodyPlant that owns this MultibodyElement. More... | |
void | DeclareParameters (internal::MultibodyTreeSystem< T > *tree_system) |
Declares MultibodyTreeSystem Parameters at MultibodyTreeSystem::Finalize() time. More... | |
void | SetDefaultParameters (systems::Parameters< T > *parameters) const |
Sets default values of parameters belonging to each MultibodyElement in parameters at a call to MultibodyTreeSystem::SetDefaultParameters(). More... | |
void | DeclareDiscreteState (internal::MultibodyTreeSystem< T > *tree_system) |
Declares MultibodyTreeSystem discrete states. More... | |
void | DeclareCacheEntries (internal::MultibodyTreeSystem< T > *tree_system) |
(Advanced) Declares all cache entries needed by this element. More... | |
bool | is_ephemeral () const |
Returns true if this MultibodyElement was added during Finalize() rather than something a user added. More... | |
void | set_is_ephemeral (bool is_ephemeral) |
(Internal use only) Sets the is_ephemeral flag to the indicated value. More... | |
Does not allow copy, move, or assignment | |
MultibodyElement (const MultibodyElement &)=delete | |
MultibodyElement & | operator= (const MultibodyElement &)=delete |
MultibodyElement (MultibodyElement &&)=delete | |
MultibodyElement & | operator= (MultibodyElement &&)=delete |
Protected Member Functions | |
MultibodyElement () | |
Default constructor made protected so that sub-classes can still declare their default constructors if they need to. More... | |
MultibodyElement (ModelInstanceIndex model_instance) | |
Constructor which allows specifying a model instance. More... | |
MultibodyElement (ModelInstanceIndex model_instance, int64_t index) | |
Both the model instance and element index are specified. More... | |
template<typename ElementIndexType > | |
ElementIndexType | index_impl () const |
Returns this element's unique index. More... | |
int | ordinal_impl () const |
Returns this element's unique ordinal. More... | |
const internal::MultibodyTree< T > & | get_parent_tree () const |
Returns a constant reference to the parent MultibodyTree that owns this element. More... | |
const internal::MultibodyTreeSystem< T > & | GetParentTreeSystem () const |
Returns a constant reference to the parent MultibodyTreeSystem that owns the parent MultibodyTree that owns this element. More... | |
void | SetTopology (const internal::MultibodyTreeTopology &tree) |
Gives MultibodyElement-derived objects the opportunity to retrieve their topology after MultibodyTree::Finalize() is invoked. More... | |
virtual void | DoSetTopology (const internal::MultibodyTreeTopology &tree)=0 |
Implementation of the NVI SetTopology(). More... | |
virtual void | DoDeclareParameters (internal::MultibodyTreeSystem< T > *) |
Implementation of the NVI DeclareParameters(). More... | |
virtual void | DoSetDefaultParameters (systems::Parameters< T > *) const |
Implementation of the NVI SetDefaultParameters(). More... | |
virtual void | DoDeclareDiscreteState (internal::MultibodyTreeSystem< T > *) |
Implementation of the NVI DeclareDiscreteState(). More... | |
virtual void | DoDeclareCacheEntries (internal::MultibodyTreeSystem< T > *) |
Derived classes must override this method to declare cache entries needed by this element. More... | |
systems::NumericParameterIndex | DeclareNumericParameter (internal::MultibodyTreeSystem< T > *tree_system, const systems::BasicVector< T > &model_vector) |
To be used by MultibodyElement-derived objects when declaring parameters in their implementation of DoDeclareParameters(). More... | |
systems::AbstractParameterIndex | DeclareAbstractParameter (internal::MultibodyTreeSystem< T > *tree_system, const AbstractValue &model_value) |
To be used by MultibodyElement-derived objects when declaring parameters in their implementation of DoDeclareParameters(). More... | |
systems::DiscreteStateIndex | DeclareDiscreteState (internal::MultibodyTreeSystem< T > *tree_system, const VectorX< T > &model_value) |
To be used by MultibodyElement-derived objects when declaring discrete states in their implementation of DoDeclareDiscreteStates(). More... | |
systems::CacheEntry & | DeclareCacheEntry (internal::MultibodyTreeSystem< T > *tree_system, std::string description, systems::ValueProducer value_producer, std::set< systems::DependencyTicket > prerequisites_of_calc) |
To be used by MultibodyElement-derived objects when declaring cache entries in their implementation of DoDeclareCacheEntries(). More... | |
bool | has_parent_tree () const |
Returns true if this multibody element has a parent tree, otherwise false. More... | |
Friends | |
class | internal::MultibodyTree< T > |
class | DeformableModel< T > |
class | MultibodyElementTester |
|
delete |
|
delete |
|
virtual |
|
protected |
Default constructor made protected so that sub-classes can still declare their default constructors if they need to.
|
explicitprotected |
Constructor which allows specifying a model instance.
|
explicitprotected |
Both the model instance and element index are specified.
|
protected |
To be used by MultibodyElement-derived objects when declaring parameters in their implementation of DoDeclareParameters().
For an example, see Joint::DoDeclareParameters().
void DeclareCacheEntries | ( | internal::MultibodyTreeSystem< T > * | tree_system | ) |
(Advanced) Declares all cache entries needed by this element.
This method is called by MultibodyTree on this
element during MultibodyTree::Finalize(). It subsequently calls DoDeclareCacheEntries(). Custom elements that need to declare cache entries must override DoDeclareCacheEntries().
|
protected |
To be used by MultibodyElement-derived objects when declaring cache entries in their implementation of DoDeclareCacheEntries().
For an example, see DeformableBody::DoDeclareCacheEntries().
void DeclareDiscreteState | ( | internal::MultibodyTreeSystem< T > * | tree_system | ) |
Declares MultibodyTreeSystem discrete states.
NVI to the virtual method DoDeclareDiscreteState().
[in] | tree_system | A mutable copy of the parent MultibodyTreeSystem. |
|
protected |
To be used by MultibodyElement-derived objects when declaring discrete states in their implementation of DoDeclareDiscreteStates().
For an example, see DeformableBody::DoDeclareDiscreteStates().
|
protected |
To be used by MultibodyElement-derived objects when declaring parameters in their implementation of DoDeclareParameters().
For an example, see RigidBody::DoDeclareParameters().
void DeclareParameters | ( | internal::MultibodyTreeSystem< T > * | tree_system | ) |
Declares MultibodyTreeSystem Parameters at MultibodyTreeSystem::Finalize() time.
NVI to the virtual method DoDeclareParameters().
[in] | tree_system | A mutable copy of the parent MultibodyTreeSystem. |
|
protectedvirtual |
Derived classes must override this method to declare cache entries needed by this
element.
The default implementation is a no-op.
|
protectedvirtual |
Implementation of the NVI DeclareDiscreteState().
MultibodyElement-derived objects may override to declare their specific state variables.
|
protectedvirtual |
Implementation of the NVI DeclareParameters().
MultibodyElement-derived objects may override to declare their specific parameters.
|
protectedvirtual |
Implementation of the NVI SetDefaultParameters().
MultibodyElement-derived objects may override to set default values of their specific parameters.
|
protectedpure virtual |
Implementation of the NVI SetTopology().
For advanced use only for developers implementing new MultibodyTree components.
Implemented in Joint< T >.
|
protected |
Returns a constant reference to the parent MultibodyTree that owns this element.
std::exception | in debug builds if has_parent_tree() is false. |
const MultibodyPlant<T>& GetParentPlant | ( | ) | const |
Returns the MultibodyPlant that owns this MultibodyElement.
drake/multibody/plant/multibody_plant.h
in the translation unit that invokes this method; multibody_element.h cannot do that for you.std::exception | if there is no MultibodyPlant owner. |
|
protected |
Returns a constant reference to the parent MultibodyTreeSystem that owns the parent MultibodyTree that owns this element.
std::exception | in debug builds if has_parent_tree() is false. |
|
protected |
Returns true if this multibody element has a parent tree, otherwise false.
|
protected |
Returns this element's unique index.
bool is_ephemeral | ( | ) | const |
Returns true
if this MultibodyElement was added during Finalize() rather than something a user added.
(See class comments.)
ModelInstanceIndex model_instance | ( | ) | const |
Returns the ModelInstanceIndex of the model instance to which this element belongs.
|
delete |
|
delete |
|
protected |
Returns this element's unique ordinal.
void set_is_ephemeral | ( | bool | is_ephemeral | ) |
(Internal use only) Sets the is_ephemeral
flag to the indicated value.
The default if this is never called is false
. Any element that is added during Finalize() should set this flag to true
.
void SetDefaultParameters | ( | systems::Parameters< T > * | parameters | ) | const |
Sets default values of parameters belonging to each MultibodyElement in parameters
at a call to MultibodyTreeSystem::SetDefaultParameters().
[out] | parameters | A mutable collections of parameters in a context. |
|
protected |
Gives MultibodyElement-derived objects the opportunity to retrieve their topology after MultibodyTree::Finalize() is invoked.
NVI to pure virtual method DoSetTopology().
|
friend |
|
friend |
|
friend |