Drake
MultibodyPlant< T > Class Template Reference

Detailed Description

template<typename T>
class drake::multibody::MultibodyPlant< T >

MultibodyPlant is a Drake system framework representation (see systems::System) for the model of a physical system consisting of a collection of interconnected bodies.

See Multibody Kinematics and Dynamics for an overview of concepts/notation.

{model_instance_name[0]}_actuation →
... →
{model_instance_name[N-1]}_actuation →
applied_generalized_force →
applied_spatial_force →
geometry_query →
MultibodyPlant
→ continuous_state
{model_instance_name[0]}_continuous_state
→ ...
{model_instance_name[N-1]}_continuous_state
{model_instance_name[0]}_generalized_contact_forces
→ ...
{model_instance_name[N-1]}_generalized_contact_forces
→ contact_results
→ geometry_pose

Note that the outputs in orange are not allocated for model instances with no state (e.g. the world, or a welded model which isn't actuated (like a table)).

MultibodyPlant provides a user-facing API to:

  • add bodies, joints, force elements, and constraints,
  • register geometries to a provided SceneGraph instance,
  • create and manipulate its Context,
  • perform Context-dependent computational queries.

System dynamics

positions vector q, of size nq (see num_positions()), and by its generalized velocities vector v, of size nv (see num_velocities()). As a Drake System, MultibodyPlant implements the governing equations for a multibody dynamical system in the form ẋ = f(t, x, u) with t being the time and u the input vector of actuation forces. The governing equations for the dynamics of a multibody system modeled with MultibodyPlant are [Featherstone 2008, Jain 2010]:

         q̇ = N(q)v
  (1)    M(q)v̇ + C(q, v)v = τ

where M(q) is the mass matrix of the multibody system, C(q, v)v corresponds to the bias term containing Coriolis and gyroscopic effects and N(q) is the kinematic coupling matrix describing the relationship between the rate of change of the generalized coordinates and the generalized velocities, [Seth 2010]. N(q) is an nq x nv matrix. The vector τ ∈ ℝⁿᵛ on the right hand side of Eq. (1) corresponds to generalized forces applied on the system. These can include externally applied body forces, constraint forces, and contact forces.

Loading models from SDF files

Drake has the capability of loading multibody models from SDF and URDF files. Consider the example below which loads an acrobot model:

MultibodyPlant<T> acrobot;
SceneGraph<T> scene_graph;
Parser parser(&acrobot, &scene_graph);
const std::string relative_name =
"drake/multibody/benchmarks/acrobot/acrobot.sdf";
const std::string full_name = FindResourceOrThrow(relative_name);
parser.AddModelFromFile(full_name);

As in the example above, for models including visual geometry, collision geometry or both, the user must specify a SceneGraph for geometry handling. You can find a full example of the LQR controlled acrobot in examples/multibody/acrobot/run_lqr.cc.

AddModelFromFile() can be invoked multiple times on the same plant in order to load multiple model instances. Other methods are available on Parser such as AddAllModelsFromFile() which allows creating model instances per each <model> tag found in the file. Please refer to each of these methods' documentation for further details.

Adding modeling elements

methods:

All modeling elements must be added pre-finalize.

Registering geometry with a SceneGraph

MultibodyPlant users can register geometry with a SceneGraph for essentially two purposes; a) visualization and, b) contact modeling.Before any geometry registration takes place, a user must first make a call to RegisterAsSourceForSceneGraph() in order to register the MultibodyPlant as a client of a SceneGraph instance, point at which the plant will have assigned a valid geometry::SourceId. At Finalize(), MultibodyPlant will declare input/output ports as appropriate to communicate with the SceneGraph instance on which registrations took place. All geometry registration must be performed pre-finalize.

If MultibodyPlant registers geometry with a SceneGraph via calls to RegisterCollisionGeometry(), an input port for geometric queries will be declared at Finalize() time, see get_geometry_query_input_port(). Users must connect this input port to the output port for geometric queries of the SceneGraph used for registration, which can be obtained with SceneGraph::get_query_output_port(). In summary, if MultibodyPlant registers collision geometry, the setup process will include:

  1. Call to RegisterAsSourceForSceneGraph().
  2. Calls to RegisterCollisionGeometry(), as many as needed.
  3. Call to Finalize(), user is done specifying the model.
  4. Connect SceneGraph::get_query_output_port() to get_geometry_query_input_port().

Refer to the documentation provided in each of the methods above for further details.

Modeling contact

Please refer to Contact Modeling in Drake for details on the available approximations, setup, and considerations for a multibody simulation with frictional contact.

Finalize() stage

Once the user is done adding modeling elements and registering geometry, a call to Finalize() must be performed. This call will:

  • Build the underlying MultibodyTree topology, see MultibodyTree::Finalize() for details,
  • declare the plant's state,
  • declare the plant's input and output ports,
  • declare input and output ports for communication with a SceneGraph.

    References

  • [Featherstone 2008] Featherstone, R., 2008. Rigid body dynamics algorithms. Springer.
  • [Jain 2010] Jain, A., 2010. Robot and multibody dynamics: analysis and algorithms. Springer Science & Business Media.
  • [Seth 2010] Seth, A., Sherman, M., Eastman, P. and Delp, S., 2010. Minimal formulation of joint motion for biomechanisms. Nonlinear dynamics, 62(1), pp.291-303.
Template Parameters
TMust be one of drake's default scalar types.

#include <drake/multibody/plant/multibody_plant.h>

Public Member Functions

 MultibodyPlant (double time_step=0)
 Default constructor creates a plant with a single "world" body. More...
 
template<typename U >
 MultibodyPlant (const MultibodyPlant< U > &other)
 Scalar-converting copy constructor. See System Scalar Conversion. More...
 
void set_contact_model (ContactModel model)
 Sets the contact model to be used by this MultibodyPlant, see ContactModel for available options. More...
 
ContactModel get_contact_model () const
 Returns the model used for contact. See documentation for ContactModel. More...
 
int num_frames () const
 Returns the number of Frame objects in this model. More...
 
int num_bodies () const
 Returns the number of bodies in the model, including the "world" body, which is always part of the model. More...
 
int num_joints () const
 Returns the number of joints in the model. More...
 
int num_actuators () const
 Returns the number of joint actuators in the model. More...
 
int num_force_elements () const
 Returns the number of ForceElement objects. More...
 
int num_model_instances () const
 Returns the number of model instances in the model. More...
 
int num_positions () const
 Returns the size of the generalized position vector q for this model. More...
 
int num_positions (ModelInstanceIndex model_instance) const
 Returns the size of the generalized position vector q for a specific model instance. More...
 
int num_velocities () const
 Returns the size of the generalized velocity vector v for this model. More...
 
int num_velocities (ModelInstanceIndex model_instance) const
 Returns the size of the generalized velocity vector v for a specific model instance. More...
 
int num_multibody_states () const
 Returns the size of the multibody system state vector x = [q; v]. More...
 
int num_actuated_dofs () const
 Returns the total number of actuated degrees of freedom. More...
 
int num_actuated_dofs (ModelInstanceIndex model_instance) const
 Returns the total number of actuated degrees of freedom for a specific model instance. More...
 
void SetPositionsAndVelocities (systems::Context< T > *context, const VectorX< T > &q_v) const
 Sets all generalized positions and velocities from the given vector [q; v]. More...
 
void SetPositionsAndVelocities (systems::Context< T > *context, ModelInstanceIndex model_instance, const VectorX< T > &q_v) const
 Sets generalized positions and velocities from the given vector [q; v] for the specified model instance. More...
 
Eigen::VectorBlock< const VectorX< T > > GetPositions (const systems::Context< T > &context) const
 Returns a const vector reference containing the vector of generalized positions. More...
 
VectorX< T > GetPositions (const systems::Context< T > &context, ModelInstanceIndex model_instance) const
 Returns an vector containing the generalized positions (q) for the given model instance. More...
 
Eigen::VectorBlock< VectorX< T > > GetMutablePositions (systems::Context< T > *context) const
 (Advanced) Returns a mutable vector reference containing the vector of generalized positions (see warning). More...
 
Eigen::VectorBlock< VectorX< T > > GetMutablePositions (const systems::Context< T > &context, systems::State< T > *state) const
 (Advanced) Returns a mutable vector reference containing the vector of generalized positions (see warning). More...
 
void SetPositions (systems::Context< T > *context, const VectorX< T > &q) const
 Sets all generalized positions from the given vector. More...
 
void SetPositions (systems::Context< T > *context, ModelInstanceIndex model_instance, const VectorX< T > &q_instance) const
 Sets the positions for a particular model instance from the given vector. More...
 
void SetPositions (const systems::Context< T > &context, systems::State< T > *state, ModelInstanceIndex model_instance, const VectorX< T > &q_instance) const
 Sets the positions for a particular model instance from the given vector. More...
 
Eigen::VectorBlock< const VectorX< T > > GetVelocities (const systems::Context< T > &context) const
 Returns a const vector reference containing the generalized velocities. More...
 
VectorX< T > GetVelocities (const systems::Context< T > &context, ModelInstanceIndex model_instance) const
 Returns a vector containing the generalized velocities (v) for the given model instance. More...
 
Eigen::VectorBlock< VectorX< T > > GetMutableVelocities (const systems::Context< T > &context, systems::State< T > *state) const
 (Advanced) Returns a mutable vector reference containing the vector of generalized velocities (see warning). More...
 
Eigen::VectorBlock< VectorX< T > > GetMutableVelocities (systems::Context< T > *context) const
 See GetMutableVelocities() method above. More...
 
void SetVelocities (systems::Context< T > *context, const VectorX< T > &v) const
 Sets all generalized velocities from the given vector. More...
 
void SetVelocities (const systems::Context< T > &context, systems::State< T > *state, ModelInstanceIndex model_instance, const VectorX< T > &v_instance) const
 Sets the generalized velocities for a particular model instance from the given vector. More...
 
void SetVelocities (systems::Context< T > *context, ModelInstanceIndex model_instance, const VectorX< T > &v_instance) const
 Sets the generalized velocities for a particular model instance from the given vector. More...
 
MatrixX< T > MakeActuationMatrix () const
 This method creates an actuation matrix B mapping a vector of actuation values u into generalized forces tau_u = B * u, where B is a matrix of size nv x nu with nu equal to num_actuators() and nv equal to num_velocities(). More...
 
geometry::SourceId RegisterAsSourceForSceneGraph (geometry::SceneGraph< T > *scene_graph)
 Registers this plant to serve as a source for an instance of SceneGraph. More...
 
std::vector< const Body< T > * > GetBodiesWeldedTo (const Body< T > &body) const
 Returns all bodies that are transitively welded, or rigidly affixed, to body, per these two definitions: More...
 
const CoulombFriction< double > & default_coulomb_friction (geometry::GeometryId id) const
 Returns the friction coefficients provided during geometry registration for the given geometry id. More...
 
bool geometry_source_is_registered () const
 Returns true if this MultibodyPlant was registered with a SceneGraph. More...
 
const Body< T > * GetBodyFromFrameId (geometry::FrameId frame_id) const
 Given a geometry frame identifier, returns a pointer to the body associated with that id (nullptr if there is no such body). More...
 
optional< geometry::FrameIdGetBodyFrameIdIfExists (BodyIndex body_index) const
 If the body with body_index has geometry registered with it, it returns the geometry::FrameId associated with it. More...
 
geometry::FrameId GetBodyFrameIdOrThrow (BodyIndex body_index) const
 If the body with body_index has geometry registered with it, it returns the geometry::FrameId associated with it. More...
 
const systems::OutputPort< T > & get_generalized_contact_forces_output_port (ModelInstanceIndex model_instance) const
 Returns a constant reference to the output port of generalized contact forces for a specific model instance. More...
 
const systems::OutputPort< T > & get_contact_results_output_port () const
 Returns a constant reference to the port that outputs ContactResults. More...
 
const systems::OutputPort< T > & get_reaction_forces_output_port () const
 Returns the port for joint reaction forces. More...
 
const RigidBody< T > & world_body () const
 Returns a constant reference to the world body. More...
 
const BodyFrame< T > & world_frame () const
 Returns a constant reference to the world frame. More...
 
const Body< T > & get_body (BodyIndex body_index) const
 Returns a constant reference to the body with unique index body_index. More...
 
const Joint< T > & get_joint (JointIndex joint_index) const
 Returns a constant reference to the joint with unique index joint_index. More...
 
Joint< T > & get_mutable_joint (JointIndex joint_index)
 Returns a mutable reference to the joint with unique index joint_index. More...
 
const JointActuator< T > & get_joint_actuator (JointActuatorIndex actuator_index) const
 Returns a constant reference to the joint actuator with unique index actuator_index. More...
 
const Frame< T > & get_frame (FrameIndex frame_index) const
 Returns a constant reference to the frame with unique index frame_index. More...
 
const UniformGravityFieldElement< T > & gravity_field () const
 An accessor to the current gravity field. More...
 
UniformGravityFieldElement< T > & mutable_gravity_field ()
 A mutable accessor to the current gravity field. More...
 
const std::string & GetModelInstanceName (ModelInstanceIndex model_instance) const
 Returns the name of a model_instance. More...
 
bool is_finalized () const
 Returns true if this MultibodyPlant was finalized with a call to Finalize(). More...
 
