Drake
Drake C++ Documentation
SystemBase Class Referenceabstract

Detailed Description

Provides non-templatized functionality shared by the templatized System classes.

Terminology: in general a Drake System is a tree structure composed of "subsystems", which are themselves System objects. The corresponding Context is a parallel tree structure composed of "subcontexts", which are themselves Context objects. There is a one-to-one correspondence between subsystems and subcontexts. Within a given System (Context), its child subsystems (subcontexts) are indexed using a SubsystemIndex; there is no separate SubcontextIndex since the numbering must be identical.

#include <drake/systems/framework/system_base.h>

Classes

struct  ContextSizes
 Return type for get_context_sizes(). More...
 
struct  GraphvizFragment
 (Advanced) The return type of GetGraphvizFragment(). More...
 
struct  GraphvizFragmentParams
 (Advanced) The arguments to the protected method DoGetGraphvizFragment(). More...
 

Public Member Functions

 ~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...
 
std::string GetMemoryObjectName () const
 Returns a name for this System based on a stringification of its type name and memory address. 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...
 
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...
 
virtual std::multimap< int, intGetDirectFeedthroughs () const =0
 Reports all direct feedthroughs from input ports to output ports. 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...
 
int num_continuous_states () const
 Returns the number of declared continuous state variables. 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...
 
int implicit_time_derivatives_residual_size () const
 Returns the size of the implicit time derivatives residual vector. More...
 
void ValidateContext (const ContextBase &context) const final
 Checks whether the given context was created for this system. More...
 
void ValidateContext (const ContextBase *context) const
 Checks whether the given context was created for this system. More...
 
template<class Clazz >
void ValidateCreatedForThisSystem (const Clazz &object) const
 Checks whether the given object was created for this system. More...
 
Does not allow copy, move, or assignment
 SystemBase (const SystemBase &)=delete
 
SystemBaseoperator= (const SystemBase &)=delete
 
 SystemBase (SystemBase &&)=delete
 
SystemBaseoperator= (SystemBase &&)=delete
 
Graphviz methods
std::string GetGraphvizString (std::optional< int > max_depth={}, const std::map< std::string, std::string > &options={}) const
 Returns a Graphviz string describing this System. More...
 
GraphvizFragment GetGraphvizFragment (std::optional< int > max_depth={}, const std::map< std::string, std::string > &options={}) const
 (Advanced) Like GetGraphvizString() but does not wrap the string in a digraph { … }. More...
 
Input port evaluation (deprecated)

These deprecated methods provide scalar type-independent evaluation of a System input port in a particular Context.

Instead of these, prefer to use InputPort::Eval(), acquiring the port with get_input_port(port_index).

If necessary, the methods here first cause the port's value to become up to date, then they return a reference to the now-up-to-date value in the given Context.

Specified preconditions for these methods operate as follows: The preconditions will be checked in Debug builds but some or all might not be checked in Release builds for performance reasons. If we do check, and a precondition is violated, an std::exception will be thrown with a helpful message.

See also
System::get_input_port(), InputPort::Eval() for scalar type-specific input port access.
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...
 

