Drake
RigidBodyPlant< T > Class Template Reference

This class provides a System interface around a multibody dynamics model of the world represented by a RigidBodyTree. More...

#include <drake/attic/multibody/rigid_body_plant/rigid_body_plant.h>

## Public Member Functions

RigidBodyPlant (std::unique_ptr< const RigidBodyTree< double >> tree, double timestep=0.0)
Instantiates a RigidBodyPlant from a Multi-Body Dynamics (MBD) model of the world in tree. More...

template<typename U >
RigidBodyPlant (const RigidBodyPlant< U > &other)
Scalar-converting copy constructor. See System Scalar Conversion. More...

~RigidBodyPlant () override

void set_contact_model_parameters (const CompliantContactModelParameters &parameters)
Sets the parameters of the compliance model. More...

void set_default_compliant_material (const CompliantMaterial &material)
Sets the compliant material values to use for default-configured material properties on collision elements (see CompliantMaterial for details). More...

const RigidBodyTree< double > & get_rigid_body_tree () const
Returns a constant reference to the multibody dynamics model of the world. More...

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

int get_num_positions () const
Returns the number of generalized coordinates of the model. More...

int get_num_positions (int model_instance_id) const
Returns the number of generalized coordinates for a specific model instance. More...

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

int get_num_velocities (int model_instance_id) const
Returns the number of generalized velocities for a specific model instance. More...

int get_num_states () const
Returns the size of the continuous state of the system which equals get_num_positions() plus get_num_velocities(). More...

int get_num_states (int model_instance_id) const
Returns the size of the continuous state of a specific model instance which equals get_num_positions() plus get_num_velocities(). More...

int get_num_actuators () const
Returns the number of actuators. More...

int get_num_actuators (int model_instance_id) const
Returns the number of actuators for a specific model instance. More...

int get_num_model_instances () const
Returns the number of model instances in the world, not including the world. More...

int get_input_size () const
Returns the size of the input vector to the system. More...

int get_output_size () const
Returns the size of the output vector of the system. More...

void set_position (Context< T > *context, int position_index, T position) const
Sets the generalized coordinate position_index to the value position. More...

void SetModelInstancePositions (Context< T > *context, int model_instance_id, const Eigen::Ref< const VectorX< T >> positions) const
Sets the generalized coordinates of the model instance specified by model_instance_id to the values in position. More...

void set_velocity (Context< T > *context, int velocity_index, T velocity) const
Sets the generalized velocity velocity_index to the value velocity. More...

void set_state_vector (Context< T > *context, const Eigen::Ref< const VectorX< T >> x) const
Sets the continuous state vector of the system to be x. More...

void set_state_vector (State< T > *state, const Eigen::Ref< const VectorX< T >> x) const
Sets the continuous state vector of the system to be x. More...

void SetDefaultState (const Context< T > &, State< T > *state) const override
Sets the state in context so that generalized positions and velocities are zero. More...

int FindInstancePositionIndexFromWorldIndex (int model_instance_id, int world_position_index)
Returns the index into the output port for model_instance_id which corresponds to the world position index of world_position_index, or throws if the position index does not correspond to the model id. More...

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

bool is_state_discrete () const
Gets whether this system is modeled using discrete state. More...

double get_time_step () const
Get the time step used to construct the plant. More...

Does not allow copy, move, or assignment
RigidBodyPlant (const RigidBodyPlant &)=delete

RigidBodyPlantoperator= (const RigidBodyPlant &)=delete

RigidBodyPlant (RigidBodyPlant &&)=delete

RigidBodyPlantoperator= (RigidBodyPlant &&)=delete

System input port accessors.

These are accessors for obtaining this RigidBodyPlant's input ports.

See this class's description for details about these ports and how these accessors are typically used.

const InputPort< T > & actuator_command_input_port () const
Returns a the actuator command input port. More...

bool model_instance_has_actuators (int model_instance_id) const
Returns true if and only if the model instance with the provided model_instance_id has actuators. More...

const InputPort< T > & model_instance_actuator_command_input_port (int model_instance_id) const
Returns the input port for a specific model instance. More...

System output port accessors.

These are accessors for obtaining this RigidBodyPlant's output ports.

See this class's description for details about these ports and how these accessors are typically used.

const OutputPort< T > & state_output_port () const
Returns the plant-centric state output port. More...

const OutputPort< T > & state_derivative_output_port () const
Returns the plant-centric state derivative output port. More...