bool IsAnchored (const Body< T > &body) const
 Returns true if body is anchored (i.e. More...
 
void Finalize ()
 This method must be called after all elements in the model (joints, bodies, force elements, constraints, etc.) are added and before any computations are performed. More...
 
double time_step () const
 The time step (or period) used to model this plant as a discrete system with periodic updates. More...
 
const std::vector< geometry::PenetrationAsPointPair< T > > & EvalPointPairPenetrations (const systems::Context< T > &context) const
 Evaluates all point pairs of contact for a given state of the model stored in context. More...
 
void SetDefaultState (const systems::Context< T > &context, systems::State< T > *state) const override
 Sets the state so that generalized positions and velocities are zero. More...
 
void SetRandomState (const systems::Context< T > &context, systems::State< T > *state, RandomGenerator *generator) const override
 Assigns random values to all elements of the state, by drawing samples independently for each joint/floating-base (coming soon: and then solving a mathematical program to "project" these samples onto the registered system constraints). More...
 
Does not allow copy, move, or assignment
 MultibodyPlant (const MultibodyPlant &)=delete
 
MultibodyPlantoperator= (const MultibodyPlant &)=delete
 
 MultibodyPlant (MultibodyPlant &&)=delete
 
MultibodyPlantoperator= (MultibodyPlant &&)=delete
 
Position and velocity state component accessors and mutators.

Various methods for accessing and mutating [q; v], where q is the vector of generalized positions and v is the vector of generalized velocities, or some portion thereof (e.g., only v).

Eigen::VectorBlock< const VectorX< T > > GetPositionsAndVelocities (const systems::Context< T > &context) const
 Returns a const vector reference containing the vector [q; v] with q the vector of generalized positions and v the vector of generalized velocities. More...
 
VectorX< T > GetPositionsAndVelocities (const systems::Context< T > &context, ModelInstanceIndex model_instance) const
 Returns the vector [q; v] of the model with q the vector of generalized positions and v the vector of generalized velocities for model instance model_instance. More...
 
Eigen::VectorBlock< VectorX< T > > GetMutablePositionsAndVelocities (systems::Context< T > *context) const
 (Advanced) Returns a mutable vector containing the vector [q; v] of the model with q the vector of generalized positions and v the vector of generalized velocities (see warning). More...
 
Working with free bodies

A MultibodyPlant user adds sets of Body and Joint objects to this plant to build a physical representation of a mechanical model.

At Finalize(), MultibodyPlant builds a mathematical representation of such system, consisting of a tree representation. In this representation each body is assigned a Mobilizer, which grants a certain number of degrees of freedom in accordance to the physical specification. In this regard, the modeling representation can be seen as a forest of tree structures each of which contains a single body at the root of the tree. This root body, if connected to the world with a floating mobilizer (that is, a mobilizer which grants 6-dofs), is labeled as a "floating body". A user can request the set of floating bodies with a call to GetFloatingBaseBodies(). Alternatively, a user can query whether a Body is floating or not with Body::is_floating(). For many applications, a user might need to work with indexes in the multibody state vector. For such applications, Body::floating_positions_start() and Body::floating_velocities_start() offer the additional level of introspection needed.

std::unordered_set< BodyIndexGetFloatingBaseBodies () const
 Returns the set of body indexes corresponding to the "floating bodies" in the model, in no particular order. More...
 
math::RigidTransform< T > GetFreeBodyPose (const systems::Context< T > &context, const Body< T > &body) const
 Gets the pose of a given body in the world frame W. More...
 
void SetFreeBodyPose (systems::Context< T > *context, const Body< T > &body, const math::RigidTransform< T > &X_WB) const
 Sets context to store the pose X_WB of a given body B in the world frame W. More...
 
void SetFreeBodyPose (const systems::Context< T > &context, systems::State< T > *state, const Body< T > &body, const math::RigidTransform< T > &X_WB) const
 Sets state to store the pose X_WB of a given body B in the world frame W, for a given context of this model. More...
 
void SetFreeBodySpatialVelocity (systems::Context< T > *context, const Body< T > &body, const SpatialVelocity< T > &V_WB) const
 Sets context to store the spatial velocity V_WB of a given body B in the world frame W. More...
 
void SetFreeBodySpatialVelocity (const systems::Context< T > &context, systems::State< T > *state, const Body< T > &body, const SpatialVelocity< T > &V_WB) const
 Sets state to store the spatial velocity V_WB of a given body B in the world frame W, for a given context of this model. More...
 
void SetFreeBodyRandomPositionDistribution (const Body< T > &body, const Vector3< symbolic::Expression > &position)
 Sets the distribution used by SetRandomState() to populate the x-y-z position component of the floating-base state. More...
 
void SetFreeBodyRandomRotationDistribution (const Body< T > &body, const Eigen::Quaternion< symbolic::Expression > &rotation)
 Sets the distribution used by SetRandomState() to populate the rotation component of the floating-base state. More...
 
void SetFreeBodyRandomRotationDistributionToUniform (const Body< T > &body)
 Sets the distribution used by SetRandomState() to populate the rotation component of the floating-base state using uniformly random rotations. More...
 
Adding new multibody elements

MultibodyPlant users will add modeling elements like bodies, joints, force elements, constraints, etc, using one of these methods.

Once a user is done adding all modeling elements, the Finalize() method must be called before invoking any MultibodyPlant service to perform computations. An attempt to call any of these methods after a call to Finalize() on the plant, will result on an exception being thrown. See Finalize() for details.

const RigidBody< T > & AddRigidBody (const std::string &name, ModelInstanceIndex model_instance, const SpatialInertia< double > &M_BBo_B)
 Creates a rigid body with the provided name and spatial inertia. More...
 
const RigidBody< T > & AddRigidBody (const std::string &name, const SpatialInertia< double > &M_BBo_B)
 Creates a rigid body with the provided name and spatial inertia. More...
 
template<template< typename > class FrameType>
const FrameType< T > & AddFrame (std::unique_ptr< FrameType< T >> frame)
 This method adds a Frame of type FrameType<T>. More...
 
template<template< typename Scalar > class JointType>
const JointType< T > & AddJoint (std::unique_ptr< JointType< T >> joint)
 This method adds a Joint of type JointType between two bodies. More...
 
template<template< typename > class JointType, typename... Args>
const JointType< T > & AddJoint (const std::string &name, const Body< T > &parent, const optional< math::RigidTransform< double >> &X_PF, const Body< T > &child, const optional< math::RigidTransform< double >> &X_BM, Args &&... args)
 This method adds a Joint of type JointType between two bodies. More...
 
template<template< typename Scalar > class ForceElementType, typename... Args>
const ForceElementType< T > & AddForceElement (Args &&... args)
 Adds a new force element model of type ForceElementType to this MultibodyPlant. More...
 
const JointActuator< T > & AddJointActuator (const std::string &name, const Joint< T > &joint, double effort_limit=std::numeric_limits< double >::infinity())
 Creates and adds a JointActuator model for an actuator acting on a given joint. More...
 
ModelInstanceIndex AddModelInstance (const std::string &name)
 Creates a new model instance. More...
 
const WeldJoint< T > & WeldFrames (const Frame< T > &A, const Frame< T > &B, const math::RigidTransform< double > &X_AB=math::RigidTransform< double >::Identity())
 Welds frames A and B with relative pose X_AB. More...
 
Querying for multibody elements by name

These methods allow a user to query whether a given multibody element is part of this plant's model.

These queries can be performed at any time during the lifetime of a MultibodyPlant model, i.e. there is no restriction on whether they must be called before or after Finalize(). That is, these queries can be performed while new multibody elements are being added to the model.

bool HasBodyNamed (const std::string &name) const
 
bool HasBodyNamed (const std::string &name, ModelInstanceIndex model_instance) const
 
bool HasFrameNamed (const std::string &name) const
 
bool HasFrameNamed (const std::string &name, ModelInstanceIndex model_instance) const
 
bool HasJointNamed (const std::string &name) const
 
bool HasJointNamed (const std::string &name, ModelInstanceIndex model_instance) const
 
bool HasJointActuatorNamed (const std::string &name) const
 
bool HasJointActuatorNamed (const std::string &name, ModelInstanceIndex model_instance) const
 
bool HasModelInstanceNamed (const std::string &name) const
 
Retrieving multibody elements by name

These methods allow a user to retrieve a reference to a multibody element by its name.

An exception is thrown if there is no element with the requested name.

const Body< T > & GetBodyByName (const std::string &name) const
 These queries can be performed at any time during the lifetime of a MultibodyPlant, i.e. More...
 
const Body< T > & GetBodyByName (const std::string &name, ModelInstanceIndex model_instance) const
 Returns a constant reference to the body that is uniquely identified by the string name and model_instance in this MultibodyPlant. More...
 
std::vector< BodyIndexGetBodyIndices (ModelInstanceIndex model_instance) const
 Returns a list of body indices associated with model_instance. More...
 
std::vector< JointIndexGetJointIndices (ModelInstanceIndex model_instance) const
 Returns a list of joint indices associated with model_instance. More...
 
const Frame< T > & GetFrameByName (const std::string &name) const
 Returns a constant reference to a frame that is identified by the string name in this model. More...
 
const Frame< T > & GetFrameByName (const std::string &name, ModelInstanceIndex model_instance) const
 Returns a constant reference to the frame that is uniquely identified by the string name in model_instance. More...
 
const RigidBody< T > & GetRigidBodyByName (const std::string &name) const
 Returns a constant reference to a rigid body that is identified by the string name in this model. More...
 
const RigidBody< T > & GetRigidBodyByName (const std::string &name, ModelInstanceIndex model_instance) const
 Returns a constant reference to the rigid body that is uniquely identified by the string name in model_instance. More...
 
template<template< typename > class JointType = Joint>
const JointType< T > & GetJointByName (const std::string &name, optional< ModelInstanceIndex > model_instance=nullopt) const
 Returns a constant reference to a joint that is identified by the string name in this MultibodyPlant. More...
 
template<template< typename > class JointType = Joint>
JointType< T > & GetMutableJointByName (const std::string &name, optional< ModelInstanceIndex > model_instance=nullopt)
 A version of GetJointByName that returns a mutable reference. More...
 
const JointActuator< T > & GetJointActuatorByName (const std::string &name) const
 Returns a constant reference to an actuator that is identified by the string name in this MultibodyPlant. More...
 
const JointActuator< T > & GetJointActuatorByName (const std::string &name, ModelInstanceIndex model_instance) const
 Returns a constant reference to the actuator that is uniquely identified by the string name and model_instance in this MultibodyPlant. More...
 
ModelInstanceIndex GetModelInstanceByName (const std::string &name) const
 Returns the index to the model instance that is uniquely identified by the string name in this MultibodyPlant. More...
 
Model instance accessors

Many of this class's methods expect vectors of tree state or joint actuator inputs which encompass the entire tree.

Methods in this section are convenience accessors for the portion of those vectors which apply to a single model instance only.

void SetActuationInArray (ModelInstanceIndex model_instance, const Eigen::Ref< const VectorX< T >> &u_instance, EigenPtr< VectorX< T >> u) const
 Given the actuation values u_instance for all actuators in model_instance, this method sets the actuation vector u for the entire model to which this actuator belongs to. More...
 
VectorX< T > GetPositionsFromArray (ModelInstanceIndex model_instance, const Eigen::Ref< const VectorX< T >> &q) const
 Returns a vector of generalized positions for model_instance from a vector q_array of generalized positions for the entire model model. More...
 
void SetPositionsInArray (ModelInstanceIndex model_instance, const Eigen::Ref< const VectorX< T >> &q_instance, EigenPtr< VectorX< T >> q) const
 Sets the vector of generalized positions for model_instance in q using q_instance, leaving all other elements in the array untouched. More...
 
VectorX< T > GetVelocitiesFromArray (ModelInstanceIndex model_instance, const Eigen::Ref< const VectorX< T >> &v) const
 Returns a vector of generalized velocities for model_instance from a vector v of generalized velocities for the entire MultibodyPlant model. More...
 
void SetVelocitiesInArray (ModelInstanceIndex model_instance, const Eigen::Ref< const VectorX< T >> &v_instance, EigenPtr< VectorX< T >> v) const
 Sets the vector of generalized velocities for model_instance in v using v_instance, leaving all other elements in the array untouched. More...
 
Accessing the state
void SetFreeBodyPoseInWorldFrame (systems::Context< T > *context, const Body< T > &body, const math::RigidTransform< T > &X_WB) const
 Sets context to store the pose X_WB of a given body B in the world frame W. More...
 
void SetFreeBodyPoseInAnchoredFrame (systems::Context< T > *context, const Frame< T > &frame_F, const Body< T > &body, const math::RigidTransform< T > &X_FB) const
 Updates context to store the pose X_FB of a given body B in a frame F. More...
 
math::RigidTransform< T > CalcRelativeTransform (const systems::Context< T > &context, const Frame< T > &frame_F, const Frame< T > &frame_G) const
 Calculates the rigid transform (pose) X_FG relating frame F and frame G. More...
 
math::RotationMatrix< T > CalcRelativeRotationMatrix (const systems::Context< T > &context, const Frame< T > &frame_F, const Frame< T > &frame_G) const
 Calculates the rotation matrix R_FG relating frame F and frame G. More...
 
void CalcPointsPositions (const systems::Context< T > &context, const Frame< T > &frame_B, const Eigen::Ref< const MatrixX< T >> &p_BQi, const Frame< T > &frame_A, EigenPtr< MatrixX< T >> p_AQi) const
 Given the positions p_BQi for a set of points Qi measured and expressed in a frame B, this method computes the positions p_AQi(q) of each point Qi in the set as measured and expressed in another frame A, as a function of the generalized positions q of the model. More...
 
Vector3< T > CalcCenterOfMassPosition (const systems::Context< T > &context) const
 This method computes the center of mass position p_WCcm of all bodies in MultibodyPlant measured and expressed in world frame W. More...
 
Vector3< T > CalcCenterOfMassPosition (const systems::Context< T > &context, const std::vector< ModelInstanceIndex > &model_instances) const
 This method computes the center of mass position p_WCcm of specified model instances measured and expressed in world frame W. More...
 
const math::RigidTransform< T > & EvalBodyPoseInWorld (const systems::Context< T > &context, const Body< T > &body_B) const
 Evaluate the pose X_WB of a body B in the world frame W. More...
 
const SpatialVelocity< T > & EvalBodySpatialVelocityInWorld (const systems::Context< T > &context, const Body< T > &body_B) const
 Evaluate the spatial velocity V_WB of a body B in the world frame W. More...
 
VectorX< T > CalcBiasForJacobianTranslationalVelocity (const systems::Context< T > &context, JacobianWrtVariable with_respect_to, const Frame< T > &frame_F, const Eigen::Ref< const MatrixX< T >> &p_FP_list, const Frame< T > &frame_A, const Frame< T > &frame_E) const
 For a point Fp that is fixed to a frame F, calculates Fp's translational acceleration "bias" term abias_AFp = J̇s_v_AFp(q, s) * s in frame A with respect to "speeds" 𝑠. More...
 
void CalcFrameGeometricJacobianExpressedInWorld (const systems::Context< T > &context, const Frame< T > &frame_F, const Eigen::Ref< const Vector3< T >> &p_FP, EigenPtr< MatrixX< T >> J_WFp) const
 For a point Fp fixed/welded to a frame F, calculates Jv_V_WFp, Fp's spatial velocity Jacobian with respect to generalized velocities v. More...
 
Vector6< T > CalcBiasForJacobianSpatialVelocity (const systems::Context< T > &context, JacobianWrtVariable with_respect_to, const Frame< T > &frame_F, const Eigen::Ref< const Vector3< T >> &p_FoFp_F, const Frame< T > &frame_A, const Frame< T > &frame_E) const
 For a point Fp that is fixed to a frame F, calculates Fp's spatial acceleration "bias" term Abias_AFp = J̇s_V_AFp * s in frame A with respect to "speeds" 𝑠. More...
 
void CalcJacobianSpatialVelocity (const systems::Context< T > &context, JacobianWrtVariable with_respect_to, const Frame< T > &frame_B, const Eigen::Ref< const Vector3< T >> &p_BoBi_B, const Frame< T > &frame_A, const Frame< T > &frame_E, EigenPtr< MatrixX< T >> Jw_ABp_E) const
 For each point Bi of (fixed to) a frame B, calculates J𝑠_V_ABi, Bi's spatial velocity Jacobian in frame A with respect to "speeds" 𝑠. More...
 
void CalcJacobianAngularVelocity (const systems::Context< T > &context, const JacobianWrtVariable with_respect_to, const Frame< T > &frame_B, const Frame< T > &frame_A, const Frame< T > &frame_E, EigenPtr< Matrix3X< T >> Js_w_AB_E) const
 Calculates J𝑠_w_AB, a frame B's angular velocity Jacobian in a frame A with respect to "speeds" 𝑠. More...
 
void CalcJacobianTranslationalVelocity (const systems::Context< T > &context, JacobianWrtVariable with_respect_to, const Frame< T > &frame_B, const Eigen::Ref< const Matrix3X< T >> &p_BoBi_B, const Frame< T > &frame_A, const Frame< T > &frame_E, EigenPtr< MatrixX< T >> Js_v_ABi_E) const
 For each point Bi of (fixed to) a frame B, calculates J𝑠_v_ABi, Bi's translational velocity Jacobian in frame A with respect to "speeds" 𝑠. More...
 
void CalcSpatialAccelerationsFromVdot (const systems::Context< T > &context, const VectorX< T > &known_vdot, std::vector< SpatialAcceleration< T >> *A_WB_array) const
 Given the state of this model in context and a known vector of generalized accelerations known_vdot, this method computes the spatial acceleration A_WB for each body as measured and expressed in the world frame W. More...
 
VectorX< T > CalcInverseDynamics (const systems::Context< T > &context, const VectorX< T > &known_vdot, const MultibodyForces< T > &external_forces) const
 Given the state of this model in context and a known vector of generalized accelerations vdot, this method computes the set of generalized forces tau that would need to be applied in order to attain the specified generalized accelerations. More...
 
void CalcForceElementsContribution (const systems::Context< T > &context, MultibodyForces< T > *forces) const
 Computes the combined force contribution of ForceElement objects in the model. More...
 
CalcPotentialEnergy (const systems::Context< T > &context) const
 Computes and returns the total potential energy stored in this multibody model for the configuration given by context. More...
 
CalcConservativePower (const systems::Context< T > &context) const
 Computes and returns the power generated by conservative forces in the multibody model. More...
 
void CalcBiasTerm (const systems::Context< T > &context, EigenPtr< VectorX< T >> Cv) const
 Computes the bias term C(q, v)v containing Coriolis, centripetal, and gyroscopic effects in the multibody equations of motion: More...
 
VectorX< T > CalcGravityGeneralizedForces (const systems::Context< T > &context) const
 Computes the generalized forces tau_g(q) due to gravity as a function of the generalized positions q stored in the input context. More...
 
void MapVelocityToQDot (const systems::Context< T > &context, const Eigen::Ref< const VectorX< T >> &v, EigenPtr< VectorX< T >> qdot) const
 Transforms generalized velocities v to time derivatives qdot of the generalized positions vector q (stored in context). More...
 
void MapQDotToVelocity (const systems::Context< T > &context, const Eigen::Ref< const VectorX< T >> &qdot, EigenPtr< VectorX< T >> v) const
 Transforms the time derivative qdot of the generalized positions vector q (stored in context) to generalized velocities v. More...
 
MatrixX< doubleMakeStateSelectorMatrix (const std::vector< JointIndex > &user_to_joint_index_map) const
 This method allows users to map the state of this model, x, into a vector of selected state xₛ with a given preferred ordering. More...
 
MatrixX< doubleMakeActuatorSelectorMatrix (const std::vector< JointActuatorIndex > &user_to_actuator_index_map) const
 This method allows user to map a vector uₛ containing the actuation for a set of selected actuators into the vector u containing the actuation values for this full model. More...
 
MatrixX< doubleMakeActuatorSelectorMatrix (const std::vector< JointIndex > &user_to_joint_index_map) const
 Alternative signature to build an actuation selector matrix Su such that u = Su⋅uₛ, where u is the vector of actuation values for the full model (ordered by JointActuatorIndex) and uₛ is a vector of actuation values for the actuators acting on the joints listed by user_to_joint_index_map. More...
 
VectorX< doubleGetPositionLowerLimits () const
 Returns a vector of size num_positions() containing the lower position limits for every generalized position coordinate. More...
 
VectorX< doubleGetPositionUpperLimits () const
 Upper limit analog of GetPositionsLowerLimits(), where any unbounded or unspecified limits will be +infinity. More...
 
VectorX< doubleGetVelocityLowerLimits () const
 Returns a vector of size num_velocities() containing the lower velocity limits for every generalized velocity coordinate. More...
 
VectorX< doubleGetVelocityUpperLimits () const
 Upper limit analog of GetVelocitysLowerLimits(), where any unbounded or unspecified limits will be +infinity. More...
 
VectorX< doubleGetAccelerationLowerLimits () const
 Returns a vector of size num_velocities() containing the lower acceleration limits for every generalized velocity coordinate. More...
 
VectorX< doubleGetAccelerationUpperLimits () const
 Upper limit analog of GetAccelerationsLowerLimits(), where any unbounded or unspecified limits will be +infinity. More...
 
void CalcMassMatrixViaInverseDynamics (const systems::Context< T > &context, EigenPtr< MatrixX< T >> H) const
 Performs the computation of the mass matrix M(q) of the model using inverse dynamics, where the generalized positions q are stored in context. More...
 
Managing geometries for bodies

The following methods provide a convenient means for associating geometries with bodies.

Ultimately, the geometries are owned by SceneGraph. These methods do the work of registering the requested geometries with SceneGraph and maintaining a mapping between the body and the registered data. Particularly, SceneGraph knows nothing about the concepts inherent in the MultibodyPlant. These methods account for those differences as documented below.

Geometry registration with roles

Geometries can be associated with bodies via the RegisterXXXGeometry family of methods. In SceneGraph, geometries have roles. The RegisterCollisionGeometry() methods register geometry with SceneGraph and assign it the proximity role. The RegisterVisualGeometry() methods do the same, but assign the illustration role.

All geometry registration methods return a geometry::GeometryId GeometryId. This is how SceneGraph refers to the geometries. The properties of an individual geometry can be accessed with its id and geometry::SceneGraphInspector and geometry::QueryObject (for its state-dependent pose in world).

Body frames and SceneGraph frames

The first time a geometry registration method is called on a particular body, that body's frame B is registered with SceneGraph. As SceneGraph knows nothing about bodies, in the SceneGraph domain, the frame is simply notated as F; this is merely an alias for the body frame. Thus, the pose of the geometry G in the SceneGraph frame F is the same as the pose of the geometry in the body frame B; X_FG = X_BG.

The model instance index of the body is passed to the SceneGraph frame as its "frame group". This can be retrieved from the geometry::SceneGraphInspector::GetFrameGroup(FrameId) method.

Given a GeometryId, SceneGraph cannot report what body it is affixed to. It can only report the SceneGraph alias frame F. But the following idiom can report the body:

const MultibodyPlant<T>& plant = ...;
const SceneGraphInspector<T>& inspector = ...;
const GeometryId g_id = id_from_some_query;
const FrameId f_id = inspector.GetFrameId(g_id);
const Body<T>* body = plant.GetBodyFromFrameId(f_id);

See documentation of geometry::SceneGraphInspector on where to get an inspector.

In MultibodyPlant, frame names only have to be unique in a single model instance. However, SceneGraph knows nothing of model instances. So, to generate unique names for the corresponding frames in SceneGraph, when MultibodyPlant registers the corresponding SceneGraph frame, it is named with a "scoped name". This is a concatenation of [model instance name]::[body name]. Searching for a frame with just the name body name will fail. (See Body::name() and GetModelInstanceName() for those values.)

geometry::GeometryId RegisterVisualGeometry (const Body< T > &body, const math::RigidTransform< double > &X_BG, const geometry::Shape &shape, const std::string &name, const geometry::IllustrationProperties &properties)
 Registers geometry in a SceneGraph with a given geometry::Shape to be used for visualization of a given body. More...
 
geometry::GeometryId RegisterVisualGeometry (const Body< T > &body, const math::RigidTransform< double > &X_BG, const geometry::Shape &shape, const std::string &name, const Vector4< double > &diffuse_color)
 Overload for visual geometry registration; it converts the diffuse_color (RGBA with values in the range [0, 1]) into a geometry::ConnectDrakeVisualizer()-compatible set of geometry::IllustrationProperties. More...
 
geometry::GeometryId RegisterVisualGeometry (const Body< T > &body, const math::RigidTransform< double > &X_BG, const geometry::Shape &shape, const std::string &name)
 Overload for visual geometry registration; it relies on the downstream geometry::IllustrationProperties consumer to provide default parameter values (see Geometry Roles for details). More...
 
const std::vector< geometry::GeometryId > & GetVisualGeometriesForBody (const Body< T > &body) const
 Returns an array of GeometryId's identifying the different visual geometries for body previously registered with a SceneGraph. More...
 
int num_visual_geometries () const
 Returns the number of geometries registered for visualization. More...
 
geometry::GeometryId RegisterCollisionGeometry (const Body< T > &body, const math::RigidTransform< double > &X_BG, const geometry::Shape &shape, const std::string &name, const CoulombFriction< double > &coulomb_friction)
 Registers geometry in a SceneGraph with a given geometry::Shape to be used for the contact modeling of a given body. More...
 
const std::vector< geometry::GeometryId > & GetCollisionGeometriesForBody (const Body< T > &body) const
 Returns an array of GeometryId's identifying the different contact geometries for body previously registered with a SceneGraph. More...
 
int num_collision_geometries () const
 Returns the number of geometries registered for contact modeling. More...
 
geometry::GeometrySet CollectRegisteredGeometries (const std::vector< const Body< T > * > &bodies) const
 For each of the provided bodies, collects up all geometries that have been registered to that body. More...
 
Hydroelastic model material properties

To understand how material properties enter into the modeling of contact traction in the hydroelastic model, the user is referred to [R. Elandt 2019] for details. For brevity, here we limit ourselves to state the relationship between the material properties and the computation of the normal traction or "pressure" p(x) at each point x in the contact patch. Given two bodies A and B, with elastic moduli Eᵃ and Eᵇ respectively and dissipation dᵃ and dᵇ respectively, we define the effective material properties of the pair according to:

  E = Eᵃ⋅Eᵇ/(Eᵃ + Eᵇ),
  d = E/Eᵃ⋅dᵃ + E/Eᵇ⋅dᵇ = Eᵇ/(Eᵃ+Eᵇ)⋅dᵃ + Eᵃ/(Eᵃ+Eᵇ)⋅dᵇ

The effective modulus of elasticity is computed in accordance with the Hertz theory of contact. Dissipation is weighted in accordance with the fact that the softer material will deform more and faster and thus the softer material dissipation is given more importance. The elastic modulus and dissipation can be specified with set_elastic_modulus() and set_hunt_crossley_dissipation() respectively. Elastic modulus has units of pressure, i.e. Pa (N/m²). We use a dissipation model inspired by the model in [Hunt and Crossley, 1975], parameterized by a dissipation constant with units of inverse of velocity, i.e. s/m. With the effective properties of the pair defined as above, the hydroelastic model pressure field is computed according to:

  p(x) = E⋅ε(x)⋅(1 - d⋅vₙ(x))₊

where we defined the effective strain:

  ε(x) = εᵃ(x) + εᵇ(x)

which relates to the quasi-static pressure field p₀(x) (i.e. when velocity is neglected) by:

  p₀(x) = E⋅ε(x) = Eᵃ⋅εᵃ(x) = Eᵇ⋅εᵇ(x)

that is, the hydroelastic model computes the contact patch assuming quasi-static equilibrium. The separation speed vₙ(x) is computed as the component in the direction of the contact surface's normal n̂(x) of the relative velocity between points Ax and Bx at point x instantaneously moving with body frames A and B respectively, i.e. vₙ(x) = ᴬˣvᴮˣ⋅n̂(x), where the normal n̂(x) points from body A into body B.

[Elandt 2019] R. Elandt, E. Drumwright, M. Sherman, and A. Ruina. A pressure field model for fast, robust approximation of net contact force and moment between nominally rigid objects. Proc. IEEE/RSJ Intl. Conf. on Intelligent Robots and Systems (IROS), 2019. [Hunt and Crossley 1975] Hunt, KH and Crossley, FRE, 1975. Coefficient of restitution interpreted as damping in vibroimpact. Journal of Applied Mechanics, vol. 42, pp. 440–445.

void set_elastic_modulus (geometry::GeometryId id, double elastic_modulus)
 Specifies the elastic_modulus E for a geometry identified by its id. More...
 
void set_hunt_crossley_dissipation (geometry::GeometryId id, double dissipation)
 Specifies the Hunt & Crossley dissipation coefficient for the hydroelastic model. More...
 
Retrieving ports for communication with a SceneGraph.
optional< geometry::SourceIdget_source_id () const
 Returns the unique id identifying this plant as a source for a SceneGraph. More...
 
const systems::InputPort< T > & get_geometry_query_input_port () const
 Returns a constant reference to the input port used to perform geometric queries on a SceneGraph. More...
 
const systems::OutputPort< T > & get_geometry_poses_output_port () const
 Returns the output port of frames' poses to communicate with a SceneGraph. More...
 
Actuation input

The input vector of actuation values can be provided either as a single input port which describes the entire plant (in the case where only a single model instance has actuated dofs), or through multiple input ports which each provide the actuation values for a specific model instance.

See AddJointActuator() and num_actuators().

const systems::InputPort< T > & get_actuation_input_port () const
 Returns a constant reference to the input port for external actuation for the case where only one model instance has actuated dofs. More...
 
const systems::InputPort< T > & get_actuation_input_port (ModelInstanceIndex model_instance) const
 Returns a constant reference to the input port for external actuation for a specific model instance. More...
 
const systems::InputPort< T > & get_applied_generalized_force_input_port () const
 Returns a constant reference to the vector-valued input port for applied generalized forces, and the vector will be added directly into tau (see System dynamics). More...
 
const systems::InputPort< T > & get_applied_spatial_force_input_port () const
 Returns a constant reference to the input port for applying spatial forces to bodies in the plant. More...
 
Continuous state output

Output ports are provided to access the continuous state of the whole plant and for individual model instances.

const systems::OutputPort< T > & get_state_output_port () const
 Returns a constant reference to the output port for the full state x = [q v] of the model. More...
 
const systems::OutputPort< T > & get_state_output_port (ModelInstanceIndex model_instance) const
 Returns a constant reference to the output port for the state of a specific model instance. More...
 
Contact by penalty method

Currently MultibodyPlant uses a rigid contact model that is, bodies in the model are infinitely stiff or ideal rigid bodies. Therefore, the mathematical description of the rigid contact model needs to include non-penetration constraints among bodies in the formulation. There are several numerical methods to impose and solve these constraints. In a penalty method approach, we allow for a certain amount of interpenetration and we compute contact forces according to a simple law of the form:

  fₙ = k(1+dẋ)x

where the normal contact force fₙ is made a continuous function of the penetration distance x between the bodies (defined to be positive when the bodies are in contact) and the penetration distance rate ẋ (with ẋ > 0 meaning the penetration distance is increasing and therefore the interpenetration between the bodies is also increasing). k and d are the penalty method coefficients for stiffness and damping. These are ad-hoc parameters which need to be tuned as a trade-off between:

  • The accuracy of the numerical approximation to rigid contact, which requires a stiffness that approaches infinity, and
  • the computational cost of the numerical integration, which will require smaller time steps for stiffer systems.

There is no exact procedure for choosing these coefficients, and estimating them manually can be cumbersome since in general they will depend on the scale of the problem including masses, speeds and even body sizes. However, MultibodyPlant aids the estimation of these coefficients using a heuristic function based on a user-supplied "penetration allowance", see set_penetration_allowance(). The penetration allowance is a number in meters that specifies the order of magnitude of the average penetration between bodies in the system that the user is willing to accept as reasonable for the problem being solved. For instance, in the robotics manipulation of ordinary daily objects the user might set this number to 1 millimeter. However, the user might want to increase it for the simulation of heavy walking robots for which an allowance of 1 millimeter would result in a very stiff system.

As for the damping coefficient in the simple law above, MultibodyPlant chooses the damping coefficient d to model inelastic collisions and therefore sets it so that the penetration distance x behaves as a critically damped oscillator. That is, at the limit of ideal rigid contact (very stiff penalty coefficient k or equivalently the penetration allowance goes to zero), this method behaves as a unilateral constraint on the penetration distance, which models a perfect inelastic collision. For most applications, such as manipulation and walking, this is the desired behavior.

When set_penetration_allowance() is called, MultibodyPlant will estimate reasonable penalty method coefficients as a function of the input penetration allowance. Users will want to run their simulation a number of times and asses they are satisfied with the level of inter-penetration actually observed in the simulation; if the observed penetration is too large, the user will want to set a smaller penetration allowance. If the system is too stiff and the time integration requires very small time steps while at the same time the user can afford larger inter-penetrations, the user will want to increase the penetration allowance. Typically, the observed penetration will be proportional to the penetration allowance. Thus scaling the penetration allowance by say a factor of 0.5, would typically results in inter-penetrations being reduced by the same factor of 0.5. In summary, users should choose the largest penetration allowance that results in inter-penetration levels that are acceptable for the particular application (even when in theory this penetration should be zero for perfectly rigid bodies.)

For a given penetration allowance, the contact interaction that takes two bodies with a non-zero approaching velocity to zero approaching velocity, takes place in a finite amount of time (for ideal rigid contact this time is zero.) A good estimate of this time period is given by a call to get_contact_penalty_method_time_scale(). Users might want to query this value to either set the maximum time step in error-controlled time integration or to set the time step for fixed time step integration. As a guidance, typical fixed time step integrators will become unstable for time steps larger than about a tenth of this time scale.

For further details on contact modeling in Drake, please refer to the section Contact Modeling in Drake of our documentation.

void set_penetration_allowance (double penetration_allowance=0.001)
 Sets the penetration allowance used to estimate the coefficients in the penalty method used to impose non-penetration among bodies. More...
 
double get_contact_penalty_method_time_scale () const
 Returns a time-scale estimate tc based on the requested penetration allowance δ set with set_penetration_allowance(). More...
 
Stribeck model of friction

Currently MultibodyPlant uses the Stribeck approximation to model dry friction. The Stribeck model of friction is an approximation to Coulomb's law of friction that allows using continuous time integration without the need to specify complementarity constraints. While this results in a simpler model immediately tractable with standard numerical methods for integration of ODE's, it often leads to stiff dynamics that require an explicit integrator to take very small time steps. It is therefore recommended to use error controlled integrators when using this model or the discrete time stepping (see Choice of Time Advancement Strategy). See Continuous Approximation of Coulomb for a detailed discussion of the Stribeck model.

void set_stiction_tolerance (double v_stiction=0.001)
 Sets the stiction tolerance v_stiction for the Stribeck model, where v_stiction must be specified in m/s (meters per second.) v_stiction defaults to a value of 1 millimeter per second. More...
 
- Public Member Functions inherited from MultibodyTreeSystem< T >
 MultibodyTreeSystem (std::unique_ptr< MultibodyTree< T >> tree, bool is_discrete=false)
 Takes ownership of the given tree, finalizes it if it hasn't already been finalized, and then allocates the resources it needs. More...
 
template<typename U >
 MultibodyTreeSystem (const MultibodyTreeSystem< U > &other)
 Scalar-converting copy constructor. More...
 
 ~MultibodyTreeSystem () override
 
bool is_discrete () const
 
const PositionKinematicsCache< T > & EvalPositionKinematics (const systems::Context< T > &context) const
 Returns a reference to the up to date PositionKinematicsCache in the given Context, recalculating it first if necessary. More...
 
const VelocityKinematicsCache< T > & EvalVelocityKinematics (const systems::Context< T > &context) const
 Returns a reference to the up to date VelocityKinematicsCache in the given Context, recalculating it first if necessary. More...
 
const std::vector< SpatialInertia< T > > & EvalSpatialInertiaInWorldCache (const systems::Context< T > &context) const
 Returns a reference to the up to date cache of per-body spatial inertias in the given Context, recalculating it first if necessary. More...
 
const std::vector< SpatialForce< T > > & EvalDynamicBiasCache (const systems::Context< T > &context) const
 Returns a reference to the up to date cache of per-body bias terms in the given Context, recalculating it first if necessary. More...
 
const std::vector< Vector6< T > > & EvalAcrossNodeJacobianWrtVExpressedInWorld (const systems::Context< T > &context) const
 For a body B connected to its parent P, returns a reference to the up to date cached value for H_PB_W, where H_PB_W is the 6 x nm body-node hinge matrix that relates V_PB_W (body B's spatial velocity in its parent body P, expressed in world W) to this node's nm generalized velocities (or mobilities) v_B as V_PB_W = H_PB_W * v_B. More...
 
 MultibodyTreeSystem (const MultibodyTreeSystem &)=delete
 
MultibodyTreeSystemoperator= (const MultibodyTreeSystem &)=delete
 
 MultibodyTreeSystem (MultibodyTreeSystem &&)=delete
 
MultibodyTreeSystemoperator= (MultibodyTreeSystem &&)=delete
 
- Public Member Functions inherited from LeafSystem< T >
 ~LeafSystem () override
 
std::unique_ptr< CompositeEventCollection< T > > AllocateCompositeEventCollection () const final
 Allocates a CompositeEventCollection object for this system. More...
 
std::unique_ptr< LeafContext< T > > AllocateContext () const
 Shadows System<T>::AllocateContext to provide a more concrete return type LeafContext<T>. More...
 
std::unique_ptr< ContextBaseDoAllocateContext () const final
 Derived class implementations should allocate a suitable concrete Context type, then invoke the above InitializeContextBase() method. More...
 
void SetDefaultState (const Context< T > &context, State< T > *state) const override
 Default implementation: sets all continuous state to the model vector given in DeclareContinuousState (or zero if no model vector was given) and discrete states to zero. More...
 
void SetDefaultParameters (const Context< T > &context, Parameters< T > *parameters) const override
 Default implementation: sets all numeric parameters to the model vector given to DeclareNumericParameter, or else if no model was provided sets the numeric parameter to one. More...
 
std::unique_ptr< ContinuousState< T > > AllocateTimeDerivatives () const override
 Returns the AllocateContinuousState value, which must not be nullptr. More...
 
std::unique_ptr< DiscreteValues< T > > AllocateDiscreteVariables () const override
 Returns the AllocateDiscreteState value, which must not be nullptr. More...
 
std::multimap< int, intGetDirectFeedthroughs () const final
 Reports all direct feedthroughs from input ports to output ports. More...
 
 LeafSystem (const LeafSystem &)=delete
 
LeafSystemoperator= (const LeafSystem &)=delete
 
 LeafSystem (LeafSystem &&)=delete
 
LeafSystemoperator= (LeafSystem &&)=delete
 
- Public Member Functions inherited from System< T >
 ~System () override
 
void GetWitnessFunctions (const Context< T > &context, std::vector< const WitnessFunction< T > * > *w) const
 Gets the witness functions active for the given state. More...
 
CalcWitnessValue (const Context< T > &context, const WitnessFunction< T > &witness_func) const
 Evaluates a witness function at the given context. More...
 
const CacheEntryDeclareCacheEntry (std::string description, CacheEntry::AllocCallback alloc_function, CacheEntry::CalcCallback calc_function, std::set< DependencyTicket > prerequisites_of_calc={ all_sources_ticket()})
 Declares a new CacheEntry in this System using the least-restrictive definitions for the associated functions. More...
 
template<class MySystem , class MyContext , typename ValueType >
const CacheEntryDeclareCacheEntry (std::string description, ValueType(MySystem::*make)() const, void(MySystem::*calc)(const MyContext &, ValueType *) const, std::set< DependencyTicket > prerequisites_of_calc={ all_sources_ticket()})
 Declares a cache entry by specifying member functions to use both for the allocator and calculator. More...
 
template<class MySystem , class MyContext , typename ValueType >
const CacheEntryDeclareCacheEntry (std::string description, const ValueType &model_value, void(MySystem::*calc)(const MyContext &, ValueType *) const, std::set< DependencyTicket > prerequisites_of_calc={ all_sources_ticket()})
 Declares a cache entry by specifying a model value of concrete type ValueType and a calculator function that is a class member function (method) with signature: More...
 
template<class MySystem , class MyContext , typename ValueType >
const CacheEntryDeclareCacheEntry (std::string description, const ValueType &model_value, ValueType(MySystem::*calc)(const MyContext &) const, std::set< DependencyTicket > prerequisites_of_calc={ all_sources_ticket()})
 Declares a cache entry by specifying a model value of concrete type ValueType and a calculator function that is a class member function (method) with signature: More...
 
template<class MySystem , class MyContext , typename ValueType >
const CacheEntryDeclareCacheEntry (std::string description, void(MySystem::*calc)(const MyContext &, ValueType *) const, std::set< DependencyTicket > prerequisites_of_calc={ all_sources_ticket()})
 Declares a cache entry by specifying only a calculator function that is a class member function (method) with signature: More...
 
template<class MySystem , class MyContext , typename ValueType >
const CacheEntryDeclareCacheEntry (std::string description, ValueType(MySystem::*calc)(const MyContext &) const, std::set< DependencyTicket > prerequisites_of_calc={ all_sources_ticket()})
 Declares a cache entry by specifying only a calculator function that is a class member function (method) with signature: More...
 
DependencyTicket discrete_state_ticket (DiscreteStateIndex index) const
 Returns a ticket indicating dependence on a particular discrete state variable xdᵢ (may be a vector). More...
 
DependencyTicket abstract_state_ticket (AbstractStateIndex index) const
 Returns a ticket indicating dependence on a particular abstract state variable xaᵢ. More...
 
DependencyTicket numeric_parameter_ticket (NumericParameterIndex index) const
 Returns a ticket indicating dependence on a particular numeric parameter pnᵢ (may be a vector). More...
 
DependencyTicket abstract_parameter_ticket (AbstractParameterIndex index) const
 Returns a ticket indicating dependence on a particular abstract parameter paᵢ. More...
 
DependencyTicket input_port_ticket (InputPortIndex index) const
 Returns a ticket indicating dependence on input port uᵢ indicated by index. More...
 
DependencyTicket cache_entry_ticket (CacheIndex index) const
 Returns a ticket indicating dependence on the cache entry indicated by index. More...
 
 System (const System &)=delete
 
Systemoperator= (const System &)=delete
 
 System (System &&)=delete
 
Systemoperator= (System &&)=delete
 
std::unique_ptr< Context< T > > AllocateContext () const
 Returns a Context<T> suitable for use with this System<T>. More...
 
std::unique_ptr< BasicVector< T > > AllocateInputVector (const InputPort< T > &input_port) const
 Given an input port, allocates the vector storage. More...
 
std::unique_ptr< AbstractValueAllocateInputAbstract (const InputPort< T > &input_port) const
 Given an input port, allocates the abstract storage. More...
 
std::unique_ptr< SystemOutput< T > > AllocateOutput () const
 Returns a container that can hold the values of all of this System's output ports. More...
 
std::unique_ptr< Context< T > > CreateDefaultContext () const
 This convenience method allocates a context using AllocateContext() and sets its default values using SetDefaultContext(). More...
 
void SetDefaultContext (Context< T > *context) const
 
virtual void SetRandomState (const Context< T > &context, State< T > *state, RandomGenerator *generator) const
 Assigns random values to all elements of the state. More...
 
virtual void SetRandomParameters (const Context< T > &context, Parameters< T > *parameters, RandomGenerator *generator) const
 Assigns random values to all parameters. More...
 
void SetRandomContext (Context< T > *context, RandomGenerator *generator) const
 
void AllocateFixedInputs (Context< T > *context) const
 For each input port, allocates a fixed input of the concrete type that this System requires, and binds it to the port, disconnecting any prior input. More...
 
bool HasAnyDirectFeedthrough () const
 Returns true if any of the inputs to the system might be directly fed through to any of its outputs and false otherwise. More...
 
bool HasDirectFeedthrough (int output_port) const
 Returns true if there might be direct-feedthrough from any input port to the given output_port, and false otherwise. More...
 
bool HasDirectFeedthrough (int input_port, int output_port) const
 Returns true if there might be direct-feedthrough from the given input_port to the given output_port, and false otherwise. More...
 
virtual std::multimap< int, intGetDirectFeedthroughs () const=0
 Reports all direct feedthroughs from input ports to output ports. More...
 
void Publish (const Context< T > &context, const EventCollection< PublishEvent< T >> &events) const
 This method is the public entry point for dispatching all publish event handlers. More...
 
void Publish (const Context< T > &context) const
 Forces a publish on the system, given a context. More...
 
const ContinuousState< T > & EvalTimeDerivatives (const Context< T > &context) const
 Returns a reference to the cached value of the continuous state variable time derivatives, evaluating first if necessary using CalcTimeDerivatives(). More...
 
const CacheEntryget_time_derivatives_cache_entry () const
 (Advanced) Returns the CacheEntry used to cache time derivatives for EvalTimeDerivatives(). More...
 
const T & EvalPotentialEnergy (const Context< T > &context) const
 Returns a reference to the cached value of the potential energy (PE), evaluating first if necessary using CalcPotentialEnergy(). More...
 
const T & EvalKineticEnergy (const Context< T > &context) const
 Returns a reference to the cached value of the kinetic energy (KE), evaluating first if necessary using CalcKineticEnergy(). More...
 
const T & EvalConservativePower (const Context< T > &context) const
 Returns a reference to the cached value of the conservative power (Pc), evaluating first if necessary using CalcConservativePower(). More...
 
const T & EvalNonConservativePower (const Context< T > &context) const
 Returns a reference to the cached value of the non-conservative power (Pnc), evaluating first if necessary using CalcNonConservativePower(). More...
 
template<template< typename > class Vec = BasicVector>
const Vec< T > * EvalVectorInput (const Context< T > &context, int port_index) const
 Returns the value of the vector-valued input port with the given port_index as a BasicVector or a specific subclass Vec derived from BasicVector. More...
 
Eigen::VectorBlock< const VectorX< T > > EvalEigenVectorInput (const Context< T > &context, int port_index) const
 Returns the value of the vector-valued input port with the given port_index as an Eigen vector. More...
 
int num_constraint_equations (const Context< T > &context) const
 Gets the number of constraint equations for this system using the given context (useful in case the number of constraints is dependent upon the current state (as might be the case with a system modeled using piecewise differential algebraic equations). More...
 
Eigen::VectorXd EvalConstraintEquations (const Context< T > &context) const
 Evaluates the constraint equations for the system at the generalized coordinates and generalized velocity specified by the context. More...
 
Eigen::VectorXd EvalConstraintEquationsDot (const Context< T > &context) const
 Computes the time derivative of each constraint equation, evaluated at the generalized coordinates and generalized velocity specified by the context. More...
 
Eigen::VectorXd CalcVelocityChangeFromConstraintImpulses (const Context< T > &context, const Eigen::MatrixXd &J, const Eigen::VectorXd &lambda) const
 Computes the change in velocity from applying the given constraint forces to the system at the given context. More...
 
double CalcConstraintErrorNorm (const Context< T > &context, const Eigen::VectorXd &error) const
 Computes the norm on constraint error (used as a metric for comparing errors between the outputs of algebraic equations applied to two different state variable instances). More...
 
SystemConstraintIndex AddExternalConstraint (ExternalSystemConstraint constraint)
 Adds an "external" constraint to this System. More...
 
void CalcTimeDerivatives (const Context< T > &context, ContinuousState< T > *derivatives) const
 Calculates the time derivatives xcdot of the continuous state xc into a given output argument. More...
 
void CalcDiscreteVariableUpdates (const Context< T > &context, const EventCollection< DiscreteUpdateEvent< T >> &events, DiscreteValues< T > *discrete_state) const
 This method is the public entry point for dispatching all discrete variable update event handlers. More...
 
void ApplyDiscreteVariableUpdate (const EventCollection< DiscreteUpdateEvent< T >> &events, DiscreteValues< T > *discrete_state, Context< T > *context) const
 Given the discrete_state results of a previous call to CalcDiscreteVariableUpdates() that processed the given collection of events, modifies the context to reflect the updated discrete_state. More...
 
void CalcDiscreteVariableUpdates (const Context< T > &context, DiscreteValues< T > *discrete_state) const
 This method forces a discrete update on the system given a context, and the updated discrete state is stored in discrete_state. More...
 
void CalcUnrestrictedUpdate (const Context< T > &context, const EventCollection< UnrestrictedUpdateEvent< T >> &events, State< T > *state) const
 This method is the public entry point for dispatching all unrestricted update event handlers. More...
 
void ApplyUnrestrictedUpdate (const EventCollection< UnrestrictedUpdateEvent< T >> &events, State< T > *state, Context< T > *context) const
 Given the state results of a previous call to CalcUnrestrictedUpdate() that processed the given collection of events, modifies the context to reflect the updated state. More...
 
void CalcUnrestrictedUpdate (const Context< T > &context, State< T > *state) const
 This method forces an unrestricted update on the system given a context, and the updated state is stored in state. More...
 
CalcNextUpdateTime (const Context< T > &context, CompositeEventCollection< T > *events) const
 This method is called by a Simulator during its calculation of the size of the next continuous step to attempt. More...
 
void GetPerStepEvents (const Context< T > &context, CompositeEventCollection< T > *events) const
 This method is called by Simulator::Initialize() to gather all update and publish events that are to be handled in AdvanceTo() at the point before Simulator integrates continuous state. More...
 
void GetInitializationEvents (const Context< T > &context, CompositeEventCollection< T > *events) const
 This method is called by Simulator::Initialize() to gather all update and publish events that need to be handled at initialization before the simulator starts integration. More...
 
optional< PeriodicEventDataGetUniquePeriodicDiscreteUpdateAttribute () const
 Gets whether there exists a unique periodic attribute that triggers one or more discrete update events (and, if so, returns that unique periodic attribute). More...
 
std::map< PeriodicEventData, std::vector< const Event< T > * >, PeriodicEventDataComparatorGetPeriodicEvents () const
 Gets all periodic triggered events for a system. More...
 
void CalcOutput (const Context< T > &context, SystemOutput< T > *outputs) const
 Utility method that computes for every output port i the value y(i) that should result from the current contents of the given Context. More...
 
CalcPotentialEnergy (const Context< T > &context) const
 Calculates and returns the potential energy represented by the current configuration provided in context. More...
 
CalcKineticEnergy (const Context< T > &context) const
 Calculates and returns the kinetic energy represented by the current configuration and velocity provided in context. More...
 
CalcConservativePower (const Context< T > &context) const
 Calculates and returns the conservative power represented by the current contents of the given context. More...
 
CalcNonConservativePower (const Context< T > &context) const
 Calculates and returns the non-conservative power represented by the current contents of the given context. More...
 
void MapVelocityToQDot (const Context< T > &context, const VectorBase< T > &generalized_velocity, VectorBase< T > *qdot) const
 Transforms a given generalized velocity v to the time derivative qdot of the generalized configuration q taken from the supplied Context. More...
 
void MapVelocityToQDot (const Context< T > &context, const Eigen::Ref< const VectorX< T >> &generalized_velocity, VectorBase< T > *qdot) const
 Transforms the given generalized velocity to the time derivative of generalized configuration. More...
 
void MapQDotToVelocity (const Context< T > &context, const VectorBase< T > &qdot, VectorBase< T > *generalized_velocity) const
 Transforms the time derivative qdot of the generalized configuration q to generalized velocities v. More...
 
void MapQDotToVelocity (const Context< T > &context, const Eigen::Ref< const VectorX< T >> &qdot, VectorBase< T > *generalized_velocity) const
 Transforms the given time derivative qdot of generalized configuration q to generalized velocity v. More...
 
std::string GetMemoryObjectName () const
 Returns a name for this System based on a stringification of its type name and memory address. More...
 
const InputPort< T > & get_input_port (int port_index) const
 Returns the typed input port at index port_index. More...
 
const InputPort< T > * get_input_port_selection (variant< InputPortSelection, InputPortIndex > port_index) const
 Returns the typed input port specified by the InputPortSelection or by the InputPortIndex. More...
 
const InputPort< T > & GetInputPort (const std::string &port_name) const
 Returns the typed input port with the unique name port_name. More...
 
const OutputPort< T > & get_output_port (int port_index) const
 Returns the typed output port at index port_index. More...
 
const OutputPort< T > * get_output_port_selection (variant< OutputPortSelection, OutputPortIndex > port_index) const
 Returns the typed output port specified by the OutputPortSelection or by the OutputPortIndex. More...
 
const OutputPort< T > & GetOutputPort (const std::string &port_name) const
 Returns the typed output port with the unique name port_name. More...
 
int num_constraints () const
 Returns the number of constraints specified for the system. More...
 
int num_continuous_states () const
 Returns the dimension of the continuous state vector that has been declared until now. More...
 
const SystemConstraint< T > & get_constraint (SystemConstraintIndex constraint_index) const
 Returns the constraint at index constraint_index. More...
 
boolean< T > CheckSystemConstraintsSatisfied (const Context< T > &context, double tol) const
 Returns true if context satisfies all of the registered SystemConstraints with tolerance tol. More...
 
void CheckValidOutput (const SystemOutput< T > *output) const
 Checks that output is consistent with the number and size of output ports declared by the system. More...
 
template<typename T1 = T>
void CheckValidContextT (const Context< T1 > &context) const
 Checks that context is consistent for this System template. More...
 
VectorX< T > CopyContinuousStateVector (const Context< T > &context) const
 Returns a copy of the continuous state vector xc into an Eigen vector. More...
 
int num_input_ports () const
 Returns the number of input ports currently allocated in this System. More...
 
int num_output_ports () const
 Returns the number of output ports currently allocated in this System. More...
 
std::string GetGraphvizString (int max_depth=std::numeric_limits< int >::max()) const
 Returns a Graphviz string describing this System. More...
 
int64_t GetGraphvizId () const
 Returns an opaque integer that uniquely identifies this system in the Graphviz output. More...
 
void FixInputPortsFrom (const System< double > &other_system, const Context< double > &other_context, Context< T > *target_context) const
 Fixes all of the input ports in target_context to their current values in other_context, as evaluated by other_system. More...
 
const SystemScalarConverterget_system_scalar_converter () const
 (Advanced) Returns the SystemScalarConverter for this object. More...
 
std::unique_ptr< System< AutoDiffXd > > ToAutoDiffXd () const
 Creates a deep copy of this System, transmogrified to use the autodiff scalar type, with a dynamic-sized vector of partial derivatives. More...
 
std::unique_ptr< System< AutoDiffXd > > ToAutoDiffXdMaybe () const
 Creates a deep copy of this system exactly like ToAutoDiffXd(), but returns nullptr if this System does not support autodiff, instead of throwing an exception. More...
 
std::unique_ptr< System< symbolic::Expression > > ToSymbolic () const
 Creates a deep copy of this System, transmogrified to use the symbolic scalar type. More...
 
std::unique_ptr< System< symbolic::Expression > > ToSymbolicMaybe () const
 Creates a deep copy of this system exactly like ToSymbolic(), but returns nullptr if this System does not support symbolic, instead of throwing an exception. More...
 
- Public Member Functions inherited from SystemBase
 ~SystemBase () override
 
void set_name (const std::string &name)
 Sets the name of the system. More...
 
const std::string & get_name () const
 Returns the name last supplied to set_name(), if any. More...
 
const std::string & GetSystemName () const final
 Returns a human-readable name for this system, for use in messages and logging. More...
 
std::string GetSystemPathname () const final
 Generates and returns a human-readable full path name of this subsystem, for use in messages and logging. More...
 
std::string GetSystemType () const final
 Returns the most-derived type of this concrete System object as a human-readable string suitable for use in error messages. More...
 
void ThrowIfContextNotCompatible (const ContextBase &context) const final
 Throws an exception with an appropriate message if the given context is not compatible with this System. More...
 
std::unique_ptr< ContextBaseAllocateContext () const
 Returns a Context suitable for use with this System. More...
 
int num_input_ports () const
 Returns the number of input ports currently allocated in this System. More...
 
int num_output_ports () const
 Returns the number of output ports currently allocated in this System. More...
 
const InputPortBaseget_input_port_base (InputPortIndex port_index) const
 Returns a reference to an InputPort given its port_index. More...
 
const OutputPortBaseget_output_port_base (OutputPortIndex port_index) const
 Returns a reference to an OutputPort given its port_index. More...
 
int num_total_inputs () const
 Returns the total dimension of all of the vector-valued input ports (as if they were muxed). More...
 
int num_total_outputs () const
 Returns the total dimension of all of the vector-valued output ports (as if they were muxed). More...
 
int num_cache_entries () const
 Returns the number nc of cache entries currently allocated in this System. More...
 
const CacheEntryget_cache_entry (CacheIndex index) const
 Returns a reference to a CacheEntry given its index. More...
 
CacheEntryget_mutable_cache_entry (CacheIndex index)
 (Advanced) Returns a mutable reference to a CacheEntry given its index. More...
 
void CheckValidContext (const ContextBase &context) const
 Checks whether the given context is valid for this System and throws an exception with a helpful message if not. More...
 
 SystemBase (const SystemBase &)=delete
 
SystemBaseoperator= (const SystemBase &)=delete
 
 SystemBase (SystemBase &&)=delete
 
SystemBaseoperator= (SystemBase &&)=delete
 
const AbstractValueEvalAbstractInput (const ContextBase &context, int port_index) const
 Returns the value of the input port with the given port_index as an AbstractValue, which is permitted for ports of any type. More...
 
template<typename V >
const V * EvalInputValue (const ContextBase &context, int port_index) const
 Returns the value of an abstract-valued input port with the given port_index as a value of known type V. More...
 
const CacheEntryDeclareCacheEntry (std::string description, CacheEntry::AllocCallback alloc_function, CacheEntry::CalcCallback calc_function, std::set< DependencyTicket > prerequisites_of_calc={ all_sources_ticket()})
 Declares a new CacheEntry in this System using the least-restrictive definitions for the associated functions. More...
 
template<class MySystem , class MyContext , typename ValueType >
const CacheEntryDeclareCacheEntry (std::string description, ValueType(MySystem::*make)() const, void(MySystem::*calc)(const MyContext &, ValueType *) const, std::set< DependencyTicket > prerequisites_of_calc={ all_sources_ticket()})
 Declares a cache entry by specifying member functions to use both for the allocator and calculator. More...
 
template<class MySystem , class MyContext , typename ValueType >
const CacheEntryDeclareCacheEntry (std::string description, const ValueType &model_value, void(MySystem::*calc)(const MyContext &, ValueType *) const, std::set< DependencyTicket > prerequisites_of_calc={ all_sources_ticket()})
 Declares a cache entry by specifying a model value of concrete type ValueType and a calculator function that is a class member function (method) with signature: More...
 
template<class MySystem , class MyContext , typename ValueType >
const CacheEntryDeclareCacheEntry (std::string description, const ValueType &model_value, ValueType(MySystem::*calc)(const MyContext &) const, std::set< DependencyTicket > prerequisites_of_calc={ all_sources_ticket()})
 Declares a cache entry by specifying a model value of concrete type ValueType and a calculator function that is a class member function (method) with signature: More...
 
template<class MySystem , class MyContext , typename ValueType >
const CacheEntryDeclareCacheEntry (std::string description, void(MySystem::*calc)(const MyContext &, ValueType *) const, std::set< DependencyTicket > prerequisites_of_calc={ all_sources_ticket()})
 Declares a cache entry by specifying only a calculator function that is a class member function (method) with signature: More...
 
template<class MySystem , class MyContext , typename ValueType >
const CacheEntryDeclareCacheEntry (std::string description, ValueType(MySystem::*calc)(const MyContext &) const, std::set< DependencyTicket > prerequisites_of_calc={ all_sources_ticket()})
 Declares a cache entry by specifying only a calculator function that is a class member function (method) with signature: More...
 
DependencyTicket discrete_state_ticket (DiscreteStateIndex index) const
 Returns a ticket indicating dependence on a particular discrete state variable xdᵢ (may be a vector). More...
 
DependencyTicket abstract_state_ticket (AbstractStateIndex index) const
 Returns a ticket indicating dependence on a particular abstract state variable xaᵢ. More...
 
DependencyTicket numeric_parameter_ticket (NumericParameterIndex index) const
 Returns a ticket indicating dependence on a particular numeric parameter pnᵢ (may be a vector). More...
 
DependencyTicket abstract_parameter_ticket (AbstractParameterIndex index) const
 Returns a ticket indicating dependence on a particular abstract parameter paᵢ. More...
 
DependencyTicket input_port_ticket (InputPortIndex index) const
 Returns a ticket indicating dependence on input port uᵢ indicated by index. More...
 
DependencyTicket cache_entry_ticket (CacheIndex index) const
 Returns a ticket indicating dependence on the cache entry indicated by index. More...
 
DependencyTicket output_port_ticket (OutputPortIndex index) const
 (Internal use only) Returns a ticket indicating dependence on the output port indicated by index. More...
 
int num_discrete_state_groups () const
 Returns the number of declared discrete state groups (each group is a vector-valued discrete state variable). More...
 
int num_abstract_states () const
 Returns the number of declared abstract state variables. More...
 
int num_numeric_parameter_groups () const
 Returns the number of declared numeric parameters (each of these is a vector-valued parameter). More...
 
int num_abstract_parameters () const
 Returns the number of declared abstract parameters. More...
 

Friends

template<typename U >
class MultibodyPlant
 
class MultibodyPlantTester
 

Additional Inherited Members

- Static Public Member Functions inherited from System< T >
static DependencyTicket nothing_ticket ()
 Returns a ticket indicating that a computation does not depend on any source value; that is, it is a constant. More...
 
static DependencyTicket time_ticket ()
 Returns a ticket indicating dependence on time. More...
 
static DependencyTicket accuracy_ticket ()
 Returns a ticket indicating dependence on the accuracy setting in the Context. More...
 
static DependencyTicket q_ticket ()
 Returns a ticket indicating that a computation depends on configuration state variables q. More...
 
static DependencyTicket v_ticket ()
 Returns a ticket indicating dependence on velocity state variables v. More...
 
static DependencyTicket z_ticket ()
 Returns a ticket indicating dependence on any or all of the miscellaneous continuous state variables z. More...
 
static DependencyTicket xc_ticket ()
 Returns a ticket indicating dependence on all of the continuous state variables q, v, or z. More...
 
static DependencyTicket xd_ticket ()
 Returns a ticket indicating dependence on all of the numerical discrete state variables, in any discrete variable group. More...
 
static DependencyTicket xa_ticket ()
 Returns a ticket indicating dependence on all of the abstract state variables in the current Context. More...
 
static DependencyTicket all_state_ticket ()
 Returns a ticket indicating dependence on all state variables x in this system, including continuous variables xc, discrete (numeric) variables xd, and abstract state variables xa. More...
 
static DependencyTicket pn_ticket ()
 Returns a ticket indicating dependence on all of the numerical parameters in the current Context. More...
 
static DependencyTicket pa_ticket ()
 Returns a ticket indicating dependence on all of the abstract parameters pa in the current Context. More...
 
static DependencyTicket all_parameters_ticket ()
 Returns a ticket indicating dependence on all parameters p in this system, including numeric parameters pn, and abstract parameters pa. More...
 
static DependencyTicket all_input_ports_ticket ()
 Returns a ticket indicating dependence on all input ports u of this system. More...
 
static DependencyTicket all_sources_ticket ()
 Returns a ticket indicating dependence on every possible independent source value, including time, accuracy, state, input ports, and parameters (but not cache entries). More...
 
static DependencyTicket configuration_ticket ()
 Returns a ticket indicating dependence on all source values that may affect configuration-dependent computations. More...
 
static DependencyTicket kinematics_ticket ()
 Returns a ticket indicating dependence on all source values that may affect configuration- or velocity-dependent computations. More...
 
static DependencyTicket xcdot_ticket ()
 Returns a ticket for the cache entry that holds time derivatives of the continuous variables. More...
 
static DependencyTicket pe_ticket ()
 Returns a ticket for the cache entry that holds the potential energy calculation. More...
 
static DependencyTicket ke_ticket ()
 Returns a ticket for the cache entry that holds the kinetic energy calculation. More...
 
static DependencyTicket pc_ticket ()
 Returns a ticket for the cache entry that holds the conservative power calculation. More...
 
static DependencyTicket pnc_ticket ()
 Returns a ticket for the cache entry that holds the non-conservative power calculation. More...
 
template<template< typename > class S = ::drake::systems::System>
static std::unique_ptr< S< AutoDiffXd > > ToAutoDiffXd (const S< T > &from)
 Creates a deep copy of from, transmogrified to use the autodiff scalar type, with a dynamic-sized vector of partial derivatives. More...
 
template<template< typename > class S = ::drake::systems::System>
static std::unique_ptr< S< symbolic::Expression > > ToSymbolic (const S< T > &from)
 Creates a deep copy of from, transmogrified to use the symbolic scalar type. More...
 
- Static Public Member Functions inherited from SystemBase
static DependencyTicket nothing_ticket ()
 Returns a ticket indicating that a computation does not depend on any source value; that is, it is a constant. More...
 
static DependencyTicket time_ticket ()
 Returns a ticket indicating dependence on time. More...
 
static DependencyTicket accuracy_ticket ()
 Returns a ticket indicating dependence on the accuracy setting in the Context. More...
 
static DependencyTicket q_ticket ()
 Returns a ticket indicating that a computation depends on configuration state variables q. More...
 
static DependencyTicket v_ticket ()
 Returns a ticket indicating dependence on velocity state variables v. More...
 
static DependencyTicket z_ticket ()
 Returns a ticket indicating dependence on any or all of the miscellaneous continuous state variables z. More...
 
static DependencyTicket xc_ticket ()
 Returns a ticket indicating dependence on all of the continuous state variables q, v, or z. More...
 
static DependencyTicket xd_ticket ()
 Returns a ticket indicating dependence on all of the numerical discrete state variables, in any discrete variable group. More...
 
static DependencyTicket xa_ticket ()
 Returns a ticket indicating dependence on all of the abstract state variables in the current Context. More...
 
static DependencyTicket all_state_ticket ()
 Returns a ticket indicating dependence on all state variables x in this system, including continuous variables xc, discrete (numeric) variables xd, and abstract state variables xa. More...
 
static DependencyTicket pn_ticket ()
 Returns a ticket indicating dependence on all of the numerical parameters in the current Context. More...
 
static DependencyTicket pa_ticket ()
 Returns a ticket indicating dependence on all of the abstract parameters pa in the current Context. More...
 
static DependencyTicket all_parameters_ticket ()
 Returns a ticket indicating dependence on all parameters p in this system, including numeric parameters pn, and abstract parameters pa. More...
 
static DependencyTicket all_input_ports_ticket ()
 Returns a ticket indicating dependence on all input ports u of this system. More...
 
static DependencyTicket all_sources_ticket ()
 Returns a ticket indicating dependence on every possible independent source value, including time, accuracy, state, input ports, and parameters (but not cache entries). More...
 
static DependencyTicket configuration_ticket ()
 Returns a ticket indicating dependence on all source values that may affect configuration-dependent computations. More...
 
static DependencyTicket kinematics_ticket ()
 Returns a ticket indicating dependence on all source values that may affect configuration- or velocity-dependent computations. More...
 
static DependencyTicket xcdot_ticket ()
 Returns a ticket for the cache entry that holds time derivatives of the continuous variables. More...
 
static DependencyTicket pe_ticket ()
 Returns a ticket for the cache entry that holds the potential energy calculation. More...
 
static DependencyTicket ke_ticket ()
 Returns a ticket for the cache entry that holds the kinetic energy calculation. More...
 
static DependencyTicket pc_ticket ()
 Returns a ticket for the cache entry that holds the conservative power calculation. More...
 
static DependencyTicket pnc_ticket ()
 Returns a ticket for the cache entry that holds the non-conservative power calculation. More...
 
- Protected Member Functions inherited from MultibodyTreeSystem< T >
void SetDefaultState (const systems::Context< T > &context, systems::State< T > *state) const override
 
 MultibodyTreeSystem (bool is_discrete=false)
 Default constructor allocates a MultibodyTree, with the intent that it will be filled in later, using mutable_tree() for access. More...
 
 MultibodyTreeSystem (systems::SystemScalarConverter converter, std::unique_ptr< MultibodyTree< T >> tree, bool is_discrete=false)
 Constructor that specifies scalar-type conversion support. More...
 
const MultibodyTree< T > & internal_tree () const
 Returns a const reference to the MultibodyTree owned by this class. More...
 
MultibodyTree< T > & mutable_tree () const
 Returns a mutable reference to the MultibodyTree owned by this class. More...
 
void Finalize ()
 Finalize the tree if that hasn't already been done, complete System construction, and declare any needed Context resources for the tree. More...
 
- Protected Member Functions inherited from LeafSystem< T >
 LeafSystem ()
 Default constructor that declares no inputs, outputs, state, parameters, events, nor scalar-type conversion support (AutoDiff, etc.). More...
 
 LeafSystem (SystemScalarConverter converter)
 Constructor that declares no inputs, outputs, state, parameters, or events, but allows subclasses to declare scalar-type conversion support (AutoDiff, etc.). More...
 
virtual std::unique_ptr< LeafContext< T > > DoMakeLeafContext () const
 Provides a new instance of the leaf context for this system. More...
 
virtual void DoValidateAllocatedLeafContext (const LeafContext< T > &context) const
 Derived classes that impose restrictions on what resources are permitted should check those restrictions by implementing this. More...
 
DoCalcWitnessValue (const Context< T > &context, const WitnessFunction< T > &witness_func) const final
 Derived classes will implement this method to evaluate a witness function at the given context. More...
 
void AddTriggeredWitnessFunctionToCompositeEventCollection (Event< T > *event, CompositeEventCollection< T > *events) const final
 Add event to events due to a witness function triggering. More...
 
void DoCalcNextUpdateTime (const Context< T > &context, CompositeEventCollection< T > *events, T *time) const override
 Computes the next update time based on the configured periodic events, for scalar types that are arithmetic, or aborts for scalar types that are not arithmetic. More...
 
void GetGraphvizFragment (int max_depth, std::stringstream *dot) const override
 Emits a graphviz fragment for this System. More...
 
void GetGraphvizInputPortToken (const InputPort< T > &port, int max_depth, std::stringstream *dot) const final
 Appends a fragment to the dot stream identifying the graphviz node representing port. More...
 
void GetGraphvizOutputPortToken (const OutputPort< T > &port, int max_depth, std::stringstream *dot) const final
 Appends a fragment to the dot stream identifying the graphviz node representing port. More...
 
virtual std::unique_ptr< ContinuousState< T > > AllocateContinuousState () const
 Returns a ContinuousState used to implement both CreateDefaultContext and AllocateTimeDerivatives. More...
 
virtual std::unique_ptr< DiscreteValues< T > > AllocateDiscreteState () const
 Reserves the discrete state as required by CreateDefaultContext. More...
 
virtual std::unique_ptr< AbstractValuesAllocateAbstractState () const
 Reserves the abstract state as required by CreateDefaultContext. More...
 
virtual std::unique_ptr< Parameters< T > > AllocateParameters () const
 Reserves the parameters as required by CreateDefaultContext. More...
 
int DeclareNumericParameter (const BasicVector< T > &model_vector)
 Declares a numeric parameter using the given model_vector. More...
 
template<template< typename > class U = BasicVector>
const U< T > & GetNumericParameter (const Context< T > &context, int index) const
 Extracts the numeric parameters of type U from the context at index. More...
 
template<template< typename > class U = BasicVector>
U< T > & GetMutableNumericParameter (Context< T > *context, int index) const
 Extracts the numeric parameters of type U from the context at index. More...
 
int DeclareAbstractParameter (const AbstractValue &model_value)
 Declares an abstract parameter using the given model_value. More...
 
template<class MySystem >
SystemConstraintIndex DeclareEqualityConstraint (void(MySystem::*calc)(const Context< T > &, VectorX< T > *) const, int count, std::string description)
 Declares a system constraint of the form f(context) = 0 by specifying a member function to use to calculate the (VectorX) constraint value with a signature: More...
 
SystemConstraintIndex DeclareEqualityConstraint (ContextConstraintCalc< T > calc, int count, std::string description)
 Declares a system constraint of the form f(context) = 0 by specifying a std::function to use to calculate the (Vector) constraint value with a signature: More...
 
template<class MySystem >
SystemConstraintIndex DeclareInequalityConstraint (void(MySystem::*calc)(const Context< T > &, VectorX< T > *) const, SystemConstraintBounds bounds, std::string description)
 Declares a system constraint of the form bounds.lower() <= calc(context) <= bounds.upper() by specifying a member function to use to calculate the (VectorX) constraint value with a signature: More...
 
SystemConstraintIndex DeclareInequalityConstraint (ContextConstraintCalc< T > calc, SystemConstraintBounds bounds, std::string description)
 Declares a system constraint of the form bounds.lower() <= calc(context) <= bounds.upper() by specifying a std::function to use to calculate the (Vector) constraint value with a signature: More...
 
virtual void DoPublish (const Context< T > &context, const std::vector< const PublishEvent< T > * > &events) const
 Derived-class event dispatcher for all simultaneous publish events in events. More...
 
virtual void DoCalcDiscreteVariableUpdates (const Context< T > &context, const std::vector< const DiscreteUpdateEvent< T > * > &events, DiscreteValues< T > *discrete_state) const
 Derived-class event dispatcher for all simultaneous discrete update events. More...
 
virtual void DoCalcUnrestrictedUpdate (const Context< T > &context, const std::vector< const UnrestrictedUpdateEvent< T > * > &events, State< T > *state) const
 Derived-class event dispatcher for all simultaneous unrestricted update events. More...
 
template<class MySystem >
void DeclarePeriodicPublishEvent (double period_sec, double offset_sec, EventStatus(MySystem::*publish)(const Context< T > &) const)
 Declares that a Publish event should occur periodically and that it should invoke the given event handler method. More...
 
template<class MySystem >
void DeclarePeriodicPublishEvent (double period_sec, double offset_sec, void(MySystem::*publish)(const Context< T > &) const)
 This variant accepts a handler that is assumed to succeed rather than one that returns an EventStatus result. More...
 
template<class MySystem >
void DeclarePeriodicDiscreteUpdateEvent (double period_sec, double offset_sec, EventStatus(MySystem::*update)(const Context< T > &, DiscreteValues< T > *) const)
 Declares that a DiscreteUpdate event should occur periodically and that it should invoke the given event handler method. More...
 
template<class MySystem >
void DeclarePeriodicDiscreteUpdateEvent (double period_sec, double offset_sec, void(MySystem::*update)(const Context< T > &, DiscreteValues< T > *) const)
 This variant accepts a handler that is assumed to succeed rather than one that returns an EventStatus result. More...
 
template<class MySystem >
void DeclarePeriodicUnrestrictedUpdateEvent (double period_sec, double offset_sec, EventStatus(MySystem::*update)(const Context< T > &, State< T > *) const)
 Declares that an UnrestrictedUpdate event should occur periodically and that it should invoke the given event handler method. More...
 
template<class MySystem >
void DeclarePeriodicUnrestrictedUpdateEvent (double period_sec, double offset_sec, void(MySystem::*update)(const Context< T > &, State< T > *) const)
 This variant accepts a handler that is assumed to succeed rather than one that returns an EventStatus result. More...
 
template<typename EventType >
void DeclarePeriodicEvent (double period_sec, double offset_sec, const EventType &event)
 (Advanced) Declares that a particular Event object should be dispatched periodically. More...
 
void DeclarePeriodicPublish (double period_sec, double offset_sec=0)
 (To be deprecated) Declares a periodic publish event that invokes the Publish() dispatcher but does not provide a handler function. More...
 
void DeclarePeriodicDiscreteUpdate (double period_sec, double offset_sec=0)
 (To be deprecated) Declares a periodic discrete update event that invokes the DiscreteUpdate() dispatcher but does not provide a handler function. More...
 
void DeclarePeriodicUnrestrictedUpdate (double period_sec, double offset_sec=0)
 (To be deprecated) Declares a periodic unrestricted update event that invokes the UnrestrictedUpdate() dispatcher but does not provide a handler function. More...
 
template<class MySystem >
void DeclarePerStepPublishEvent (EventStatus(MySystem::*publish)(const Context< T > &) const)
 Declares that a Publish event should occur at initialization and at the end of every trajectory-advancing step and that it should invoke the given event handler method. More...
 
template<class MySystem >
void DeclarePerStepDiscreteUpdateEvent (EventStatus(MySystem::*update)(const Context< T > &, DiscreteValues< T > *) const)
 Declares that a DiscreteUpdate event should occur at the start of every trajectory-advancing step and that it should invoke the given event handler method. More...
 
template<class MySystem >
void DeclarePerStepUnrestrictedUpdateEvent (EventStatus(MySystem::*update)(const Context< T > &, State< T > *) const)
 Declares that an UnrestrictedUpdate event should occur at the start of every trajectory-advancing step and that it should invoke the given event handler method. More...
 
template<typename EventType >
void DeclarePerStepEvent (const EventType &event)
 (Advanced) Declares that a particular Event object should be dispatched at every trajectory-advancing step. More...
 
template<class MySystem >
void DeclareInitializationPublishEvent (EventStatus(MySystem::*publish)(const Context< T > &) const)
 Declares that a Publish event should occur at initialization and that it should invoke the given event handler method. More...
 
template<class MySystem >
void DeclareInitializationDiscreteUpdateEvent (EventStatus(MySystem::*update)(const Context< T > &, DiscreteValues< T > *) const)
 Declares that a DiscreteUpdate event should occur at initialization and that it should invoke the given event handler method. More...
 
template<class MySystem >
void DeclareInitializationUnrestrictedUpdateEvent (EventStatus(MySystem::*update)(const Context< T > &, State< T > *) const)
 Declares that an UnrestrictedUpdate event should occur at initialization and that it should invoke the given event handler method. More...
 
template<typename EventType >
void DeclareInitializationEvent (const EventType &event)
 (Advanced) Declares that a particular Event object should be dispatched at initialization. More...
 
template<class MySystem >
void DeclareForcedPublishEvent (EventStatus(MySystem::*publish)(const Context< T > &) const)
 Declares a function that is called whenever a user directly calls Publish(const Context&). More...
 
template<class MySystem >
void DeclareForcedDiscreteUpdateEvent (EventStatus(MySystem::*update)(const Context< T > &, DiscreteValues< T > *) const)
 Declares a function that is called whenever a user directly calls CalcDiscreteVariableUpdates(const Context&, DiscreteValues<T>*). More...
 
template<class MySystem >
void DeclareForcedUnrestrictedUpdateEvent (EventStatus(MySystem::*update)(const Context< T > &, State< T > *) const)
 Declares a function that is called whenever a user directly calls CalcUnrestrictedUpdate(const Context&, State<T>*). More...
 
void DeclareContinuousState (int num_state_variables)
 Declares that this System should reserve continuous state with num_state_variables state variables, which have no second-order structure. More...
 
void DeclareContinuousState (int num_q, int num_v, int num_z)
 Declares that this System should reserve continuous state with num_q generalized positions, num_v generalized velocities, and num_z miscellaneous state variables. More...
 
void DeclareContinuousState (const BasicVector< T > &model_vector)
 Declares that this System should reserve continuous state with model_vector.size() miscellaneous state variables, stored in a vector cloned from model_vector. More...
 
void DeclareContinuousState (const BasicVector< T > &model_vector, int num_q, int num_v, int num_z)
 Declares that this System should reserve continuous state with num_q generalized positions, num_v generalized velocities, and num_z miscellaneous state variables, stored in a vector cloned from model_vector. More...
 
DiscreteStateIndex DeclareDiscreteState (const BasicVector< T > &model_vector)
 Declares a discrete state group with model_vector.size() state variables, stored in a vector cloned from model_vector (preserving the concrete type and value). More...
 
DiscreteStateIndex DeclareDiscreteState (const Eigen::Ref< const VectorX< T >> &vector)
 Declares a discrete state group with vector.size() state variables, stored in a BasicVector initialized with the contents of vector. More...
 
DiscreteStateIndex DeclareDiscreteState (int num_state_variables)
 Declares a discrete state group with num_state_variables state variables, stored in a BasicVector initialized to be all-zero. More...
 
AbstractStateIndex DeclareAbstractState (std::unique_ptr< AbstractValue > abstract_state)
 Declares an abstract state. More...
 
const InputPort< T > & DeclareVectorInputPort (variant< std::string, UseDefaultName > name, const BasicVector< T > &model_vector, optional< RandomDistribution > random_type=nullopt)
 Declares a vector-valued input port using the given model_vector. More...
 
const InputPort< T > & DeclareAbstractInputPort (variant< std::string, UseDefaultName > name, const AbstractValue &model_value)
 Declares an abstract-valued input port using the given model_value. More...
 
const InputPort< T > & DeclareVectorInputPort (const BasicVector< T > &model_vector, optional< RandomDistribution > random_type=nullopt)
 See the nearly identical signature with an additional (first) argument specifying the port name. More...
 
const InputPort< T > & DeclareAbstractInputPort (const AbstractValue &model_value)
 See the nearly identical signature with an additional (first) argument specifying the port name. More...
 
template<class MySystem , typename BasicVectorSubtype >
const OutputPort< T > & DeclareVectorOutputPort (variant< std::string, UseDefaultName > name, const BasicVectorSubtype &model_vector, void(MySystem::*calc)(const Context< T > &, BasicVectorSubtype *) const, std::set< DependencyTicket > prerequisites_of_calc={ all_sources_ticket()})
 Declares a vector-valued output port by specifying (1) a model vector of type BasicVectorSubtype derived from BasicVector and initialized to the correct size and desired initial value, and (2) a calculator function that is a class member function (method) with signature: More...
 
template<class MySystem , typename BasicVectorSubtype >
const OutputPort< T > & DeclareVectorOutputPort (variant< std::string, UseDefaultName > name, void(MySystem::*calc)(const Context< T > &, BasicVectorSubtype *) const, std::set< DependencyTicket > prerequisites_of_calc={ all_sources_ticket()})
 Declares a vector-valued output port by specifying only a calculator function that is a class member function (method) with signature: More...
 
const OutputPort< T > & DeclareVectorOutputPort (variant< std::string, UseDefaultName > name, const BasicVector< T > &model_vector, typename LeafOutputPort< T >::CalcVectorCallback vector_calc_function, std::set< DependencyTicket > prerequisites_of_calc={ all_sources_ticket()})
 (Advanced) Declares a vector-valued output port using the given model_vector and a function for calculating the port's value at runtime. More...
 
template<class MySystem , typename OutputType >
const OutputPort< T > & DeclareAbstractOutputPort (variant< std::string, UseDefaultName > name, const OutputType &model_value, void(MySystem::*calc)(const Context< T > &, OutputType *) const, std::set< DependencyTicket > prerequisites_of_calc={ all_sources_ticket()})
 Declares an abstract-valued output port by specifying a model value of concrete type OutputType and a calculator function that is a class member function (method) with signature: More...
 
template<class MySystem , typename OutputType >
const OutputPort< T > & DeclareAbstractOutputPort (variant< std::string, UseDefaultName > name, void(MySystem::*calc)(const Context< T > &, OutputType *) const, std::set< DependencyTicket > prerequisites_of_calc={ all_sources_ticket()})
 Declares an abstract-valued output port by specifying only a calculator function that is a class member function (method) with signature: More...
 
template<class MySystem , typename OutputType >
const OutputPort< T > & DeclareAbstractOutputPort (variant< std::string, UseDefaultName > name, OutputType(MySystem::*make)() const, void(MySystem::*calc)(const Context< T > &, OutputType *) const, std::set< DependencyTicket > prerequisites_of_calc={ all_sources_ticket()})
 Declares an abstract-valued output port by specifying member functions to use both for the allocator and calculator. More...
 
const OutputPort< T > & DeclareAbstractOutputPort (variant< std::string, UseDefaultName > name, typename LeafOutputPort< T >::AllocCallback alloc_function, typename LeafOutputPort< T >::CalcCallback calc_function, std::set< DependencyTicket > prerequisites_of_calc={ all_sources_ticket()})
 (Advanced) Declares an abstract-valued output port using the given allocator and calculator functions provided in their most generic forms. More...
 
template<class MySystem , typename BasicVectorSubtype >
const OutputPort< T > & DeclareVectorOutputPort (const BasicVectorSubtype &model_vector, void(MySystem::*calc)(const Context< T > &, BasicVectorSubtype *) const, std::set< DependencyTicket > prerequisites_of_calc={ all_sources_ticket()})
 See the nearly identical signature with an additional (first) argument specifying the port name. More...
 
template<class MySystem , typename BasicVectorSubtype >
const OutputPort< T > & DeclareVectorOutputPort (void(MySystem::*calc)(const Context< T > &, BasicVectorSubtype *) const, std::set< DependencyTicket > prerequisites_of_calc={ all_sources_ticket()})
 See the nearly identical signature with an additional (first) argument specifying the port name. More...
 
const OutputPort< T > & DeclareVectorOutputPort (const BasicVector< T > &model_vector, typename LeafOutputPort< T >::CalcVectorCallback vector_calc_function, std::set< DependencyTicket > prerequisites_of_calc={ all_sources_ticket()})
 See the nearly identical signature with an additional (first) argument specifying the port name. More...
 
template<class MySystem , typename OutputType >
std::enable_if_t<!std::is_same< OutputType, std::string >::value, const OutputPort< T > & > DeclareAbstractOutputPort (const OutputType &model_value, void(MySystem::*calc)(const Context< T > &, OutputType *) const, std::set< DependencyTicket > prerequisites_of_calc={ all_sources_ticket()})
 See the nearly identical signature with an additional (first) argument specifying the port name. More...
 
template<class MySystem , typename OutputType >
const OutputPort< T > & DeclareAbstractOutputPort (void(MySystem::*calc)(const Context< T > &, OutputType *) const, std::set< DependencyTicket > prerequisites_of_calc={ all_sources_ticket()})
 See the nearly identical signature with an additional (first) argument specifying the port name. More...
 
template<class MySystem , typename OutputType >
const OutputPort< T > & DeclareAbstractOutputPort (OutputType(MySystem::*make)() const, void(MySystem::*calc)(const Context< T > &, OutputType *) const, std::set< DependencyTicket > prerequisites_of_calc={ all_sources_ticket()})
 See the nearly identical signature with an additional (first) argument specifying the port name. More...
 
const OutputPort< T > & DeclareAbstractOutputPort (typename LeafOutputPort< T >::AllocCallback alloc_function, typename LeafOutputPort< T >::CalcCallback calc_function, std::set< DependencyTicket > prerequisites_of_calc={ all_sources_ticket()})
 See the nearly identical signature with an additional (first) argument specifying the port name. More...
 
template<class MySystem >
std::unique_ptr< WitnessFunction< T > > MakeWitnessFunction (const std::string &description, const WitnessFunctionDirection &direction_type, T(MySystem::*calc)(const Context< T > &) const) const
 Constructs the witness function with the given description (used primarily for debugging and logging), direction type, and calculator function; and with no event object. More...
 
std::unique_ptr< WitnessFunction< T > > MakeWitnessFunction (const std::string &description, const WitnessFunctionDirection &direction_type, std::function< T(const Context< T > &)> calc) const
 Constructs the witness function with the given description (used primarily for debugging and logging), direction type, and calculator function; and with no event object. More...
 
template<class MySystem >
std::unique_ptr< WitnessFunction< T > > MakeWitnessFunction (const std::string &description, const WitnessFunctionDirection &direction_type, T(MySystem::*calc)(const Context< T > &) const, void(MySystem::*publish_callback)(const Context< T > &, const PublishEvent< T > &) const) const
 Constructs the witness function with the given description (used primarily for debugging and logging), direction type, calculator function, and publish event callback function for when this triggers. More...
 
template<class MySystem >
std::unique_ptr< WitnessFunction< T > > MakeWitnessFunction (const std::string &description, const WitnessFunctionDirection &direction_type, T(MySystem::*calc)(const Context< T > &) const, void(MySystem::*du_callback)(const Context< T > &, const DiscreteUpdateEvent< T > &, DiscreteValues< T > *) const) const
 Constructs the witness function with the given description (used primarily for debugging and logging), direction type, calculator function, and discrete update event callback function for when this triggers. More...
 
template<class MySystem >
std::unique_ptr< WitnessFunction< T > > MakeWitnessFunction (const std::string &description, const WitnessFunctionDirection &direction_type, T(MySystem::*calc)(const Context< T > &) const, void(MySystem::*uu_callback)(const Context< T > &, const UnrestrictedUpdateEvent< T > &, State< T > *) const) const
 Constructs the witness function with the given description (used primarily for debugging and logging), direction type, calculator function, and unrestricted update event callback function for when this triggers. More...
 
template<class MySystem >
std::unique_ptr< WitnessFunction< T > > MakeWitnessFunction (const std::string &description, const WitnessFunctionDirection &direction_type, T(MySystem::*calc)(const Context< T > &) const, const Event< T > &e) const
 Constructs the witness function with the given description (used primarily for debugging and logging), direction type, and calculator function, and with an object corresponding to the event that is to be dispatched when this witness function triggers. More...
 
std::unique_ptr< WitnessFunction< T > > MakeWitnessFunction (const std::string &description, const WitnessFunctionDirection &direction_type, std::function< T(const Context< T > &)> calc, const Event< T > &e) const
 Constructs the witness function with the given description (used primarily for debugging and logging), direction type, and calculator function, and with an object corresponding to the event that is to be dispatched when this witness function triggers. More...
 
- Protected Member Functions inherited from System< T >
virtual void DoGetWitnessFunctions (const Context< T > &, std::vector< const WitnessFunction< T > * > *) const
 Derived classes can override this method to provide witness functions active for the given state. More...
 
SystemConstraintIndex AddConstraint (std::unique_ptr< SystemConstraint< T >> constraint)
 Adds an already-created constraint to the list of constraints for this System. More...
 
bool forced_publish_events_exist () const
 
bool forced_discrete_update_events_exist () const
 
bool forced_unrestricted_update_events_exist () const
 
EventCollection< PublishEvent< T > > & get_mutable_forced_publish_events ()
 
EventCollection< DiscreteUpdateEvent< T > > & get_mutable_forced_discrete_update_events ()
 
EventCollection< UnrestrictedUpdateEvent< T > > & get_mutable_forced_unrestricted_update_events ()
 
const EventCollection< PublishEvent< T > > & get_forced_publish_events () const
 
const EventCollection< DiscreteUpdateEvent< T > > & get_forced_discrete_update_events () const
 
const EventCollection< UnrestrictedUpdateEvent< T > > & get_forced_unrestricted_update_events () const
 
void set_forced_publish_events (std::unique_ptr< EventCollection< PublishEvent< T >>> forced)
 
void set_forced_discrete_update_events (std::unique_ptr< EventCollection< DiscreteUpdateEvent< T >>> forced)
 
void set_forced_unrestricted_update_events (std::unique_ptr< EventCollection< UnrestrictedUpdateEvent< T >>> forced)
 
 System (SystemScalarConverter converter)
 Constructs an empty System base class object and allocates base class resources, possibly supporting scalar-type conversion support (AutoDiff, etc.) using converter. More...
 
const InputPort< T > & DeclareInputPort (variant< std::string, UseDefaultName > name, PortDataType type, int size, optional< RandomDistribution > random_type=nullopt)
 Adds a port with the specified type and size to the input topology. More...
 
const InputPort< T > & DeclareInputPort (PortDataType type, int size, optional< RandomDistribution > random_type=nullopt)
 See the nearly identical signature with an additional (first) argument specifying the port name. More...
 
virtual void DoCalcTimeDerivatives (const Context< T > &context, ContinuousState< T > *derivatives) const
 Override this if you have any continuous state variables xc in your concrete System to calculate their time derivatives. More...
 
virtual T DoCalcPotentialEnergy (const Context< T > &context) const
 Override this method for physical systems to calculate the potential energy PE currently stored in the configuration provided in the given Context. More...
 
virtual T DoCalcKineticEnergy (const Context< T > &context) const
 Override this method for physical systems to calculate the kinetic energy KE currently present in the motion provided in the given Context. More...
 
virtual T DoCalcConservativePower (const Context< T > &context) const
 Override this method to return the rate Pc at which mechanical energy is being converted from potential energy to kinetic energy by this system in the given Context. More...
 
virtual T DoCalcNonConservativePower (const Context< T > &context) const
 Override this method to return the rate Pnc at which work W is done on the system by non-conservative forces. More...
 
virtual void DoMapQDotToVelocity (const Context< T > &context, const Eigen::Ref< const VectorX< T >> &qdot, VectorBase< T > *generalized_velocity) const
 Provides the substantive implementation of MapQDotToVelocity(). More...
 
virtual void DoMapVelocityToQDot (const Context< T > &context, const Eigen::Ref< const VectorX< T >> &generalized_velocity, VectorBase< T > *qdot) const
 Provides the substantive implementation of MapVelocityToQDot(). More...
 
virtual int do_get_num_constraint_equations (const Context< T > &context) const
 Gets the number of constraint equations for this system from the given context. More...
 
virtual Eigen::VectorXd DoEvalConstraintEquations (const Context< T > &context) const
 Evaluates the constraint equations for the system at the generalized coordinates and generalized velocity specified by the context. More...
 
virtual Eigen::VectorXd DoEvalConstraintEquationsDot (const Context< T > &context) const
 Computes the time derivative of each constraint equation, evaluated at the generalized coordinates and generalized velocity specified by the context. More...
 
virtual Eigen::VectorXd DoCalcVelocityChangeFromConstraintImpulses (const Context< T > &context, const Eigen::MatrixXd &J, const Eigen::VectorXd &lambda) const
 Computes the change in velocity from applying the given constraint forces to the system at the given context. More...
 
virtual double DoCalcConstraintErrorNorm (const Context< T > &context, const Eigen::VectorXd &error) const
 Computes the norm of the constraint error. More...
 
Eigen::VectorBlock< VectorX< T > > GetMutableOutputVector (SystemOutput< T > *output, int port_index) const
 Returns a mutable Eigen expression for a vector valued output port with index port_index in this system. More...
 
- Protected Member Functions inherited from SystemBase
 SystemBase ()=default
 (Internal use only) Default constructor. More...
 
void AddInputPort (std::unique_ptr< InputPortBase > port)
 (Internal use only) Adds an already-constructed input port to this System. More...
 
void AddOutputPort (std::unique_ptr< OutputPortBase > port)
 (Internal use only) Adds an already-constructed output port to this System. More...
 
std::string NextInputPortName (variant< std::string, UseDefaultName > given_name) const
 (Internal use only) Returns a name for the next input port, using the given name if it isn't kUseDefaultName, otherwise making up a name like "u3" from the next available input port index. More...
 
std::string NextOutputPortName (variant< std::string, UseDefaultName > given_name) const
 (Internal use only) Returns a name for the next output port, using the given name if it isn't kUseDefaultName, otherwise making up a name like "y3" from the next available output port index. More...
 
void AddDiscreteStateGroup (DiscreteStateIndex index)
 (Internal use only) Assigns a ticket to a new discrete variable group with the given index. More...
 
void AddAbstractState (AbstractStateIndex index)
 (Internal use only) Assigns a ticket to a new abstract state variable with the given index. More...
 
void AddNumericParameter (NumericParameterIndex index)
 (Internal use only) Assigns a ticket to a new numeric parameter with the given index. More...
 
void AddAbstractParameter (AbstractParameterIndex index)
 (Internal use only) Assigns a ticket to a new abstract parameter with the given index. More...
 
const CacheEntryDeclareCacheEntryWithKnownTicket (DependencyTicket known_ticket, std::string description, CacheEntry::AllocCallback alloc_function, CacheEntry::CalcCallback calc_function, std::set< DependencyTicket > prerequisites_of_calc={ all_sources_ticket()})
 (Internal use only) This is for cache entries associated with pre-defined tickets, for example the cache entry for time derivatives. More...
 
const internal::SystemParentServiceInterface * get_parent_service () const
 Returns a pointer to the service interface of the immediately enclosing Diagram if one has been set, otherwise nullptr. More...
 
DependencyTicket assign_next_dependency_ticket ()
 (Internal use only) Assigns the next unused dependency ticket number, unique only within a particular system. More...
 
const AbstractValueEvalAbstractInputImpl (const char *func, const ContextBase &context, InputPortIndex port_index) const
 (Internal use only) Shared code for updating an input port and returning a pointer to its abstract value, or nullptr if the port is not connected. More...
 
void ThrowNegativePortIndex (const char *func, int port_index) const
 Throws std::out_of_range to report a negative port_index that was passed to API method func. More...
 
void ThrowInputPortIndexOutOfRange (const char *func, InputPortIndex port_index) const
 Throws std::out_of_range to report bad input port_index that was passed to API method func. More...
 
void ThrowOutputPortIndexOutOfRange (const char *func, OutputPortIndex port_index) const
 Throws std::out_of_range to report bad output port_index that was passed to API method func. More...
 
void ThrowNotAVectorInputPort (const char *func, InputPortIndex port_index) const
 Throws std::logic_error because someone misused API method func, that is only allowed for declared-vector input ports, on an abstract port whose index is given here. More...
 
void ThrowInputPortHasWrongType (const char *func, InputPortIndex port_index, const std::string &expected_type, const std::string &actual_type) const
 Throws std::logic_error because someone called API method func claiming the input port had some value type that was wrong. More...
 
void ThrowCantEvaluateInputPort (const char *func, InputPortIndex port_index) const
 Throws std::logic_error because someone called API method func, that requires this input port to be evaluatable, but the port was neither fixed nor connected. More...
 
const InputPortBaseGetInputPortBaseOrThrow (const char *func, int port_index) const
 (Internal use only) Returns the InputPortBase at index port_index, throwing std::out_of_range we don't like the port index. More...
 
const OutputPortBaseGetOutputPortBaseOrThrow (const char *func, int port_index) const
 (Internal use only) Returns the OutputPortBase at index port_index, throwing std::out_of_range if we don't like the port index. More...
 
void InitializeContextBase (ContextBase *context) const
 This method must be invoked from within derived class DoAllocateContext() implementations right after the concrete Context object has been allocated. More...
 
- Static Protected Member Functions inherited from LeafSystem< T >
static DependencyTicket all_sources_ticket ()
 Returns a ticket indicating dependence on every possible independent source value, including time, accuracy, state, input ports, and parameters (but not cache entries). More...
 
- Static Protected Member Functions inherited from SystemBase
static void set_parent_service (SystemBase *child, const internal::SystemParentServiceInterface *parent_service)
 (Internal use only) Declares that parent_service is the service interface of the Diagram that owns this subsystem. More...
 
static void ThrowInputPortHasWrongType (const char *func, const std::string &system_pathname, InputPortIndex, const std::string &port_name, const std::string &expected_type, const std::string &actual_type)
 Throws std::logic_error because someone called API method func claiming the input port had some value type that was wrong. More...
 

Constructor & Destructor Documentation

◆ MultibodyPlant() [1/4]

MultibodyPlant ( const MultibodyPlant< T > &  )
delete

◆ MultibodyPlant() [2/4]

MultibodyPlant ( MultibodyPlant< T > &&  )
delete

◆ MultibodyPlant() [3/4]

MultibodyPlant ( double  time_step = 0)
explicit

Default constructor creates a plant with a single "world" body.

Therefore, right after creation, num_bodies() returns one.

Parameters
[in]time_stepAn optional parameter indicating whether this plant is modeled as a continuous system (time_step = 0) or as a discrete system with periodic updates of period time_step > 0.
Default: 0.0.
Exceptions
std::exceptionif time_step is negative.

◆ MultibodyPlant() [4/4]

MultibodyPlant ( const MultibodyPlant< U > &  other)

Scalar-converting copy constructor. See System Scalar Conversion.

Member Function Documentation

◆ AddForceElement()

const ForceElementType<T>& AddForceElement ( Args &&...  args)

Adds a new force element model of type ForceElementType to this MultibodyPlant.

The arguments to this method args are forwarded to ForceElementType's constructor.

Parameters
[in]argsZero or more parameters provided to the constructor of the new force element. It must be the case that ForceElementType<T>(args) is a valid constructor.
Template Parameters
ForceElementTypeThe type of the ForceElement to add. As there is always a UniformGravityFieldElement present (accessible through gravity_field()), an exception will be thrown if this function is called to add another UniformGravityFieldElement.
Returns
A constant reference to the new ForceElement just added, of type ForceElementType<T> specialized on the scalar type T of this MultibodyPlant. It will remain valid for the lifetime of this MultibodyPlant.
See also
The ForceElement class's documentation for further details on how a force element is defined.

◆ AddFrame()

const FrameType<T>& AddFrame ( std::unique_ptr< FrameType< T >>  frame)

This method adds a Frame of type FrameType<T>.

For more information, please see the corresponding constructor of FrameType.

Template Parameters
FrameTypeTemplate which will be instantiated on T.
Parameters
frameUnique pointer frame instance.
Returns
A constant reference to the new Frame just added, which will remain valid for the lifetime of this MultibodyPlant.

◆ AddJoint() [1/2]

const JointType<T>& AddJoint ( std::unique_ptr< JointType< T >>  joint)

This method adds a Joint of type JointType between two bodies.

For more information, see the below overload of AddJoint<>, and the related MultibodyTree::AddJoint<> method.

◆ AddJoint() [2/2]

const JointType<T>& AddJoint ( const std::string &  name,
const Body< T > &  parent,
const optional< math::RigidTransform< double >> &  X_PF,
const Body< T > &  child,
const optional< math::RigidTransform< double >> &  X_BM,
Args &&...  args 
)

This method adds a Joint of type JointType between two bodies.

The two bodies connected by this Joint object are referred to as the parent and child bodies. Although the terms parent and child are sometimes used synonymously to describe the relationship between inboard and outboard bodies in multibody models, this usage is wholly unrelated and implies nothing about the inboard-outboard relationship between the bodies. As explained in the Joint class's documentation, in Drake we define a frame F attached to the parent body P with pose X_PF and a frame M attached to the child body B with pose X_BM. This method helps creating a joint between two bodies with fixed poses X_PF and X_BM. Refer to the Joint class's documentation for more details.

Parameters
nameA string that uniquely identifies the new joint to be added to this model. A std::runtime_error is thrown if a joint named name already is part of the model. See HasJointNamed(), Joint::name().
[in]parentThe parent body connected by the new joint.
[in]X_PFThe fixed pose of frame F attached to the parent body, measured in the frame P of that body. X_PF is an optional parameter; empty curly braces {} imply that frame F is the same body frame P. If instead your intention is to make a frame F with pose X_PF equal to the identity pose, provide RigidTransform<double>::Identity() as your input.
[in]childThe child body connected by the new joint.
[in]X_BMThe fixed pose of frame M attached to the child body, measured in the frame B of that body. X_BM is an optional parameter; empty curly braces {} imply that frame M is the same body frame B. If instead your intention is to make a frame M with pose X_BM equal to the identity pose, provide RigidTransform<double>::Identity() as your input.
[in]argsZero or more parameters provided to the constructor of the new joint. It must be the case that JointType<T>( const std::string&, const Frame<T>&, const Frame<T>&, args) is a valid constructor.
Template Parameters
JointTypeThe type of the Joint to add.
Returns
A constant reference to the new joint just added, of type JointType<T> specialized on the scalar type T of this MultibodyPlant. It will remain valid for the lifetime of this MultibodyPlant.

Example of usage:

MultibodyPlant<T> plant;
// Code to define bodies serving as the joint's parent and child bodies.
const RigidBody<double>& body_1 =
plant.AddRigidBody("Body1", SpatialInertia<double>(...));
const RigidBody<double>& body_2 =
plant.AddRigidBody("Body2", SpatialInertia<double>(...));
// Body 1 serves as parent, Body 2 serves as child.
// Define the pose X_BM of a frame M rigidly atached to child body B.
const RevoluteJoint<double>& elbow =
plant.AddJoint<RevoluteJoint>(
"Elbow", /* joint name */
body_1, /* parent body */
{}, /* frame F IS the parent body frame P */
body_2, /* child body, the pendulum */
X_BM, /* pose of frame M in the body frame B */
Vector3d::UnitZ()); /* revolute axis in this case */
Exceptions
std::exceptionif this MultibodyPlant already contains a joint with the given name. See HasJointNamed(), Joint::name().
See also
The Joint class's documentation for further details on how a Joint is defined.

◆ AddJointActuator()

const JointActuator<T>& AddJointActuator ( const std::string &  name,
const Joint< T > &  joint,
double  effort_limit = std::numeric_limits<double>::infinity() 
)

Creates and adds a JointActuator model for an actuator acting on a given joint.

This method returns a constant reference to the actuator just added, which will remain valid for the lifetime of this plant.

Parameters
[in]nameA string that uniquely identifies the new actuator to be added to this model. A std::runtime_error is thrown if an actuator with the same name already exists in the model. See HasJointActuatorNamed().
[in]jointThe Joint to be actuated by the new JointActuator.
[in]effort_limitThe maximum effort for the actuator. It must be strictly positive, otherwise an std::exception is thrown. If +∞, the actuator has no limit, which is the default. The effort limit has physical units in accordance to the joint type it actuates. For instance, it will have units of N⋅m (torque) for revolute joints while it will have units of N (force) for prismatic joints.
Returns
A constant reference to the new JointActuator just added, which will remain valid for the lifetime of this plant.
Exceptions
std::exceptionif joint.num_velocities() > 1 since for now we only support actuators for single dof joints.

◆ AddModelInstance()

ModelInstanceIndex AddModelInstance ( const std::string &  name)

Creates a new model instance.

Returns the index for the model instance.

Parameters
[in]nameA string that uniquely identifies the new instance to be added to this model. An exception is thrown if an instance with the same name already exists in the model. See HasModelInstanceNamed().

◆ AddRigidBody() [1/2]

const RigidBody<T>& AddRigidBody ( const std::string &  name,
ModelInstanceIndex  model_instance,
const SpatialInertia< double > &  M_BBo_B 
)

Creates a rigid body with the provided name and spatial inertia.

This method returns a constant reference to the body just added, which will remain valid for the lifetime of this MultibodyPlant.

Example of usage:

MultibodyPlant<T> plant;
// ... Code to define spatial_inertia, a SpatialInertia<T> object ...
ModelInstanceIndex model_instance = plant.AddModelInstance("instance");
const RigidBody<T>& body =
plant.AddRigidBody("BodyName", model_instance, spatial_inertia);
Parameters
[in]nameA string that identifies the new body to be added to this model. A std::runtime_error is thrown if a body named name already is part of model_instance. See HasBodyNamed(), Body::name().
[in]model_instanceA model instance index which this body is part of.
[in]M_BBo_BThe SpatialInertia of the new rigid body to be added to this MultibodyPlant, computed about the body frame origin Bo and expressed in the body frame B.
Returns
A constant reference to the new RigidBody just added, which will remain valid for the lifetime of this MultibodyPlant.

◆ AddRigidBody() [2/2]

const RigidBody<T>& AddRigidBody ( const std::string &  name,
const SpatialInertia< double > &  M_BBo_B 
)

Creates a rigid body with the provided name and spatial inertia.

This method returns a constant reference to the body just added, which will remain valid for the lifetime of this MultibodyPlant. The body will use the default model instance (more on model instances).

Example of usage:

MultibodyPlant<T> plant;
// ... Code to define spatial_inertia, a SpatialInertia<T> object ...
const RigidBody<T>& body =
plant.AddRigidBody("BodyName", spatial_inertia);
Parameters
[in]nameA string that identifies the new body to be added to this model. A std::runtime_error is thrown if a body named name already is part of the model in the default model instance. See HasBodyNamed(), Body::name().
[in]M_BBo_BThe SpatialInertia of the new rigid body to be added to this MultibodyPlant, computed about the body frame origin Bo and expressed in the body frame B.
Returns
A constant reference to the new RigidBody just added, which will remain valid for the lifetime of this MultibodyPlant.
Exceptions
std::logic_errorif additional model instances have been created beyond the world and default instances.

◆ CalcBiasForJacobianSpatialVelocity()

Vector6<T> CalcBiasForJacobianSpatialVelocity ( const systems::Context< T > &  context,
JacobianWrtVariable  with_respect_to,
const Frame< T > &  frame_F,
const Eigen::Ref< const Vector3< T >> &  p_FoFp_F,
const Frame< T > &  frame_A,
const Frame< T > &  frame_E 
) const

For a point Fp that is fixed to a frame F, calculates Fp's spatial acceleration "bias" term Abias_AFp = J̇s_V_AFp * s in frame A with respect to "speeds" 𝑠.

  A_AFp = J𝑠_V_AFp(q)⋅ṡ + Abias_AFp(q, v)

A_AFp is point Fp's spatial acceleration in frame A and 𝑠 is either q̇ ≜ [q̇₁ ... q̇ⱼ]ᵀ (time-derivatives of generalized positions) or v ≜ [v₁ ... vₖ]ᵀ (generalized velocities). Note: Abias_AFp = J̇s_V_AFp(q, s)⋅s  is quadratic in 𝑠 ≜ [𝑠₁ ... 𝑠ₙ]ᵀ Note: This method is misnamed CalcBiasForJacobianSpatialVelocity. Expect a name change to reflect its acceleration (not velocity) nature.

See also
CalcJacobianSpatialVelocity() to compute J𝑠_V_AFp, point Fp's spatial velocity Jacobian in frame A with respect to 𝑠.
Parameters
[in]contextThe state of the multibody system, which includes the generalized positions q and generalized velocities v.
[in]with_respect_toEnum equal to JacobianWrtVariable::kQDot or JacobianWrtVariable::kV, indicating whether the Jacobian J𝑠_v_AFp is partial derivatives with respect to 𝑠 = q̇ (time-derivatives of generalized positions) or with respect to 𝑠 = v (generalized velocities).
[in]frame_FThe frame on which point Fp is fixed/welded.
[in]p_FoFp_Fposition vector from Fo (frame F's origin) to point Fp, expressed in frame F.
[in]frame_AThe frame that measures Abias_AFp. Currently, an exception is thrown if frame_A is not the World frame.
[in]frame_EThe frame in which Abias_AFp is expressed on output.
Returns
Abias_AFp_E Fp's spatial acceleration bias in frame_A is returned in a 6 x 1 matrix whose first three elements are frame_F's angular acceleration bias in frame_A (expressed in frame_E) and whose last three elements are point Fp's translational acceleration bias in frame_A (expressed in frame_E). These bias terms are functions of the generalized positions q and the generalized velocities v and depend on whether with_respect_to is kQDot or kV. Note: Although the return quantity is a Vector6, it is actually a SpatialAcceleration (having units of that type).
Exceptions
std::exceptionif with_respect_to is not JacobianWrtVariable::kV
std::exceptionif frame_A is not the world frame.

◆ CalcBiasForJacobianTranslationalVelocity()

VectorX<T> CalcBiasForJacobianTranslationalVelocity ( const systems::Context< T > &  context,
JacobianWrtVariable  with_respect_to,
const Frame< T > &  frame_F,
const Eigen::Ref< const MatrixX< T >> &  p_FP_list,
const Frame< T > &  frame_A,
const Frame< T > &  frame_E 
) const

For a point Fp that is fixed to a frame F, calculates Fp's translational acceleration "bias" term abias_AFp = J̇s_v_AFp(q, s) * s in frame A with respect to "speeds" 𝑠.

  a_AFp = J𝑠_v_AFp(q)⋅ṡ + abias_AFp(q, v)

a_AFp is point Fp's translational acceleration in frame A and 𝑠 is either q̇ ≜ [q̇₁ ... q̇ⱼ]ᵀ (time-derivatives of generalized positions) or v ≜ [v₁ ... vₖ]ᵀ (generalized velocities). Note: abias_AFp = J̇s_v_AFp(q, s)⋅s  is quadratic in 𝑠 ≜ [𝑠₁ ... 𝑠ₙ]ᵀ Note: This method is misnamed CalcBiasForJacobianTranslationalVelocity. Expect a name change to reflect its acceleration (not velocity) nature.

This method computes abias_AFp for each point Fp in the p_FP_list. The p_FP_list is a list of position vectors from Fo (Frame F's origin) to each such point Fp, expressed in frame F.

See also
CalcJacobianTranslationalVelocity() to compute J𝑠_v_AFp, point Fp's translational velocity Jacobian in frame A with respect to s.
Parameters
[in]contextThe state of the multibody system, which includes the generalized positions q and generalized velocities v.
[in]with_respect_toEnum equal to JacobianWrtVariable::kQDot or JacobianWrtVariable::kV, indicating whether the Jacobian J𝑠_v_AFp is partial derivatives with respect to 𝑠 = q̇ (time-derivatives of generalized positions) or with respect to 𝑠 = v (generalized velocities).
[in]frame_FThe frame on which point Fp is fixed/welded.
[in]p_FP_list3 x n matrix of position vectors p_FoFp_F from Fo (frame F's origin) to each such point Fp, expressed in frame F.
[in]frame_AThe frame that measures abias_AFp. Currently, an exception is thrown if frame_A is not the World frame.
[in]frame_EThe frame in which abias_AFp is expressed on output.
Returns
abias_AFp_E matrix of translational acceleration bias terms in frame_A and expressed in frame_E for each of the n points associated with p_FP_list. These bias terms are functions of the generalized positions q and the generalized velocities v and depend on whether with_respect_to is kQDot or kV.
Exceptions
std::exceptionif p_FP_list does not have 3 rows.
std::exceptionif with_respect_to is not JacobianWrtVariable::kV
std::exceptionif frame_A is not the world frame.

◆ CalcBiasTerm()

void CalcBiasTerm ( const systems::Context< T > &  context,
EigenPtr< VectorX< T >>  Cv 
) const

Computes the bias term C(q, v)v containing Coriolis, centripetal, and gyroscopic effects in the multibody equations of motion:

  M(q) v̇ + C(q, v) v = tau_app + ∑ (Jv_V_WBᵀ(q) ⋅ Fapp_Bo_W)

where M(q) is the multibody model's mass matrix and tau_app is a vector of generalized forces. The last term is a summation over all bodies of the dot-product of Fapp_Bo_W (applied spatial force on body B at Bo) with Jv_V_WB(q) (B's spatial Jacobian in world W with respect to generalized velocities v). Note: B's spatial velocity in W can be written V_WB = Jv_V_WB * v.

Parameters
[in]contextThe context containing the state of the model. It stores the generalized positions q and the generalized velocities v.
[out]CvOn output, Cv will contain the product C(q, v)v. It must be a valid (non-null) pointer to a column vector in ℛⁿ with n the number of generalized velocities (num_velocities()) of the model. This method aborts if Cv is nullptr or if it does not have the proper size.

◆ CalcCenterOfMassPosition() [1/2]

Vector3<T> CalcCenterOfMassPosition ( const systems::Context< T > &  context) const

This method computes the center of mass position p_WCcm of all bodies in MultibodyPlant measured and expressed in world frame W.

The bodies are considered as a single composite body C, whose center of mass composite_mass is located at Ccm. The world_body() is ignored.

Parameters
[in]contextThe context containing the state of the model. It stores the generalized positions q of the model.
Return values
p_WCcmThe output position of center of mass in the world frame W.
Exceptions
std::runtime_errorif MultibodyPlant has no body except world_body().
std::runtime_errorunless composite_mass > 0.

◆ CalcCenterOfMassPosition() [2/2]

Vector3<T> CalcCenterOfMassPosition ( const systems::Context< T > &  context,
const std::vector< ModelInstanceIndex > &  model_instances 
) const

This method computes the center of mass position p_WCcm of specified model instances measured and expressed in world frame W.

The specified model instances are considered as a single composite body C, whose center of mass composite_mass is located at Ccm. The models are selected by a vector of model instances model_instances. This function does not distinguish between welded bodies, joint connected bodies and floating bodies in the model_instances. The world_body() is ignored.

Parameters
[in]contextThe context containing the state of the model. It stores the generalized positions q of the model.
[in]model_instancesThe vector of selected model instances.
Return values
p_WCcmThe output position of center of mass in the world frame W.
Exceptions
std::runtime_errorif MultibodyPlant has no model_instance except world_model_instance().
std::runtime_errorunless composite_mass > 0.

◆ CalcConservativePower()

T CalcConservativePower ( const systems::Context< T > &  context) const

Computes and returns the power generated by conservative forces in the multibody model.

This quantity is defined to be positive when the potential energy is decreasing. In other words, if U(q) is the potential energy as defined by CalcPotentialEnergy(), then the conservative power, Pc, is Pc = -U̇(q).

See also
CalcPotentialEnergy()

◆ CalcForceElementsContribution()

void CalcForceElementsContribution ( const systems::Context< T > &  context,
MultibodyForces< T > *  forces 
) const

Computes the combined force contribution of ForceElement objects in the model.

A ForceElement can apply forces as a spatial force per body or as generalized forces, depending on the ForceElement model. ForceElement contributions are a function of the state and time only. The output from this method can immediately be used as input to CalcInverseDynamics() to include the effect of applied forces by force elements.

Parameters
[in]contextThe context containing the state of this model.
[out]forcesA pointer to a valid, non nullptr, multibody forces object. On output forces will store the forces exerted by all the ForceElement objects in the model.
Exceptions
std::exceptionif forces is null or not compatible with this model, per MultibodyForces::CheckInvariants().

◆ CalcFrameGeometricJacobianExpressedInWorld()

void CalcFrameGeometricJacobianExpressedInWorld ( const systems::Context< T > &  context,
const Frame< T > &  frame_F,
const Eigen::Ref< const Vector3< T >> &  p_FP,
EigenPtr< MatrixX< T >>  J_WFp 
) const

For a point Fp fixed/welded to a frame F, calculates Jv_V_WFp, Fp's spatial velocity Jacobian with respect to generalized velocities v.

Parameters
[in]contextThe context containing the state of the model. It stores the generalized positions q.
[in]frame_FThe position vector p_FoFp is expressed in this frame F.
[in]p_FoFpThe position vector from Fo (frame F's origin) to Fp, expressed in F.
[out]Jv_V_WFpFp's spatial velocity Jacobian with respect to generalized velocities v. V_WFp, Fp's spatial velocity in world frame W, can be written
  V_WFp(q, v) = Jv_V_WFp(q) * v
The Jacobian Jv_V_WFp(q) is a matrix of size 6 x nv, with nv the number of generalized velocities. On input, matrix Jv_WFp must have size 6 x nv or this method throws an exception. The top rows of this matrix (which can be accessed with Jv_WFp.topRows<3>()) is the Jacobian Hw_WFp related to the angular velocity of Fp in W by w_WFp = Hw_WFp⋅v. The bottom rows of this matrix (which can be accessed with Jv_WFp.bottomRows<3>()) is the Jacobian Hv_WFp related to the translational velocity of the origin P of frame Fp in W by v_WFpo = Hv_WFp⋅v. This ordering is consistent with the internal storage of the SpatialVelocity class. Therefore the following operations results in a valid spatial velocity:
    SpatialVelocity<double> Jv_WFp_times_v(Jv_WFp * v);
  
Exceptions
std::exceptionif J_WFp is nullptr or if it is not of size 6 x nv. (Deprecated.)
Deprecated:
"Use CalcJacobianSpatialVelocity()."
This will be removed from Drake on or after "2020-02-01" .

◆ CalcGravityGeneralizedForces()

VectorX<T> CalcGravityGeneralizedForces ( const systems::Context< T > &  context) const

Computes the generalized forces tau_g(q) due to gravity as a function of the generalized positions q stored in the input context.

The vector of generalized forces due to gravity tau_g(q) is defined such that it appears on the right hand side of the equations of motion together with any other generalized forces, like so:

  Mv̇ + C(q, v)v = tau_g(q) + tau_app

where tau_app includes any other generalized forces applied on the system.

Parameters
[in]contextThe context storing the state of the model.
Returns
tau_g A vector containing the generalized forces due to gravity. The generalized forces are consistent with the vector of generalized velocities v for this so that the inner product v⋅tau_g corresponds to the power applied by the gravity forces on the mechanical system. That is, v⋅tau_g > 0 corresponds to potential energy going into the system, as either mechanical kinetic energy, some other potential energy, or heat, and therefore to a decrease of the gravitational potential energy.

◆ CalcInverseDynamics()

VectorX<T> CalcInverseDynamics ( const systems::Context< T > &  context,
const VectorX< T > &  known_vdot,
const MultibodyForces< T > &  external_forces 
) const

Given the state of this model in context and a known vector of generalized accelerations vdot, this method computes the set of generalized forces tau that would need to be applied in order to attain the specified generalized accelerations.

Mathematically, this method computes:

  tau = M(q)v̇ + C(q, v)v - tau_app - ∑ J_WBᵀ(q) Fapp_Bo_W

where M(q) is the model's mass matrix, C(q, v)v is the bias term containing Coriolis and gyroscopic effects and tau_app consists of a vector applied generalized forces. The last term is a summation over all bodies in the model where Fapp_Bo_W is an applied spatial force on body B at Bo which gets projected into the space of generalized forces with the transpose of Jv_V_WB(q) (where Jv_V_WB is B's spatial velocity Jacobian in W with respect to generalized velocities v). Note: B's spatial velocity in W can be written as V_WB = Jv_V_WB * v. This method does not compute explicit expressions for the mass matrix nor for the bias term, which would be of at least O(n²) complexity, but it implements an O(n) Newton-Euler recursive algorithm, where n is the number of bodies in the model. The explicit formation of the mass matrix M(q) would require the calculation of O(n²) entries while explicitly forming the product C(q, v) * v could require up to O(n³) operations (see [Featherstone 1987, §4]), depending on the implementation. The recursive Newton-Euler algorithm is the most efficient currently known general method for solving inverse dynamics [Featherstone 2008].

Parameters
[in]contextThe context containing the state of the model.
[in]known_vdotA vector with the known generalized accelerations vdot for the full model. Use the provided Joint APIs in order to access entries into this array.
[in]external_forcesA set of forces to be applied to the system either as body spatial forces Fapp_Bo_W or generalized forces tau_app, see MultibodyForces for details.
Returns
the vector of generalized forces that would need to be applied to the mechanical system in order to achieve the desired acceleration given by known_vdot.

◆ CalcJacobianAngularVelocity()

void CalcJacobianAngularVelocity ( const systems::Context< T > &  context,
const JacobianWrtVariable  with_respect_to,
const Frame< T > &  frame_B,
const Frame< T > &  frame_A,
const Frame< T > &  frame_E,
EigenPtr< Matrix3X< T >>  Js_w_AB_E 
) const

Calculates J𝑠_w_AB, a frame B's angular velocity Jacobian in a frame A with respect to "speeds" 𝑠.

     J𝑠_w_AB = [ ∂(w_AB)/∂𝑠₁,  ...  ∂(w_AB)/∂𝑠ₙ ]    (n is j or k)

w_AB is B's angular velocity in frame A and "speeds" 𝑠 is either q̇ ≜ [q̇₁ ... q̇ⱼ]ᵀ (time-derivatives of j generalized positions) or v ≜ [v₁ ... vₖ]ᵀ (k generalized velocities). Note: w_AB = J𝑠_w_AB * 𝑠  which is linear in 𝑠 ≜ [𝑠₁ ... 𝑠ₙ]ᵀ.

Parameters
[in]contextThe state of the multibody system.
[in]with_respect_toEnum equal to JacobianWrtVariable::kQDot or JacobianWrtVariable::kV, indicating whether the Jacobian J𝑠_w_AB is partial derivatives with respect to 𝑠 = q̇ (time-derivatives of generalized positions) or with respect to 𝑠 = v (generalized velocities).
[in]frame_BThe frame B in w_AB (B's angular velocity in A).
[in]frame_AThe frame A in w_AB (B's angular velocity in A).
[in]frame_EThe frame in which w_AB is expressed on input and the frame in which the Jacobian J𝑠_w_AB is expressed on output.
[out]J𝑠_w_AB_EFrame B's angular velocity Jacobian in frame A with respect to speeds 𝑠 (which is either q̇ or v), expressed in frame E. The Jacobian is a function of only generalized positions q (which are pulled from the context). The previous definition shows J𝑠_w_AB_E is a matrix of size 3 x n, where n is the number of elements in 𝑠.
Exceptions
std::exceptionif J𝑠_w_AB_E is nullptr or not of size 3 x n.

◆ CalcJacobianSpatialVelocity()

void CalcJacobianSpatialVelocity ( const systems::Context< T > &  context,
JacobianWrtVariable  with_respect_to,
const Frame< T > &  frame_B,
const Eigen::Ref< const Vector3< T >> &  p_BoBi_B,
const Frame< T > &  frame_A,
const Frame< T > &  frame_E,
EigenPtr< MatrixX< T >>  Jw_ABp_E 
) const

For each point Bi of (fixed to) a frame B, calculates J𝑠_V_ABi, Bi's spatial velocity Jacobian in frame A with respect to "speeds" 𝑠.

     J𝑠_V_ABi = [ ∂(V_ABi)/∂𝑠₁,  ...  ∂(V_ABi)/∂𝑠ₙ ]    (n is j or k)

V_ABi is Bi's spatial velocity in frame A and "speeds" 𝑠 is either q̇ ≜ [q̇₁ ... q̇ⱼ]ᵀ (time-derivatives of j generalized positions) or v ≜ [v₁ ... vₖ]ᵀ (k generalized velocities). Note: V_ABi = J𝑠_V_ABi ⋅ 𝑠  which is linear in 𝑠 ≜ [𝑠₁ ... 𝑠ₙ]ᵀ.

Parameters
[in]contextThe state of the multibody system.
[in]with_respect_toEnum equal to JacobianWrtVariable::kQDot or JacobianWrtVariable::kV, indicating whether the Jacobian J𝑠_V_ABi is partial derivatives with respect to 𝑠 = q̇ (time-derivatives of generalized positions) or with respect to 𝑠 = v (generalized velocities).
[in]frame_BThe frame on which point Bi is fixed (e.g., welded).
[in]p_BoBi_BA position vector or list of p position vectors from Bo (frame_B's origin) to points Bi (regarded as fixed to B), where each position vector is expressed in frame_B.
[in]frame_AThe frame that measures v_ABi (Bi's velocity in A). Note: It is natural to wonder why there is no parameter p_AoAi_A (similar to the parameter p_BoBi_B for frame_B). There is no need for p_AoAi_A because Bi's velocity in A is defined as the derivative in frame A of Bi's position vector from any point fixed on A.
[in]frame_EThe frame in which v_ABi is expressed on input and the frame in which the Jacobian J𝑠_V_ABi is expressed on output.
[out]J𝑠_V_ABi_EPoint Bi's spatial velocity Jacobian in frame A with respect to speeds 𝑠 (which is either q̇ or v), expressed in frame E. J𝑠_V_ABi_E is a 6*p x n matrix, where p is the number of points Bi and n is the number of elements in 𝑠. The Jacobian is a function of only generalized positions q (which are pulled from the context). Note: If p = 1 (one point), a 6 x n matrix is returned with the first three rows storing frame B's angular velocity Jacobian in A and rows 4-6 storing point Bi's translational velocity Jacobian in A, i.e.,
J𝑠_wAB_E = J𝑠_V_ABi_E.topRows<3>();
J𝑠_vAB1_E = J𝑠_V_ABi_E.bottomRows<3>();
If p = 2 (two points), a 12 x n matrix is returned. Rows 1-3 and 7-9 store exactly identical information (B's angular velocity Jacobian in A). Rows 4-6 store point B1's translational velocity Jacobian which differs from rows 10-12 which store point B2's translational velocity Jacobian. If p is large and storage efficiency is a concern, calculate frame B's angular velocity Jacobian using CalcJacobianAngularVelocity() and then use CalcJacobianTranslationalVelocity().
Exceptions
std::exceptionif J𝑠_V_ABi_E is nullptr or not sized 3*p x n.

◆ CalcJacobianTranslationalVelocity()

void CalcJacobianTranslationalVelocity ( const systems::Context< T > &  context,
JacobianWrtVariable  with_respect_to,
const Frame< T > &  frame_B,
const Eigen::Ref< const Matrix3X< T >> &  p_BoBi_B,
const Frame< T > &  frame_A,
const Frame< T > &  frame_E,
EigenPtr< MatrixX< T >>  Js_v_ABi_E 
) const

For each point Bi of (fixed to) a frame B, calculates J𝑠_v_ABi, Bi's translational velocity Jacobian in frame A with respect to "speeds" 𝑠.

     J𝑠_v_ABi = [ ∂(v_ABi)/∂𝑠₁,  ...  ∂(v_ABi)/∂𝑠ₙ ]    (n is j or k)

v_ABi is Bi's translational velocity in frame A and "speeds" 𝑠 is either q̇ ≜ [q̇₁ ... q̇ⱼ]ᵀ (time-derivatives of j generalized positions) or v ≜ [v₁ ... vₖ]ᵀ (k generalized velocities). Note: v_ABi = J𝑠_v_ABi ⋅ 𝑠  which is linear in 𝑠 ≜ [𝑠₁ ... 𝑠ₙ]ᵀ.

Parameters
[in]contextThe state of the multibody system.
[in]with_respect_toEnum equal to JacobianWrtVariable::kQDot or JacobianWrtVariable::kV, indicating whether the Jacobian J𝑠_v_ABi is partial derivatives with respect to 𝑠 = q̇ (time-derivatives of generalized positions) or with respect to 𝑠 = v (generalized velocities).
[in]frame_BThe frame on which point Bi is fixed (e.g., welded).
[in]p_BoBi_BA position vector or list of p position vectors from Bo (frame_B's origin) to points Bi (regarded as fixed to B), where each position vector is expressed in frame_B.
[in]frame_AThe frame that measures v_ABi (Bi's velocity in A). Note: It is natural to wonder why there is no parameter p_AoAi_A (similar to the parameter p_BoBi_B for frame_B). There is no need for p_AoAi_A because Bi's velocity in A is defined as the derivative in frame A of Bi's position vector from any point fixed on A.
[in]frame_EThe frame in which v_ABi is expressed on input and the frame in which the Jacobian J𝑠_v_ABi is expressed on output.
[out]J𝑠_v_ABi_EPoint Bi's velocity Jacobian in frame A with respect to speeds 𝑠 (which is either q̇ or v), expressed in frame E. J𝑠_v_ABi_E is a 3*p x n matrix, where p is the number of points Bi and n is the number of elements in 𝑠. The Jacobian is a function of only generalized positions q (which are pulled from the context).
Exceptions
std::exceptionif J𝑠_v_ABi_E is nullptr or not sized 3*p x n.
Note
When 𝑠 = q̇, Jq̇_v_ABi = Jq_p_AoBi. In other words, point Bi's velocity Jacobian in frame A with respect to q̇ is equal to point Bi's position Jacobian from Ao (A's origin) in frame A with respect to q.
[∂(v_ABi)/∂q̇₁,  ...  ∂(v_ABi)/∂q̇ⱼ] = [∂(p_AoBi)/∂q₁,  ...  ∂(p_AoBi)/∂qⱼ]
Note: Each partial derivative of p_AoBi is taken in frame A.

◆ CalcMassMatrixViaInverseDynamics()

void CalcMassMatrixViaInverseDynamics ( const systems::Context< T > &  context,
EigenPtr< MatrixX< T >>  H 
) const

Performs the computation of the mass matrix M(q) of the model using inverse dynamics, where the generalized positions q are stored in context.

See CalcInverseDynamics().

Parameters
[in]contextThe context containing the state of the model.
[out]HA valid (non-null) pointer to a squared matrix in ℛⁿˣⁿ with n the number of generalized velocities (num_velocities()) of the model. This method aborts if H is nullptr or if it does not have the proper size.

The algorithm used to build M(q) consists in computing one column of M(q) at a time using inverse dynamics. The result from inverse dynamics, with no applied forces, is the vector of generalized forces:

  tau = M(q)v̇ + C(q, v)v

where q and v are the generalized positions and velocities, respectively. When v = 0 the Coriolis and gyroscopic forces term C(q, v)v is zero. Therefore the i-th column of M(q) can be obtained performing inverse dynamics with an acceleration vector v̇ = eᵢ, with eᵢ the standard (or natural) basis of ℛⁿ with n the number of generalized velocities. We write this as:

  H.ᵢ(q) = M(q) * e_i

where H.ᵢ(q) (notice the dot for the rows index) denotes the i-th column in M(q).

Warning
This is an O(n²) algorithm. Avoid the explicit computation of the mass matrix whenever possible.

◆ CalcPointsPositions()

void CalcPointsPositions ( const systems::Context< T > &  context,
const Frame< T > &  frame_B,
const Eigen::Ref< const MatrixX< T >> &  p_BQi,
const Frame< T > &  frame_A,
EigenPtr< MatrixX< T >>  p_AQi 
) const

Given the positions p_BQi for a set of points Qi measured and expressed in a frame B, this method computes the positions p_AQi(q) of each point Qi in the set as measured and expressed in another frame A, as a function of the generalized positions q of the model.

Parameters
[in]contextThe context containing the state of the model. It stores the generalized positions q of the model.
[in]frame_BThe frame B in which the positions p_BQi of a set of points Qi are given.
[in]p_BQiThe input positions of each point Qi in frame B. p_BQi ∈ ℝ³ˣⁿᵖ with np the number of points in the set. Each column of p_BQi corresponds to a vector in ℝ³ holding the position of one of the points in the set as measured and expressed in frame B.
[in]frame_AThe frame A in which it is desired to compute the positions p_AQi of each point Qi in the set.
[out]p_AQiThe output positions of each point Qi now computed as measured and expressed in frame A. The output p_AQi must have the same size as the input p_BQi or otherwise this method aborts. That is p_AQi must be in ℝ³ˣⁿᵖ.
Note
Both p_BQi and p_AQi must have three rows. Otherwise this method will throw a std::runtime_error exception. This method also throws a std::runtime_error exception if p_BQi and p_AQi differ in the number of columns.

◆ CalcPotentialEnergy()

T CalcPotentialEnergy ( const systems::Context< T > &  context) const

Computes and returns the total potential energy stored in this multibody model for the configuration given by context.

Parameters
[in]contextThe context containing the state of the model.
Returns
The total potential energy stored in this multibody model.

◆ CalcRelativeRotationMatrix()

math::RotationMatrix<T> CalcRelativeRotationMatrix ( const systems::Context< T > &  context,
const Frame< T > &  frame_F,
const Frame< T > &  frame_G 
) const

Calculates the rotation matrix R_FG relating frame F and frame G.

Parameters
[in]contextThe state of the multibody system, which includes the system's generalized positions q. Note: R_FG is a function of q.
[in]frame_FThe frame F designated in the rigid transform R_FG.
[in]frame_GThe frame G designated in the rigid transform R_FG.
Return values
R_FGThe RigidTransform relating frame F and frame G.

◆ CalcRelativeTransform()

math::RigidTransform<T> CalcRelativeTransform ( const systems::Context< T > &  context,
const Frame< T > &  frame_F,
const Frame< T > &  frame_G 
) const

Calculates the rigid transform (pose) X_FG relating frame F and frame G.

Parameters
[in]contextThe state of the multibody system, which includes the system's generalized positions q. Note: X_FG is a function of q.
[in]frame_FThe frame F designated in the rigid transform X_FG.
[in]frame_GThe frame G designated in the rigid transform X_FG.
Return values
X_FGThe RigidTransform relating frame F and frame G.

◆ CalcSpatialAccelerationsFromVdot()

void CalcSpatialAccelerationsFromVdot ( const systems::Context< T > &  context,
const VectorX< T > &  known_vdot,
std::vector< SpatialAcceleration< T >> *  A_WB_array 
) const

Given the state of this model in context and a known vector of generalized accelerations known_vdot, this method computes the spatial acceleration A_WB for each body as measured and expressed in the world frame W.

Parameters
[in]contextThe context containing the state of this model.
[in]known_vdotA vector with the generalized accelerations for the full model.
[out]A_WB_arrayA pointer to a valid, non nullptr, vector of spatial accelerations containing the spatial acceleration A_WB for each body. It must be of size equal to the number of bodies in the model. On output, entries will be ordered by BodyIndex.
Exceptions
std::exceptionif A_WB_array is not of size num_bodies().

◆ CollectRegisteredGeometries()

geometry::GeometrySet CollectRegisteredGeometries ( const std::vector< const Body< T > * > &  bodies) const

For each of the provided bodies, collects up all geometries that have been registered to that body.

Intended to be used in conjunction with SceneGraph::ExcludeCollisionsWithin() and SceneGraph::ExcludeCollisionsBetween() to filter collisions between the geometries registered to the bodies.

For example:

// Don't report on collisions between geometries affixed to `body1`,
// `body2`, or `body3`.
std::vector<const RigidBody<T>*> bodies{&body1, &body2, &body3};
geometry::GeometrySet set = plant.CollectRegisteredGeometries(bodies);
scene_graph.ExcludeCollisionsWithin(set);
Note
There is a very specific order of operations:
  1. Bodies and geometries must be added to the MultibodyPlant.
  2. The MultibodyPlant must be finalized (via Finalize()).
  3. Create GeometrySet instances from bodies (via this method).
  4. Invoke SceneGraph::ExcludeCollisions*() to filter collisions.
  5. Allocate context.

Changing the order will cause exceptions to be thrown.

Exceptions
std::exceptionif called pre-finalize.

◆ default_coulomb_friction()

const CoulombFriction<double>& default_coulomb_friction ( geometry::GeometryId  id) const

Returns the friction coefficients provided during geometry registration for the given geometry id.

We call these the "default" coefficients but note that we mean user-supplied per-geometry default, not something more global.

Exceptions
std::exceptionif id does not correspond to a geometry in this model registered for contact modeling.
See also
RegisterCollisionGeometry() for details on geometry registration.

◆ EvalBodyPoseInWorld()

const math::RigidTransform<T>& EvalBodyPoseInWorld ( const systems::Context< T > &  context,
const Body< T > &  body_B 
) const

Evaluate the pose X_WB of a body B in the world frame W.

Parameters
[in]contextThe context storing the state of the model.
[in]body_BThe body B for which the pose is requested.
Return values
X_WBThe pose of body frame B in the world frame W.
Exceptions
std::exceptionif Finalize() was not called on this model or if body_B does not belong to this model.

◆ EvalBodySpatialVelocityInWorld()

const SpatialVelocity<T>& EvalBodySpatialVelocityInWorld ( const systems::Context< T > &  context,
const Body< T > &  body_B 
) const

Evaluate the spatial velocity V_WB of a body B in the world frame W.

Parameters
[in]contextThe context storing the state of the model.
[in]body_BThe body B for which the spatial velocity is requested.
Returns
V_WB The spatial velocity of body frame B in the world frame W.
Exceptions
std::exceptionif Finalize() was not called on this model or if body_B does not belong to this model.

◆ EvalPointPairPenetrations()

const std::vector<geometry::PenetrationAsPointPair<T> >& EvalPointPairPenetrations ( const systems::Context< T > &  context) const

Evaluates all point pairs of contact for a given state of the model stored in context.

Each entry in the returned vector corresponds to a single point pair corresponding to two interpenetrating bodies A and B. The size of the returned vector corresponds to the total number of contact penetration pairs. If no geometry was registered, the output vector is empty.

See also
PenetrationAsPointPair for further details on the returned data.
Exceptions
std::exceptionif called pre-finalize. See Finalize().

◆ Finalize()

void Finalize ( )

This method must be called after all elements in the model (joints, bodies, force elements, constraints, etc.) are 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 enable computations at a later stage.

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

At Finalize(), state and input/output ports for this plant are declared. If this plant registered geometry with a SceneGraph, input and output ports to enable communication with that SceneGraph are declared as well.

If geometry has been registered on a SceneGraph instance, that instance must be provided to the Finalize() method so that any geometric implications of the finalization process can be appropriately handled.

See also
is_finalized().
Exceptions
std::logic_errorif the MultibodyPlant has already been finalized.

◆ geometry_source_is_registered()

bool geometry_source_is_registered ( ) const

Returns true if this MultibodyPlant was registered with a SceneGraph.

This method can be called at any time during the lifetime of this plant to query if this plant has been registered with a SceneGraph, either pre- or post-finalize, see Finalize().

◆ get_actuation_input_port() [1/2]

const systems::InputPort< T > & get_actuation_input_port ( ) const

Returns a constant reference to the input port for external actuation for the case where only one model instance has actuated dofs.

This input port is a vector valued port, which can be set with JointActuator::set_actuation_vector().

Precondition
Finalize() was already called on this plant.
Exceptions
std::exceptionif called before Finalize(), if the model does not contain any actuators, or if multiple model instances have actuated dofs.

◆ get_actuation_input_port() [2/2]

const systems::InputPort< T > & get_actuation_input_port ( ModelInstanceIndex  model_instance) const

Returns a constant reference to the input port for external actuation for a specific model instance.

This input port is a vector valued port, which can be set with JointActuator::set_actuation_vector().

Precondition
Finalize() was already called on this plant.
Exceptions
std::exceptionif called before Finalize().
std::exceptionif the model instance does not exist.

◆ get_applied_generalized_force_input_port()

const systems::InputPort< T > & get_applied_generalized_force_input_port ( ) const

Returns a constant reference to the vector-valued input port for applied generalized forces, and the vector will be added directly into tau (see System dynamics).

This vector is ordered using the same convention as the plant velocities: you can set the generalized forces that will be applied to model instance i using, e.g., SetVelocitiesInArray(i, model_forces, &force_array).

Exceptions
std::exceptionif called before Finalize().

◆ get_applied_spatial_force_input_port()

const systems::InputPort< T > & get_applied_spatial_force_input_port ( ) const

Returns a constant reference to the input port for applying spatial forces to bodies in the plant.

The data type for the port is an std::vector of ExternallyAppliedSpatialForce; any number of spatial forces can be applied to any number of bodies in the plant.

◆ get_body()

const Body<T>& get_body ( BodyIndex  body_index) const

Returns a constant reference to the body with unique index body_index.

Exceptions
std::exceptionif body_index does not correspond to a body in this model.

◆ get_contact_model()

ContactModel get_contact_model ( ) const

Returns the model used for contact. See documentation for ContactModel.

◆ get_contact_penalty_method_time_scale()

double get_contact_penalty_method_time_scale ( ) const

Returns a time-scale estimate tc based on the requested penetration allowance δ set with set_penetration_allowance().

For the penalty method in use to enforce non-penetration, this time scale relates to the time it takes the relative normal velocity between two bodies to go to zero. This time scale tc is artificially introduced by the penalty method and goes to zero in the limit to ideal rigid contact. Since numerical integration methods for continuum systems must be able to resolve a system's dynamics, the time step used by an integrator must in general be much smaller than the time scale tc. How much smaller will depend on the details of the problem and the convergence characteristics of the integrator and should be tuned appropriately. Another factor to take into account for setting up the simulation's time step is the speed of the objects in your simulation. If vn represents a reference velocity scale for the normal relative velocity between bodies, the new time scale tn = δ / vn represents the time it would take for the distance between two bodies approaching with relative normal velocity vn to decrease by the penetration_allowance δ. In this case a user should choose a time step for simulation that can resolve the smallest of the two time scales tc and tn.

◆ get_contact_results_output_port()

const systems::OutputPort< T > & get_contact_results_output_port ( ) const

Returns a constant reference to the port that outputs ContactResults.

Exceptions
std::exceptionif called pre-finalize, see Finalize().

◆ get_frame()

const Frame<T>& get_frame ( FrameIndex  frame_index) const

Returns a constant reference to the frame with unique index frame_index.

Exceptions
std::exceptionif frame_index does not correspond to a frame in this plant.

◆ get_generalized_contact_forces_output_port()

const systems::OutputPort< T > & get_generalized_contact_forces_output_port ( ModelInstanceIndex  model_instance) const

Returns a constant reference to the output port of generalized contact forces for a specific model instance.

Precondition
Finalize() was already called on this plant.
Exceptions
std::exceptionif called before Finalize() or if the model instance does not have any generalized velocities.
std::exceptionif the model instance does not exist.

◆ get_geometry_poses_output_port()

const OutputPort< T > & get_geometry_poses_output_port ( ) const

Returns the output port of frames' poses to communicate with a SceneGraph.

Exceptions
std::exceptionif this system was not registered with a SceneGraph.

◆ get_geometry_query_input_port()

const systems::InputPort< T > & get_geometry_query_input_port ( ) const

Returns a constant reference to the input port used to perform geometric queries on a SceneGraph.

See SceneGraph::get_query_output_port(). Refer to section Registering geometry with a SceneGraph of this class's documentation for further details on collision geometry registration and connection with a SceneGraph.

Exceptions
std::exceptionif this system was not registered with a SceneGraph.

◆ get_joint()

const Joint<T>& get_joint ( JointIndex  joint_index) const

Returns a constant reference to the joint with unique index joint_index.

Exceptions
std::runtime_errorwhen joint_index does not correspond to a joint in this model.

◆ get_joint_actuator()

const JointActuator<T>& get_joint_actuator ( JointActuatorIndex  actuator_index) const

Returns a constant reference to the joint actuator with unique index actuator_index.

Exceptions
std::exceptionif actuator_index does not correspond to a joint actuator in this tree.

◆ get_mutable_joint()

Joint<T>& get_mutable_joint ( JointIndex  joint_index)

Returns a mutable reference to the joint with unique index joint_index.

Exceptions
std::runtime_errorwhen joint_index does not correspond to a joint in this model.

◆ get_reaction_forces_output_port()

const systems::OutputPort< T > & get_reaction_forces_output_port ( ) const

Returns the port for joint reaction forces.

A Joint models the kinematical relationship which characterizes the possible relative motion between two bodies. In Drake, a joint connects a frame Jp on parent body P with a frame Jc on a child body C. This usage of the terms parent and child is just a convention and implies nothing about the inboard-outboard relationship between the bodies. Since a Joint imposes a kinematical relationship which characterizes the possible relative motion between frames Jp and Jc, reaction forces on each body are established. That is, we could cut the model at the joint and replace it with equivalent forces equal to these reaction forces in order to attain the same motions of the mechanical system.

This output port allows to evaluate the reaction force F_CJc_Jc on the child body C, at Jc, and expressed in Jc for all joints in the model. This port evaluates to a vector of type std::vector<SpatialForce<T>> and size num_joints() indexed by JointIndex, see Joint::index(). Each entry corresponds to the spatial force F_CJc_Jc applied on the joint's child body C (Joint::child_body()), at the joint's child frame Jc (Joint::frame_on_child()) and expressed in frame Jc.

Exceptions
std::exceptionif called pre-finalize.

◆ get_source_id()

optional<geometry::SourceId> get_source_id ( ) const

Returns the unique id identifying this plant as a source for a SceneGraph.

Returns nullopt if this plant did not register any geometry. This method can be called at any time during the lifetime of this plant to query if this plant has been registered with a SceneGraph, either pre- or post-finalize, see Finalize(). However, a geometry::SourceId is only assigned once at the first call of any of this plant's geometry registration methods, and it does not change after that. Post-finalize calls will always return the same value.

◆ get_state_output_port() [1/2]

const systems::OutputPort< T > & get_state_output_port ( ) const

Returns a constant reference to the output port for the full state x = [q v] of the model.

Precondition
Finalize() was already called on this plant.

◆ get_state_output_port() [2/2]

const systems::OutputPort< T > & get_state_output_port ( ModelInstanceIndex  model_instance) const

Returns a constant reference to the output port for the state of a specific model instance.

Precondition
Finalize() was already called on this plant.
Exceptions
std::exceptionif called before Finalize() or if the model instance does not have any state.
std::exceptionif the model instance does not exist.

◆ GetAccelerationLowerLimits()

VectorX<double> GetAccelerationLowerLimits ( ) const

Returns a vector of size num_velocities() containing the lower acceleration limits for every generalized velocity coordinate.

These include joint and floating base coordinates. Any unbounded or unspecified limits will be -infinity.

Exceptions
std::logic_errorif called pre-finalize.

◆ GetAccelerationUpperLimits()

VectorX<double> GetAccelerationUpperLimits ( ) const

Upper limit analog of GetAccelerationsLowerLimits(), where any unbounded or unspecified limits will be +infinity.

See also
GetAccelerationLowerLimits() for more information.

◆ GetBodiesWeldedTo()

std::vector< const Body< T > * > GetBodiesWeldedTo ( const Body< T > &  body) const

Returns all bodies that are transitively welded, or rigidly affixed, to body, per these two definitions:

  1. A body is always considered welded to itself.
  2. Two unique bodies are considered welded together exclusively by the presence of a weld joint, not by other constructs that prevent mobility (e.g. constraints).

This method can be called at any time during the lifetime of this plant, either pre- or post-finalize, see Finalize().

Meant to be used with CollectRegisteredGeometries.

The following example demonstrates filtering collisions between all bodies rigidly affixed to a door (which could be moving) and all bodies rigidly affixed to the world:

GeometrySet g_world = plant.CollectRegisteredGeometries(
plant.GetBodiesWeldedTo(plant.world_body()));
GeometrySet g_door = plant.CollectRegisteredGeometries(
plant.GetBodiesWeldedTo(plant.GetBodyByName("door")));
scene_graph.ExcludeCollisionsBetweeen(g_world, g_door);
Note
Usages akin to this example may introduce redundant collision filtering; this will not have a functional impact, but may have a minor performance impact.
Returns
all bodies rigidly fixed to body. This does not return the bodies in any prescribed order.
Exceptions
std::exceptionif body is not part of this plant.

◆ GetBodyByName() [1/2]

const Body<T>& GetBodyByName ( const std::string &  name) const

These queries can be performed at any time during the lifetime of a MultibodyPlant, i.e.

there is no restriction on whether they must be called before or after Finalize(). This implies that these queries can be performed while new multibody elements are being added to the model.

If the named element is present in more than one model instance and a model instance is not explicitly specified, std::logic_error is thrown.Returns a constant reference to a body that is identified by the string name in this MultibodyPlant.

Exceptions
std::logic_errorif there is no body with the requested name.
std::logic_errorif the body name occurs in multiple model instances.
See also
HasBodyNamed() to query if there exists a body in this MultibodyPlant with a given specified name.

◆ GetBodyByName() [2/2]

const Body<T>& GetBodyByName ( const std::string &  name,
ModelInstanceIndex  model_instance 
) const

Returns a constant reference to the body that is uniquely identified by the string name and model_instance in this MultibodyPlant.

Exceptions
std::logic_errorif there is no body with the requested name.
See also
HasBodyNamed() to query if there exists a body in this MultibodyPlant with a given specified name.

◆ GetBodyFrameIdIfExists()

optional<geometry::FrameId> GetBodyFrameIdIfExists ( BodyIndex  body_index) const

If the body with body_index has geometry registered with it, it returns the geometry::FrameId associated with it.

Otherwise, it returns nullopt.

◆ GetBodyFrameIdOrThrow()

geometry::FrameId GetBodyFrameIdOrThrow ( BodyIndex  body_index) const

If the body with body_index has geometry registered with it, it returns the geometry::FrameId associated with it.

Otherwise this method throws an exception.

Exceptions
std::exceptionif no geometry has been registered with the body indicated by body_index.

◆ GetBodyFromFrameId()

const Body<T>* GetBodyFromFrameId ( geometry::FrameId  frame_id) const

Given a geometry frame identifier, returns a pointer to the body associated with that id (nullptr if there is no such body).

◆ GetBodyIndices()

std::vector<BodyIndex> GetBodyIndices ( ModelInstanceIndex  model_instance) const

Returns a list of body indices associated with model_instance.

◆ GetCollisionGeometriesForBody()

const std::vector< geometry::GeometryId > & GetCollisionGeometriesForBody ( const Body< T > &  body) const

Returns an array of GeometryId's identifying the different contact geometries for body previously registered with a SceneGraph.

Note
This method can be called at any time during the lifetime of this plant, either pre- or post-finalize, see Finalize(). Post-finalize calls will always return the same value.
See also
RegisterCollisionGeometry(), Finalize()

◆ GetFloatingBaseBodies()

std::unordered_set< BodyIndex > GetFloatingBaseBodies ( ) const

Returns the set of body indexes corresponding to the "floating bodies" in the model, in no particular order.

Exceptions
std::exceptionif called pre-finalize, see Finalize().

◆ GetFrameByName() [1/2]

const Frame<T>& GetFrameByName ( const std::string &  name) const

Returns a constant reference to a frame that is identified by the string name in this model.

Exceptions
std::logic_errorif there is no frame with the requested name.
std::logic_errorif the frame name occurs in multiple model instances.
See also
HasFrameNamed() to query if there exists a frame in this model with a given specified name.

◆ GetFrameByName() [2/2]

const Frame<T>& GetFrameByName ( const std::string &  name,
ModelInstanceIndex  model_instance 
) const

Returns a constant reference to the frame that is uniquely identified by the string name in model_instance.

Exceptions
std::logic_errorif there is no frame with the requested name.
std::runtime_errorif model_instance is not valid for this model.
See also
HasFrameNamed() to query if there exists a frame in this model with a given specified name.

◆ GetFreeBodyPose()

math::RigidTransform<T> GetFreeBodyPose ( const systems::Context< T > &  context,
const Body< T > &  body 
) const

Gets the pose of a given body in the world frame W.

Note
In general getting the pose of a body in the model would involve solving the kinematics. This method allows us to simplify this process when we know the body is free in space.
Exceptions
std::exceptionif body is not a free body in the model.
std::exceptionif called pre-finalize.

◆ GetJointActuatorByName() [1/2]

const JointActuator<T>& GetJointActuatorByName ( const std::string &  name) const

Returns a constant reference to an actuator that is identified by the string name in this MultibodyPlant.

Exceptions
std::logic_errorif there is no actuator with the requested name.
std::logic_errorif the actuator name occurs in multiple model instances.
See also
HasJointActuatorNamed() to query if there exists an actuator in this MultibodyPlant with a given specified name.

◆ GetJointActuatorByName() [2/2]

const JointActuator<T>& GetJointActuatorByName ( const std::string &  name,
ModelInstanceIndex  model_instance 
) const

Returns a constant reference to the actuator that is uniquely identified by the string name and model_instance in this MultibodyPlant.

Exceptions
std::logic_errorif there is no actuator with the requested name.
std::exceptionif model_instance is not valid for this model.
See also
HasJointActuatorNamed() to query if there exists an actuator in this MultibodyPlant with a given specified name.

◆ GetJointByName()

const JointType<T>& GetJointByName ( const std::string &  name,
optional< ModelInstanceIndex model_instance = nullopt 
) const

Returns a constant reference to a joint that is identified by the string name in this MultibodyPlant.

If the optional template argument is supplied, then the returned value is downcast to the specified JointType.

Template Parameters
JointTypeThe specific type of the Joint to be retrieved. It must be a subclass of Joint.
Exceptions
std::logic_errorif the named joint is not of type JointType or if there is no Joint with that name.
std::exceptionif model_instance is not valid for this model.
See also
HasJointNamed() to query if there exists a joint in this MultibodyPlant with a given specified name.

◆ GetJointIndices()

std::vector<JointIndex> GetJointIndices ( ModelInstanceIndex  model_instance) const

Returns a list of joint indices associated with model_instance.

◆ GetModelInstanceByName()

ModelInstanceIndex GetModelInstanceByName ( const std::string &  name) const

Returns the index to the model instance that is uniquely identified by the string name in this MultibodyPlant.

Exceptions
std::logic_errorif there is no instance with the requested name.
See also
HasModelInstanceNamed() to query if there exists an instance in this MultibodyPlant with a given specified name.

◆ GetModelInstanceName()

const std::string& GetModelInstanceName ( ModelInstanceIndex  model_instance) const

Returns the name of a model_instance.

Exceptions
std::logic_errorwhen model_instance does not correspond to a model in this model.

◆ GetMutableJointByName()

JointType<T>& GetMutableJointByName ( const std::string &  name,
optional< ModelInstanceIndex model_instance = nullopt 
)

A version of GetJointByName that returns a mutable reference.

See also
GetJointByName.

◆ GetMutablePositions() [1/2]

Eigen::VectorBlock<VectorX<T> > GetMutablePositions ( systems::Context< T > *  context) const

(Advanced) Returns a mutable vector reference containing the vector of generalized positions (see warning).

Note
This method returns a reference to existing data, exhibits constant i.e., O(1) time complexity, and runs very quickly.
Warning
You should use SetPositions() instead of this method unless you are fully aware of the possible interactions with the caching mechanism (see dangerous_get_mutable).
Exceptions
std::exceptionif the context is nullptr or if it does not correspond to the context for a multibody model.

◆ GetMutablePositions() [2/2]

Eigen::VectorBlock<VectorX<T> > GetMutablePositions ( const systems::Context< T > &  context,
systems::State< T > *  state 
) const

(Advanced) Returns a mutable vector reference containing the vector of generalized positions (see warning).

Note
This method returns a reference to existing data, exhibits constant i.e., O(1) time complexity, and runs very quickly.
Warning
You should use SetPositions() instead of this method unless you are fully aware of the possible interactions with the caching mechanism (see dangerous_get_mutable).
Exceptions
std::exceptionif the state is nullptr or if the context does not correspond to the context for a multibody model.
Precondition
state comes from this MultibodyPlant.

◆ GetMutablePositionsAndVelocities()

Eigen::VectorBlock<VectorX<T> > GetMutablePositionsAndVelocities ( systems::Context< T > *  context) const

(Advanced) Returns a mutable vector containing the vector [q; v] of the model with q the vector of generalized positions and v the vector of generalized velocities (see warning).

Warning
You should use SetPositionsAndVelocities() instead of this method unless you are fully aware of the interactions with the caching mechanism (see dangerous_get_mutable).
Exceptions
std::exceptionif the context is nullptr or if it does not correspond to the context for a multibody model.

◆ GetMutableVelocities() [1/2]

Eigen::VectorBlock<VectorX<T> > GetMutableVelocities ( const systems::Context< T > &  context,
systems::State< T > *  state 
) const

(Advanced) Returns a mutable vector reference containing the vector of generalized velocities (see warning).

Note
This method returns a reference to existing data, exhibits constant i.e., O(1) time complexity, and runs very quickly.
Warning
You should use SetVelocities() instead of this method unless you are fully aware of the possible interactions with the caching mechanism (see dangerous_get_mutable).
Exceptions
std::exceptionif the context is nullptr or the context does not correspond to the context for a multibody model.
Precondition
state comes from this MultibodyPlant.

◆ GetMutableVelocities() [2/2]

Eigen::VectorBlock<VectorX<T> > GetMutableVelocities ( systems::Context< T > *  context) const

See GetMutableVelocities() method above.

◆ GetPositionLowerLimits()

VectorX<double> GetPositionLowerLimits ( ) const

Returns a vector of size num_positions() containing the lower position limits for every generalized position coordinate.

These include joint and floating base coordinates. Any unbounded or unspecified limits will be -infinity.

Exceptions
std::logic_errorif called pre-finalize.

◆ GetPositions() [1/2]

Eigen::VectorBlock<const VectorX<T> > GetPositions ( const systems::Context< T > &  context) const

Returns a const vector reference containing the vector of generalized positions.

Note
This method returns a reference to existing data, exhibits constant i.e., O(1) time complexity, and runs very quickly.
Exceptions
std::exceptionif the context does not correspond to the context for a multibody model.

◆ GetPositions() [2/2]

VectorX<T> GetPositions ( const systems::Context< T > &  context,
ModelInstanceIndex  model_instance 
) const

Returns an vector containing the generalized positions (q) for the given model instance.

Exceptions
std::exceptionif the context does not correspond to the context for a multibody model.
Note
returns a dense vector of dimension q.size() associated with model_instance in O(q.size()) time.

◆ GetPositionsAndVelocities() [1/2]

Eigen::VectorBlock<const VectorX<T> > GetPositionsAndVelocities ( const systems::Context< T > &  context) const

Returns a const vector reference containing the vector [q; v] with q the vector of generalized positions and v the vector of generalized velocities.

Note
This method returns a reference to existing data, exhibits constant i.e., O(1) time complexity, and runs very quickly.
Exceptions
std::exceptionif the context does not correspond to the context for a multibody model.

◆ GetPositionsAndVelocities() [2/2]

VectorX<T> GetPositionsAndVelocities ( const systems::Context< T > &  context,
ModelInstanceIndex  model_instance 
) const

Returns the vector [q; v] of the model with q the vector of generalized positions and v the vector of generalized velocities for model instance model_instance.

Exceptions
std::exceptionif the context does not correspond to the context for a multibody model or model_instance is invalid.
Note
returns a dense vector of dimension q.size() + v.size() associated with model_instance in O(q.size()) time.

◆ GetPositionsFromArray()

VectorX<T> GetPositionsFromArray ( ModelInstanceIndex  model_instance,
const Eigen::Ref< const VectorX< T >> &  q 
) const

Returns a vector of generalized positions for model_instance from a vector q_array of generalized positions for the entire model model.

This method throws an exception if q is not of size MultibodyPlant::num_positions().

◆ GetPositionUpperLimits()

VectorX<double> GetPositionUpperLimits ( ) const

Upper limit analog of GetPositionsLowerLimits(), where any unbounded or unspecified limits will be +infinity.

See also
GetPositionLowerLimits() for more information.

◆ GetRigidBodyByName() [1/2]

const RigidBody<T>& GetRigidBodyByName ( const std::string &  name) const

Returns a constant reference to a rigid body that is identified by the string name in this model.

Exceptions
std::logic_errorif there is no body with the requested name.
std::logic_errorif the body name occurs in multiple model instances.
std::logic_errorif the requested body is not a RigidBody.
See also
HasBodyNamed() to query if there exists a body in this model with a given specified name.

◆ GetRigidBodyByName() [2/2]

const RigidBody<T>& GetRigidBodyByName ( const std::string &  name,
ModelInstanceIndex  model_instance 
) const

Returns a constant reference to the rigid body that is uniquely identified by the string name in model_instance.

Exceptions
std::logic_errorif there is no body with the requested name.
std::logic_errorif the requested body is not a RigidBody.
std::runtime_errorif model_instance is not valid for this model.
See also
HasBodyNamed() to query if there exists a body in this model with a given specified name.

◆ GetVelocities() [1/2]

Eigen::VectorBlock<const VectorX<T> > GetVelocities ( const systems::Context< T > &  context) const

Returns a const vector reference containing the generalized velocities.

Note
This method returns a reference to existing data, exhibits constant i.e., O(1) time complexity, and runs very quickly.

◆ GetVelocities() [2/2]

VectorX<T> GetVelocities ( const systems::Context< T > &  context,
ModelInstanceIndex  model_instance 
) const

Returns a vector containing the generalized velocities (v) for the given model instance.

Exceptions
std::exceptionif the context does not correspond to the context for a multibody model.
Note
returns a dense vector of dimension v.size() associated with model_instance in O(v.size()) time.

◆ GetVelocitiesFromArray()

VectorX<T> GetVelocitiesFromArray ( ModelInstanceIndex  model_instance,
const Eigen::Ref< const VectorX< T >> &  v 
) const

Returns a vector of generalized velocities for model_instance from a vector v of generalized velocities for the entire MultibodyPlant model.

This method throws an exception if the input array is not of size MultibodyPlant::num_velocities().

◆ GetVelocityLowerLimits()

VectorX<double> GetVelocityLowerLimits ( ) const

Returns a vector of size num_velocities() containing the lower velocity limits for every generalized velocity coordinate.

These include joint and floating base coordinates. Any unbounded or unspecified limits will be -infinity.

Exceptions
std::logic_errorif called pre-finalize.

◆ GetVelocityUpperLimits()

VectorX<double> GetVelocityUpperLimits ( ) const

Upper limit analog of GetVelocitysLowerLimits(), where any unbounded or unspecified limits will be +infinity.

See also
GetVelocityLowerLimits() for more information.

◆ GetVisualGeometriesForBody()

const std::vector< geometry::GeometryId > & GetVisualGeometriesForBody ( const Body< T > &  body) const

Returns an array of GeometryId's identifying the different visual geometries for body previously registered with a SceneGraph.

Note
This method can be called at any time during the lifetime of this plant, either pre- or post-finalize, see Finalize(). Post-finalize calls will always return the same value.
See also
RegisterVisualGeometry(), Finalize()

◆ gravity_field()

const UniformGravityFieldElement<T>& gravity_field ( ) const

An accessor to the current gravity field.

◆ HasBodyNamed() [1/2]

bool HasBodyNamed ( const std::string &  name) const
Returns
true if a body named name was added to the MultibodyPlant.
See also
AddRigidBody().
Exceptions
std::logic_errorif the body name occurs in multiple model instances.

◆ HasBodyNamed() [2/2]

bool HasBodyNamed ( const std::string &  name,
ModelInstanceIndex  model_instance 
) const
Returns
true if a body named name was added to the MultibodyPlant in model_instance.
See also
AddRigidBody().
Exceptions
std::exceptionif model_instance is not valid for this model.

◆ HasFrameNamed() [1/2]

bool HasFrameNamed ( const std::string &  name) const
Returns
true if a frame named name was added to the model.
See also
AddFrame().
Exceptions
std::logic_errorif the frame name occurs in multiple model instances.

◆ HasFrameNamed() [2/2]

bool HasFrameNamed ( const std::string &  name,
ModelInstanceIndex  model_instance 
) const
Returns
true if a frame named name was added to model_instance.
See also
AddFrame().
Exceptions
std::exceptionif model_instance is not valid for this model.

◆ HasJointActuatorNamed() [1/2]

bool HasJointActuatorNamed ( const std::string &  name) const
Returns
true if an actuator named name was added to this model.
See also
AddJointActuator().
Exceptions
std::logic_errorif the actuator name occurs in multiple model instances.

◆ HasJointActuatorNamed() [2/2]

bool HasJointActuatorNamed ( const std::string &  name,
ModelInstanceIndex  model_instance 
) const
Returns
true if an actuator named name was added to model_instance.
See also
AddJointActuator().
Exceptions
std::exceptionif model_instance is not valid for this model.

◆ HasJointNamed() [1/2]

bool HasJointNamed ( const std::string &  name) const
Returns
true if a joint named name was added to this model.
See also
AddJoint().
Exceptions
std::logic_errorif the joint name occurs in multiple model instances.

◆ HasJointNamed() [2/2]

bool HasJointNamed ( const std::string &  name,
ModelInstanceIndex  model_instance 
) const
Returns
true if a joint named name was added to model_instance.
See also
AddJoint().
Exceptions
std::exceptionif model_instance is not valid for this model.

◆ HasModelInstanceNamed()

bool HasModelInstanceNamed ( const std::string &  name) const
Returns
true if a model instance named name was added to this model.
See also
AddModelInstance().

◆ is_finalized()

bool is_finalized ( ) const

Returns true if this MultibodyPlant was finalized with a call to Finalize().

See also
Finalize().

◆ IsAnchored()

bool IsAnchored ( const Body< T > &  body) const

Returns true if body is anchored (i.e.

the kinematic path between body and the world only contains weld joints.)

Exceptions
std::exceptionif called pre-finalize.

◆ MakeActuationMatrix()

MatrixX< T > MakeActuationMatrix ( ) const

This method creates an actuation matrix B mapping a vector of actuation values u into generalized forces tau_u = B * u, where B is a matrix of size nv x nu with nu equal to num_actuators() and nv equal to num_velocities().

The vector u of actuation values is of size num_actuators(). For a given JointActuator, u[JointActuator::index()] stores the value for the external actuation corresponding to that actuator. tau_u on the other hand is indexed by generalized velocity indexes according to Joint::velocity_start().

Warning
B is a permutation matrix. While making a permutation has O(n) complexity, making a full B matrix has O(n²) complexity. For most applications this cost can be neglected but it could become significant for very large systems.

◆ MakeActuatorSelectorMatrix() [1/2]

MatrixX<double> MakeActuatorSelectorMatrix ( const std::vector< JointActuatorIndex > &  user_to_actuator_index_map) const

This method allows user to map a vector uₛ containing the actuation for a set of selected actuators into the vector u containing the actuation values for this full model.

The mapping, or selection, is returned in the form of a selector matrix Su such that u = Su⋅uₛ. The size nₛ of uₛ is always smaller or equal than the size of the full vector of actuation values u. That is, a user might be interested in only a given subset of actuators in the model.

This selection matrix is particularly useful when adding PID control on a portion of the state, see systems::controllers::PidController.

A user specifies the preferred order in uₛ via user_to_actuator_index_map. The actuation values in uₛ are a concatenation of the values for each actuator in the order they appear in user_to_actuator_index_map. The full vector of actuation values u is ordered by JointActuatorIndex.

◆ MakeActuatorSelectorMatrix() [2/2]

MatrixX<double> MakeActuatorSelectorMatrix ( const std::vector< JointIndex > &  user_to_joint_index_map) const

Alternative signature to build an actuation selector matrix Su such that u = Su⋅uₛ, where u is the vector of actuation values for the full model (ordered by JointActuatorIndex) and uₛ is a vector of actuation values for the actuators acting on the joints listed by user_to_joint_index_map.

It is assumed that all joints referenced by user_to_joint_index_map are actuated. See MakeActuatorSelectorMatrix(const std::vector<JointActuatorIndex>&) for details.

Exceptions
std::logic_errorif any of the joints in user_to_joint_index_map does not have an actuator.

◆ MakeStateSelectorMatrix()

MatrixX<double> MakeStateSelectorMatrix ( const std::vector< JointIndex > &  user_to_joint_index_map) const

This method allows users to map the state of this model, x, into a vector of selected state xₛ with a given preferred ordering.

The mapping, or selection, is returned in the form of a selector matrix Sx such that xₛ = Sx⋅x. The size nₛ of xₛ is always smaller or equal than the size of the full state x. That is, a user might be interested in only a given portion of the full state x.

This selection matrix is particularly useful when adding PID control on a portion of the state, see systems::controllers::PidController.

A user specifies the preferred order in xₛ via user_to_joint_index_map. The selected state is built such that selected positions are followed by selected velocities, as in xₛ = [qₛ, vₛ]. The positions in qₛ are a concatenation of the positions for each joint in the order they appear in user_to_joint_index_map. That is, the positions for user_to_joint_index_map[0] are first, followed by the positions for user_to_joint_index_map[1], etc. Similarly for the selected velocities vₛ.

Exceptions
std::logic_errorif there are repeated indexes in user_to_joint_index_map.

◆ MapQDotToVelocity()

void MapQDotToVelocity ( const systems::Context< T > &  context,
const Eigen::Ref< const VectorX< T >> &  qdot,
EigenPtr< VectorX< T >>  v 
) const

Transforms the time derivative qdot of the generalized positions vector q (stored in context) to generalized velocities v.

v and are related linearly by q̇ = N(q)⋅v. Although N(q) is not necessarily square, its left pseudo-inverse N⁺(q) can be used to invert that relationship without residual error, provided that qdot is in the range space of N(q) (that is, if it could have been produced as q̇ = N(q)⋅v for some v). Using the configuration q stored in the given context this method calculates v = N⁺(q)⋅q̇.

Parameters
[in]contextThe context containing the state of the model.
[in]qdotA vector containing the time derivatives of the generalized positions. This method aborts if qdot is not of size num_positions().
[out]vA valid (non-null) pointer to a vector in ℛⁿ with n the number of generalized velocities. This method aborts if v is nullptr or if it is not of size num_velocities().
See also
MapVelocityToQDot()
Mobilizer::MapQDotToVelocity()

◆ MapVelocityToQDot()

void MapVelocityToQDot ( const systems::Context< T > &  context,
const Eigen::Ref< const VectorX< T >> &  v,
EigenPtr< VectorX< T >>  qdot 
) const

Transforms generalized velocities v to time derivatives qdot of the generalized positions vector q (stored in context).

v and qdot are related linearly by q̇ = N(q)⋅v. Using the configuration q stored in the given context this method calculates q̇ = N(q)⋅v.

Parameters
[in]contextThe context containing the state of the model.
[in]vA vector of of generalized velocities for this model. This method aborts if v is not of size num_velocities().
[out]qdotA valid (non-null) pointer to a vector in ℝⁿ with n being the number of generalized positions in this model, given by num_positions(). This method aborts if qdot is nullptr or if it is not of size num_positions().
See also
MapQDotToVelocity()
Mobilizer::MapVelocityToQDot()

◆ mutable_gravity_field()

UniformGravityFieldElement<T>& mutable_gravity_field ( )

A mutable accessor to the current gravity field.

◆ num_actuated_dofs() [1/2]

int num_actuated_dofs ( ) const

Returns the total number of actuated degrees of freedom.

That is, the vector of actuation values u has this size. See AddJointActuator().

◆ num_actuated_dofs() [2/2]

int num_actuated_dofs ( ModelInstanceIndex  model_instance) const

Returns the total number of actuated degrees of freedom for a specific model instance.

That is, the vector of actuation values u has this size. See AddJointActuator().

◆ num_actuators()

int num_actuators ( ) const

Returns the number of joint actuators in the model.

See also
AddJointActuator().

◆ num_bodies()

int num_bodies ( ) const

Returns the number of bodies in the model, including the "world" body, which is always part of the model.

See also
AddRigidBody().

◆ num_collision_geometries()

int num_collision_geometries ( ) const

Returns the number of geometries registered for contact modeling.

This method can be called at any time during the lifetime of this plant, either pre- or post-finalize, see Finalize(). Post-finalize calls will always return the same value.

◆ num_force_elements()

int num_force_elements ( ) const

Returns the number of ForceElement objects.

See also
AddForceElement().

◆ num_frames()

int num_frames ( ) const

Returns the number of Frame objects in this model.

Frames include body frames associated with each of the bodies, including the world body. This means the minimum number of frames is one.

◆ num_joints()

int num_joints ( ) const

Returns the number of joints in the model.

See also
AddJoint().

◆ num_model_instances()

int num_model_instances ( ) const

Returns the number of model instances in the model.

See also
AddModelInstance().

◆ num_multibody_states()

int num_multibody_states ( ) const

Returns the size of the multibody system state vector x = [q; v].

This will be num_positions() plus num_velocities().

◆ num_positions() [1/2]

int num_positions ( ) const

Returns the size of the generalized position vector q for this model.

◆ num_positions() [2/2]

int num_positions ( ModelInstanceIndex  model_instance) const

Returns the size of the generalized position vector q for a specific model instance.

◆ num_velocities() [1/2]

int num_velocities ( ) const

Returns the size of the generalized velocity vector v for this model.

◆ num_velocities() [2/2]

int num_velocities ( ModelInstanceIndex  model_instance) const

Returns the size of the generalized velocity vector v for a specific model instance.

◆ num_visual_geometries()

int num_visual_geometries ( ) const

Returns the number of geometries registered for visualization.

This method can be called at any time during the lifetime of this plant, either pre- or post-finalize, see Finalize(). Post-finalize calls will always return the same value.

◆ operator=() [1/2]

MultibodyPlant& operator= ( const MultibodyPlant< T > &  )
delete

◆ operator=() [2/2]

MultibodyPlant& operator= ( MultibodyPlant< T > &&  )
delete

◆ RegisterAsSourceForSceneGraph()

geometry::SourceId RegisterAsSourceForSceneGraph ( geometry::SceneGraph< T > *  scene_graph)

Registers this plant to serve as a source for an instance of SceneGraph.

This registration allows MultibodyPlant to register geometry with scene_graph for visualization and/or collision queries. Successive registration calls with SceneGraph must be performed on the same instance to which the pointer argument scene_graph points to. Failure to do so will result in runtime exceptions.

Parameters
scene_graphA valid non nullptr to the SceneGraph instance for which this plant will sever as a source, see SceneGraph documentation for further details.
Returns
the SourceId of this plant in scene_graph. It can also later on be retrieved with get_source_id().
Exceptions
std::exceptionif called post-finalize.
std::exceptionif scene_graph is the nullptr.
std::exceptionif called more than once.

◆ RegisterCollisionGeometry()

geometry::GeometryId RegisterCollisionGeometry ( const Body< T > &  body,
const math::RigidTransform< double > &  X_BG,
const geometry::Shape shape,
const std::string &  name,
const CoulombFriction< double > &  coulomb_friction 
)

Registers geometry in a SceneGraph with a given geometry::Shape to be used for the contact modeling of a given body.

More than one geometry can be registered with a body, in which case the body's contact geometry is the union of all geometries registered to that body.

Parameters
[in]bodyThe body for which geometry is being registered.
[in]X_BGThe fixed pose of the geometry frame G in the body frame B.
[in]shapeThe geometry::Shape used for visualization. E.g.: geometry::Sphere, geometry::Cylinder, etc.
[in]coulomb_frictionCoulomb's law of friction coefficients to model friction on the surface of shape for the given body.
Exceptions
std::exceptionif called post-finalize.

◆ RegisterVisualGeometry() [1/3]

geometry::GeometryId RegisterVisualGeometry ( const Body< T > &  body,
const math::RigidTransform< double > &  X_BG,
const geometry::Shape shape,
const std::string &  name,
const geometry::IllustrationProperties properties 
)

Registers geometry in a SceneGraph with a given geometry::Shape to be used for visualization of a given body.

Note
Currently, the visual geometry will also be assigned a perception role. Its render label's value will be equal to the body's index and its perception color will be the same as its illustration color (defaulting to gray if no color is provided). This behavior will change in the near future and code that directly relies on this behavior will break.
Parameters
[in]bodyThe body for which geometry is being registered.
[in]X_BGThe fixed pose of the geometry frame G in the body frame B.
[in]shapeThe geometry::Shape used for visualization. E.g.: geometry::Sphere, geometry::Cylinder, etc.
[in]nameThe name for the geometry. It must satisfy the requirements defined in drake::geometry::GeometryInstance.
[in]propertiesThe illustration properties for this geometry.
Exceptions
std::exceptionif called post-finalize.
std::exceptionif scene_graph does not correspond to the same instance with which RegisterAsSourceForSceneGraph() was called.
Returns
the id for the registered geometry.

◆ RegisterVisualGeometry() [2/3]

geometry::GeometryId RegisterVisualGeometry ( const Body< T > &  body,
const math::RigidTransform< double > &  X_BG,
const geometry::Shape shape,
const std::string &  name,
const Vector4< double > &  diffuse_color 
)

Overload for visual geometry registration; it converts the diffuse_color (RGBA with values in the range [0, 1]) into a geometry::ConnectDrakeVisualizer()-compatible set of geometry::IllustrationProperties.

◆ RegisterVisualGeometry() [3/3]

geometry::GeometryId RegisterVisualGeometry ( const Body< T > &  body,
const math::RigidTransform< double > &  X_BG,
const geometry::Shape shape,
const std::string &  name 
)

Overload for visual geometry registration; it relies on the downstream geometry::IllustrationProperties consumer to provide default parameter values (see Geometry Roles for details).

◆ set_contact_model()

void set_contact_model ( ContactModel  model)

Sets the contact model to be used by this MultibodyPlant, see ContactModel for available options.

The default contact model is ContactModel::kPointContactOnly.

Exceptions
std::exceptioniff called post-finalize.

◆ set_elastic_modulus()

void set_elastic_modulus ( geometry::GeometryId  id,
double  elastic_modulus 
)

Specifies the elastic_modulus E for a geometry identified by its id.

elastic_modulus must be specified with units of Pa (N/m²). The elastic modulus is often estimated based on the Young's modulus of the material though in the hydroelastic model it represents an effective elastic property. For instance, [R. Elandt 2019] chooses to use E = G, with G the P-wave elastic modulus G = (1-ν)/(1+ν)/(1-2ν)E, with ν the Poisson ratio, consistent with the theory of layered solids in which plane sections remain planar after compression. Another possibly is to specify E = E*, with E* the effective elastic modulus given by the Hertz theory of contact, E* = E/(1-ν²). In all of these cases a sound estimation of elastic_modulus starts with the Young's modulus of the material. See Hydroelastic model materialproperties" for further details. By default geometries are assumed to be rigid, i.e. with an infinite elastic_modulus.

Exceptions
std::exceptionif elastic_modulus is negative or zero.
std::exceptionif id does not correspond to a collision geometry previously registered with this model.
std::exceptionif called post-finalize.

◆ set_hunt_crossley_dissipation()

void set_hunt_crossley_dissipation ( geometry::GeometryId  id,
double  dissipation 
)

Specifies the Hunt & Crossley dissipation coefficient for the hydroelastic model.

It has units of s/m, inverse of velocity. See Hydroelastic modelmaterial properties" for further details. By default dissipation is zero.

Exceptions
std::exceptionif dissipation is negative (it can be zero).
std::exceptionif id does not correspond to a collision geometry previously registered with this model.
std::exceptionif called post-finalize.

◆ set_penetration_allowance()

void set_penetration_allowance ( double  penetration_allowance = 0.001)

Sets the penetration allowance used to estimate the coefficients in the penalty method used to impose non-penetration among bodies.

Refer to the section Contact by penalty method for further details.

◆ set_stiction_tolerance()

void set_stiction_tolerance ( double  v_stiction = 0.001)

Sets the stiction tolerance v_stiction for the Stribeck model, where v_stiction must be specified in m/s (meters per second.) v_stiction defaults to a value of 1 millimeter per second.

In selecting a value for v_stiction, you must ask yourself the question, "When two objects are ostensibly in stiction, how much slip am I willing to allow?" There are two opposing design issues in picking a value for vₛ. On the one hand, small values of vₛ make the problem numerically stiff during stiction, potentially increasing the integration cost. On the other hand, it should be picked to be appropriate for the scale of the problem. For example, a car simulation could allow a "large" value for vₛ of 1 cm/s (1×10⁻² m/s), but reasonable stiction for grasping a 10 cm box might require limiting residual slip to 1×10⁻³ m/s or less. Ultimately, picking the largest viable value will allow your simulation to run faster and more robustly. Note that v_stiction is the slip velocity that we'd have when we are at edge of the friction cone. For cases when the friction force is well within the friction cone the slip velocity will always be smaller than this value. See also Continuous Approximation of Coulomb.

Exceptions
std::exceptionif v_stiction is non-positive.

◆ SetActuationInArray()

void SetActuationInArray ( ModelInstanceIndex  model_instance,
const Eigen::Ref< const VectorX< T >> &  u_instance,
EigenPtr< VectorX< T >>  u 
) const

Given the actuation values u_instance for all actuators in model_instance, this method sets the actuation vector u for the entire model to which this actuator belongs to.

This method throws an exception if the size of u_instance is not equal to the number of degrees of freedom of all of the actuated joints in model_instance.

Parameters
[in]u_instanceActuation values for the actuators. It must be of size equal to the number of degrees of freedom of all of the actuated joints in model_instance.
[out]uThe vector containing the actuation values for the entire model.

◆ SetDefaultState()

void SetDefaultState ( const systems::Context< T > &  context,
systems::State< T > *  state 
) const
override

Sets the state so that generalized positions and velocities are zero.

Exceptions
std::exceptionif called pre-finalize. See Finalize().

◆ SetFreeBodyPose() [1/2]

void SetFreeBodyPose ( systems::Context< T > *  context,
const Body< T > &  body,
const math::RigidTransform< T > &  X_WB 
) const

Sets context to store the pose X_WB of a given body B in the world frame W.

Note
In general setting the pose and/or velocity of a body in the model would involve a complex inverse kinematics problem. This method allows us to simplify this process when we know the body is free in space.
Exceptions
std::exceptionif body is not a free body in the model.
std::exceptionif called pre-finalize.

◆ SetFreeBodyPose() [2/2]

void SetFreeBodyPose ( const systems::Context< T > &  context,
systems::State< T > *  state,
const Body< T > &  body,
const math::RigidTransform< T > &  X_WB 
) const

Sets state to store the pose X_WB of a given body B in the world frame W, for a given context of this model.

Note
In general setting the pose and/or velocity of a body in the model would involve a complex inverse kinematics problem. This method allows us to simplify this process when we know the body is free in space.
Exceptions
std::exceptionif body is not a free body in the model.
std::exceptionif called pre-finalize.
Precondition
state comes from this MultibodyPlant.

◆ SetFreeBodyPoseInAnchoredFrame()

void SetFreeBodyPoseInAnchoredFrame ( systems::Context< T > *  context,
const Frame< T > &  frame_F,
const Body< T > &  body,
const math::RigidTransform< T > &  X_FB 
) const

Updates context to store the pose X_FB of a given body B in a frame F.

Frame F must be anchored, meaning that it is either directly welded to the world frame W or, more generally, that there is a kinematic path between frame F and the world frame W that only includes weld joints.

Exceptions
std::logic_errorif called pre-finalize.
std::logic_errorif frame F is not anchored to the world.

◆ SetFreeBodyPoseInWorldFrame()

void SetFreeBodyPoseInWorldFrame ( systems::Context< T > *  context,
const Body< T > &  body,
const math::RigidTransform< T > &  X_WB 
) const

Sets context to store the pose X_WB of a given body B in the world frame W.

Parameters
[in]contextThe context to store the pose X_WB of body_B.
[in]body_BThe body B corresponding to the pose X_WB to be stored in context.
Return values
X_WBThe pose of body frame B in the world frame W.
Note
In general setting the pose and/or velocity of a body in the model would involve a complex inverse kinematics problem. This method allows us to simplify this process when we know the body is free in space.
Exceptions
std::exceptionif body is not a free body in the model.
std::logic_errorif called pre-finalize.

◆ SetFreeBodyRandomPositionDistribution()

void SetFreeBodyRandomPositionDistribution ( const Body< T > &  body,
const Vector3< symbolic::Expression > &  position 
)

Sets the distribution used by SetRandomState() to populate the x-y-z position component of the floating-base state.

Exceptions
std::exceptionif body is not a free body in the model.
std::exceptionif called pre-finalize.

◆ SetFreeBodyRandomRotationDistribution()

void SetFreeBodyRandomRotationDistribution ( const Body< T > &  body,
const Eigen::Quaternion< symbolic::Expression > &  rotation 
)

Sets the distribution used by SetRandomState() to populate the rotation component of the floating-base state.

Exceptions
std::exceptionif body is not a free body in the model.
std::exceptionif called pre-finalize.

◆ SetFreeBodyRandomRotationDistributionToUniform()

void SetFreeBodyRandomRotationDistributionToUniform ( const Body< T > &  body)

Sets the distribution used by SetRandomState() to populate the rotation component of the floating-base state using uniformly random rotations.

Exceptions
std::exceptionif body is not a free body in the model.
std::exceptionif called pre-finalize.

◆ SetFreeBodySpatialVelocity() [1/2]

void SetFreeBodySpatialVelocity ( systems::Context< T > *  context,
const Body< T > &  body,
const SpatialVelocity< T > &  V_WB 
) const

Sets context to store the spatial velocity V_WB of a given body B in the world frame W.

Note
In general setting the pose and/or velocity of a body in the model would involve a complex inverse kinematics problem. This method allows us to simplify this process when we know the body is free in space.
Exceptions
std::exceptionif body is not a free body in the model.
std::exceptionif called pre-finalize.

◆ SetFreeBodySpatialVelocity() [2/2]

void SetFreeBodySpatialVelocity ( const systems::Context< T > &  context,
systems::State< T > *  state,
const Body< T > &  body,
const SpatialVelocity< T > &  V_WB 
) const

Sets state to store the spatial velocity V_WB of a given body B in the world frame W, for a given context of this model.

Note
In general setting the pose and/or velocity of a body in the model would involve a complex inverse kinematics problem. This method allows us to simplify this process when we know the body is free in space.
Exceptions
std::exceptionif body is not a free body in the model.
std::exceptionif called pre-finalize.
Precondition
state comes from this MultibodyPlant.

◆ SetPositions() [1/3]

void SetPositions ( systems::Context< T > *  context,
const VectorX< T > &  q 
) const

Sets all generalized positions from the given vector.

Exceptions
std::exceptionif the context is nullptr, if the context does not correspond to the context for a multibody model, or if the length of q is not equal to num_positions().

◆ SetPositions() [2/3]

void SetPositions ( systems::Context< T > *  context,
ModelInstanceIndex  model_instance,
const VectorX< T > &  q_instance 
) const

Sets the positions for a particular model instance from the given vector.

Exceptions
std::exceptionif the context is nullptr, if the context does not correspond to the context for a multibody model, if the model instance index is invalid, or if the length of q_instance is not equal to num_positions(model_instance).

◆ SetPositions() [3/3]

void SetPositions ( const systems::Context< T > &  context,
systems::State< T > *  state,
ModelInstanceIndex  model_instance,
const VectorX< T > &  q_instance 
) const

Sets the positions for a particular model instance from the given vector.

Exceptions
std::exceptionif the state is nullptr, if the context does not correspond to the context for a multibody model, if the model instance index is invalid, or if the length of q_instance is not equal to num_positions(model_instance).
Precondition
state comes from this MultibodyPlant.

◆ SetPositionsAndVelocities() [1/2]

void SetPositionsAndVelocities ( systems::Context< T > *  context,
const VectorX< T > &  q_v 
) const

Sets all generalized positions and velocities from the given vector [q; v].

Exceptions
std::exceptionif the context is nullptr, if the context does not correspond to the context for a multibody model, or if the length of q_v is not equal to num_positions() + num_velocities().

◆ SetPositionsAndVelocities() [2/2]

void SetPositionsAndVelocities ( systems::Context< T > *  context,
ModelInstanceIndex  model_instance,
const VectorX< T > &  q_v 
) const

Sets generalized positions and velocities from the given vector [q; v] for the specified model instance.

Exceptions
std::exceptionif the context is nullptr, if the context does not correspond to the context for a multibody model, if the model instance index is invalid, or if the length of q_v is not equal to num_positions(model_instance) + num_velocities(model_instance).

◆ SetPositionsInArray()

void SetPositionsInArray ( ModelInstanceIndex  model_instance,
const Eigen::Ref< const VectorX< T >> &  q_instance,
EigenPtr< VectorX< T >>  q 
) const

Sets the vector of generalized positions for model_instance in q using q_instance, leaving all other elements in the array untouched.

This method throws an exception if q is not of size MultibodyPlant::num_positions() or q_instance is not of size MultibodyPlant::num_positions(model_instance).

◆ SetRandomState()

void SetRandomState ( const systems::Context< T > &  context,
systems::State< T > *  state,
RandomGenerator generator 
) const
override

Assigns random values to all elements of the state, by drawing samples independently for each joint/floating-base (coming soon: and then solving a mathematical program to "project" these samples onto the registered system constraints).

See also
Stochastic Systems

◆ SetVelocities() [1/3]

void SetVelocities ( systems::Context< T > *  context,
const VectorX< T > &  v 
) const

Sets all generalized velocities from the given vector.

Exceptions
std::exceptionif the context is nullptr, if the context does not correspond to the context for a multibody model, or if the length of v is not equal to num_velocities().

◆ SetVelocities() [2/3]

void SetVelocities ( const systems::Context< T > &  context,
systems::State< T > *  state,
ModelInstanceIndex  model_instance,
const VectorX< T > &  v_instance 
) const

Sets the generalized velocities for a particular model instance from the given vector.

Exceptions
std::exceptionif the context is nullptr, if the context does not correspond to the context for a multibody model, if the model instance index is invalid, or if the length of v_instance is not equal to num_velocities(model_instance).
Precondition
state comes from this MultibodyPlant.

◆ SetVelocities() [3/3]

void SetVelocities ( systems::Context< T > *  context,
ModelInstanceIndex  model_instance,
const VectorX< T > &  v_instance 
) const

Sets the generalized velocities for a particular model instance from the given vector.

Exceptions
std::exceptionif the context is nullptr, if the context does not correspond to the context for a multibody model, if the model instance index is invalid, or if the length of v_instance is not equal to num_velocities(model_instance).

◆ SetVelocitiesInArray()

void SetVelocitiesInArray ( ModelInstanceIndex  model_instance,
const Eigen::Ref< const VectorX< T >> &  v_instance,
EigenPtr< VectorX< T >>  v 
) const

Sets the vector of generalized velocities for model_instance in v using v_instance, leaving all other elements in the array untouched.

This method throws an exception if v is not of size MultibodyPlant::num_velocities() or v_instance is not of size MultibodyPlant::num_positions(model_instance).

◆ time_step()

double time_step ( ) const

The time step (or period) used to model this plant as a discrete system with periodic updates.

Returns 0 (zero) if the plant is modeled as a continuous system. This property of the plant is specified at construction and therefore this query can be performed either pre- or post- finalize, see Finalize().

See also
MultibodyPlant::MultibodyPlant(double)

◆ WeldFrames()

const WeldJoint< T > & WeldFrames ( const Frame< T > &  A,
const Frame< T > &  B,
const math::RigidTransform< double > &  X_AB = math::RigidTransform<double>::Identity() 
)

Welds frames A and B with relative pose X_AB.

That is, the pose of frame B in frame A is fixed, with value X_AB. The call to this method creates and adds a new WeldJoint to the model. The new WeldJoint is named as: A.name() + "_welds_to_" + B.name().

Returns
a constant reference to the WeldJoint welding frames A and B.

◆ world_body()

const RigidBody<T>& world_body ( ) const

Returns a constant reference to the world body.

◆ world_frame()

const BodyFrame<T>& world_frame ( ) const

Returns a constant reference to the world frame.

Friends And Related Function Documentation

◆ MultibodyPlant

friend class MultibodyPlant
friend

◆ MultibodyPlantTester

friend class MultibodyPlantTester
friend

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