Protected Member Functions

 SystemBase ()=default
 (Internal use only). 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 (std::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 (std::variant< std::string, UseDefaultName > given_name) const
 (Internal use only) Returns a name for the next output port, using the given name if it isn't kUseDefaultName, otherwise making up a name like "y3" from the next available output port index. More...
 
void AddDiscreteStateGroup (DiscreteStateIndex index)
 (Internal use only) Assigns a ticket to a new discrete variable group with the given index. More...
 
void AddAbstractState (AbstractStateIndex index)
 (Internal use only) Assigns a ticket to a new abstract state variable with the given index. More...
 
void AddNumericParameter (NumericParameterIndex index)
 (Internal use only) Assigns a ticket to a new numeric parameter with the given index. More...
 
void AddAbstractParameter (AbstractParameterIndex index)
 (Internal use only) Assigns a ticket to a new abstract parameter with the given index. More...
 
CacheEntryDeclareCacheEntryWithKnownTicket (DependencyTicket known_ticket, std::string description, ValueProducer value_producer, 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...
 
bool IsObviouslyNotInputDependent (DependencyTicket dependency_ticket) const
 (Internal use only) Checks if a ticket depends on (any) input port. More...
 
virtual std::function< void(const AbstractValue &)> MakeFixInputPortTypeChecker (InputPortIndex port_index) const =0
 (Internal use only) Given a port_index, returns a function to be called when validating Context::FixInputPort requests. 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::exception 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::exception 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::exception 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::exception 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::exception 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::exception 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, bool warn_deprecated) const
 (Internal use only) Returns the InputPortBase at index port_index, throwing std::exception we don't like the port index. More...
 
const OutputPortBaseGetOutputPortBaseOrThrow (const char *func, int port_index, bool warn_deprecated) const
 (Internal use only) Returns the OutputPortBase at index port_index, throwing std::exception if we don't like the port index. More...
 
void ThrowValidateContextMismatch (const ContextBase &) const
 (Internal use only) Throws std::exception with a message that the sanity check(s) given by ValidateContext have failed. More...
 
virtual std::string GetUnsupportedScalarConversionMessage (const std::type_info &source_type, const std::type_info &destination_type) const
 (Internal use only) Returns the message to use for a std::exception in the case of unsupported scalar type conversions. 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...
 
virtual std::unique_ptr< ContextBaseDoAllocateContext () const =0
 Derived class implementations should allocate a suitable concrete Context type, then invoke the above InitializeContextBase() method. More...
 
const ContextSizesget_context_sizes () const
 Obtains access to the declared Context partition sizes as accumulated during LeafSystem or Diagram construction . More...
 
ContextSizesget_mutable_context_sizes ()
 Obtains mutable access to the Context sizes struct. More...
 
void set_implicit_time_derivatives_residual_size (int n)
 Allows a LeafSystem to override the default size for the implicit time derivatives residual and a Diagram to sum up the total size. More...
 
internal::SystemId get_system_id () const
 (Internal) Gets the id used to tag context data as being created by this system. More...
 
virtual GraphvizFragment DoGetGraphvizFragment (const GraphvizFragmentParams &params) const
 The NVI implementation of GetGraphvizFragment() for subclasses to override if desired. More...
 
Declare cache entries

Methods in this section are used by derived classes to declare cache entries for their own internal computations. (Other cache entries are provided automatically for well-known computations such as output ports and time derivatives.) Cache entries may contain values of any type, however the type for any particular cache entry is fixed after first allocation. Every cache entry must have an allocator function Allocate() and a calculator function Calc(). Allocate() returns an object suitable for holding a value of the cache entry. Calc() uses the contents of a given Context to produce the cache entry's value, which is placed in an object of the type returned by Allocate().

Prerequisites

Correct runtime caching behavior depends critically on understanding the dependencies of the cache entry's Calc() function (we call those "prerequisites"). If none of the prerequisites has changed since the last time Calc() was invoked to set the cache entry's value, then we don't need to perform a potentially expensive recalculation. On the other hand, if any of the prerequisites has changed then the current value is invalid and must not be used without first recomputing.

Currently it is not possible for Drake to infer prerequisites accurately and automatically from inspection of the Calc() implementation. Therefore, if you don't say otherwise, Drake will assume Calc() is dependent on all value sources in the Context, including time, state, input ports, parameters, and accuracy. That means the cache entry's value will be considered invalid if any of those sources has changed since the last time the value was calculated. That is safe, but can result in more computation than necessary. If you know that your Calc() method has fewer prerequisites, you may say so by providing an explicit list in the prerequisites_of_calc parameter. Every possible prerequisite has a DependencyTicket ("ticket"), and the list should consist of tickets. For example, if your calculator depends only on time (e.g. Calc(context) is sin(context.get_time())) then you would specify prerequisites_of_calc={time_ticket()} here. See Dependency tickets for a list of the possible tickets and what they mean.

Warning
It is critical that the prerequisite list you supply be accurate, or at least conservative, for correct functioning of the caching system. Drake cannot currently detect that a Calc() function accesses an undeclared prerequisite. Even assuming you have correctly listed the prerequisites, you should include a prominent comment in every Calc() implementation noting that if the implementation is changed then the prerequisite list must be updated correspondingly.

A technique you can use to ensure that prerequisites have been properly specified is to make use of the Context's DisableCaching() method, which causes cache values to be recalculated unconditionally. You should get identical results with caching enabled or disabled, with speed being the only difference. You can also disable caching for individual cache entries in a Context, or specify that individual cache entries should be disabled by default when they are first allocated.

See also
ContextBase::DisableCaching()
CacheEntry::disable_caching()
CacheEntry::disable_caching_by_default()
LeafOutputPort::disable_caching_by_default()

Which signature to use?

Although the allocator and calculator functions ultimately satisfy generic function signatures defined by a ValueProducer, we provide a variety of DeclareCacheEntry() signatures here for convenient specification, with mapping to the generic form handled invisibly. In particular, allocators are most easily defined by providing a model value that can be used to construct an allocator that copies the model when a new value object is needed. Alternatively a method can be provided that constructs a value object when invoked (those methods are conventionally, but not necessarily, named MakeSomething() where Something is replaced by the cache entry value type).

Because cache entry values are ultimately stored in AbstractValue objects, the underlying types must be suitable. That means the type must be copy constructible or cloneable. For methods below that are not given an explicit model value or construction ("make") method, the underlying type must also be default constructible.

See also
drake::Value for more about abstract values.
CacheEntryDeclareCacheEntry (std::string description, ValueProducer value_producer, std::set< DependencyTicket > prerequisites_of_calc={ all_sources_ticket()})
 Declares a new CacheEntry in this System using the most generic form of the calculation function. More...
 
template<class MySystem , class MyContext , typename ValueType >
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 >
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...
 

Static Protected Member Functions

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::exception because someone called API method func claiming the input port had some value type that was wrong. More...
 
static const ContextSizesget_context_sizes (const SystemBase &system)
 Allows Diagram to access protected get_context_sizes() recursively on its subsystems. More...
 

Friends

class internal::DiagramSystemBaseAttorney
 

Dependency tickets

Use these tickets to declare well-known sources as prerequisites of a downstream computation such as an output port, derivative, update, or cache entry. The ticket numbers for the built-in sources are the same for all systems. For time and accuracy they refer to the same global resource; otherwise they refer to the specified sources within the referencing system.

A dependency ticket for a more specific resource (a particular input or output port, a discrete variable group, abstract state variable, a parameter, or a cache entry) is allocated and stored with the resource when it is declared. Usually the tickets are obtained directly from the resource but you can recover them with methods here knowing only the resource index.

DependencyTicket discrete_state_ticket (DiscreteStateIndex index) const
 Returns a ticket indicating dependence on a particular discrete state variable xdᵢ (may be a vector). More...
 
DependencyTicket abstract_state_ticket (AbstractStateIndex index) const
 Returns a ticket indicating dependence on a particular abstract state variable xaᵢ. More...
 
DependencyTicket numeric_parameter_ticket (NumericParameterIndex index) const
 Returns a ticket indicating dependence on a particular numeric parameter pnᵢ (may be a vector). More...
 
DependencyTicket abstract_parameter_ticket (AbstractParameterIndex index) const
 Returns a ticket indicating dependence on a particular abstract parameter paᵢ. More...
 
DependencyTicket input_port_ticket (InputPortIndex index) const
 Returns a ticket indicating dependence on input port uᵢ indicated by index. More...
 
DependencyTicket cache_entry_ticket (CacheIndex index) const
 Returns a ticket indicating dependence on the cache entry indicated by index. More...
 
DependencyTicket output_port_ticket (OutputPortIndex index) const
 (Internal use only) Returns a ticket indicating dependence on the output port indicated by index. More...
 
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_except_input_ports_ticket ()
 Returns a ticket indicating dependence on every possible independent source value except input ports. 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...
 
static DependencyTicket xd_unique_periodic_update_ticket ()
 (Internal use only) Returns a ticket for the cache entry that holds the unique periodic discrete update computation. More...
 

Constructor & Destructor Documentation

◆ SystemBase() [1/3]

SystemBase ( const SystemBase )
delete

◆ SystemBase() [2/3]

SystemBase ( SystemBase &&  )
delete

◆ ~SystemBase()

~SystemBase ( )
override

◆ SystemBase() [3/3]

SystemBase ( )
protecteddefault

(Internal use only).

Member Function Documentation

◆ abstract_parameter_ticket()

DependencyTicket abstract_parameter_ticket ( AbstractParameterIndex  index) const

Returns a ticket indicating dependence on a particular abstract parameter paᵢ.

See also
pa_ticket() to obtain a ticket for all abstract parameters.

◆ abstract_state_ticket()

DependencyTicket abstract_state_ticket ( AbstractStateIndex  index) const

Returns a ticket indicating dependence on a particular abstract state variable xaᵢ.

See also
xa_ticket() to obtain a ticket for all abstract variables.

◆ accuracy_ticket()

static DependencyTicket accuracy_ticket ( )
static

Returns a ticket indicating dependence on the accuracy setting in the Context.

This is the same ticket for all systems and refers to the same accuracy value.

◆ AddAbstractParameter()

void AddAbstractParameter ( AbstractParameterIndex  index)
protected

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

Precondition
The supplied index must be the next available one; that is, indexes must be assigned sequentially.

◆ AddAbstractState()

void AddAbstractState ( AbstractStateIndex  index)
protected

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

Precondition
The supplied index must be the next available one; that is, indexes must be assigned sequentially.

◆ AddDiscreteStateGroup()

void AddDiscreteStateGroup ( DiscreteStateIndex  index)
protected

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

Precondition
The supplied index must be the next available one; that is, indexes must be assigned sequentially.

◆ AddInputPort()

void AddInputPort ( std::unique_ptr< InputPortBase port)
protected

(Internal use only) Adds an already-constructed input port to this System.

Insists that the port already contains a reference to this System, and that the port's index is already set to the next available input port index for this System, that the port name is unique (just within this System), and that the port name is non-empty.

◆ AddNumericParameter()

void AddNumericParameter ( NumericParameterIndex  index)
protected

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

Precondition
The supplied index must be the next available one; that is, indexes must be assigned sequentially.

◆ AddOutputPort()

void AddOutputPort ( std::unique_ptr< OutputPortBase port)
protected

(Internal use only) Adds an already-constructed output port to this System.

Insists that the port already contains a reference to this System, and that the port's index is already set to the next available output port index for this System, and that the name of the port is unique.

Exceptions
std::exceptionif the name of the output port is not unique.

◆ all_input_ports_ticket()

static DependencyTicket all_input_ports_ticket ( )
static

Returns a ticket indicating dependence on all input ports u of this system.

See also
input_port_ticket() to obtain a ticket for just one input port.

◆ all_parameters_ticket()

static DependencyTicket all_parameters_ticket ( )
static

Returns a ticket indicating dependence on all parameters p in this system, including numeric parameters pn, and abstract parameters pa.

◆ all_sources_except_input_ports_ticket()

static DependencyTicket all_sources_except_input_ports_ticket ( )
static

Returns a ticket indicating dependence on every possible independent source value except input ports.

This can be helpful in avoiding the incorrect appearance of algebraic loops in a Diagram (those always involve apparent input port dependencies). For an output port, use this ticket plus tickets for just the input ports on which the output computation actually depends. The sources included in this ticket are: time, accuracy, state, and parameters. Note that dependencies on cache entries are not included here. Usually that won't matter since cache entries typically depend on at least one of time, accuracy, state, or parameters so will be invalidated for the same reason the current computation is. However, for a computation that depends on a cache entry that depends only on input ports, be sure that you have included those input ports in the dependency list, or include a direct dependency on the cache entry.

See also
input_port_ticket() to obtain a ticket for an input port.
cache_entry_ticket() to obtain a ticket for a cache entry.
all_sources_ticket() to also include all input ports as dependencies.

◆ all_sources_ticket()

static DependencyTicket all_sources_ticket ( )
static

Returns a ticket indicating dependence on every possible independent source value, including time, accuracy, state, input ports, and parameters (but not cache entries).

This is the default dependency for computations that have not specified anything more refined. It is equivalent to the set {all_sources_except_input_ports_ticket(), all_input_ports_ticket()}.

See also
cache_entry_ticket() to obtain a ticket for a cache entry.

◆ all_state_ticket()

static DependencyTicket all_state_ticket ( )
static

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.

This does not imply dependence on time, accuracy, parameters, or inputs; those must be specified separately. If you mean to express dependence on all possible value sources, use all_sources_ticket() instead.

◆ AllocateContext()

std::unique_ptr<ContextBase> AllocateContext ( ) const

Returns a Context suitable for use with this System.

Context resources are allocated based on resource requests that were made during System construction.

◆ assign_next_dependency_ticket()

DependencyTicket assign_next_dependency_ticket ( )
protected

(Internal use only) Assigns the next unused dependency ticket number, unique only within a particular system.

Each call to this method increments the ticket number.

◆ cache_entry_ticket()

DependencyTicket cache_entry_ticket ( CacheIndex  index) const

Returns a ticket indicating dependence on the cache entry indicated by index.

Note that cache entries are not included in the all_sources ticket so must be listed separately.

Precondition
index selects an existing cache entry in this System.

◆ configuration_ticket()

static DependencyTicket configuration_ticket ( )
static

Returns a ticket indicating dependence on all source values that may affect configuration-dependent computations.

In particular, this category does not include time, generalized velocities v, miscellaneous continuous state variables z, or input ports. Generalized coordinates q are included, as well as any discrete state variables that have been declared as configuration variables, and configuration-affecting parameters. Finally we assume that the accuracy setting may affect some configuration-dependent computations. Examples: a parameter that affects length may change the computation of an end-effector location. A change in accuracy requirement may require recomputation of an iterative approximation of contact forces.

See also
kinematics_ticket()
Note
Currently there is no way to declare specific variables and parameters to be configuration-affecting so we include all state variables and parameters except for state variables v and z.

◆ DeclareCacheEntry() [1/3]

CacheEntry& DeclareCacheEntry ( std::string  description,
ValueProducer  value_producer,
std::set< DependencyTicket prerequisites_of_calc = all_sources_ticket()} 
)
protected