const OutputPort< T > & model_instance_state_output_port (int model_instance_id) const
Returns the output port containing the state of a particular model with instance ID equal to model_instance_id. More...

const OutputPort< T > & torque_output_port () const
Returns the output port containing measured joint torques. More...

const OutputPort< T > & model_instance_torque_output_port (int model_instance_id) const
Returns the output port containing the measured joint torques of a particular model with model_instance_id. More...

const OutputPort< T > & kinematics_results_output_port () const
Returns the KinematicsResults output port. More...

const OutputPort< T > & contact_results_output_port () const
Returns the ContactResults output port. More...

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)
Returns a ticket indicating dependence on input port uᵢ indicated by index. More...

DependencyTicket cache_entry_ticket (CacheIndex index)
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...

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)
Returns a ticket indicating dependence on input port uᵢ indicated by index. More...

DependencyTicket cache_entry_ticket (CacheIndex index)
Returns a ticket indicating dependence on the cache entry indicated by index. More...

DependencyTicket output_port_ticket (OutputPortIndex index)
(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...

## Static Public Member Functions

static T JointLimitForce (const DrakeJoint &joint, const T &position, const T &velocity)
Computes the force exerted by the stop when a joint hits its limit, using a linear stiffness model. More...

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

RigidBodyPlant (SystemScalarConverter converter, std::unique_ptr< const RigidBodyTree< double >> tree, double timestep=0.0)

VectorX< T > EvaluateActuatorInputs (const Context< T > &context) const

std::unique_ptr< ContinuousState< T > > AllocateContinuousState () const override
Returns a ContinuousState used to implement both CreateDefaultContext and AllocateTimeDerivatives. More...

std::unique_ptr< DiscreteValues< T > > AllocateDiscreteState () const override
Reserves the discrete state as required by CreateDefaultContext. More...

void DoCalcTimeDerivatives (const Context< T > &context, ContinuousState< T > *derivatives) const override
Override this if you have any continuous state variables xc in your concrete System to calculate their time derivatives. More...

void DoCalcDiscreteVariableUpdates (const drake::systems::Context< T > &context, const std::vector< const drake::systems::DiscreteUpdateEvent< T > * > &events, drake::systems::DiscreteValues< T > *updates) const override

optional< boolDoHasDirectFeedthrough (int, int) const override
Returns true if there is direct-feedthrough from the given input_port to the given output_port, false if there is not direct-feedthrough, or nullopt if unknown (in which case SystemSymbolicInspector will attempt to measure the feedthrough using symbolic form). More...

DoCalcPotentialEnergy (const Context< T > &) const override
Override this method for physical systems to calculate the potential energy PE currently stored in the configuration provided in the given Context. More...

DoCalcKineticEnergy (const Context< T > &) const override
Override this method for physical systems to calculate the kinetic energy KE currently present in the motion provided in the given Context. More...

DoCalcConservativePower (const Context< T > &) const override
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...

DoCalcNonConservativePower (const Context< T > &) const override
Override this method to return the rate Pnc at which work W is done on the system by non-conservative forces. More...

void DoMapVelocityToQDot (const Context< T > &context, const Eigen::Ref< const VectorX< T >> &generalized_velocity, VectorBase< T > *positions_derivative) const override
Provides the substantive implementation of MapVelocityToQDot(). More...

void DoMapQDotToVelocity (const Context< T > &context, const Eigen::Ref< const VectorX< T >> &configuration_dot, VectorBase< T > *generalized_velocity) const override
Provides the substantive implementation of MapQDotToVelocity(). 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< 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 >
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 >
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...

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...

template<class MySystem >
std::unique_ptr< WitnessFunction< T > > DeclareWitnessFunction (const std::string &description, const WitnessFunctionDirection &direction_type, T(MySystem::*calc)(const Context< T > &) const) const
(Deprecated.) More...

std::unique_ptr< WitnessFunction< T > > DeclareWitnessFunction (const std::string &description, const WitnessFunctionDirection &direction_type, std::function< T(const Context< T > &)> calc) const
(Deprecated.) More...

template<class MySystem >
std::unique_ptr< WitnessFunction< T > > DeclareWitnessFunction (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
(Deprecated.) More...

template<class MySystem >
std::unique_ptr< WitnessFunction< T > > DeclareWitnessFunction (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
(Deprecated.) More...

template<class MySystem >
std::unique_ptr< WitnessFunction< T > > DeclareWitnessFunction (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
(Deprecated.) More...

template<class MySystem >
std::unique_ptr< WitnessFunction< T > > DeclareWitnessFunction (const std::string &description, const WitnessFunctionDirection &direction_type, T(MySystem::*calc)(const Context< T > &) const, const Event< T > &e) const
(Deprecated.) More...

std::unique_ptr< WitnessFunction< T > > DeclareWitnessFunction (const std::string &description, const WitnessFunctionDirection &direction_type, std::function< T(const Context< T > &)> calc, const Event< T > &e) const
(Deprecated.) 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 ()

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 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...

(Internal use only) Assigns a ticket to a new discrete variable group with the given index. More...

(Internal use only) Assigns a ticket to a new abstract state variable with the given index. More...

(Internal use only) Assigns a ticket to a new numeric parameter with the given index. More...

(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...

## Friends

class RigidBodyPlantTimeSteppingDataTest_NormalJacobian_Test

class RigidBodyPlantTimeSteppingDataTest_TangentJacobian_Test

template<typename U >
class RigidBodyPlant

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...

## Detailed Description

### template<typename T> class drake::systems::RigidBodyPlant< T >

This class provides a System interface around a multibody dynamics model of the world represented by a RigidBodyTree.

The RigidBodyPlant provides a number of input and output ports. The number and types of port accessors depends on the number of model instances within the RigidBodyTree with actuators. The following lists the accessors for obtaining the input and output ports of the RigidBodyPlant. These accessors are typically used when "wiring up" a RigidBodyPlant within a Diagram using DiagramBuilder. See, for example, DiagramBuilder::Connect(), DiagramBuilder::ExportInput(), and DiagramBuilder::ExportOutput().

Plant-Centric Port Accessors:

• actuator_command_input_port(): Contains the command vector for the RigidBodyTree's actuators. This method can only be called when there is only one model instance in the RigidBodyTree, as determined by get_num_model_instances(), and this model instance has at least one actuator. The size of this vector equals the number of RigidBodyActuator's in the RigidBodyTree. Each RigidBodyActuator maps to a single-DOF joint (currently actuation cannot be applied to multiple-DOF joints). The units of the actuation are the same as the units of the generalized force on the joint. In addition, actuators allow for a gear box reduction factor and for actuation limits which are only used by controllers; the RigidBodyPlant does not apply these limits. The gear box factor effectively is a multiplier on the input actuation to the RigidBodyPlant.
• state_output_port(): A vector-valued port containing the state vector, x, of the system. This is useful for downstream systems that require x, which includes DrakeVisualizer. The state vector, x, consists of generalized positions followed by generalized velocities. Semantics of x can be obtained using the following methods:
• state_derivative_output_port(): A vector-valued port containing the time derivative xcdot of the state vector. The order of indices within the vector is identical to state_output_port() as explained above.
• kinematics_results_output_port(): An abstract-valued port containing a KinematicsResults object allowing access to the results from kinematics computations for each RigidBody in the RigidBodyTree.
• contact_results_output_port(): An abstract-valued port containing a ContactsResults object allowing access to the results from contact computations.

Model-Instance-Centric Port Accessors:

The RigidBodyPlant's state consists of a vector containing the generalized positions followed by the generalized velocities of the system. This state is applied to a RigidBodyTree, which is a multibody model that consists of a set of rigid bodies connected through joints in a tree structure. Bodies may have a collision model, in which case, collisions are considered. In addition, the model may contain loop constraints described by RigidBodyLoop instances in the multibody model. Even though loop constraints are a particular case of holonomic constraints, general holonomic constraints are not yet supported. For simulating discretized RigidBodyPlant systems, an additional (discrete) scalar state variable stores the last time that the system's state was updated.

The system dynamics is given by the set of multibody equations written in generalized coordinates including loop joints as a set of holonomic constraints like so:

  H(q) * vdot + C(q, v) = tau_actuators + tau_constraints.


where q is the vector of generalized coordinates (or positions), v is the vector of generalized velocities, C includes the velocity-dependent Coriolis and gyroscopic forces, tau_actuators is the vector of externally applied generalized forces and finally tau_constraints is the vector of generalized forces due to constraints. tau_constraints is computed as

  tau_constraints = -J^T * lambda


where lambda is the vector of Lagrange multipliers representing the constraint forces and J is the constraint Jacobian. The time derivative of the generalized coordinates is then obtained from the generalized velocities as

  qdot = N(q) * v


where N(q) is a transformation matrix only dependent on the positions.

Template Parameters
 T The scalar type. Must be a valid Eigen scalar.

Instantiated templates for the following kinds of T's are provided:

• double
• AutoDiffXd
Exceptions
 std::runtime_error The AutodiffXd implementation has some restrictions: The collision detection code does not yet support AutoDiff, and calls to RigidBodyTree that would have required that gradient information will throw a std::runtime_error. Currently, the implication is that AutoDiff calls for RigidBodyPlants with Context that do not require gradients of the contact forces will succeed, but calls where Context results in non-zero contact forces will throw. DoCalcDiscreteVariableUpdates does not yet support AutoDiff, and will throw if called. In practice this means that AutoDiff of the dynamics are only available if the RigidBodyPlant is constructed with timestep=0.

## ◆ RigidBodyPlant() [1/5]

 RigidBodyPlant ( const RigidBodyPlant< T > & )
delete

## ◆ RigidBodyPlant() [2/5]

 RigidBodyPlant ( RigidBodyPlant< T > && )
delete

## ◆ RigidBodyPlant() [3/5]

 RigidBodyPlant ( std::unique_ptr< const RigidBodyTree< double >> tree, double timestep = 0.0 )
explicit

Instantiates a RigidBodyPlant from a Multi-Body Dynamics (MBD) model of the world in tree.

tree must not be nullptr.

Parameters
 [in] tree the dynamic model to use with this plant. [in] timestep a non-negative value specifying the update period of the model; 0.0 implies continuous-time dynamics with derivatives, and values > 0.0 result in discrete-time dynamics implementing a discretization of the dynamics equation. Default: 0.0.

## ◆ RigidBodyPlant() [4/5]

 RigidBodyPlant ( const RigidBodyPlant< U > & other )
explicit

Scalar-converting copy constructor. See System Scalar Conversion.

## ◆ ~RigidBodyPlant()

 ~RigidBodyPlant ( )
override

## ◆ RigidBodyPlant() [5/5]

 RigidBodyPlant ( SystemScalarConverter converter, std::unique_ptr< const RigidBodyTree< double >> tree, double timestep = 0.0 )
explicitprotected

## ◆ actuator_command_input_port()

 const InputPort& actuator_command_input_port ( ) const

Returns a the actuator command input port.

This method can only be called when there is only one model instance in the RigidBodyTree. Otherwise, a std::runtime_error will be thrown. It returns the same port as model_instance_actuator_command_input_port() using input parameter RigidBodyTreeConstants::kFirstNonWorldModelInstanceId.

## ◆ AllocateContinuousState()

 std::unique_ptr< ContinuousState< T > > AllocateContinuousState ( ) const
overrideprotectedvirtual

Returns a ContinuousState used to implement both CreateDefaultContext and AllocateTimeDerivatives.

Allocates the state configured with DeclareContinuousState, or none by default. Systems with continuous state variables may override (not recommended), but must ensure the ContinuousState vector is a subclass of BasicVector.

Reimplemented from LeafSystem< T >.

## ◆ AllocateDiscreteState()

 std::unique_ptr< DiscreteValues< T > > AllocateDiscreteState ( ) const
overrideprotectedvirtual

Reserves the discrete state as required by CreateDefaultContext.

By default, clones the model values as provided in DeclareDiscreteState() calls. Alternatively, systems with discrete state can override this method (not recommended).

Reimplemented from LeafSystem< T >.

## ◆ contact_results_output_port()

 const OutputPort& contact_results_output_port ( ) const

Returns the ContactResults output port.

## ◆ DoCalcConservativePower()

 T DoCalcConservativePower ( const Context< T > & context ) const
overrideprotectedvirtual

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.

By default, returns zero. Physical systems should override. You may assume that context has already been validated before it is passed to you here.

See EvalConservativePower() for details on what you must compute here. In particular, this quantity must be positive when potential energy is decreasing, and your conservative power method must not depend explicitly on time or any input port values.

Reimplemented from System< T >.

 void DoCalcDiscreteVariableUpdates ( const drake::systems::Context< T > & context, const std::vector< const drake::systems::DiscreteUpdateEvent< T > * > & events, drake::systems::DiscreteValues< T > * updates ) const
overrideprotected

## ◆ DoCalcKineticEnergy()

 T DoCalcKineticEnergy ( const Context< T > & context ) const
overrideprotectedvirtual

Override this method for physical systems to calculate the kinetic energy KE currently present in the motion provided in the given Context.

The default implementation returns 0 which is correct for non-physical systems. You may assume that context has already been validated before it is passed to you here.

See EvalKineticEnergy() for details on what you must compute here. In particular, your kinetic energy method must not depend explicitly on time or any input port values.

Reimplemented from System< T >.

## ◆ DoCalcNonConservativePower()

 T DoCalcNonConservativePower ( const Context< T > & context ) const
overrideprotectedvirtual

Override this method to return the rate Pnc at which work W is done on the system by non-conservative forces.

By default, returns zero. Physical systems should override. You may assume that context has already been validated before it is passed to you here.

See EvalNonConservativePower() for details on what you must compute here. In particular, this quantity must be negative if the non-conservative forces are dissipative, positive otherwise. Your non-conservative power method can depend on anything you find in the given Context, including time and input ports.

Reimplemented from System< T >.

## ◆ DoCalcPotentialEnergy()

 T DoCalcPotentialEnergy ( const Context< T > & context ) const
overrideprotectedvirtual

Override this method for physical systems to calculate the potential energy PE currently stored in the configuration provided in the given Context.

The default implementation returns 0 which is correct for non-physical systems. You may assume that context has already been validated before it is passed to you here.

See EvalPotentialEnergy() for details on what you must compute here. In particular, your potential energy method must not depend explicitly on time, velocities, or any input port values.

Reimplemented from System< T >.

## ◆ DoCalcTimeDerivatives()

 void DoCalcTimeDerivatives ( const Context< T > & context, ContinuousState< T > * derivatives ) const
overrideprotectedvirtual

Override this if you have any continuous state variables xc in your concrete System to calculate their time derivatives.

The derivatives vector will correspond elementwise with the state vector Context.state.continuous_state.get_state(). Thus, if the state in the Context has second-order structure xc=[q,v,z], that same structure applies to the derivatives.

This method is called only from the public non-virtual CalcTimeDerivatives() which will already have error-checked the parameters so you don't have to. In particular, implementations may assume that the given Context is valid for this System; that the derivatives pointer is non-null, and that the referenced object has the same constituent structure as was produced by AllocateTimeDerivatives().

The default implementation does nothing if the derivatives vector is size zero and aborts otherwise.

Reimplemented from System< T >.

## ◆ DoHasDirectFeedthrough()

 optional< bool > DoHasDirectFeedthrough ( int input_port, int output_port ) const
overrideprotectedvirtual

Returns true if there is direct-feedthrough from the given input_port to the given output_port, false if there is not direct-feedthrough, or nullopt if unknown (in which case SystemSymbolicInspector will attempt to measure the feedthrough using symbolic form).

By default, LeafSystem assumes there is direct feedthrough of values from every input to every output. This is a conservative assumption that ensures we detect and can prevent the formation of algebraic loops (implicit computations) in system Diagrams. Systems which do not have direct feedthrough may override that assumption in two ways:

• Override DoToSymbolic, allowing LeafSystem to infer the sparsity from the symbolic equations. This method is typically preferred for systems that have a symbolic form, but should be avoided in certain corner cases where fully descriptive symbolic analysis is impossible, e.g., when the symbolic form depends on C++ native conditionals. For additional discussion, consult the documentation for SystemSymbolicInspector.
• Override this function directly, reporting manual sparsity. This method is recommended when DoToSymbolic has not been implemented, or when creating the symbolic form is too computationally expensive, or when its output is not fully descriptive, as discussed above. Manually configured sparsity must be conservative: if there is any Context for which an input port is direct-feedthrough to an output port, this function must return either true or nullopt for those two ports.

Reimplemented from LeafSystem< T >.

## ◆ DoMapQDotToVelocity()

 void DoMapQDotToVelocity ( const Context< T > & context, const Eigen::Ref< const VectorX< T >> & qdot, VectorBase< T > * generalized_velocity ) const
overrideprotectedvirtual

Provides the substantive implementation of MapQDotToVelocity().

The default implementation uses the identity mapping, and correctly does nothing if the System does not have second-order state variables. It throws std::runtime_error if the generalized_velocity and qdot are not the same size, but that is not enough to guarantee that the default implementation is adequate. Child classes must override this function if qdot != v (even if they are the same size). This occurs, for example, if a joint uses roll-pitch-yaw rotation angles for orientation but angular velocity for rotational rate rather than rotation angle derivatives.

If you implement this method you are required to use no more than O(nq) time where nq is the size of qdot, so that the System can meet the performance guarantee made for the public interface, and you must also implement DoMapVelocityToQDot(). Implementations may assume that qdot has already been validated to be the same size as q in the given Context, and that generalized_velocity is non-null.

Reimplemented from System< T >.

## ◆ DoMapVelocityToQDot()

 void DoMapVelocityToQDot ( const Context< T > & context, const Eigen::Ref< const VectorX< T >> & generalized_velocity, VectorBase< T > * qdot ) const
overrideprotectedvirtual

Provides the substantive implementation of MapVelocityToQDot().

The default implementation uses the identity mapping, and correctly does nothing if the System does not have second-order state variables. It throws std::runtime_error if the generalized_velocity (v) and qdot are not the same size, but that is not enough to guarantee that the default implementation is adequate. Child classes must override this function if qdot != v (even if they are the same size). This occurs, for example, if a joint uses roll-pitch-yaw rotation angles for orientation but angular velocity for rotational rate rather than rotation angle derivatives.

If you implement this method you are required to use no more than O(nq) time where nq is the size of qdot, so that the System can meet the performance guarantee made for the public interface, and you must also implement DoMapQDotToVelocity(). Implementations may assume that generalized_velocity has already been validated to be the same size as v in the given Context, and that qdot is non-null.

Reimplemented from System< T >.

## ◆ EvaluateActuatorInputs()

 VectorX< T > EvaluateActuatorInputs ( const Context< T > & context ) const
protected

## ◆ FindInstancePositionIndexFromWorldIndex()

 int FindInstancePositionIndexFromWorldIndex ( int model_instance_id, int world_position_index )

Returns the index into the output port for model_instance_id which corresponds to the world position index of world_position_index, or throws if the position index does not correspond to the model id.

## ◆ get_input_size()

 int get_input_size ( ) const

Returns the size of the input vector to the system.

This equals the number of actuators.

## ◆ get_num_actuators() [1/2]

 int get_num_actuators ( ) const

Returns the number of actuators.

## ◆ get_num_actuators() [2/2]

 int get_num_actuators ( int model_instance_id ) const

Returns the number of actuators for a specific model instance.

## ◆ get_num_bodies()

 int get_num_bodies ( ) const

Returns the number of bodies in the world.

## ◆ get_num_model_instances()

 int get_num_model_instances ( ) const

Returns the number of model instances in the world, not including the world.

## ◆ get_num_positions() [1/2]

 int get_num_positions ( ) const

Returns the number of generalized coordinates of the model.

## ◆ get_num_positions() [2/2]

 int get_num_positions ( int model_instance_id ) const

Returns the number of generalized coordinates for a specific model instance.

## ◆ get_num_states() [1/2]

 int get_num_states ( ) const

Returns the size of the continuous state of the system which equals get_num_positions() plus get_num_velocities().

## ◆ get_num_states() [2/2]

 int get_num_states ( int model_instance_id ) const

Returns the size of the continuous state of a specific model instance which equals get_num_positions() plus get_num_velocities().

## ◆ get_num_velocities() [1/2]

 int get_num_velocities ( ) const

Returns the number of generalized velocities of the model.

## ◆ get_num_velocities() [2/2]

 int get_num_velocities ( int model_instance_id ) const

Returns the number of generalized velocities for a specific model instance.

## ◆ get_output_size()

 int get_output_size ( ) const

Returns the size of the output vector of the system.

This equals the size of the continuous state vector.

## ◆ get_rigid_body_tree()

 const RigidBodyTree< double > & get_rigid_body_tree ( ) const

Returns a constant reference to the multibody dynamics model of the world.

## ◆ get_time_step()

 double get_time_step ( ) const

Get the time step used to construct the plant.

If the step is zero, the system is continuous. Otherwise, the step corresponds to the update rate (seconds per update).

## ◆ GetStateVector()

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

## ◆ is_state_discrete()

 bool is_state_discrete ( ) const

Gets whether this system is modeled using discrete state.

## ◆ JointLimitForce()

 T JointLimitForce ( const DrakeJoint & joint, const T & position, const T & velocity )
static

Computes the force exerted by the stop when a joint hits its limit, using a linear stiffness model.

Exposed for unit testing of the formula.

Linear stiffness formula (and definition of "dissipation") from: https://simtk.org/api_docs/simbody/latest/classSimTK_1_1Force_1_1MobilityLinearStop.html#details

## ◆ kinematics_results_output_port()

 const OutputPort& kinematics_results_output_port ( ) const

Returns the KinematicsResults output port.

## ◆ model_instance_actuator_command_input_port()

 const InputPort< T > & model_instance_actuator_command_input_port ( int model_instance_id ) const

Returns the input port for a specific model instance.

This method can only be called when this class is instantiated with constructor parameter export_model_instance_centric_ports equal to true.

## ◆ model_instance_has_actuators()

 bool model_instance_has_actuators ( int model_instance_id ) const

Returns true if and only if the model instance with the provided model_instance_id has actuators.

This is useful when trying to determine whether it's safe to call model_instance_actuator_command_input_port().

## ◆ model_instance_state_output_port()

 const OutputPort< T > & model_instance_state_output_port ( int model_instance_id ) const

Returns the output port containing the state of a particular model with instance ID equal to model_instance_id.

Exceptions
 std::runtime_error if model_instance_id does not exist.

This method can only be called when this class is instantiated with constructor parameter export_model_instance_centric_ports equal to true.

## ◆ model_instance_torque_output_port()

 const OutputPort< T > & model_instance_torque_output_port ( int model_instance_id ) const

Returns the output port containing the measured joint torques of a particular model with model_instance_id.

## ◆ operator=() [1/2]

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

## ◆ operator=() [2/2]

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

## ◆ set_contact_model_parameters()

 void set_contact_model_parameters ( const CompliantContactModelParameters & parameters )

Sets the parameters of the compliance model.

To set material parameters, use the CompliantMaterial instance associated with the collision element.

## ◆ set_default_compliant_material()

 void set_default_compliant_material ( const CompliantMaterial & material )

Sets the compliant material values to use for default-configured material properties on collision elements (see CompliantMaterial for details).

## ◆ set_position()

 void set_position ( Context< T > * context, int position_index, T position ) const

Sets the generalized coordinate position_index to the value position.

## ◆ set_state_vector() [1/2]

 void set_state_vector ( Context< T > * context, const Eigen::Ref< const VectorX< T >> x ) const

Sets the continuous state vector of the system to be x.

## ◆ set_state_vector() [2/2]

 void set_state_vector ( State< T > * state, const Eigen::Ref< const VectorX< T >> x ) const

Sets the continuous state vector of the system to be x.

## ◆ set_velocity()

 void set_velocity ( Context< T > * context, int velocity_index, T velocity ) const

Sets the generalized velocity velocity_index to the value velocity.

## ◆ SetDefaultState()

 void SetDefaultState ( const Context< T > & , State< T > * state ) const
overridevirtual

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

For quaternion based joints the quaternion is set to be the identity (or equivalently a zero rotation).

Implements System< T >.

## ◆ SetModelInstancePositions()

 void SetModelInstancePositions ( Context< T > * context, int model_instance_id, const Eigen::Ref< const VectorX< T >> positions ) const

Sets the generalized coordinates of the model instance specified by model_instance_id to the values in position.

## ◆ state_derivative_output_port()

 const OutputPort& state_derivative_output_port ( ) const

Returns the plant-centric state derivative output port.

The size of this port is equal to get_num_states().

Precondition
This RigidBodyPlant is using continuous-time dynamics.

## ◆ state_output_port()

 const OutputPort& state_output_port ( ) const

Returns the plant-centric state output port.

The size of this port is equal to get_num_states().

## ◆ torque_output_port()

 const OutputPort& torque_output_port ( ) const

Returns the output port containing measured joint torques.

Exceptions
 std::runtime_error if this RigidBodyTree contains more than one model instances.

## ◆ RigidBodyPlant

 friend class RigidBodyPlant
friend

## ◆ RigidBodyPlantTimeSteppingDataTest_NormalJacobian_Test

 friend class RigidBodyPlantTimeSteppingDataTest_NormalJacobian_Test
friend

## ◆ RigidBodyPlantTimeSteppingDataTest_TangentJacobian_Test

 friend class RigidBodyPlantTimeSteppingDataTest_TangentJacobian_Test
friend

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