Declares a new CacheEntry in this System using the most generic form of the calculation function.

Prefer one of the more convenient signatures below if you can. The new cache entry is assigned a unique CacheIndex and DependencyTicket, which can be obtained from the returned CacheEntry.

Parameters
[in]descriptionA human-readable description of this cache entry, most useful for debugging and documentation. Not interpreted in any way by Drake; it is retained by the cache entry and used to generate the description for the corresponding CacheEntryValue in the Context.
[in]value_producerProvides the computation that maps from a given Context to the current value that this cache entry should have, as well as a way to allocate storage prior to the computation.
[in]prerequisites_of_calcProvides the DependencyTicket list containing a ticket for every Context value on which calc_function may depend when it computes its result. Defaults to {all_sources_ticket()} if unspecified. If the cache value is truly independent of the Context (rare!) say so explicitly by providing the list {nothing_ticket()}; an explicitly empty list {} is forbidden.
Returns
a reference to the newly-created CacheEntry.
Exceptions
std::exceptionif given an explicitly empty prerequisite list.

◆ DeclareCacheEntry() [2/3]

CacheEntry & DeclareCacheEntry ( std::string  description,
const ValueType &  model_value,
void(MySystem::*)(const MyContext &, ValueType *) const  calc,
std::set< DependencyTicket prerequisites_of_calc = all_sources_ticket()} 
)
protected

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:

void MySystem::CalcCacheValue(const MyContext&, ValueType*) const;

where MySystem is a class derived from SystemBase, MyContext is a class derived from ContextBase, and ValueType is any concrete type such that Value<ValueType> is permitted. (The method names are arbitrary.) Template arguments will be deduced and do not need to be specified. See the primary DeclareCacheEntry() signature above for more information about the parameters and behavior.

See also
drake::Value

◆ DeclareCacheEntry() [3/3]

CacheEntry & DeclareCacheEntry ( std::string  description,
void(MySystem::*)(const MyContext &, ValueType *) const  calc,
std::set< DependencyTicket prerequisites_of_calc = all_sources_ticket()} 
)
protected

Declares a cache entry by specifying only a calculator function that is a class member function (method) with signature:

void MySystem::CalcCacheValue(const MyContext&, ValueType*) const;

where MySystem is a class derived from SystemBase and MyContext is a class derived from ContextBase. ValueType is a concrete type such that (a) Value<ValueType> is permitted, and (b) ValueType is default constructible. That allows us to create a model value using Value<ValueType>{} (value initialized so numerical types will be zeroed in the model). (The method name is arbitrary.) Template arguments will be deduced and do not need to be specified. See the first DeclareCacheEntry() signature above for more information about the parameters and behavior.

Note
The default constructor will be called once immediately to create a model value, and subsequent allocations will just copy the model value without invoking the constructor again. If you want the constructor invoked again at each allocation (not common), use one of the other signatures to explicitly provide a method for the allocator to call; that method can then invoke the ValueType default constructor each time it is called.
See also
drake::Value

◆ DeclareCacheEntryWithKnownTicket()

CacheEntry& DeclareCacheEntryWithKnownTicket ( DependencyTicket  known_ticket,
std::string  description,
ValueProducer  value_producer,
std::set< DependencyTicket prerequisites_of_calc = all_sources_ticket()} 
)
protected

(Internal use only) This is for cache entries associated with pre-defined tickets, for example the cache entry for time derivatives.

See the public API for the most-general DeclareCacheEntry() signature for the meanings of the other parameters here.

◆ discrete_state_ticket()

DependencyTicket discrete_state_ticket ( DiscreteStateIndex  index) const

Returns a ticket indicating dependence on a particular discrete state variable xdᵢ (may be a vector).

(We sometimes refer to this as a "discrete variable group".)

See also
xd_ticket() to obtain a ticket for all discrete variables.

◆ DoAllocateContext()

virtual std::unique_ptr<ContextBase> DoAllocateContext ( ) const
protectedpure virtual

Derived class implementations should allocate a suitable concrete Context type, then invoke the above InitializeContextBase() method.

A Diagram must then invoke AllocateContext() to obtain each of the subcontexts for its DiagramContext, and must set up inter-subcontext dependencies among its children and between itself and its children. Then context resources such as parameters and state should be allocated.

Implemented in LeafSystem< T >, LeafSystem< Element::T >, LeafSystem< double >, and LeafSystem< AutoDiffXd >.

◆ DoGetGraphvizFragment()

virtual GraphvizFragment DoGetGraphvizFragment ( const GraphvizFragmentParams params) const
protectedvirtual

The NVI implementation of GetGraphvizFragment() for subclasses to override if desired.

The default behavior should be sufficient in most cases.

Reimplemented in Diagram< T >, and Diagram< double >.

◆ EvalAbstractInput()

const AbstractValue* EvalAbstractInput ( 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.

Causes the value to become up to date first if necessary, delegating to our parent Diagram. Returns a pointer to the port's value, or nullptr if the port is not connected. If you know the actual type, use one of the more-specific signatures.

Precondition
port_index selects an existing input port of this System.
See also
InputPort::Eval() (preferred)

◆ EvalAbstractInputImpl()

const AbstractValue* EvalAbstractInputImpl ( const char *  func,
const ContextBase context,
InputPortIndex  port_index 
) const
protected

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

func should be the user-visible API function name obtained with func.

◆ EvalInputValue()

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.

Causes the value to become up to date first if necessary. See EvalAbstractInput() for more information.

The result is returned as a pointer to the input port's value of type V, or nullptr if the port is not connected.

Precondition
port_index selects an existing input port of this System.
the port's value must be retrievable from the stored abstract value using AbstractValue::get_value<V>.
See also
InputPort::Eval() (preferred)
Template Parameters
VThe type of data expected.

◆ get_cache_entry()

const CacheEntry& get_cache_entry ( CacheIndex  index) const

Returns a reference to a CacheEntry given its index.

◆ get_context_sizes() [1/2]

const ContextSizes& get_context_sizes ( ) const
protected

Obtains access to the declared Context partition sizes as accumulated during LeafSystem or Diagram construction .

◆ get_context_sizes() [2/2]

static const ContextSizes& get_context_sizes ( const SystemBase system)
staticprotected

Allows Diagram to access protected get_context_sizes() recursively on its subsystems.

◆ get_input_port_base()

const InputPortBase& get_input_port_base ( InputPortIndex  port_index) const

Returns a reference to an InputPort given its port_index.

Precondition
port_index selects an existing input port of this System.

◆ get_mutable_cache_entry()

CacheEntry& get_mutable_cache_entry ( CacheIndex  index)

(Advanced) Returns a mutable reference to a CacheEntry given its index.

Note that you do not need mutable access to a CacheEntry to modify its value in a Context, so most users should not use this method.

◆ get_mutable_context_sizes()

ContextSizes& get_mutable_context_sizes ( )
protected

Obtains mutable access to the Context sizes struct.

Should be used only during LeafSystem or Diagram construction.

◆ get_name()

const std::string& get_name ( ) const

Returns the name last supplied to set_name(), if any.

Diagrams built with DiagramBuilder will always have a default name for every contained subsystem for which no user-provided name is available. Systems created by copying with a scalar type change have the same name as the source system. An empty string is returned if no name has been set.

◆ get_output_port_base()

const OutputPortBase& get_output_port_base ( OutputPortIndex  port_index) const

Returns a reference to an OutputPort given its port_index.

Precondition
port_index selects an existing output port of this System.

◆ get_parent_service()

const internal::SystemParentServiceInterface* get_parent_service ( ) const
protected

Returns a pointer to the service interface of the immediately enclosing Diagram if one has been set, otherwise nullptr.

◆ get_system_id()

internal::SystemId get_system_id ( ) const
protected

(Internal) Gets the id used to tag context data as being created by this system.

See System Compatibility.

◆ GetDirectFeedthroughs()

virtual std::multimap<int, int> GetDirectFeedthroughs ( ) const
pure virtual

Reports all direct feedthroughs from input ports to output ports.

For a system with m input ports: I = i₀, i₁, ..., iₘ₋₁, and n output ports, O = o₀, o₁, ..., oₙ₋₁, the return map will contain pairs (u, v) such that

  • 0 ≤ u < m,
  • 0 ≤ v < n,
  • and there might be a direct feedthrough from input iᵤ to each output oᵥ.

See DeclareLeafOutputPort documentation for how leaf systems can report their feedthrough.

Implemented in Diagram< T >, Diagram< double >, LeafSystem< T >, LeafSystem< Element::T >, LeafSystem< double >, and LeafSystem< AutoDiffXd >.

◆ GetGraphvizFragment()

GraphvizFragment GetGraphvizFragment ( std::optional< int max_depth = {},
const std::map< std::string, std::string > &  options = {} 
) const

(Advanced) Like GetGraphvizString() but does not wrap the string in a digraph { … }.

This is useful when merging the fragment into another graph, and is how Diagram obtains the Graphviz content for its subsystems. The parameters are identical to GetGraphvizString(). The return value contains additional metadata beyond the Graphviz content, to better support merging.

◆ GetGraphvizString()

std::string GetGraphvizString ( std::optional< int max_depth = {},
const std::map< std::string, std::string > &  options = {} 
) const

Returns a Graphviz string describing this System.

To render the string, use the Graphviz tool, dot.

Notes about the display conventions:

  • The nodes of the graph are systems, and the solid edges are connections between system input and output ports.
  • The class name of a System is shown in Bold atop the node.
  • Under the class name, if a System has been given a name via set_name(), it will be displayed as name=....
  • Systems can elect to display additional properties besides their name; see GraphvizFragmentParams::header_lines for implementation details.
  • A Diagram's input ports are shown with a blue border and output ports are shown with a green border.
  • Zero-sized ports are greyed out.
  • Deprecated ports are struck through and flagged with a headstone emoji (🪦) after their name.
Parameters
max_depthSets a limit to the depth of nested diagrams to visualize. Use zero to render a diagram as a single system block.
optionsArbitrary strings to request alterations to the output. Options that are unknown will be silently skipped. These options are often bespoke flags that are only understood by particular systems, but Drake has one built-in flag that is generally applicable: "split". When set to "I/O", the system will be added as two nodes with all inputs on one node and all outputs on the other; this is useful for systems that might otherwise cause problematic visual cycles.

Options are applied only to this immediate system; they are not inherited by the subsystems of a Diagram. To specify an option for a Diagram's subsystem, prefix the option name with the subsystem's path, e.g., use "plant/split"="I/O" to set the "split" option on the subsystem named "plant".

◆ GetInputPortBaseOrThrow()

const InputPortBase& GetInputPortBaseOrThrow ( const char *  func,
int  port_index,
bool  warn_deprecated 
) const
protected

(Internal use only) Returns the InputPortBase at index port_index, throwing std::exception we don't like the port index.

The name of the public API method that received the bad index is provided in func and is included in the error message. The warn_deprecated governs whether or not a deprecation warning should occur when the port_index is deprecated; calls made on behalf of the user should pass true; calls made on behalf or the framework internals should pass false.

◆ GetMemoryObjectName()

std::string GetMemoryObjectName ( ) const

Returns a name for this System based on a stringification of its type name and memory address.

This is intended for use in diagnostic output and should not be used for behavioral logic, because the stringification of the type name may produce differing results across platforms and because the address can vary from run to run.

◆ GetOutputPortBaseOrThrow()

const OutputPortBase& GetOutputPortBaseOrThrow ( const char *  func,
int  port_index,
bool  warn_deprecated 
) const
protected

(Internal use only) Returns the OutputPortBase at index port_index, throwing std::exception if we don't like the port index.

The name of the public API method that received the bad index is provided in func and is included in the error message. The warn_deprecated governs whether or not a deprecation warning should occur when the port_index is deprecated; calls made on behalf of the user should pass true; calls made on behalf or the framework internals should pass false.

◆ GetSystemName()

const std::string& GetSystemName ( ) const
final

Returns a human-readable name for this system, for use in messages and logging.

This will be the same as returned by get_name(), unless that would be an empty string. In that case we return a non-unique placeholder name, currently just "_" (a lone underscore).

◆ GetSystemPathname()

std::string GetSystemPathname ( ) const
final

Generates and returns a human-readable full path name of this subsystem, for use in messages and logging.

The name starts from the root System, with "::" delimiters between parent and child subsystems, with the individual subsystems represented by their names as returned by GetSystemName().

◆ GetSystemType()

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.

The format is as generated by NiceTypeName and will include namespace qualification if present.

See also
NiceTypeName for more specifics.

◆ GetUnsupportedScalarConversionMessage()

virtual std::string GetUnsupportedScalarConversionMessage ( const std::type_info &  source_type,
const std::type_info &  destination_type 
) const
protectedvirtual

(Internal use only) Returns the message to use for a std::exception in the case of unsupported scalar type conversions.

Reimplemented in Diagram< T >, and Diagram< double >.

◆ implicit_time_derivatives_residual_size()

int implicit_time_derivatives_residual_size ( ) const

Returns the size of the implicit time derivatives residual vector.

By default this is the same as num_continuous_states() but a LeafSystem can change it during construction via LeafSystem::DeclareImplicitTimeDerivativesResidualSize().

◆ InitializeContextBase()

void InitializeContextBase ( ContextBase context) const
protected

This method must be invoked from within derived class DoAllocateContext() implementations right after the concrete Context object has been allocated.

It allocates cache entries, sets up all intra-Context dependencies, and marks the ContextBase as initialized so that we can verify proper derived-class behavior.

Precondition
The supplied context must not be null and must not already have been initialized.

◆ input_port_ticket()

DependencyTicket input_port_ticket ( InputPortIndex  index) const

Returns a ticket indicating dependence on input port uᵢ indicated by index.

Precondition
index selects an existing input port of this System.

◆ IsObviouslyNotInputDependent()

bool IsObviouslyNotInputDependent ( DependencyTicket  dependency_ticket) const
protected

(Internal use only) Checks if a ticket depends on (any) input port.

When this returns "true" the ticket MUST NOT depend on input. When this returns "false", it just means that we're not sure. This is intended to be an inexpensive check, withough searching the entire graph.

◆ ke_ticket()

static DependencyTicket ke_ticket ( )
static

Returns a ticket for the cache entry that holds the kinetic energy calculation.

See also
System::EvalKineticEnergy()

◆ kinematics_ticket()

static DependencyTicket kinematics_ticket ( )
static

Returns a ticket indicating dependence on all source values that may affect configuration- or velocity-dependent computations.

This ticket depends on the configuration_ticket defined above, and adds in velocity-affecting source values. This does not include time or input ports.

See also
configuration_ticket()
Note
Currently there is no way to declare specific variables and parameters to be configuration- or velocity-affecting so we include all state variables and parameters except for state variables z.

◆ MakeFixInputPortTypeChecker()

virtual std::function<void(const AbstractValue&)> MakeFixInputPortTypeChecker ( InputPortIndex  port_index) const
protectedpure virtual

(Internal use only) Given a port_index, returns a function to be called when validating Context::FixInputPort requests.

The function should attempt to throw an exception if the input AbstractValue is invalid, so that errors can be reported at Fix-time instead of EvalInput-time.

◆ NextInputPortName()

std::string NextInputPortName ( std::variant< std::string, UseDefaultName given_name) const
protected

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

Precondition
given_name must not be empty.

◆ NextOutputPortName()

std::string NextOutputPortName ( std::variant< std::string, UseDefaultName given_name) const
protected

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

Precondition
given_name must not be empty.

◆ nothing_ticket()

static DependencyTicket nothing_ticket ( )
static

Returns a ticket indicating that a computation does not depend on any source value; that is, it is a constant.

If this appears in a prerequisite list, it must be the only entry.

◆ num_abstract_parameters()

int num_abstract_parameters ( ) const

Returns the number of declared abstract parameters.

◆ num_abstract_states()

int num_abstract_states ( ) const

Returns the number of declared abstract state variables.

◆ num_cache_entries()

int num_cache_entries ( ) const

Returns the number nc of cache entries currently allocated in this System.

These are indexed from 0 to nc-1.

◆ num_continuous_states()

int num_continuous_states ( ) const

Returns the number of declared continuous state variables.

◆ num_discrete_state_groups()

int num_discrete_state_groups ( ) const

Returns the number of declared discrete state groups (each group is a vector-valued discrete state variable).

◆ num_input_ports()

int num_input_ports ( ) const

Returns the number of input ports currently allocated in this System.

These are indexed from 0 to num_input_ports()-1.

◆ num_numeric_parameter_groups()

int num_numeric_parameter_groups ( ) const

Returns the number of declared numeric parameters (each of these is a vector-valued parameter).

◆ num_output_ports()

int num_output_ports ( ) const

Returns the number of output ports currently allocated in this System.

These are indexed from 0 to num_output_ports()-1.

◆ num_total_inputs()

int num_total_inputs ( ) const

Returns the total dimension of all of the vector-valued input ports (as if they were muxed).

◆ num_total_outputs()

int num_total_outputs ( ) const

Returns the total dimension of all of the vector-valued output ports (as if they were muxed).

◆ numeric_parameter_ticket()

DependencyTicket numeric_parameter_ticket ( NumericParameterIndex  index) const

Returns a ticket indicating dependence on a particular numeric parameter pnᵢ (may be a vector).

See also
pn_ticket() to obtain a ticket for all numeric parameters.

◆ operator=() [1/2]

SystemBase& operator= ( SystemBase &&  )
delete

◆ operator=() [2/2]

SystemBase& operator= ( const SystemBase )
delete

◆ output_port_ticket()

DependencyTicket output_port_ticket ( OutputPortIndex  index) const

(Internal use only) Returns a ticket indicating dependence on the output port indicated by index.

No user-definable quantities in a system can meaningfully depend on that system's own output ports.

Precondition
index selects an existing output port of this System.

◆ pa_ticket()

static DependencyTicket pa_ticket ( )
static

Returns a ticket indicating dependence on all of the abstract parameters pa in the current Context.

See also
abstract_parameter_ticket() to obtain a ticket for just one abstract parameter.

◆ pc_ticket()

static DependencyTicket pc_ticket ( )
static

Returns a ticket for the cache entry that holds the conservative power calculation.

See also
System::EvalConservativePower()

◆ pe_ticket()

static DependencyTicket pe_ticket ( )
static

Returns a ticket for the cache entry that holds the potential energy calculation.

See also
System::EvalPotentialEnergy()

◆ pn_ticket()

static DependencyTicket pn_ticket ( )
static

Returns a ticket indicating dependence on all of the numerical parameters in the current Context.

See also
numeric_parameter_ticket() to obtain a ticket for just one numeric parameter.

◆ pnc_ticket()

static DependencyTicket pnc_ticket ( )
static

Returns a ticket for the cache entry that holds the non-conservative power calculation.

See also
System::EvalNonConservativePower()

◆ q_ticket()

static DependencyTicket q_ticket ( )
static

Returns a ticket indicating that a computation depends on configuration state variables q.

There is no ticket representing just one of the state variables qᵢ.

◆ set_implicit_time_derivatives_residual_size()

void set_implicit_time_derivatives_residual_size ( int  n)
protected

Allows a LeafSystem to override the default size for the implicit time derivatives residual and a Diagram to sum up the total size.

If no value is set, the default size is n=num_continuous_states().

Parameters
[in]nThe size of the residual vector output argument of System::CalcImplicitTimeDerivativesResidual(). If n <= 0 restore to the default, num_continuous_states().
See also
implicit_time_derivatives_residual_size()
LeafSystem::DeclareImplicitTimeDerivativesResidualSize()
System::CalcImplicitTimeDerivativesResidual()

◆ set_name()

void set_name ( const std::string &  name)

Sets the name of the system.

Do not use the path delimiter character ':' in the name. When creating a Diagram, names of sibling subsystems should be unique. DiagramBuilder uses this method to assign a unique default name if none is provided.

◆ set_parent_service()

static void set_parent_service ( SystemBase child,
const internal::SystemParentServiceInterface *  parent_service 
)
staticprotected

(Internal use only) Declares that parent_service is the service interface of the Diagram that owns this subsystem.

Aborts if the parent service has already been set to something else.

◆ ThrowCantEvaluateInputPort()

void ThrowCantEvaluateInputPort ( const char *  func,
InputPortIndex  port_index 
) const
protected

Throws std::exception because someone called API method func, that requires this input port to be evaluatable, but the port was neither fixed nor connected.

◆ ThrowInputPortHasWrongType() [1/2]

void ThrowInputPortHasWrongType ( const char *  func,
InputPortIndex  port_index,
const std::string &  expected_type,
const std::string &  actual_type 
) const
protected

Throws std::exception because someone called API method func claiming the input port had some value type that was wrong.

◆ ThrowInputPortHasWrongType() [2/2]

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 
)
staticprotected

Throws std::exception because someone called API method func claiming the input port had some value type that was wrong.

◆ ThrowInputPortIndexOutOfRange()

void ThrowInputPortIndexOutOfRange ( const char *  func,
InputPortIndex  port_index 
) const
protected

Throws std::exception to report bad input port_index that was passed to API method func.

◆ ThrowNegativePortIndex()

void ThrowNegativePortIndex ( const char *  func,
int  port_index 
) const
protected

Throws std::exception to report a negative port_index that was passed to API method func.

Caller must ensure that the function name makes it clear what kind of port we're complaining about.

◆ ThrowNotAVectorInputPort()

void ThrowNotAVectorInputPort ( const char *  func,
InputPortIndex  port_index 
) const
protected

Throws std::exception because someone misused API method func, that is only allowed for declared-vector input ports, on an abstract port whose index is given here.

◆ ThrowOutputPortIndexOutOfRange()

void ThrowOutputPortIndexOutOfRange ( const char *  func,
OutputPortIndex  port_index 
) const
protected

Throws std::exception to report bad output port_index that was passed to API method func.

◆ ThrowValidateContextMismatch()

void ThrowValidateContextMismatch ( const ContextBase ) const
protected

(Internal use only) Throws std::exception with a message that the sanity check(s) given by ValidateContext have failed.

◆ time_ticket()

static DependencyTicket time_ticket ( )
static

Returns a ticket indicating dependence on time.

This is the same ticket for all systems and refers to the same time value.

◆ v_ticket()

static DependencyTicket v_ticket ( )
static

Returns a ticket indicating dependence on velocity state variables v.

This does not also indicate a dependence on configuration variables q – you must list that explicitly or use kinematics_ticket() instead. There is no ticket representing just one of the state variables vᵢ.

◆ ValidateContext() [1/2]

void ValidateContext ( const ContextBase context) const
final

Checks whether the given context was created for this system.

Note
This method is sufficiently fast for performance sensitive code.
Exceptions
std::exceptionif the System Ids don't match.

◆ ValidateContext() [2/2]

void ValidateContext ( const ContextBase context) const

Checks whether the given context was created for this system.

Note
This method is sufficiently fast for performance sensitive code.
Exceptions
std::exceptionif the System Ids don't match.
std::exceptionif context is null.

◆ ValidateCreatedForThisSystem()

void ValidateCreatedForThisSystem ( const Clazz &  object) const

Checks whether the given object was created for this system.

Note
This method is sufficiently fast for performance sensitive code.
Exceptions
std::exceptionif the System Ids don't match or if object doesn't have an associated System Id.
std::exceptionif the argument type is a pointer and it is null.

◆ xa_ticket()

static DependencyTicket xa_ticket ( )
static

Returns a ticket indicating dependence on all of the abstract state variables in the current Context.

See also
abstract_state_ticket() to obtain a ticket for just one abstract state variable.

◆ xc_ticket()

static DependencyTicket xc_ticket ( )
static

Returns a ticket indicating dependence on all of the continuous state variables q, v, or z.

◆ xcdot_ticket()

static DependencyTicket xcdot_ticket ( )
static

Returns a ticket for the cache entry that holds time derivatives of the continuous variables.

See also
EvalTimeDerivatives()

◆ xd_ticket()

static DependencyTicket xd_ticket ( )
static

Returns a ticket indicating dependence on all of the numerical discrete state variables, in any discrete variable group.

See also
discrete_state_ticket() to obtain a ticket for just one discrete state variable.

◆ xd_unique_periodic_update_ticket()

static DependencyTicket xd_unique_periodic_update_ticket ( )
static

(Internal use only) Returns a ticket for the cache entry that holds the unique periodic discrete update computation.

See also
System::EvalUniquePeriodicDiscreteUpdate()

◆ z_ticket()

static DependencyTicket z_ticket ( )
static

Returns a ticket indicating dependence on any or all of the miscellaneous continuous state variables z.

There is no ticket representing just one of the state variables zᵢ.

Friends And Related Function Documentation

◆ internal::DiagramSystemBaseAttorney

friend class internal::DiagramSystemBaseAttorney
friend

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