pydrake.systems.framework

Bindings for the core Systems framework.

class pydrake.systems.framework.AbstractParameterIndex
__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: pydrake.systems.framework.AbstractParameterIndex) -> None

Default constructor; the result is an invalid index. This only exists to serve applications which require a default constructor.

  1. __init__(self: pydrake.systems.framework.AbstractParameterIndex, arg0: int) -> None

Construction from a non-negative int value. The value must lie in the range of [0, 2³¹). Constructor only promises to test validity in Debug build.

is_valid(self: pydrake.systems.framework.AbstractParameterIndex) bool

Reports if the index is valid–the only operation on an invalid index that doesn’t throw an exception in Debug builds.

class pydrake.systems.framework.AbstractStateIndex
__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: pydrake.systems.framework.AbstractStateIndex) -> None

Default constructor; the result is an invalid index. This only exists to serve applications which require a default constructor.

  1. __init__(self: pydrake.systems.framework.AbstractStateIndex, arg0: int) -> None

Construction from a non-negative int value. The value must lie in the range of [0, 2³¹). Constructor only promises to test validity in Debug build.

is_valid(self: pydrake.systems.framework.AbstractStateIndex) bool

Reports if the index is valid–the only operation on an invalid index that doesn’t throw an exception in Debug builds.

class pydrake.systems.framework.AbstractValues

AbstractValues is a container for non-numerical state and parameters. It may or may not own the underlying data, and therefore is suitable for both leaf Systems and diagrams.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: pydrake.systems.framework.AbstractValues) -> None

Constructs an empty AbstractValues.

  1. __init__(self: pydrake.systems.framework.AbstractValues, arg0: list[pydrake.common.value.AbstractValue]) -> None

Constructs an AbstractValues that does not own the underlying data.

Clone(self: pydrake.systems.framework.AbstractValues) pydrake.systems.framework.AbstractValues
get_mutable_value(self: pydrake.systems.framework.AbstractValues, index: int) pydrake.common.value.AbstractValue

Returns the element of AbstractValues at the given index, or aborts if the index is out-of-bounds.

get_value(self: pydrake.systems.framework.AbstractValues, index: int) pydrake.common.value.AbstractValue

Returns the element of AbstractValues at the given index, or aborts if the index is out-of-bounds.

SetFrom(self: pydrake.systems.framework.AbstractValues, arg0: pydrake.systems.framework.AbstractValues) None

Copies all of the AbstractValues in other into this. Asserts if the two are not equal in size.

Raises

RuntimeError if any of the elements are of incompatible type.

size(self: pydrake.systems.framework.AbstractValues) int

Returns the number of elements of AbstractValues.

class pydrake.systems.framework.BasicVector

Bases: pydrake.systems.framework.VectorBase

BasicVector is a semantics-free wrapper around an Eigen vector that satisfies VectorBase. Once constructed, its size is fixed.

Note

This class is templated; see BasicVector_ for the list of instantiations.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: pydrake.systems.framework.BasicVector, data: numpy.ndarray[numpy.float64[m, 1]]) -> None

Constructs a BasicVector with the specified vec data.

  1. __init__(self: pydrake.systems.framework.BasicVector, size: int) -> None

Initializes with the given size using the drake::dummy_value<T>, which is NaN when T = double.

Clone(self: pydrake.systems.framework.BasicVector) pydrake.systems.framework.BasicVector
get_mutable_value(self: pydrake.systems.framework.BasicVector) numpy.ndarray[numpy.float64[m, 1], flags.writeable]

Returns the entire vector as a mutable Eigen::VectorBlock, which allows mutation of the values, but does not allow resize() to be invoked on the returned object.

get_value(self: pydrake.systems.framework.BasicVector) numpy.ndarray[numpy.float64[m, 1]]

(Don’t use this in new code) Returns the entire vector as a const Eigen::VectorBlock. Prefer value() which returns direct access to the underlying VectorX rather than wrapping it in a VectorBlock.

set_value(self: pydrake.systems.framework.BasicVector, arg0: numpy.ndarray[numpy.float64[m, 1]]) None

Sets the vector to the given value. After a.set_value(b.get_value()), a must be identical to b.

Raises

RuntimeError if the new value has different dimensions.

value(self: pydrake.systems.framework.BasicVector) numpy.ndarray[numpy.float64[m, 1]]

Returns a const reference to the contained VectorX<T>. This is the preferred method for examining a BasicVector’s value.

template pydrake.systems.framework.BasicVector_

Instantiations: BasicVector_[float], BasicVector_[AutoDiffXd], BasicVector_[Expression]

class pydrake.systems.framework.BasicVector_[AutoDiffXd]

Bases: pydrake.systems.framework.VectorBase_[AutoDiffXd]

BasicVector is a semantics-free wrapper around an Eigen vector that satisfies VectorBase. Once constructed, its size is fixed.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: pydrake.systems.framework.BasicVector_[AutoDiffXd], data: numpy.ndarray[object[m, 1]]) -> None

Constructs a BasicVector with the specified vec data.

  1. __init__(self: pydrake.systems.framework.BasicVector_[AutoDiffXd], size: int) -> None

Initializes with the given size using the drake::dummy_value<T>, which is NaN when T = double.

Clone(self: pydrake.systems.framework.BasicVector_[AutoDiffXd]) pydrake.systems.framework.BasicVector_[AutoDiffXd]
get_mutable_value(self: pydrake.systems.framework.BasicVector_[AutoDiffXd]) numpy.ndarray[object[m, 1], flags.writeable]

Returns the entire vector as a mutable Eigen::VectorBlock, which allows mutation of the values, but does not allow resize() to be invoked on the returned object.

get_value(self: pydrake.systems.framework.BasicVector_[AutoDiffXd]) numpy.ndarray[object[m, 1]]

(Don’t use this in new code) Returns the entire vector as a const Eigen::VectorBlock. Prefer value() which returns direct access to the underlying VectorX rather than wrapping it in a VectorBlock.

set_value(self: pydrake.systems.framework.BasicVector_[AutoDiffXd], arg0: numpy.ndarray[object[m, 1]]) None

Sets the vector to the given value. After a.set_value(b.get_value()), a must be identical to b.

Raises

RuntimeError if the new value has different dimensions.

value(self: pydrake.systems.framework.BasicVector_[AutoDiffXd]) numpy.ndarray[object[m, 1]]

Returns a const reference to the contained VectorX<T>. This is the preferred method for examining a BasicVector’s value.

class pydrake.systems.framework.BasicVector_[Expression]

Bases: pydrake.systems.framework.VectorBase_[Expression]

BasicVector is a semantics-free wrapper around an Eigen vector that satisfies VectorBase. Once constructed, its size is fixed.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: pydrake.systems.framework.BasicVector_[Expression], data: numpy.ndarray[object[m, 1]]) -> None

Constructs a BasicVector with the specified vec data.

  1. __init__(self: pydrake.systems.framework.BasicVector_[Expression], size: int) -> None

Initializes with the given size using the drake::dummy_value<T>, which is NaN when T = double.

Clone(self: pydrake.systems.framework.BasicVector_[Expression]) pydrake.systems.framework.BasicVector_[Expression]
get_mutable_value(self: pydrake.systems.framework.BasicVector_[Expression]) numpy.ndarray[object[m, 1], flags.writeable]

Returns the entire vector as a mutable Eigen::VectorBlock, which allows mutation of the values, but does not allow resize() to be invoked on the returned object.

get_value(self: pydrake.systems.framework.BasicVector_[Expression]) numpy.ndarray[object[m, 1]]

(Don’t use this in new code) Returns the entire vector as a const Eigen::VectorBlock. Prefer value() which returns direct access to the underlying VectorX rather than wrapping it in a VectorBlock.

set_value(self: pydrake.systems.framework.BasicVector_[Expression], arg0: numpy.ndarray[object[m, 1]]) None

Sets the vector to the given value. After a.set_value(b.get_value()), a must be identical to b.

Raises

RuntimeError if the new value has different dimensions.

value(self: pydrake.systems.framework.BasicVector_[Expression]) numpy.ndarray[object[m, 1]]

Returns a const reference to the contained VectorX<T>. This is the preferred method for examining a BasicVector’s value.

class pydrake.systems.framework.CacheEntry

A CacheEntry belongs to a System and represents the properties of one of that System’s cached computations. CacheEntry objects are assigned CacheIndex values in the order they are declared; these are unique within a single System and can be used for quick access to both the CacheEntry and the corresponding CacheEntryValue in the System’s Context.

CacheEntry objects are allocated automatically for known System computations like output ports and time derivatives, and may also be allocated by user code for other cached computations.

A cache entry’s value is always stored as an AbstractValue, which can hold a concrete value of any copyable type. However, once a value has been allocated using a particular concrete type, the type cannot be changed.

CacheEntry objects support four important operations: - Allocate() returns an object that can hold the cached value. - Calc() unconditionally computes the cached value. - Eval() returns a reference to the cached value, first updating with Calc() if it was out of date. - GetKnownUpToDate() returns a reference to the current value that you are certain must already be up to date.

The allocation and calculation functions must be provided at the time a cache entry is declared. That is typically done in a System constructor, in a manner very similar to the declaration of output ports.

__init__(*args, **kwargs)
cache_index(self: pydrake.systems.framework.CacheEntry) pydrake.systems.framework.CacheIndex

Returns the CacheIndex used to locate this CacheEntry within the containing System.

description(self: pydrake.systems.framework.CacheEntry) str

Return the human-readable description for this CacheEntry.

disable_caching(self: pydrake.systems.framework.CacheEntry, context: pydrake.systems.framework.ContextBase) None

(Debugging) Disables caching for this cache entry in the given context. Eval() will recompute the cached value every time it is invoked, regardless of the state of the out_of_date flag. That should have no effect on any computed results, other than speed. See class documentation for ideas as to what might be wrong if you see a change. Note that the context is const here; cache entry values are mutable.

disable_caching_by_default(self: pydrake.systems.framework.CacheEntry) None

(Debugging) Marks this cache entry so that the corresponding CacheEntryValue object in any allocated Context is created with its disabled flag initially set. This can be useful for debugging when you have observed a difference between cached and non-cached behavior that can’t be diagnosed with the runtime disable_caching() method.

See also

disable_caching()

enable_caching(self: pydrake.systems.framework.CacheEntry, context: pydrake.systems.framework.ContextBase) None

(Debugging) Enables caching for this cache entry in the given context if it was previously disabled.

Eval(self: pydrake.systems.framework.CacheEntry, context: pydrake.systems.framework.ContextBase) object

Returns a reference to the up-to-date value of this cache entry contained in the given Context. This is the preferred way to obtain a cached value. If the value is not already up to date with respect to its prerequisites, or if caching is disabled for this entry, then this entry’s Calc() method is used first to update the value before the reference is returned. The Calc() method may be arbitrarily expensive, but this method is constant time and very fast if the value is already up to date. If you are certain the value should be up to date already, you may use the GetKnownUpToDate() method instead.

Precondition:

context is a subcontext that is compatible with the subsystem that owns this cache entry.

Raises

RuntimeError if the value doesn't actually have type V.

EvalAbstract(self: pydrake.systems.framework.CacheEntry, context: pydrake.systems.framework.ContextBase) pydrake.common.value.AbstractValue
get_cache_entry_value(self: pydrake.systems.framework.CacheEntry, context: pydrake.systems.framework.ContextBase) pydrake.systems.framework.CacheEntryValue

(Advanced) Returns a const reference to the CacheEntryValue object that corresponds to this CacheEntry, from the supplied Context. The returned object contains the current value and tracks whether it is up to date with respect to its prerequisites. If you just need the value, use the Eval() method rather than this one. This method is constant time and very fast in all circumstances.

get_mutable_cache_entry_value(self: pydrake.systems.framework.CacheEntry, context: pydrake.systems.framework.ContextBase) pydrake.systems.framework.CacheEntryValue

(Advanced) Returns a mutable reference to the CacheEntryValue object that corresponds to this CacheEntry, from the supplied Context. Note that context is const; cache values are mutable. Don’t call this method unless you know what you’re doing. This method is constant time and very fast in all circumstances.

has_default_prerequisites(self: pydrake.systems.framework.CacheEntry) bool

(Advanced) Returns True if this cache entry was created without specifying any prerequisites. This can be useful in determining whether the apparent dependencies should be believed, or whether they may just be due to some user’s ignorance.

Note

Currently we can’t distinguish between “no prerequisites given” (in which case we default to all_sources_ticket()) and “prerequisite specified as all_sources_ticket()`". Either of those cases makes this method return `true now, but we intend to change so that explicit specification of all_sources_ticket() will be considered non-default. So don’t depend on the current behavior.

is_cache_entry_disabled(self: pydrake.systems.framework.CacheEntry, context: pydrake.systems.framework.ContextBase) bool

(Debugging) Returns True if caching has been disabled for this cache entry in the given context. That means Eval() will recalculate even if the entry is marked up to date.

is_disabled_by_default(self: pydrake.systems.framework.CacheEntry) bool

(Debugging) Returns the current value of this flag. It is False unless a call to disable_caching_by_default() has previously been made.

is_out_of_date(self: pydrake.systems.framework.CacheEntry, context: pydrake.systems.framework.ContextBase) bool

Returns True if the current value of this cache entry is out of date with respect to its prerequisites. If this returns False then the Eval() method will not perform any computation when invoked, unless caching has been disabled for this entry. If this returns True the GetKnownUpToDate() methods will fail if invoked.

prerequisites(self: pydrake.systems.framework.CacheEntry) set[pydrake.systems.framework.DependencyTicket]

Returns a reference to the set of prerequisites needed by this cache entry’s Calc() function. These are all within the same subsystem that owns this CacheEntry.

ticket(self: pydrake.systems.framework.CacheEntry) pydrake.systems.framework.DependencyTicket

Returns the DependencyTicket used to register dependencies on the value of this CacheEntry. This can also be used to locate the DependencyTracker that manages dependencies at runtime for the associated CacheEntryValue in a Context.

class pydrake.systems.framework.CacheEntryValue

(Advanced) This is the representation in the Context for the value of one of a System’s CacheEntry objects. Most users will not use this class directly – System and CacheEntry provide the most common APIs, and Context provides additional useful methods.

See also

System, CacheEntry, Context for user-facing APIs.

A CacheEntryValue consists of a single type-erased value, a serial number, an out_of_date flag, and a DependencyTracker ticket. Details: - “Out of date” means that some prerequisite of this cache entry’s computation has been changed in the current Context since the stored value was last computed, and thus must be recomputed prior to use. On the other hand, if the entry is not out of date, then it is “up to date” meaning that if you were to recompute it using the current Context values you would get the identical result (so don’t bother!). - The “serial number” is an integer that is incremented whenever the value is modified, or made available for mutable access. You can use it to recognize that you are looking at the same value as you saw at some earlier time. It is also useful for performance studies since it is a count of how many times this value was recomputed. Note that marking the value “out of date” is not a modification; that does not change the serial number. The serial number is maintained internally and cannot be user-modified. - The DependencyTicket (“ticket”) stored here identifies the DependencyTracker (“tracker”) associated with this cache entry. The tracker maintains lists of all upstream prerequisites and downstream dependents of the value stored here, and also has a pointer to this CacheEntryValue that it uses for invalidation. Upstream modifications cause the tracker to set the out_of_date flag here, and mark all downstream dependents out of date also. The tracker lives in the same subcontext that owns the Cache that owns this CacheEntryValue.

We sometimes use the terms “invalid” and “invalidate” as synonyms for “out of date” and “mark out of date”.

For debugging purposes, caching may be disabled for an entire Context or for particular cache entry values. This is independent of the out_of_date flag described above, which is still expected to be operational when caching is disabled. However, when caching is disabled the Eval() methods will recompute the contained value even if it is not marked out of date. That should have no effect other than to slow computation; if results change, something is wrong. There could be a problem with the specification of dependencies, a bug in user code such as improper retention of a stale reference, or a bug in the caching system.

__init__(*args, **kwargs)
GetMutableValueOrThrow(self: pydrake.systems.framework.CacheEntryValue) object

(Advanced) Convenience method that returns a mutable reference to the contained value downcast to its known concrete type. Throws an exception if the contained value does not have the indicated concrete type. Note that you must call mark_up_to_date() after modifying the value through the returned reference. See GetMutableAbstractValueOrThrow() above for more information.

Raises
  • RuntimeError if there is no value, or if the value is already up

  • to date, of it doesn't actually have type V.

  • RuntimeError if the cache is frozen.

See also

SetValueOrThrow(), set_value(), mark_up_to_date()

Template parameter V:

The known actual value type.

GetValueOrThrow(self: pydrake.systems.framework.CacheEntryValue) object

Returns a const reference to the contained value of known type V. It is an error to call this if there is no stored value, or the value is out of date, or the value doesn’t actually have type V.

Raises
  • RuntimeError if there is no stored value, or if it is out of date,

  • or it doesn't actually have type V.

See also

get_value()

class pydrake.systems.framework.CacheIndex
__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: pydrake.systems.framework.CacheIndex) -> None

Default constructor; the result is an invalid index. This only exists to serve applications which require a default constructor.

  1. __init__(self: pydrake.systems.framework.CacheIndex, arg0: int) -> None

Construction from a non-negative int value. The value must lie in the range of [0, 2³¹). Constructor only promises to test validity in Debug build.

is_valid(self: pydrake.systems.framework.CacheIndex) bool

Reports if the index is valid–the only operation on an invalid index that doesn’t throw an exception in Debug builds.

class pydrake.systems.framework.Context

Bases: pydrake.systems.framework.ContextBase

Context is an abstract class template that represents all the typed values that are used in a System’s computations: time, numeric-valued input ports, numerical state, and numerical parameters. There are also type-erased abstract state variables, abstract-valued input ports, abstract parameters, and a double accuracy setting. The framework provides two concrete subclasses of Context: LeafContext (for leaf Systems) and DiagramContext (for composite System Diagrams). Users are forbidden to extend DiagramContext and are discouraged from subclassing LeafContext.

A Context is designed to be used only with the System that created it. Data encapsulated with State and Parameter objects can be copied between contexts for compatible systems with some restrictions. For details, see system_compatibility.

Note

This class is templated; see Context_ for the list of instantiations.

__init__(*args, **kwargs)
Clone(self: pydrake.systems.framework.Context) pydrake.systems.framework.Context

Returns a deep copy of this Context.

Raises

RuntimeError if this is not the root context.

get_abstract_parameter(self: pydrake.systems.framework.Context, index: int) pydrake.common.value.AbstractValue

Returns a const reference to the vector-valued parameter at index.

Precondition:

index must identify an existing parameter.

get_abstract_state(*args, **kwargs)

Overloaded function.

  1. get_abstract_state(self: pydrake.systems.framework.Context) -> pydrake.systems.framework.AbstractValues

Returns a const reference to the abstract component of the state, which may be of size zero.

  1. get_abstract_state(self: pydrake.systems.framework.Context, index: int) -> pydrake.common.value.AbstractValue

Returns a const reference to the abstract component of the state at index.

Precondition:

index must identify an existing element.

Precondition:

the abstract state’s type must match the template argument.

get_accuracy(self: pydrake.systems.framework.Context) Optional[float]

Returns the accuracy setting (if any). Note that the return type is optional<double> rather than the double value itself.

See also

SetAccuracy() for details.

get_continuous_state(self: pydrake.systems.framework.Context) pydrake.systems.framework.ContinuousState

Returns a const reference to the continuous component of the state, which may be of size zero.

get_continuous_state_vector(self: pydrake.systems.framework.Context) pydrake.systems.framework.VectorBase

Returns a reference to the continuous state vector, devoid of second-order structure. The vector may be of size zero.

get_discrete_state(*args, **kwargs)

Overloaded function.

  1. get_discrete_state(self: pydrake.systems.framework.Context) -> pydrake.systems.framework.DiscreteValues

Returns a reference to the entire discrete state, which may consist of multiple discrete state vectors (groups).

  1. get_discrete_state(self: pydrake.systems.framework.Context, arg0: int) -> pydrake.systems.framework.BasicVector

Returns a const reference to group (vector) index of the discrete state.

Precondition:

index must identify an existing group.

get_discrete_state_vector(self: pydrake.systems.framework.Context) pydrake.systems.framework.BasicVector

Returns a reference to the only discrete state vector. The vector may be of size zero.

Precondition:

There is only one discrete state group.

get_mutable_abstract_parameter(self: pydrake.systems.framework.Context, index: int) pydrake.common.value.AbstractValue

Returns a mutable reference to element index of the abstract-valued parameters. Sends out of date notifications for all computations dependent on this parameter.

Precondition:

index must identify an existing abstract parameter.

Note

Currently notifies dependents of all abstract parameters.

get_mutable_abstract_state(*args, **kwargs)

Overloaded function.

  1. get_mutable_abstract_state(self: pydrake.systems.framework.Context) -> pydrake.systems.framework.AbstractValues

Returns a mutable reference to the abstract component of the state, which may be of size zero. Sends out of date notifications for all abstract-state-dependent computations.

Warning

You must not use the returned reference to modify the size, number, or types of abstract state variables.

  1. get_mutable_abstract_state(self: pydrake.systems.framework.Context, index: int) -> pydrake.common.value.AbstractValue

Returns a mutable reference to element index of the abstract state. Sends out of date notifications for all computations that depend on this abstract state variable.

Precondition:

index must identify an existing element.

Precondition:

the abstract state’s type must match the template argument.

Note

Currently notifies dependents of any abstract state variable.

get_mutable_continuous_state(self: pydrake.systems.framework.Context) pydrake.systems.framework.ContinuousState

Returns a mutable reference to the continuous component of the state, which may be of size zero. Sends out of date notifications for all continuous-state-dependent computations.

get_mutable_continuous_state_vector(self: pydrake.systems.framework.Context) pydrake.systems.framework.VectorBase

Returns a mutable reference to the continuous state vector, devoid of second-order structure. The vector may be of size zero. Sends out of date notifications for all continuous-state-dependent computations.

get_mutable_discrete_state(*args, **kwargs)

Overloaded function.

  1. get_mutable_discrete_state(self: pydrake.systems.framework.Context) -> pydrake.systems.framework.DiscreteValues

Returns a mutable reference to the discrete component of the state, which may be of size zero. Sends out of date notifications for all discrete-state-dependent computations.

Warning

You must not use the returned reference to modify the size or number of discrete state variables.

  1. get_mutable_discrete_state(self: pydrake.systems.framework.Context, arg0: int) -> pydrake.systems.framework.BasicVector

Returns a mutable reference to group (vector) index of the discrete state. Sends out of date notifications for all computations that depend on this discrete state group.

Precondition:

index must identify an existing group.

Note

Currently notifies dependents of all groups.

get_mutable_discrete_state_vector(self: pydrake.systems.framework.Context) pydrake.systems.framework.BasicVector

Returns a mutable reference to the only discrete state vector. Sends out of date notifications for all discrete-state-dependent computations.

See also

get_discrete_state_vector().

Precondition:

There is only one discrete state group.

get_mutable_numeric_parameter(self: pydrake.systems.framework.Context, index: int) pydrake.systems.framework.BasicVector

Returns a mutable reference to element index of the vector-valued (numeric) parameters. Sends out of date notifications for all computations dependent on this parameter.

Precondition:

index must identify an existing numeric parameter.

Note

Currently notifies dependents of all numeric parameters.

get_mutable_parameters(self: pydrake.systems.framework.Context) pydrake.systems.framework.Parameters

Returns a mutable reference to this Context’s parameters. Sends out of date notifications for all parameter-dependent computations. If you don’t mean to change all the parameters, use the indexed methods to modify only some of the parameters so that fewer computations are invalidated and fewer notifications need be sent.

Warning

You must not use the returned reference to modify the size, number, or types of parameters.

get_mutable_state(self: pydrake.systems.framework.Context) pydrake.systems.framework.State

Returns a mutable reference to the whole State, potentially invalidating all state-dependent computations so requiring out of date notifications to be made for all such computations. If you don’t mean to change the whole state, use more focused methods to modify only a portion of the state. See class documentation for more information.

Warning

You must not use the returned reference to modify the size, number, or types of state variables.

get_numeric_parameter(self: pydrake.systems.framework.Context, index: int) pydrake.systems.framework.BasicVector

Returns a const reference to the vector-valued parameter at index.

Precondition:

index must identify an existing parameter.

get_parameters(self: pydrake.systems.framework.Context) pydrake.systems.framework.Parameters

Returns a const reference to this Context’s parameters.

get_state(self: pydrake.systems.framework.Context) pydrake.systems.framework.State

Returns a const reference to the whole State.

get_time(self: pydrake.systems.framework.Context) float

Returns the current time in seconds.

See also

SetTime()

has_only_continuous_state(self: pydrake.systems.framework.Context) bool

Returns true if the Context has continuous state, but no discrete or abstract state.

has_only_discrete_state(self: pydrake.systems.framework.Context) bool

Returns true if the Context has discrete state, but no continuous or abstract state.

is_stateless(self: pydrake.systems.framework.Context) bool

Returns true if the Context has no state.

num_abstract_parameters(self: pydrake.systems.framework.Context) int

Returns the number of abstract-valued parameters.

num_abstract_states(self: pydrake.systems.framework.Context) int

Returns the number of elements in the abstract state.

num_continuous_states(self: pydrake.systems.framework.Context) int

Returns the number of continuous state variables xc = {q, v, z}.

num_discrete_state_groups(self: pydrake.systems.framework.Context) int

Returns the number of vectors (groups) in the discrete state.

num_numeric_parameter_groups(self: pydrake.systems.framework.Context) int

Returns the number of vector-valued parameters.

num_total_states(self: pydrake.systems.framework.Context) int

Returns the total dimension of all of the basic vector states (as if they were muxed).

Raises

RuntimeError if the system contains any abstract state.

SetAbstractState(self: object, index: int, value: object) None

Sets the value of the abstract state variable selected by index. Sends out of date notifications for all computations that depend on that abstract state variable. The template type will be inferred and need not be specified explicitly.

Precondition:

index must identify an existing abstract state variable.

Precondition:

the abstract state’s type must match the template argument.

Note

Currently notifies dependents of any abstract state variable.

SetAccuracy(self: pydrake.systems.framework.Context, accuracy: Optional[float]) None

Records the user’s requested accuracy, which is a unit-less quantity designed for use with simulation and other numerical studies. Since accuracy is unit-less, algorithms and systems are free to interpret this quantity as they wish. The intention is that more computational work is acceptable as the accuracy setting is tightened (set closer to zero). If no accuracy is requested, computations are free to choose suitable defaults, or to refuse to proceed without an explicit accuracy setting. The accuracy of a complete simulation or other numerical study depends on the accuracy of all contributing computations, so it is important that each computation is done in accordance with the requested accuracy. Some examples of where this is needed: - Error-controlled numerical integrators use the accuracy setting to decide what step sizes to take. - The Simulator employs a numerical integrator, but also uses accuracy to decide how precisely to isolate witness function zero crossings. - Iterative calculations reported as results or cached internally depend on accuracy to decide how strictly to converge the results. Examples of these are: constraint projection, calculation of distances between smooth shapes, and deformation calculations for soft contact.

The common thread among these examples is that they all share the same Context, so by keeping accuracy here it can be used effectively to control all accuracy-dependent computations.

Any accuracy-dependent computation in this Context and its subcontexts may be invalidated by a change to the accuracy setting, so out of date notifications are sent to all such computations (at least if the accuracy setting has actually changed). Accuracy must have the same value in every subcontext within the same context tree so may only be modified at the root context of a tree.

Requested accuracy is stored in the Context for two reasons: - It permits all computations performed over a System to see the same accuracy request since accuracy is stored in one shared place, and - it allows us to notify accuracy-dependent cached results that they are out of date when the accuracy setting changes.

Raises

RuntimeError if this is not the root context.

SetContinuousState(self: pydrake.systems.framework.Context, arg0: numpy.ndarray[numpy.float64[m, 1]]) None

Sets the continuous state to xc, including q, v, and z partitions. The supplied vector must be the same size as the existing continuous state. Sends out of date notifications for all continuous-state-dependent computations.

SetDiscreteState(*args, **kwargs)

Overloaded function.

  1. SetDiscreteState(self: pydrake.systems.framework.Context, xd: numpy.ndarray[numpy.float64[m, 1]]) -> None

Sets the discrete state to xd, assuming there is just one discrete state group. The supplied vector must be the same size as the existing discrete state. Sends out of date notifications for all discrete-state-dependent computations. Use the other signature for this method if you have multiple discrete state groups.

Precondition:

There is exactly one discrete state group.

  1. SetDiscreteState(self: pydrake.systems.framework.Context, group_index: int, xd: numpy.ndarray[numpy.float64[m, 1]]) -> None

Sets the discrete state group indicated by group_index to xd. The supplied vector xd must be the same size as the existing discrete state group. Sends out of date notifications for all computations that depend on this discrete state group.

Precondition:

group_index identifies an existing group.

Note

Currently notifies dependents of all groups.

  1. SetDiscreteState(self: pydrake.systems.framework.Context, xd: pydrake.systems.framework.DiscreteValues) -> None

Sets all the discrete state variables in this Context from a compatible DiscreteValues object.

Raises
  • RuntimeError unless the number of groups and size of each group of

  • xd` matches those in this Context

SetStateAndParametersFrom(*args, **kwargs)

Overloaded function.

  1. SetStateAndParametersFrom(self: pydrake.systems.framework.Context, source: pydrake.systems.framework.Context) -> None

Copies all state and parameters in source, where numerical values are of type U, to this context. Time and accuracy are unchanged in this context, which means that this method can be called on a subcontext. Sends out of date notifications for all dependent computations in this context.

Note

Currently does not copy fixed input port values from source. See System::FixInputPortsFrom() if you want to copy those.

See also

SetTimeStateAndParametersFrom() if you want to copy time and accuracy along with state and parameters to a root context.

  1. SetStateAndParametersFrom(self: pydrake.systems.framework.Context, source: pydrake.systems.framework.Context_[AutoDiffXd]) -> None

Copies all state and parameters in source, where numerical values are of type U, to this context. Time and accuracy are unchanged in this context, which means that this method can be called on a subcontext. Sends out of date notifications for all dependent computations in this context.

Note

Currently does not copy fixed input port values from source. See System::FixInputPortsFrom() if you want to copy those.

See also

SetTimeStateAndParametersFrom() if you want to copy time and accuracy along with state and parameters to a root context.

  1. SetStateAndParametersFrom(self: pydrake.systems.framework.Context, source: pydrake.systems.framework.Context_[Expression]) -> None

Copies all state and parameters in source, where numerical values are of type U, to this context. Time and accuracy are unchanged in this context, which means that this method can be called on a subcontext. Sends out of date notifications for all dependent computations in this context.

Note

Currently does not copy fixed input port values from source. See System::FixInputPortsFrom() if you want to copy those.

See also

SetTimeStateAndParametersFrom() if you want to copy time and accuracy along with state and parameters to a root context.

SetTime(self: pydrake.systems.framework.Context, time_sec: float) None

Sets the current time in seconds. Sends out of date notifications for all time-dependent computations (at least if the time has actually changed). Time must have the same value in every subcontext within the same Diagram context tree so may only be modified at the root context of the tree.

Raises

RuntimeError if this is not the root context.

SetTimeAndContinuousState(self: pydrake.systems.framework.Context, arg0: float, arg1: numpy.ndarray[numpy.float64[m, 1]]) None

Sets time to time_sec and continuous state to xc. Performs a single notification sweep to avoid duplicate notifications for computations that depend on both time and state.

Raises

RuntimeError if this is not the root context.

SetTimeStateAndParametersFrom(*args, **kwargs)

Overloaded function.

  1. SetTimeStateAndParametersFrom(self: pydrake.systems.framework.Context, source: pydrake.systems.framework.Context) -> None

Copies time, accuracy, all state and all parameters in source, where numerical values are of type U, to this context. This method can only be called on root contexts because time and accuracy are copied. Sends out of date notifications for all dependent computations in this context.

Raises

RuntimeError if this is not the root context.

Note

Currently does not copy fixed input port values from source. See System::FixInputPortsFrom() if you want to copy those.

See also

SetStateAndParametersFrom() if you want to copy state and parameters to a non-root context.

  1. SetTimeStateAndParametersFrom(self: pydrake.systems.framework.Context, source: pydrake.systems.framework.Context_[AutoDiffXd]) -> None

Copies time, accuracy, all state and all parameters in source, where numerical values are of type U, to this context. This method can only be called on root contexts because time and accuracy are copied. Sends out of date notifications for all dependent computations in this context.

Raises

RuntimeError if this is not the root context.

Note

Currently does not copy fixed input port values from source. See System::FixInputPortsFrom() if you want to copy those.

See also

SetStateAndParametersFrom() if you want to copy state and parameters to a non-root context.

  1. SetTimeStateAndParametersFrom(self: pydrake.systems.framework.Context, source: pydrake.systems.framework.Context_[Expression]) -> None

Copies time, accuracy, all state and all parameters in source, where numerical values are of type U, to this context. This method can only be called on root contexts because time and accuracy are copied. Sends out of date notifications for all dependent computations in this context.

Raises

RuntimeError if this is not the root context.

Note

Currently does not copy fixed input port values from source. See System::FixInputPortsFrom() if you want to copy those.

See also

SetStateAndParametersFrom() if you want to copy state and parameters to a non-root context.

template pydrake.systems.framework.Context_

Instantiations: Context_[float], Context_[AutoDiffXd], Context_[Expression]

class pydrake.systems.framework.Context_[AutoDiffXd]

Bases: pydrake.systems.framework.ContextBase

Context is an abstract class template that represents all the typed values that are used in a System’s computations: time, numeric-valued input ports, numerical state, and numerical parameters. There are also type-erased abstract state variables, abstract-valued input ports, abstract parameters, and a double accuracy setting. The framework provides two concrete subclasses of Context: LeafContext (for leaf Systems) and DiagramContext (for composite System Diagrams). Users are forbidden to extend DiagramContext and are discouraged from subclassing LeafContext.

A Context is designed to be used only with the System that created it. Data encapsulated with State and Parameter objects can be copied between contexts for compatible systems with some restrictions. For details, see system_compatibility.

__init__(*args, **kwargs)
Clone(self: pydrake.systems.framework.Context_[AutoDiffXd]) pydrake.systems.framework.Context_[AutoDiffXd]

Returns a deep copy of this Context.

Raises

RuntimeError if this is not the root context.

get_abstract_parameter(self: pydrake.systems.framework.Context_[AutoDiffXd], index: int) pydrake.common.value.AbstractValue

Returns a const reference to the vector-valued parameter at index.

Precondition:

index must identify an existing parameter.

get_abstract_state(*args, **kwargs)

Overloaded function.

  1. get_abstract_state(self: pydrake.systems.framework.Context_[AutoDiffXd]) -> pydrake.systems.framework.AbstractValues

Returns a const reference to the abstract component of the state, which may be of size zero.

  1. get_abstract_state(self: pydrake.systems.framework.Context_[AutoDiffXd], index: int) -> pydrake.common.value.AbstractValue

Returns a const reference to the abstract component of the state at index.

Precondition:

index must identify an existing element.

Precondition:

the abstract state’s type must match the template argument.

get_accuracy(self: pydrake.systems.framework.Context_[AutoDiffXd]) Optional[float]

Returns the accuracy setting (if any). Note that the return type is optional<double> rather than the double value itself.

See also

SetAccuracy() for details.

get_continuous_state(self: pydrake.systems.framework.Context_[AutoDiffXd]) pydrake.systems.framework.ContinuousState_[AutoDiffXd]

Returns a const reference to the continuous component of the state, which may be of size zero.

get_continuous_state_vector(self: pydrake.systems.framework.Context_[AutoDiffXd]) pydrake.systems.framework.VectorBase_[AutoDiffXd]

Returns a reference to the continuous state vector, devoid of second-order structure. The vector may be of size zero.

get_discrete_state(*args, **kwargs)

Overloaded function.

  1. get_discrete_state(self: pydrake.systems.framework.Context_[AutoDiffXd]) -> pydrake.systems.framework.DiscreteValues_[AutoDiffXd]

Returns a reference to the entire discrete state, which may consist of multiple discrete state vectors (groups).

  1. get_discrete_state(self: pydrake.systems.framework.Context_[AutoDiffXd], arg0: int) -> pydrake.systems.framework.BasicVector_[AutoDiffXd]

Returns a const reference to group (vector) index of the discrete state.

Precondition:

index must identify an existing group.

get_discrete_state_vector(self: pydrake.systems.framework.Context_[AutoDiffXd]) pydrake.systems.framework.BasicVector_[AutoDiffXd]

Returns a reference to the only discrete state vector. The vector may be of size zero.

Precondition:

There is only one discrete state group.

get_mutable_abstract_parameter(self: pydrake.systems.framework.Context_[AutoDiffXd], index: int) pydrake.common.value.AbstractValue

Returns a mutable reference to element index of the abstract-valued parameters. Sends out of date notifications for all computations dependent on this parameter.

Precondition:

index must identify an existing abstract parameter.

Note

Currently notifies dependents of all abstract parameters.

get_mutable_abstract_state(*args, **kwargs)

Overloaded function.

  1. get_mutable_abstract_state(self: pydrake.systems.framework.Context_[AutoDiffXd]) -> pydrake.systems.framework.AbstractValues

Returns a mutable reference to the abstract component of the state, which may be of size zero. Sends out of date notifications for all abstract-state-dependent computations.

Warning

You must not use the returned reference to modify the size, number, or types of abstract state variables.

  1. get_mutable_abstract_state(self: pydrake.systems.framework.Context_[AutoDiffXd], index: int) -> pydrake.common.value.AbstractValue

Returns a mutable reference to element index of the abstract state. Sends out of date notifications for all computations that depend on this abstract state variable.

Precondition:

index must identify an existing element.

Precondition:

the abstract state’s type must match the template argument.

Note

Currently notifies dependents of any abstract state variable.

get_mutable_continuous_state(self: pydrake.systems.framework.Context_[AutoDiffXd]) pydrake.systems.framework.ContinuousState_[AutoDiffXd]

Returns a mutable reference to the continuous component of the state, which may be of size zero. Sends out of date notifications for all continuous-state-dependent computations.

get_mutable_continuous_state_vector(self: pydrake.systems.framework.Context_[AutoDiffXd]) pydrake.systems.framework.VectorBase_[AutoDiffXd]

Returns a mutable reference to the continuous state vector, devoid of second-order structure. The vector may be of size zero. Sends out of date notifications for all continuous-state-dependent computations.

get_mutable_discrete_state(*args, **kwargs)

Overloaded function.

  1. get_mutable_discrete_state(self: pydrake.systems.framework.Context_[AutoDiffXd]) -> pydrake.systems.framework.DiscreteValues_[AutoDiffXd]

Returns a mutable reference to the discrete component of the state, which may be of size zero. Sends out of date notifications for all discrete-state-dependent computations.

Warning

You must not use the returned reference to modify the size or number of discrete state variables.

  1. get_mutable_discrete_state(self: pydrake.systems.framework.Context_[AutoDiffXd], arg0: int) -> pydrake.systems.framework.BasicVector_[AutoDiffXd]

Returns a mutable reference to group (vector) index of the discrete state. Sends out of date notifications for all computations that depend on this discrete state group.

Precondition:

index must identify an existing group.

Note

Currently notifies dependents of all groups.

get_mutable_discrete_state_vector(self: pydrake.systems.framework.Context_[AutoDiffXd]) pydrake.systems.framework.BasicVector_[AutoDiffXd]

Returns a mutable reference to the only discrete state vector. Sends out of date notifications for all discrete-state-dependent computations.

See also

get_discrete_state_vector().

Precondition:

There is only one discrete state group.

get_mutable_numeric_parameter(self: pydrake.systems.framework.Context_[AutoDiffXd], index: int) pydrake.systems.framework.BasicVector_[AutoDiffXd]

Returns a mutable reference to element index of the vector-valued (numeric) parameters. Sends out of date notifications for all computations dependent on this parameter.

Precondition:

index must identify an existing numeric parameter.

Note

Currently notifies dependents of all numeric parameters.

get_mutable_parameters(self: pydrake.systems.framework.Context_[AutoDiffXd]) pydrake.systems.framework.Parameters_[AutoDiffXd]

Returns a mutable reference to this Context’s parameters. Sends out of date notifications for all parameter-dependent computations. If you don’t mean to change all the parameters, use the indexed methods to modify only some of the parameters so that fewer computations are invalidated and fewer notifications need be sent.

Warning

You must not use the returned reference to modify the size, number, or types of parameters.

get_mutable_state(self: pydrake.systems.framework.Context_[AutoDiffXd]) pydrake.systems.framework.State_[AutoDiffXd]

Returns a mutable reference to the whole State, potentially invalidating all state-dependent computations so requiring out of date notifications to be made for all such computations. If you don’t mean to change the whole state, use more focused methods to modify only a portion of the state. See class documentation for more information.

Warning

You must not use the returned reference to modify the size, number, or types of state variables.

get_numeric_parameter(self: pydrake.systems.framework.Context_[AutoDiffXd], index: int) pydrake.systems.framework.BasicVector_[AutoDiffXd]

Returns a const reference to the vector-valued parameter at index.

Precondition:

index must identify an existing parameter.

get_parameters(self: pydrake.systems.framework.Context_[AutoDiffXd]) pydrake.systems.framework.Parameters_[AutoDiffXd]

Returns a const reference to this Context’s parameters.

get_state(self: pydrake.systems.framework.Context_[AutoDiffXd]) pydrake.systems.framework.State_[AutoDiffXd]

Returns a const reference to the whole State.

get_time(self: pydrake.systems.framework.Context_[AutoDiffXd]) pydrake.autodiffutils.AutoDiffXd

Returns the current time in seconds.

See also

SetTime()

has_only_continuous_state(self: pydrake.systems.framework.Context_[AutoDiffXd]) bool

Returns true if the Context has continuous state, but no discrete or abstract state.

has_only_discrete_state(self: pydrake.systems.framework.Context_[AutoDiffXd]) bool

Returns true if the Context has discrete state, but no continuous or abstract state.

is_stateless(self: pydrake.systems.framework.Context_[AutoDiffXd]) bool

Returns true if the Context has no state.

num_abstract_parameters(self: pydrake.systems.framework.Context_[AutoDiffXd]) int

Returns the number of abstract-valued parameters.

num_abstract_states(self: pydrake.systems.framework.Context_[AutoDiffXd]) int

Returns the number of elements in the abstract state.

num_continuous_states(self: pydrake.systems.framework.Context_[AutoDiffXd]) int

Returns the number of continuous state variables xc = {q, v, z}.

num_discrete_state_groups(self: pydrake.systems.framework.Context_[AutoDiffXd]) int

Returns the number of vectors (groups) in the discrete state.

num_numeric_parameter_groups(self: pydrake.systems.framework.Context_[AutoDiffXd]) int

Returns the number of vector-valued parameters.

num_total_states(self: pydrake.systems.framework.Context_[AutoDiffXd]) int

Returns the total dimension of all of the basic vector states (as if they were muxed).

Raises

RuntimeError if the system contains any abstract state.

SetAbstractState(self: object, index: int, value: object) None

Sets the value of the abstract state variable selected by index. Sends out of date notifications for all computations that depend on that abstract state variable. The template type will be inferred and need not be specified explicitly.

Precondition:

index must identify an existing abstract state variable.

Precondition:

the abstract state’s type must match the template argument.

Note

Currently notifies dependents of any abstract state variable.

SetAccuracy(self: pydrake.systems.framework.Context_[AutoDiffXd], accuracy: Optional[float]) None

Records the user’s requested accuracy, which is a unit-less quantity designed for use with simulation and other numerical studies. Since accuracy is unit-less, algorithms and systems are free to interpret this quantity as they wish. The intention is that more computational work is acceptable as the accuracy setting is tightened (set closer to zero). If no accuracy is requested, computations are free to choose suitable defaults, or to refuse to proceed without an explicit accuracy setting. The accuracy of a complete simulation or other numerical study depends on the accuracy of all contributing computations, so it is important that each computation is done in accordance with the requested accuracy. Some examples of where this is needed: - Error-controlled numerical integrators use the accuracy setting to decide what step sizes to take. - The Simulator employs a numerical integrator, but also uses accuracy to decide how precisely to isolate witness function zero crossings. - Iterative calculations reported as results or cached internally depend on accuracy to decide how strictly to converge the results. Examples of these are: constraint projection, calculation of distances between smooth shapes, and deformation calculations for soft contact.

The common thread among these examples is that they all share the same Context, so by keeping accuracy here it can be used effectively to control all accuracy-dependent computations.

Any accuracy-dependent computation in this Context and its subcontexts may be invalidated by a change to the accuracy setting, so out of date notifications are sent to all such computations (at least if the accuracy setting has actually changed). Accuracy must have the same value in every subcontext within the same context tree so may only be modified at the root context of a tree.

Requested accuracy is stored in the Context for two reasons: - It permits all computations performed over a System to see the same accuracy request since accuracy is stored in one shared place, and - it allows us to notify accuracy-dependent cached results that they are out of date when the accuracy setting changes.

Raises

RuntimeError if this is not the root context.

SetContinuousState(self: pydrake.systems.framework.Context_[AutoDiffXd], arg0: numpy.ndarray[object[m, 1]]) None

Sets the continuous state to xc, including q, v, and z partitions. The supplied vector must be the same size as the existing continuous state. Sends out of date notifications for all continuous-state-dependent computations.

SetDiscreteState(*args, **kwargs)

Overloaded function.

  1. SetDiscreteState(self: pydrake.systems.framework.Context_[AutoDiffXd], xd: numpy.ndarray[object[m, 1]]) -> None

Sets the discrete state to xd, assuming there is just one discrete state group. The supplied vector must be the same size as the existing discrete state. Sends out of date notifications for all discrete-state-dependent computations. Use the other signature for this method if you have multiple discrete state groups.

Precondition:

There is exactly one discrete state group.

  1. SetDiscreteState(self: pydrake.systems.framework.Context_[AutoDiffXd], group_index: int, xd: numpy.ndarray[object[m, 1]]) -> None

Sets the discrete state group indicated by group_index to xd. The supplied vector xd must be the same size as the existing discrete state group. Sends out of date notifications for all computations that depend on this discrete state group.

Precondition:

group_index identifies an existing group.

Note

Currently notifies dependents of all groups.

  1. SetDiscreteState(self: pydrake.systems.framework.Context_[AutoDiffXd], xd: pydrake.systems.framework.DiscreteValues_[AutoDiffXd]) -> None

Sets all the discrete state variables in this Context from a compatible DiscreteValues object.

Raises
  • RuntimeError unless the number of groups and size of each group of

  • xd` matches those in this Context

SetStateAndParametersFrom(*args, **kwargs)

Overloaded function.

  1. SetStateAndParametersFrom(self: pydrake.systems.framework.Context_[AutoDiffXd], source: pydrake.systems.framework.Context) -> None

Copies all state and parameters in source, where numerical values are of type U, to this context. Time and accuracy are unchanged in this context, which means that this method can be called on a subcontext. Sends out of date notifications for all dependent computations in this context.

Note

Currently does not copy fixed input port values from source. See System::FixInputPortsFrom() if you want to copy those.

See also

SetTimeStateAndParametersFrom() if you want to copy time and accuracy along with state and parameters to a root context.

  1. SetStateAndParametersFrom(self: pydrake.systems.framework.Context_[AutoDiffXd], source: pydrake.systems.framework.Context_[AutoDiffXd]) -> None

Copies all state and parameters in source, where numerical values are of type U, to this context. Time and accuracy are unchanged in this context, which means that this method can be called on a subcontext. Sends out of date notifications for all dependent computations in this context.

Note

Currently does not copy fixed input port values from source. See System::FixInputPortsFrom() if you want to copy those.

See also

SetTimeStateAndParametersFrom() if you want to copy time and accuracy along with state and parameters to a root context.

  1. SetStateAndParametersFrom(self: pydrake.systems.framework.Context_[AutoDiffXd], source: pydrake.systems.framework.Context_[Expression]) -> None

Copies all state and parameters in source, where numerical values are of type U, to this context. Time and accuracy are unchanged in this context, which means that this method can be called on a subcontext. Sends out of date notifications for all dependent computations in this context.

Note

Currently does not copy fixed input port values from source. See System::FixInputPortsFrom() if you want to copy those.

See also

SetTimeStateAndParametersFrom() if you want to copy time and accuracy along with state and parameters to a root context.

SetTime(self: pydrake.systems.framework.Context_[AutoDiffXd], time_sec: pydrake.autodiffutils.AutoDiffXd) None

Sets the current time in seconds. Sends out of date notifications for all time-dependent computations (at least if the time has actually changed). Time must have the same value in every subcontext within the same Diagram context tree so may only be modified at the root context of the tree.

Raises

RuntimeError if this is not the root context.

SetTimeAndContinuousState(self: pydrake.systems.framework.Context_[AutoDiffXd], arg0: pydrake.autodiffutils.AutoDiffXd, arg1: numpy.ndarray[object[m, 1]]) None

Sets time to time_sec and continuous state to xc. Performs a single notification sweep to avoid duplicate notifications for computations that depend on both time and state.

Raises

RuntimeError if this is not the root context.

SetTimeStateAndParametersFrom(*args, **kwargs)

Overloaded function.

  1. SetTimeStateAndParametersFrom(self: pydrake.systems.framework.Context_[AutoDiffXd], source: pydrake.systems.framework.Context) -> None

Copies time, accuracy, all state and all parameters in source, where numerical values are of type U, to this context. This method can only be called on root contexts because time and accuracy are copied. Sends out of date notifications for all dependent computations in this context.

Raises

RuntimeError if this is not the root context.

Note

Currently does not copy fixed input port values from source. See System::FixInputPortsFrom() if you want to copy those.

See also

SetStateAndParametersFrom() if you want to copy state and parameters to a non-root context.

  1. SetTimeStateAndParametersFrom(self: pydrake.systems.framework.Context_[AutoDiffXd], source: pydrake.systems.framework.Context_[AutoDiffXd]) -> None

Copies time, accuracy, all state and all parameters in source, where numerical values are of type U, to this context. This method can only be called on root contexts because time and accuracy are copied. Sends out of date notifications for all dependent computations in this context.

Raises

RuntimeError if this is not the root context.

Note

Currently does not copy fixed input port values from source. See System::FixInputPortsFrom() if you want to copy those.

See also

SetStateAndParametersFrom() if you want to copy state and parameters to a non-root context.

  1. SetTimeStateAndParametersFrom(self: pydrake.systems.framework.Context_[AutoDiffXd], source: pydrake.systems.framework.Context_[Expression]) -> None

Copies time, accuracy, all state and all parameters in source, where numerical values are of type U, to this context. This method can only be called on root contexts because time and accuracy are copied. Sends out of date notifications for all dependent computations in this context.

Raises

RuntimeError if this is not the root context.

Note

Currently does not copy fixed input port values from source. See System::FixInputPortsFrom() if you want to copy those.

See also

SetStateAndParametersFrom() if you want to copy state and parameters to a non-root context.

class pydrake.systems.framework.Context_[Expression]

Bases: pydrake.systems.framework.ContextBase

Context is an abstract class template that represents all the typed values that are used in a System’s computations: time, numeric-valued input ports, numerical state, and numerical parameters. There are also type-erased abstract state variables, abstract-valued input ports, abstract parameters, and a double accuracy setting. The framework provides two concrete subclasses of Context: LeafContext (for leaf Systems) and DiagramContext (for composite System Diagrams). Users are forbidden to extend DiagramContext and are discouraged from subclassing LeafContext.

A Context is designed to be used only with the System that created it. Data encapsulated with State and Parameter objects can be copied between contexts for compatible systems with some restrictions. For details, see system_compatibility.

__init__(*args, **kwargs)
Clone(self: pydrake.systems.framework.Context_[Expression]) pydrake.systems.framework.Context_[Expression]

Returns a deep copy of this Context.

Raises

RuntimeError if this is not the root context.

get_abstract_parameter(self: pydrake.systems.framework.Context_[Expression], index: int) pydrake.common.value.AbstractValue

Returns a const reference to the vector-valued parameter at index.

Precondition:

index must identify an existing parameter.

get_abstract_state(*args, **kwargs)

Overloaded function.

  1. get_abstract_state(self: pydrake.systems.framework.Context_[Expression]) -> pydrake.systems.framework.AbstractValues

Returns a const reference to the abstract component of the state, which may be of size zero.

  1. get_abstract_state(self: pydrake.systems.framework.Context_[Expression], index: int) -> pydrake.common.value.AbstractValue

Returns a const reference to the abstract component of the state at index.

Precondition:

index must identify an existing element.

Precondition:

the abstract state’s type must match the template argument.

get_accuracy(self: pydrake.systems.framework.Context_[Expression]) Optional[float]

Returns the accuracy setting (if any). Note that the return type is optional<double> rather than the double value itself.

See also

SetAccuracy() for details.

get_continuous_state(self: pydrake.systems.framework.Context_[Expression]) pydrake.systems.framework.ContinuousState_[Expression]

Returns a const reference to the continuous component of the state, which may be of size zero.

get_continuous_state_vector(self: pydrake.systems.framework.Context_[Expression]) pydrake.systems.framework.VectorBase_[Expression]

Returns a reference to the continuous state vector, devoid of second-order structure. The vector may be of size zero.

get_discrete_state(*args, **kwargs)

Overloaded function.

  1. get_discrete_state(self: pydrake.systems.framework.Context_[Expression]) -> pydrake.systems.framework.DiscreteValues_[Expression]

Returns a reference to the entire discrete state, which may consist of multiple discrete state vectors (groups).

  1. get_discrete_state(self: pydrake.systems.framework.Context_[Expression], arg0: int) -> pydrake.systems.framework.BasicVector_[Expression]

Returns a const reference to group (vector) index of the discrete state.

Precondition:

index must identify an existing group.

get_discrete_state_vector(self: pydrake.systems.framework.Context_[Expression]) pydrake.systems.framework.BasicVector_[Expression]

Returns a reference to the only discrete state vector. The vector may be of size zero.

Precondition:

There is only one discrete state group.

get_mutable_abstract_parameter(self: pydrake.systems.framework.Context_[Expression], index: int) pydrake.common.value.AbstractValue

Returns a mutable reference to element index of the abstract-valued parameters. Sends out of date notifications for all computations dependent on this parameter.

Precondition:

index must identify an existing abstract parameter.

Note

Currently notifies dependents of all abstract parameters.

get_mutable_abstract_state(*args, **kwargs)

Overloaded function.

  1. get_mutable_abstract_state(self: pydrake.systems.framework.Context_[Expression]) -> pydrake.systems.framework.AbstractValues

Returns a mutable reference to the abstract component of the state, which may be of size zero. Sends out of date notifications for all abstract-state-dependent computations.

Warning

You must not use the returned reference to modify the size, number, or types of abstract state variables.

  1. get_mutable_abstract_state(self: pydrake.systems.framework.Context_[Expression], index: int) -> pydrake.common.value.AbstractValue

Returns a mutable reference to element index of the abstract state. Sends out of date notifications for all computations that depend on this abstract state variable.

Precondition:

index must identify an existing element.

Precondition:

the abstract state’s type must match the template argument.

Note

Currently notifies dependents of any abstract state variable.

get_mutable_continuous_state(self: pydrake.systems.framework.Context_[Expression]) pydrake.systems.framework.ContinuousState_[Expression]

Returns a mutable reference to the continuous component of the state, which may be of size zero. Sends out of date notifications for all continuous-state-dependent computations.

get_mutable_continuous_state_vector(self: pydrake.systems.framework.Context_[Expression]) pydrake.systems.framework.VectorBase_[Expression]

Returns a mutable reference to the continuous state vector, devoid of second-order structure. The vector may be of size zero. Sends out of date notifications for all continuous-state-dependent computations.

get_mutable_discrete_state(*args, **kwargs)

Overloaded function.

  1. get_mutable_discrete_state(self: pydrake.systems.framework.Context_[Expression]) -> pydrake.systems.framework.DiscreteValues_[Expression]

Returns a mutable reference to the discrete component of the state, which may be of size zero. Sends out of date notifications for all discrete-state-dependent computations.

Warning

You must not use the returned reference to modify the size or number of discrete state variables.

  1. get_mutable_discrete_state(self: pydrake.systems.framework.Context_[Expression], arg0: int) -> pydrake.systems.framework.BasicVector_[Expression]

Returns a mutable reference to group (vector) index of the discrete state. Sends out of date notifications for all computations that depend on this discrete state group.

Precondition:

index must identify an existing group.

Note

Currently notifies dependents of all groups.

get_mutable_discrete_state_vector(self: pydrake.systems.framework.Context_[Expression]) pydrake.systems.framework.BasicVector_[Expression]

Returns a mutable reference to the only discrete state vector. Sends out of date notifications for all discrete-state-dependent computations.

See also

get_discrete_state_vector().

Precondition:

There is only one discrete state group.

get_mutable_numeric_parameter(self: pydrake.systems.framework.Context_[Expression], index: int) pydrake.systems.framework.BasicVector_[Expression]

Returns a mutable reference to element index of the vector-valued (numeric) parameters. Sends out of date notifications for all computations dependent on this parameter.

Precondition:

index must identify an existing numeric parameter.

Note

Currently notifies dependents of all numeric parameters.

get_mutable_parameters(self: pydrake.systems.framework.Context_[Expression]) pydrake.systems.framework.Parameters_[Expression]

Returns a mutable reference to this Context’s parameters. Sends out of date notifications for all parameter-dependent computations. If you don’t mean to change all the parameters, use the indexed methods to modify only some of the parameters so that fewer computations are invalidated and fewer notifications need be sent.

Warning

You must not use the returned reference to modify the size, number, or types of parameters.

get_mutable_state(self: pydrake.systems.framework.Context_[Expression]) pydrake.systems.framework.State_[Expression]

Returns a mutable reference to the whole State, potentially invalidating all state-dependent computations so requiring out of date notifications to be made for all such computations. If you don’t mean to change the whole state, use more focused methods to modify only a portion of the state. See class documentation for more information.

Warning

You must not use the returned reference to modify the size, number, or types of state variables.

get_numeric_parameter(self: pydrake.systems.framework.Context_[Expression], index: int) pydrake.systems.framework.BasicVector_[Expression]

Returns a const reference to the vector-valued parameter at index.

Precondition:

index must identify an existing parameter.

get_parameters(self: pydrake.systems.framework.Context_[Expression]) pydrake.systems.framework.Parameters_[Expression]

Returns a const reference to this Context’s parameters.

get_state(self: pydrake.systems.framework.Context_[Expression]) pydrake.systems.framework.State_[Expression]

Returns a const reference to the whole State.

get_time(self: pydrake.systems.framework.Context_[Expression]) pydrake.symbolic.Expression

Returns the current time in seconds.

See also

SetTime()

has_only_continuous_state(self: pydrake.systems.framework.Context_[Expression]) bool

Returns true if the Context has continuous state, but no discrete or abstract state.

has_only_discrete_state(self: pydrake.systems.framework.Context_[Expression]) bool

Returns true if the Context has discrete state, but no continuous or abstract state.

is_stateless(self: pydrake.systems.framework.Context_[Expression]) bool

Returns true if the Context has no state.

num_abstract_parameters(self: pydrake.systems.framework.Context_[Expression]) int

Returns the number of abstract-valued parameters.

num_abstract_states(self: pydrake.systems.framework.Context_[Expression]) int

Returns the number of elements in the abstract state.

num_continuous_states(self: pydrake.systems.framework.Context_[Expression]) int

Returns the number of continuous state variables xc = {q, v, z}.

num_discrete_state_groups(self: pydrake.systems.framework.Context_[Expression]) int

Returns the number of vectors (groups) in the discrete state.

num_numeric_parameter_groups(self: pydrake.systems.framework.Context_[Expression]) int

Returns the number of vector-valued parameters.

num_total_states(self: pydrake.systems.framework.Context_[Expression]) int

Returns the total dimension of all of the basic vector states (as if they were muxed).

Raises

RuntimeError if the system contains any abstract state.

SetAbstractState(self: object, index: int, value: object) None

Sets the value of the abstract state variable selected by index. Sends out of date notifications for all computations that depend on that abstract state variable. The template type will be inferred and need not be specified explicitly.

Precondition:

index must identify an existing abstract state variable.

Precondition:

the abstract state’s type must match the template argument.

Note

Currently notifies dependents of any abstract state variable.

SetAccuracy(self: pydrake.systems.framework.Context_[Expression], accuracy: Optional[float]) None

Records the user’s requested accuracy, which is a unit-less quantity designed for use with simulation and other numerical studies. Since accuracy is unit-less, algorithms and systems are free to interpret this quantity as they wish. The intention is that more computational work is acceptable as the accuracy setting is tightened (set closer to zero). If no accuracy is requested, computations are free to choose suitable defaults, or to refuse to proceed without an explicit accuracy setting. The accuracy of a complete simulation or other numerical study depends on the accuracy of all contributing computations, so it is important that each computation is done in accordance with the requested accuracy. Some examples of where this is needed: - Error-controlled numerical integrators use the accuracy setting to decide what step sizes to take. - The Simulator employs a numerical integrator, but also uses accuracy to decide how precisely to isolate witness function zero crossings. - Iterative calculations reported as results or cached internally depend on accuracy to decide how strictly to converge the results. Examples of these are: constraint projection, calculation of distances between smooth shapes, and deformation calculations for soft contact.

The common thread among these examples is that they all share the same Context, so by keeping accuracy here it can be used effectively to control all accuracy-dependent computations.

Any accuracy-dependent computation in this Context and its subcontexts may be invalidated by a change to the accuracy setting, so out of date notifications are sent to all such computations (at least if the accuracy setting has actually changed). Accuracy must have the same value in every subcontext within the same context tree so may only be modified at the root context of a tree.

Requested accuracy is stored in the Context for two reasons: - It permits all computations performed over a System to see the same accuracy request since accuracy is stored in one shared place, and - it allows us to notify accuracy-dependent cached results that they are out of date when the accuracy setting changes.

Raises

RuntimeError if this is not the root context.

SetContinuousState(self: pydrake.systems.framework.Context_[Expression], arg0: numpy.ndarray[object[m, 1]]) None

Sets the continuous state to xc, including q, v, and z partitions. The supplied vector must be the same size as the existing continuous state. Sends out of date notifications for all continuous-state-dependent computations.

SetDiscreteState(*args, **kwargs)

Overloaded function.

  1. SetDiscreteState(self: pydrake.systems.framework.Context_[Expression], xd: numpy.ndarray[object[m, 1]]) -> None

Sets the discrete state to xd, assuming there is just one discrete state group. The supplied vector must be the same size as the existing discrete state. Sends out of date notifications for all discrete-state-dependent computations. Use the other signature for this method if you have multiple discrete state groups.

Precondition:

There is exactly one discrete state group.

  1. SetDiscreteState(self: pydrake.systems.framework.Context_[Expression], group_index: int, xd: numpy.ndarray[object[m, 1]]) -> None

Sets the discrete state group indicated by group_index to xd. The supplied vector xd must be the same size as the existing discrete state group. Sends out of date notifications for all computations that depend on this discrete state group.

Precondition:

group_index identifies an existing group.

Note

Currently notifies dependents of all groups.

  1. SetDiscreteState(self: pydrake.systems.framework.Context_[Expression], xd: pydrake.systems.framework.DiscreteValues_[Expression]) -> None

Sets all the discrete state variables in this Context from a compatible DiscreteValues object.

Raises
  • RuntimeError unless the number of groups and size of each group of

  • xd` matches those in this Context

SetStateAndParametersFrom(*args, **kwargs)

Overloaded function.

  1. SetStateAndParametersFrom(self: pydrake.systems.framework.Context_[Expression], source: pydrake.systems.framework.Context) -> None

Copies all state and parameters in source, where numerical values are of type U, to this context. Time and accuracy are unchanged in this context, which means that this method can be called on a subcontext. Sends out of date notifications for all dependent computations in this context.

Note

Currently does not copy fixed input port values from source. See System::FixInputPortsFrom() if you want to copy those.

See also

SetTimeStateAndParametersFrom() if you want to copy time and accuracy along with state and parameters to a root context.

  1. SetStateAndParametersFrom(self: pydrake.systems.framework.Context_[Expression], source: pydrake.systems.framework.Context_[AutoDiffXd]) -> None

Copies all state and parameters in source, where numerical values are of type U, to this context. Time and accuracy are unchanged in this context, which means that this method can be called on a subcontext. Sends out of date notifications for all dependent computations in this context.

Note

Currently does not copy fixed input port values from source. See System::FixInputPortsFrom() if you want to copy those.

See also

SetTimeStateAndParametersFrom() if you want to copy time and accuracy along with state and parameters to a root context.

  1. SetStateAndParametersFrom(self: pydrake.systems.framework.Context_[Expression], source: pydrake.systems.framework.Context_[Expression]) -> None

Copies all state and parameters in source, where numerical values are of type U, to this context. Time and accuracy are unchanged in this context, which means that this method can be called on a subcontext. Sends out of date notifications for all dependent computations in this context.

Note

Currently does not copy fixed input port values from source. See System::FixInputPortsFrom() if you want to copy those.

See also

SetTimeStateAndParametersFrom() if you want to copy time and accuracy along with state and parameters to a root context.

SetTime(self: pydrake.systems.framework.Context_[Expression], time_sec: pydrake.symbolic.Expression) None

Sets the current time in seconds. Sends out of date notifications for all time-dependent computations (at least if the time has actually changed). Time must have the same value in every subcontext within the same Diagram context tree so may only be modified at the root context of the tree.

Raises

RuntimeError if this is not the root context.

SetTimeAndContinuousState(self: pydrake.systems.framework.Context_[Expression], arg0: pydrake.symbolic.Expression, arg1: numpy.ndarray[object[m, 1]]) None

Sets time to time_sec and continuous state to xc. Performs a single notification sweep to avoid duplicate notifications for computations that depend on both time and state.

Raises

RuntimeError if this is not the root context.

SetTimeStateAndParametersFrom(*args, **kwargs)

Overloaded function.

  1. SetTimeStateAndParametersFrom(self: pydrake.systems.framework.Context_[Expression], source: pydrake.systems.framework.Context) -> None

Copies time, accuracy, all state and all parameters in source, where numerical values are of type U, to this context. This method can only be called on root contexts because time and accuracy are copied. Sends out of date notifications for all dependent computations in this context.

Raises

RuntimeError if this is not the root context.

Note

Currently does not copy fixed input port values from source. See System::FixInputPortsFrom() if you want to copy those.

See also

SetStateAndParametersFrom() if you want to copy state and parameters to a non-root context.

  1. SetTimeStateAndParametersFrom(self: pydrake.systems.framework.Context_[Expression], source: pydrake.systems.framework.Context_[AutoDiffXd]) -> None

Copies time, accuracy, all state and all parameters in source, where numerical values are of type U, to this context. This method can only be called on root contexts because time and accuracy are copied. Sends out of date notifications for all dependent computations in this context.

Raises

RuntimeError if this is not the root context.

Note

Currently does not copy fixed input port values from source. See System::FixInputPortsFrom() if you want to copy those.

See also

SetStateAndParametersFrom() if you want to copy state and parameters to a non-root context.

  1. SetTimeStateAndParametersFrom(self: pydrake.systems.framework.Context_[Expression], source: pydrake.systems.framework.Context_[Expression]) -> None

Copies time, accuracy, all state and all parameters in source, where numerical values are of type U, to this context. This method can only be called on root contexts because time and accuracy are copied. Sends out of date notifications for all dependent computations in this context.

Raises

RuntimeError if this is not the root context.

Note

Currently does not copy fixed input port values from source. See System::FixInputPortsFrom() if you want to copy those.

See also

SetStateAndParametersFrom() if you want to copy state and parameters to a non-root context.

class pydrake.systems.framework.ContextBase

Provides non-templatized Context functionality shared by the templatized derived classes. That includes caching, dependency tracking, and management of local values for fixed input ports.

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.

__init__(*args, **kwargs)
DisableCaching(self: pydrake.systems.framework.ContextBase) None

(Debugging) Disables caching recursively for this context and all its subcontexts. Caching is enabled by default. Disabling forces every Eval() method to perform a full calculation rather than returning the cached one. Results should be identical with or without caching, except for performance. If they are not, there is likely a problem with (a) the specified dependencies for some calculation, or (b) a misuse of references into cached values that hides modifications from the caching system, or (c) a bug in the caching system. The is_disabled flags are independent of the out_of_date flags, which continue to be maintained even when caching is disabled (though they are ignored). Caching can be re-enabled using EnableCaching().

EnableCaching(self: pydrake.systems.framework.ContextBase) None

(Debugging) Re-enables caching recursively for this context and all its subcontexts. Caching is enabled by default but may have been disabled via a call to DisableCaching(). The is_disabled flags are independent of the out_of_date flags, which continue to be maintained even when caching is disabled (though they are ignored). Hence re-enabling the cache with this method may result in some entries being already considered up to date. See SetAllCacheEntriesOutOfDate() if you want to ensure that caching restarts with everything out of date. You might want to do that, for example, for repeatability or because you modified something in the debugger and want to make sure it gets used.

FreezeCache(self: pydrake.systems.framework.ContextBase) None

(Advanced) Freezes the cache at its current contents, preventing any further cache updates. When frozen, accessing an out-of-date cache entry causes an exception to be throw. This is applied recursively to this Context and all its subcontexts, but not to its parent or siblings so it is most useful when called on the root Context. If the cache was already frozen this method does nothing but waste a little time.

is_cache_frozen(self: pydrake.systems.framework.ContextBase) bool

(Advanced) Reports whether this Context’s cache is currently frozen. This checks only locally; it is possible that parent, child, or sibling subcontext caches are in a different state than this one.

num_input_ports(self: pydrake.systems.framework.ContextBase) int

Returns the number of input ports in this context.

num_output_ports(self: pydrake.systems.framework.ContextBase) int

Returns the number of output ports represented in this context.

SetAllCacheEntriesOutOfDate(self: pydrake.systems.framework.ContextBase) None

(Debugging) Marks all cache entries out of date, recursively for this context and all its subcontexts. This forces the next Eval() request for each cache entry to perform a full calculation rather than returning the cached one. After that first recalculation, normal caching behavior resumes (assuming the cache is not disabled). Results should be identical whether this is called or not, since the caching system should be maintaining this flag correctly. If they are not, see the documentation for SetIsCacheDisabled() for suggestions.

UnfreezeCache(self: pydrake.systems.framework.ContextBase) None

(Advanced) Unfreezes the cache if it was previously frozen. This is applied recursively to this Context and all its subcontexts, but not to its parent or siblings. If the cache was not frozen, this does nothing but waste a little time.

class pydrake.systems.framework.ContinuousState

%ContinuousState is a view of, and optionally a container for, all the continuous state variables xc of a Drake System. Continuous state variables are those whose values are defined by differential equations, so we expect there to be a well-defined time derivative xcdotd/dt xc.

The contents of xc are conceptually partitioned into three groups:

  • q is generalized position

  • v is generalized velocity

  • z is other continuous state

For a Drake LeafSystem these partitions are stored contiguously in memory in this sequence: xc=[q v z]. But because a Drake System may be a Diagram composed from subsystems, each with its own continuous state variables (“substates”), the composite continuous state will not generally be stored in contiguous memory. In that case the most we can say is that xc={q,v,z}, that is, it consists of all the q’s, v’s, and z’s, in some order.

Nevertheless, this ContinuousState class provides a vector view of the data that groups together all the q partitions, v partitions, and z partitions. For example, if there are three subsystems (possibly Diagrams) whose continuous state variables are respectively xc₁={q₁,v₁,z₁}, xc₂={q₂,v₂,z₂}, and xc₃={q₃,v₃,z₃} the composite xc includes all the partitions in an undefined order. However, composite q, v, and z appear ordered as q=[q₁ q₂ q₃], v=[v₁ v₂ v₃], z=[z₁ z₂ z₃]. Note that the element ordering of the composite xc is not a concatenation of the composite subgroups. Do not index elements of the full state xc unless you know it is the continuous state of a LeafSystem (a LeafSystem looking at its own Context can depend on that).

Any of the groups may be empty. However, groups q and v must be either both present or both empty, because the time derivative qdot of the second-order state variables q must be computable using a linear mapping qdot=N(q)*v.

The time derivative xcdot has the identical substructure to xc, with the partitions interpreted as qdot, vdot, and zdot. We use identical ContinuousState objects for both.

Memory ownership

When a ContinuousState represents the state of a LeafSystem, it always owns the memory that is used for the state variables and is responsible for destruction. For a Diagram, ContinuousState can instead be a view of the underlying LeafSystem substates, so that modifying the Diagram’s continuous state affects the LeafSystems appropriately. In that case, the memory is owned by the underlying LeafSystems. However, when a ContinuousState object of any structure is cloned, the resulting object always owns all its underlying memory, which is initialized with a copy of the original state variable values but is otherwise independent. The cloned object retains the structure and ordering of the elements and does not guarantee contiguous storage.

See also

DiagramContinuousState for more information.

Note

This class is templated; see ContinuousState_ for the list of instantiations.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: pydrake.systems.framework.ContinuousState, state: pydrake.systems.framework.VectorBase) -> None

Constructs a ContinuousState for a system that does not have second-order structure. The q and v partitions are empty; all of the state xc is miscellaneous continuous state z.

  1. __init__(self: pydrake.systems.framework.ContinuousState, state: pydrake.systems.framework.VectorBase, num_q: int, num_v: int, num_z: int) -> None

Constructs a ContinuousState that exposes second-order structure.

Parameter state:

The source xc of continuous state information.

Parameter num_q:

The number of position variables q.

Parameter num_v:

The number of velocity variables v.

Parameter num_z:

The number of other continuous variables z.

We require that num_q num_v and that the sum of the partition sizes adds up to the size of state.

  1. __init__(self: pydrake.systems.framework.ContinuousState) -> None

Constructs a zero-length ContinuousState.

Clone(self: pydrake.systems.framework.ContinuousState) pydrake.systems.framework.ContinuousState
CopyToVector(self: pydrake.systems.framework.ContinuousState) numpy.ndarray[numpy.float64[m, 1]]

Returns a copy of the entire continuous state vector into an Eigen vector.

get_generalized_position(self: pydrake.systems.framework.ContinuousState) pydrake.systems.framework.VectorBase

Returns a const reference to the subset of the state vector that is generalized position q. May be zero length.

get_generalized_velocity(self: pydrake.systems.framework.ContinuousState) pydrake.systems.framework.VectorBase

Returns a const reference to the subset of the continuous state vector that is generalized velocity v. May be zero length.

get_misc_continuous_state(self: pydrake.systems.framework.ContinuousState) pydrake.systems.framework.VectorBase

Returns a const reference to the subset of the continuous state vector that is other continuous state z. May be zero length.

get_mutable_generalized_position(self: pydrake.systems.framework.ContinuousState) pydrake.systems.framework.VectorBase

Returns a mutable reference to the subset of the state vector that is generalized position q. May be zero length.

get_mutable_generalized_velocity(self: pydrake.systems.framework.ContinuousState) pydrake.systems.framework.VectorBase

Returns a mutable reference to the subset of the continuous state vector that is generalized velocity v. May be zero length.

get_mutable_misc_continuous_state(self: pydrake.systems.framework.ContinuousState) pydrake.systems.framework.VectorBase

Returns a mutable reference to the subset of the continuous state vector that is other continuous state z. May be zero length.

get_mutable_vector(self: pydrake.systems.framework.ContinuousState) pydrake.systems.framework.VectorBase

Returns a mutable reference to the entire continuous state vector.

get_vector(self: pydrake.systems.framework.ContinuousState) pydrake.systems.framework.VectorBase

Returns a reference to the entire continuous state vector.

num_q(self: pydrake.systems.framework.ContinuousState) int

Returns the number of generalized positions q in this state vector.

num_v(self: pydrake.systems.framework.ContinuousState) int

Returns the number of generalized velocities v in this state vector.

num_z(self: pydrake.systems.framework.ContinuousState) int

Returns the number of miscellaneous continuous state variables z in this state vector.

SetFrom(self: pydrake.systems.framework.ContinuousState, arg0: pydrake.systems.framework.ContinuousState) None

Copies the values from other into this, converting the scalar type as necessary.

SetFromVector(self: pydrake.systems.framework.ContinuousState, value: numpy.ndarray[numpy.float64[m, 1]]) None

Sets the entire continuous state vector from an Eigen expression.

size(self: pydrake.systems.framework.ContinuousState) int

Returns the size of the entire continuous state vector, which is necessarily num_q + num_v + num_z.

template pydrake.systems.framework.ContinuousState_

Instantiations: ContinuousState_[float], ContinuousState_[AutoDiffXd], ContinuousState_[Expression]

class pydrake.systems.framework.ContinuousState_[AutoDiffXd]

%ContinuousState is a view of, and optionally a container for, all the continuous state variables xc of a Drake System. Continuous state variables are those whose values are defined by differential equations, so we expect there to be a well-defined time derivative xcdotd/dt xc.

The contents of xc are conceptually partitioned into three groups:

  • q is generalized position

  • v is generalized velocity

  • z is other continuous state

For a Drake LeafSystem these partitions are stored contiguously in memory in this sequence: xc=[q v z]. But because a Drake System may be a Diagram composed from subsystems, each with its own continuous state variables (“substates”), the composite continuous state will not generally be stored in contiguous memory. In that case the most we can say is that xc={q,v,z}, that is, it consists of all the q’s, v’s, and z’s, in some order.

Nevertheless, this ContinuousState class provides a vector view of the data that groups together all the q partitions, v partitions, and z partitions. For example, if there are three subsystems (possibly Diagrams) whose continuous state variables are respectively xc₁={q₁,v₁,z₁}, xc₂={q₂,v₂,z₂}, and xc₃={q₃,v₃,z₃} the composite xc includes all the partitions in an undefined order. However, composite q, v, and z appear ordered as q=[q₁ q₂ q₃], v=[v₁ v₂ v₃], z=[z₁ z₂ z₃]. Note that the element ordering of the composite xc is not a concatenation of the composite subgroups. Do not index elements of the full state xc unless you know it is the continuous state of a LeafSystem (a LeafSystem looking at its own Context can depend on that).

Any of the groups may be empty. However, groups q and v must be either both present or both empty, because the time derivative qdot of the second-order state variables q must be computable using a linear mapping qdot=N(q)*v.

The time derivative xcdot has the identical substructure to xc, with the partitions interpreted as qdot, vdot, and zdot. We use identical ContinuousState objects for both.

Memory ownership

When a ContinuousState represents the state of a LeafSystem, it always owns the memory that is used for the state variables and is responsible for destruction. For a Diagram, ContinuousState can instead be a view of the underlying LeafSystem substates, so that modifying the Diagram’s continuous state affects the LeafSystems appropriately. In that case, the memory is owned by the underlying LeafSystems. However, when a ContinuousState object of any structure is cloned, the resulting object always owns all its underlying memory, which is initialized with a copy of the original state variable values but is otherwise independent. The cloned object retains the structure and ordering of the elements and does not guarantee contiguous storage.

See also

DiagramContinuousState for more information.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: pydrake.systems.framework.ContinuousState_[AutoDiffXd], state: pydrake.systems.framework.VectorBase_[AutoDiffXd]) -> None

Constructs a ContinuousState for a system that does not have second-order structure. The q and v partitions are empty; all of the state xc is miscellaneous continuous state z.

  1. __init__(self: pydrake.systems.framework.ContinuousState_[AutoDiffXd], state: pydrake.systems.framework.VectorBase_[AutoDiffXd], num_q: int, num_v: int, num_z: int) -> None

Constructs a ContinuousState that exposes second-order structure.

Parameter state:

The source xc of continuous state information.

Parameter num_q:

The number of position variables q.

Parameter num_v:

The number of velocity variables v.

Parameter num_z:

The number of other continuous variables z.

We require that num_q num_v and that the sum of the partition sizes adds up to the size of state.

  1. __init__(self: pydrake.systems.framework.ContinuousState_[AutoDiffXd]) -> None

Constructs a zero-length ContinuousState.

Clone(self: pydrake.systems.framework.ContinuousState_[AutoDiffXd]) pydrake.systems.framework.ContinuousState_[AutoDiffXd]
CopyToVector(self: pydrake.systems.framework.ContinuousState_[AutoDiffXd]) numpy.ndarray[object[m, 1]]

Returns a copy of the entire continuous state vector into an Eigen vector.

get_generalized_position(self: pydrake.systems.framework.ContinuousState_[AutoDiffXd]) pydrake.systems.framework.VectorBase_[AutoDiffXd]

Returns a const reference to the subset of the state vector that is generalized position q. May be zero length.

get_generalized_velocity(self: pydrake.systems.framework.ContinuousState_[AutoDiffXd]) pydrake.systems.framework.VectorBase_[AutoDiffXd]

Returns a const reference to the subset of the continuous state vector that is generalized velocity v. May be zero length.

get_misc_continuous_state(self: pydrake.systems.framework.ContinuousState_[AutoDiffXd]) pydrake.systems.framework.VectorBase_[AutoDiffXd]

Returns a const reference to the subset of the continuous state vector that is other continuous state z. May be zero length.

get_mutable_generalized_position(self: pydrake.systems.framework.ContinuousState_[AutoDiffXd]) pydrake.systems.framework.VectorBase_[AutoDiffXd]

Returns a mutable reference to the subset of the state vector that is generalized position q. May be zero length.

get_mutable_generalized_velocity(self: pydrake.systems.framework.ContinuousState_[AutoDiffXd]) pydrake.systems.framework.VectorBase_[AutoDiffXd]

Returns a mutable reference to the subset of the continuous state vector that is generalized velocity v. May be zero length.

get_mutable_misc_continuous_state(self: pydrake.systems.framework.ContinuousState_[AutoDiffXd]) pydrake.systems.framework.VectorBase_[AutoDiffXd]

Returns a mutable reference to the subset of the continuous state vector that is other continuous state z. May be zero length.

get_mutable_vector(self: pydrake.systems.framework.ContinuousState_[AutoDiffXd]) pydrake.systems.framework.VectorBase_[AutoDiffXd]

Returns a mutable reference to the entire continuous state vector.

get_vector(self: pydrake.systems.framework.ContinuousState_[AutoDiffXd]) pydrake.systems.framework.VectorBase_[AutoDiffXd]

Returns a reference to the entire continuous state vector.

num_q(self: pydrake.systems.framework.ContinuousState_[AutoDiffXd]) int

Returns the number of generalized positions q in this state vector.

num_v(self: pydrake.systems.framework.ContinuousState_[AutoDiffXd]) int

Returns the number of generalized velocities v in this state vector.

num_z(self: pydrake.systems.framework.ContinuousState_[AutoDiffXd]) int

Returns the number of miscellaneous continuous state variables z in this state vector.

SetFrom(self: pydrake.systems.framework.ContinuousState_[AutoDiffXd], arg0: pydrake.systems.framework.ContinuousState) None

Copies the values from other into this, converting the scalar type as necessary.

SetFromVector(self: pydrake.systems.framework.ContinuousState_[AutoDiffXd], value: numpy.ndarray[object[m, 1]]) None

Sets the entire continuous state vector from an Eigen expression.

size(self: pydrake.systems.framework.ContinuousState_[AutoDiffXd]) int

Returns the size of the entire continuous state vector, which is necessarily num_q + num_v + num_z.

class pydrake.systems.framework.ContinuousState_[Expression]

%ContinuousState is a view of, and optionally a container for, all the continuous state variables xc of a Drake System. Continuous state variables are those whose values are defined by differential equations, so we expect there to be a well-defined time derivative xcdotd/dt xc.

The contents of xc are conceptually partitioned into three groups:

  • q is generalized position

  • v is generalized velocity

  • z is other continuous state

For a Drake LeafSystem these partitions are stored contiguously in memory in this sequence: xc=[q v z]. But because a Drake System may be a Diagram composed from subsystems, each with its own continuous state variables (“substates”), the composite continuous state will not generally be stored in contiguous memory. In that case the most we can say is that xc={q,v,z}, that is, it consists of all the q’s, v’s, and z’s, in some order.

Nevertheless, this ContinuousState class provides a vector view of the data that groups together all the q partitions, v partitions, and z partitions. For example, if there are three subsystems (possibly Diagrams) whose continuous state variables are respectively xc₁={q₁,v₁,z₁}, xc₂={q₂,v₂,z₂}, and xc₃={q₃,v₃,z₃} the composite xc includes all the partitions in an undefined order. However, composite q, v, and z appear ordered as q=[q₁ q₂ q₃], v=[v₁ v₂ v₃], z=[z₁ z₂ z₃]. Note that the element ordering of the composite xc is not a concatenation of the composite subgroups. Do not index elements of the full state xc unless you know it is the continuous state of a LeafSystem (a LeafSystem looking at its own Context can depend on that).

Any of the groups may be empty. However, groups q and v must be either both present or both empty, because the time derivative qdot of the second-order state variables q must be computable using a linear mapping qdot=N(q)*v.

The time derivative xcdot has the identical substructure to xc, with the partitions interpreted as qdot, vdot, and zdot. We use identical ContinuousState objects for both.

Memory ownership

When a ContinuousState represents the state of a LeafSystem, it always owns the memory that is used for the state variables and is responsible for destruction. For a Diagram, ContinuousState can instead be a view of the underlying LeafSystem substates, so that modifying the Diagram’s continuous state affects the LeafSystems appropriately. In that case, the memory is owned by the underlying LeafSystems. However, when a ContinuousState object of any structure is cloned, the resulting object always owns all its underlying memory, which is initialized with a copy of the original state variable values but is otherwise independent. The cloned object retains the structure and ordering of the elements and does not guarantee contiguous storage.

See also

DiagramContinuousState for more information.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: pydrake.systems.framework.ContinuousState_[Expression], state: pydrake.systems.framework.VectorBase_[Expression]) -> None

Constructs a ContinuousState for a system that does not have second-order structure. The q and v partitions are empty; all of the state xc is miscellaneous continuous state z.

  1. __init__(self: pydrake.systems.framework.ContinuousState_[Expression], state: pydrake.systems.framework.VectorBase_[Expression], num_q: int, num_v: int, num_z: int) -> None

Constructs a ContinuousState that exposes second-order structure.

Parameter state:

The source xc of continuous state information.

Parameter num_q:

The number of position variables q.

Parameter num_v:

The number of velocity variables v.

Parameter num_z:

The number of other continuous variables z.

We require that num_q num_v and that the sum of the partition sizes adds up to the size of state.

  1. __init__(self: pydrake.systems.framework.ContinuousState_[Expression]) -> None

Constructs a zero-length ContinuousState.

Clone(self: pydrake.systems.framework.ContinuousState_[Expression]) pydrake.systems.framework.ContinuousState_[Expression]
CopyToVector(self: pydrake.systems.framework.ContinuousState_[Expression]) numpy.ndarray[object[m, 1]]

Returns a copy of the entire continuous state vector into an Eigen vector.

get_generalized_position(self: pydrake.systems.framework.ContinuousState_[Expression]) pydrake.systems.framework.VectorBase_[Expression]

Returns a const reference to the subset of the state vector that is generalized position q. May be zero length.

get_generalized_velocity(self: pydrake.systems.framework.ContinuousState_[Expression]) pydrake.systems.framework.VectorBase_[Expression]

Returns a const reference to the subset of the continuous state vector that is generalized velocity v. May be zero length.

get_misc_continuous_state(self: pydrake.systems.framework.ContinuousState_[Expression]) pydrake.systems.framework.VectorBase_[Expression]

Returns a const reference to the subset of the continuous state vector that is other continuous state z. May be zero length.

get_mutable_generalized_position(self: pydrake.systems.framework.ContinuousState_[Expression]) pydrake.systems.framework.VectorBase_[Expression]

Returns a mutable reference to the subset of the state vector that is generalized position q. May be zero length.

get_mutable_generalized_velocity(self: pydrake.systems.framework.ContinuousState_[Expression]) pydrake.systems.framework.VectorBase_[Expression]

Returns a mutable reference to the subset of the continuous state vector that is generalized velocity v. May be zero length.

get_mutable_misc_continuous_state(self: pydrake.systems.framework.ContinuousState_[Expression]) pydrake.systems.framework.VectorBase_[Expression]

Returns a mutable reference to the subset of the continuous state vector that is other continuous state z. May be zero length.

get_mutable_vector(self: pydrake.systems.framework.ContinuousState_[Expression]) pydrake.systems.framework.VectorBase_[Expression]

Returns a mutable reference to the entire continuous state vector.

get_vector(self: pydrake.systems.framework.ContinuousState_[Expression]) pydrake.systems.framework.VectorBase_[Expression]

Returns a reference to the entire continuous state vector.

num_q(self: pydrake.systems.framework.ContinuousState_[Expression]) int

Returns the number of generalized positions q in this state vector.

num_v(self: pydrake.systems.framework.ContinuousState_[Expression]) int

Returns the number of generalized velocities v in this state vector.

num_z(self: pydrake.systems.framework.ContinuousState_[Expression]) int

Returns the number of miscellaneous continuous state variables z in this state vector.

SetFrom(self: pydrake.systems.framework.ContinuousState_[Expression], arg0: pydrake.systems.framework.ContinuousState) None

Copies the values from other into this, converting the scalar type as necessary.

SetFromVector(self: pydrake.systems.framework.ContinuousState_[Expression], value: numpy.ndarray[object[m, 1]]) None

Sets the entire continuous state vector from an Eigen expression.

size(self: pydrake.systems.framework.ContinuousState_[Expression]) int

Returns the size of the entire continuous state vector, which is necessarily num_q + num_v + num_z.

class pydrake.systems.framework.ContinuousStateIndex
__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: pydrake.systems.framework.ContinuousStateIndex) -> None

Default constructor; the result is an invalid index. This only exists to serve applications which require a default constructor.

  1. __init__(self: pydrake.systems.framework.ContinuousStateIndex, arg0: int) -> None

Construction from a non-negative int value. The value must lie in the range of [0, 2³¹). Constructor only promises to test validity in Debug build.

is_valid(self: pydrake.systems.framework.ContinuousStateIndex) bool

Reports if the index is valid–the only operation on an invalid index that doesn’t throw an exception in Debug builds.

class pydrake.systems.framework.DependencyTicket
__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: pydrake.systems.framework.DependencyTicket) -> None

Default constructor; the result is an invalid index. This only exists to serve applications which require a default constructor.

  1. __init__(self: pydrake.systems.framework.DependencyTicket, arg0: int) -> None

Construction from a non-negative int value. The value must lie in the range of [0, 2³¹). Constructor only promises to test validity in Debug build.

is_valid(self: pydrake.systems.framework.DependencyTicket) bool

Reports if the index is valid–the only operation on an invalid index that doesn’t throw an exception in Debug builds.

class pydrake.systems.framework.Diagram

Bases: pydrake.systems.framework.System

Diagram is a System composed of one or more constituent Systems, arranged in a directed graph where the vertices are the constituent Systems themselves, and the edges connect the output of one constituent System to the input of another. To construct a Diagram, use a DiagramBuilder.

Each System in the Diagram must have a unique, non-empty name.

Note

This class is templated; see Diagram_ for the list of instantiations.

__init__(self: pydrake.systems.framework.Diagram) None

Constructs an uninitialized Diagram. Subclasses that use this constructor are obligated to call DiagramBuilder::BuildInto(this). Provides scalar- type conversion support only if every contained subsystem provides the same support.

connection_map(self: pydrake.systems.framework.Diagram) dict

Returns a reference to the map of connections between Systems.

get_output_port_locator(self: pydrake.systems.framework.Diagram, port_index: pydrake.systems.framework.OutputPortIndex) tuple

Returns the “locator” for the subsystem output port that was exported as the port_index output port for the Diagram.

GetInputPortLocators(self: pydrake.systems.framework.Diagram, port_index: pydrake.systems.framework.InputPortIndex) list

Returns the collection of “locators” for the subsystem input ports that were exported or connected to the port_index input port for the Diagram.

GetMutableSubsystemState(self: pydrake.systems.framework.Diagram, arg0: pydrake.systems.framework.System, arg1: pydrake.systems.framework.Context) pydrake.systems.framework.State

Retrieves the state for a particular subsystem from the context for the entire diagram. Invalidates all entries in that subsystem’s cache that depend on State. Aborts if subsystem is not actually a subsystem of this diagram.

GetSubsystemByName(self: pydrake.systems.framework.Diagram, name: str) pydrake.systems.framework.System

Retrieves a const reference to the subsystem with name name returned by get_name().

Raises

RuntimeError if a match cannot be found.

See also

GetDowncastSubsystemByName()

See also

System<T>::get_name()

GetSystems(self: pydrake.systems.framework.Diagram) list[pydrake.systems.framework.System]

Returns the list of contained Systems.

HasSubsystemNamed(self: pydrake.systems.framework.Diagram, name: str) bool

Returns true iff this contains a subsystem with the given name.

See also

GetSubsystemByName()

template pydrake.systems.framework.Diagram_

Instantiations: Diagram_[float], Diagram_[AutoDiffXd], Diagram_[Expression]

class pydrake.systems.framework.Diagram_[AutoDiffXd]

Bases: pydrake.systems.framework.System_[AutoDiffXd]

Diagram is a System composed of one or more constituent Systems, arranged in a directed graph where the vertices are the constituent Systems themselves, and the edges connect the output of one constituent System to the input of another. To construct a Diagram, use a DiagramBuilder.

Each System in the Diagram must have a unique, non-empty name.

__init__(self: pydrake.systems.framework.Diagram_[AutoDiffXd]) None

Constructs an uninitialized Diagram. Subclasses that use this constructor are obligated to call DiagramBuilder::BuildInto(this). Provides scalar- type conversion support only if every contained subsystem provides the same support.

connection_map(self: pydrake.systems.framework.Diagram_[AutoDiffXd]) dict

Returns a reference to the map of connections between Systems.

get_output_port_locator(self: pydrake.systems.framework.Diagram_[AutoDiffXd], port_index: pydrake.systems.framework.OutputPortIndex) tuple

Returns the “locator” for the subsystem output port that was exported as the port_index output port for the Diagram.

GetInputPortLocators(self: pydrake.systems.framework.Diagram_[AutoDiffXd], port_index: pydrake.systems.framework.InputPortIndex) list

Returns the collection of “locators” for the subsystem input ports that were exported or connected to the port_index input port for the Diagram.

GetMutableSubsystemState(self: pydrake.systems.framework.Diagram_[AutoDiffXd], arg0: pydrake.systems.framework.System_[AutoDiffXd], arg1: pydrake.systems.framework.Context_[AutoDiffXd]) pydrake.systems.framework.State_[AutoDiffXd]

Retrieves the state for a particular subsystem from the context for the entire diagram. Invalidates all entries in that subsystem’s cache that depend on State. Aborts if subsystem is not actually a subsystem of this diagram.

GetSubsystemByName(self: pydrake.systems.framework.Diagram_[AutoDiffXd], name: str) pydrake.systems.framework.System_[AutoDiffXd]

Retrieves a const reference to the subsystem with name name returned by get_name().

Raises

RuntimeError if a match cannot be found.

See also

GetDowncastSubsystemByName()

See also

System<T>::get_name()

GetSystems(self: pydrake.systems.framework.Diagram_[AutoDiffXd]) list[pydrake.systems.framework.System_[AutoDiffXd]]

Returns the list of contained Systems.

HasSubsystemNamed(self: pydrake.systems.framework.Diagram_[AutoDiffXd], name: str) bool

Returns true iff this contains a subsystem with the given name.

See also

GetSubsystemByName()

class pydrake.systems.framework.Diagram_[Expression]

Bases: pydrake.systems.framework.System_[Expression]

Diagram is a System composed of one or more constituent Systems, arranged in a directed graph where the vertices are the constituent Systems themselves, and the edges connect the output of one constituent System to the input of another. To construct a Diagram, use a DiagramBuilder.

Each System in the Diagram must have a unique, non-empty name.

__init__(self: pydrake.systems.framework.Diagram_[Expression]) None

Constructs an uninitialized Diagram. Subclasses that use this constructor are obligated to call DiagramBuilder::BuildInto(this). Provides scalar- type conversion support only if every contained subsystem provides the same support.

connection_map(self: pydrake.systems.framework.Diagram_[Expression]) dict

Returns a reference to the map of connections between Systems.

get_output_port_locator(self: pydrake.systems.framework.Diagram_[Expression], port_index: pydrake.systems.framework.OutputPortIndex) tuple

Returns the “locator” for the subsystem output port that was exported as the port_index output port for the Diagram.

GetInputPortLocators(self: pydrake.systems.framework.Diagram_[Expression], port_index: pydrake.systems.framework.InputPortIndex) list

Returns the collection of “locators” for the subsystem input ports that were exported or connected to the port_index input port for the Diagram.

GetMutableSubsystemState(self: pydrake.systems.framework.Diagram_[Expression], arg0: pydrake.systems.framework.System_[Expression], arg1: pydrake.systems.framework.Context_[Expression]) pydrake.systems.framework.State_[Expression]

Retrieves the state for a particular subsystem from the context for the entire diagram. Invalidates all entries in that subsystem’s cache that depend on State. Aborts if subsystem is not actually a subsystem of this diagram.

GetSubsystemByName(self: pydrake.systems.framework.Diagram_[Expression], name: str) pydrake.systems.framework.System_[Expression]

Retrieves a const reference to the subsystem with name name returned by get_name().

Raises

RuntimeError if a match cannot be found.

See also

GetDowncastSubsystemByName()

See also

System<T>::get_name()

GetSystems(self: pydrake.systems.framework.Diagram_[Expression]) list[pydrake.systems.framework.System_[Expression]]

Returns the list of contained Systems.

HasSubsystemNamed(self: pydrake.systems.framework.Diagram_[Expression], name: str) bool

Returns true iff this contains a subsystem with the given name.

See also

GetSubsystemByName()

class pydrake.systems.framework.DiagramBuilder

DiagramBuilder is a factory class for Diagram.

It is single use: after calling Build or BuildInto, DiagramBuilder gives up ownership of the constituent systems, and should therefore be discarded; all member functions will throw an exception after this point.

When a Diagram (or DiagramBuilder) that owns systems is destroyed, the systems will be destroyed in the reverse of the order they were added.

A system must be added to the DiagramBuilder with AddSystem or AddNamedSystem before it can be wired up in any way. Every system must have a unique, non-empty name.

When building large Diagrams with many added systems and input-output port connections, the runtime performance of DiagramBuilder::Build() might become relevant.

As part of its correctness checks, the DiagramBuilder::Build() function performs a graph search of the diagram’s dependencies. In the graph, the nodes are the child systems that have been added to the diagram, and the edges are the diagram connections from one child’s output port to another child’s input port(s). The builder must confirm that the graph is acyclic; a cycle would imply an infinite loop in an output calculation function. With a large graph, this check can be computationally expensive. To speed it up, ensure that your output ports do not gratuitously depend on irrelevant input ports.

The dependencies are supplied via the prerequisites_of_calc argument to DeclareOutputPort family of functions. If the default value is used (i.e., when no prerequisites are provided), the default is to assume the output port value is dependent on all possible sources.

Refer to the DeclareLeafOutputPort_feedthrough “Direct feedthrough” documentation for additional details and examples. In particular, the SystemBase::all_sources_except_input_ports_ticket() is a convenient shortcut for outputs that do not depend on any inputs.

Note

This class is templated; see DiagramBuilder_ for the list of instantiations.

__init__(self: pydrake.systems.framework.DiagramBuilder) None
AddNamedSystem(self: pydrake.systems.framework.DiagramBuilder, name: str, system: pydrake.systems.framework.System) pydrake.systems.framework.System

Takes ownership of system, applies name to it, and adds it to the builder. Returns a bare pointer to the System, which will remain valid for the lifetime of the Diagram built by this builder.

Click to expand C++ code...
DiagramBuilder<T> builder;
  auto bar = builder.AddNamedSystem("bar", std::make_unique<Bar<T>>());
Template parameter S:

The type of system to add.

Postcondition:

The system’s name is name.

AddSystem(self: pydrake.systems.framework.DiagramBuilder, system: pydrake.systems.framework.System) pydrake.systems.framework.System

Takes ownership of system and adds it to the builder. Returns a bare pointer to the System, which will remain valid for the lifetime of the Diagram built by this builder.

If the system’s name is unset, sets it to System::GetMemoryObjectName() as a default in order to have unique names within the diagram.

Click to expand C++ code...
DiagramBuilder<T> builder;
  auto foo = builder.AddSystem(std::make_unique<Foo<T>>());
Template parameter S:

The type of system to add.

already_built(self: pydrake.systems.framework.DiagramBuilder) bool

Returns true iff Build() or BuildInto() has been called on this Builder, in which case it’s an error to call any member function other than the the destructor.

Build(self: pydrake.systems.framework.DiagramBuilder) pydrake.systems.framework.Diagram

Builds the Diagram that has been described by the calls to Connect, ExportInput, and ExportOutput.

Raises

RuntimeError if the graph is not buildable.

See DiagramBuilder_feedthrough “Building large Diagrams” for tips on improving runtime performance of this function.

BuildInto(self: pydrake.systems.framework.DiagramBuilder, target: pydrake.systems.framework.Diagram) None

Configures target to have the topology that has been described by the calls to Connect, ExportInput, and ExportOutput.

Raises

RuntimeError if the graph is not buildable.

Only Diagram subclasses should call this method. The target must not already be initialized.

Connect(self: pydrake.systems.framework.DiagramBuilder, arg0: pydrake.systems.framework.OutputPort, arg1: pydrake.systems.framework.InputPort) None

Declares that input port dest is connected to output port src.

Note

The connection created between src and dest via a call to this method can be effectively overridden by any subsequent call to InputPort::FixValue(). That is, calling InputPort::FixValue() on an already connected input port causes the resultant FixedInputPortValue to override any other value present on that port.

ConnectInput(*args, **kwargs)

Overloaded function.

  1. ConnectInput(self: pydrake.systems.framework.DiagramBuilder, diagram_port_name: str, input: pydrake.systems.framework.InputPort) -> None

Connects an input to the entire Diagram, indicated by diagram_port_name, to the given input port of a constituent system.

Precondition:

The Diagram input indicated by diagram_port_name must have been previously built via ExportInput().

Postcondition:

input is connected to the indicated Diagram input port.

  1. ConnectInput(self: pydrake.systems.framework.DiagramBuilder, diagram_port_index: pydrake.systems.framework.InputPortIndex, input: pydrake.systems.framework.InputPort) -> None

Connects an input to the entire Diagram, indicated by diagram_port_index, to the given input port of a constituent system.

Precondition:

The Diagram input indicated by diagram_port_index must have been previously built via ExportInput().

Postcondition:

input is connected to the indicated Diagram input port.

connection_map(self: pydrake.systems.framework.DiagramBuilder) dict

(Advanced) Returns a reference to the map of connections between Systems. The reference becomes invalid upon any call to Build or BuildInto.

ConnectToSame(self: pydrake.systems.framework.DiagramBuilder, exemplar: pydrake.systems.framework.InputPort, dest: pydrake.systems.framework.InputPort) bool

Connects dest to the same source as exemplar is connected to.

If exemplar was connected to an output port, then dest is connected to that same output. Or, if exemplar was exported as an input of this diagram, then dest will be connected to that same diagram input. Or, if exemplar was neither connected or exported, then this function is a no-op.

Both exemplar and dest must be ports of constituent systems that have already been added to this diagram.

Returns

True iff any connection or was made; or false when a no-op.

empty(self: pydrake.systems.framework.DiagramBuilder) bool

Returns whether any Systems have been added yet.

ExportInput(self: pydrake.systems.framework.DiagramBuilder, input: pydrake.systems.framework.InputPort, name: Union[str, pydrake.systems.framework.UseDefaultName] = kUseDefaultName) pydrake.systems.framework.InputPortIndex

Declares that the given input port of a constituent system is connected to a new input to the entire Diagram. name is an optional name for the new input port; if it is unspecified, then a default name will be provided.

Precondition:

If supplied at all, name must not be empty.

Precondition:

A port indicated by the resolution of name must not exist.

Postcondition:

input is connected to the new exported input port.

Returns

The index of the exported input port of the entire diagram.

ExportOutput(self: pydrake.systems.framework.DiagramBuilder, output: pydrake.systems.framework.OutputPort, name: Union[str, pydrake.systems.framework.UseDefaultName] = kUseDefaultName) pydrake.systems.framework.OutputPortIndex

Declares that the given output port of a constituent system is an output of the entire diagram. name is an optional name for the output port; if it is unspecified, then a default name will be provided.

Precondition:

If supplied at all, name must not be empty.

Returns

The index of the exported output port of the entire diagram.

GetMutableSubsystemByName(self: pydrake.systems.framework.DiagramBuilder, name: str) pydrake.systems.framework.System

Retrieves a mutable reference to the subsystem with name name returned by get_name().

Raises

RuntimeError if a unique match cannot be found.

See also

System<T>::get_name()

See also

GetSubsystemByName()

See also

GetMutableDowncastSubsystemByName()

GetMutableSystems(self: pydrake.systems.framework.DiagramBuilder) list[pydrake.systems.framework.System]

Returns the list of contained Systems.

See also

GetMutableSubsystemByName()

See also

GetSystems()

GetSubsystemByName(self: pydrake.systems.framework.DiagramBuilder, name: str) pydrake.systems.framework.System

Retrieves a const reference to the subsystem with name name returned by get_name().

Raises

RuntimeError if a unique match cannot be found.

See also

System<T>::get_name()

See also

GetMutableSubsystemByName()

See also

GetDowncastSubsystemByName()

GetSystems(self: pydrake.systems.framework.DiagramBuilder) list[pydrake.systems.framework.System]

Returns the list of contained Systems.

See also

GetSubsystemByName()

See also

GetMutableSystems()

HasSubsystemNamed(self: pydrake.systems.framework.DiagramBuilder, name: str) bool

Returns true iff this contains a subsystem with the given name.

See also

GetSubsystemByName()

IsConnectedOrExported(self: pydrake.systems.framework.DiagramBuilder, port: pydrake.systems.framework.InputPort) bool

Returns true iff the given input port of a constituent system is either connected to another constituent system or exported as a diagram input.

num_input_ports(self: pydrake.systems.framework.DiagramBuilder) int

Returns the current number of diagram input ports. The count may change as more ports are exported.

num_output_ports(self: pydrake.systems.framework.DiagramBuilder) int

Returns the current number of diagram output outputs. The count may change as more ports are exported.

RemoveSystem(self: pydrake.systems.framework.DiagramBuilder, system: pydrake.systems.framework.System) None

Removes the given system from this builder and disconnects any connections or exported ports associated with it.

Note that un-exporting this system’s ports might have a ripple effect on other exported port index assignments. The relative order will remain intact, but any “holes” created by this removal will be filled in by decrementing the indices of all higher-numbered ports that remain.

Warning

Because a DiagramBuilder owns the objects it contains, the system will be deleted.

template pydrake.systems.framework.DiagramBuilder_

Instantiations: DiagramBuilder_[float], DiagramBuilder_[AutoDiffXd], DiagramBuilder_[Expression]

class pydrake.systems.framework.DiagramBuilder_[AutoDiffXd]

DiagramBuilder is a factory class for Diagram.

It is single use: after calling Build or BuildInto, DiagramBuilder gives up ownership of the constituent systems, and should therefore be discarded; all member functions will throw an exception after this point.

When a Diagram (or DiagramBuilder) that owns systems is destroyed, the systems will be destroyed in the reverse of the order they were added.

A system must be added to the DiagramBuilder with AddSystem or AddNamedSystem before it can be wired up in any way. Every system must have a unique, non-empty name.

When building large Diagrams with many added systems and input-output port connections, the runtime performance of DiagramBuilder::Build() might become relevant.

As part of its correctness checks, the DiagramBuilder::Build() function performs a graph search of the diagram’s dependencies. In the graph, the nodes are the child systems that have been added to the diagram, and the edges are the diagram connections from one child’s output port to another child’s input port(s). The builder must confirm that the graph is acyclic; a cycle would imply an infinite loop in an output calculation function. With a large graph, this check can be computationally expensive. To speed it up, ensure that your output ports do not gratuitously depend on irrelevant input ports.

The dependencies are supplied via the prerequisites_of_calc argument to DeclareOutputPort family of functions. If the default value is used (i.e., when no prerequisites are provided), the default is to assume the output port value is dependent on all possible sources.

Refer to the DeclareLeafOutputPort_feedthrough “Direct feedthrough” documentation for additional details and examples. In particular, the SystemBase::all_sources_except_input_ports_ticket() is a convenient shortcut for outputs that do not depend on any inputs.

__init__(self: pydrake.systems.framework.DiagramBuilder_[AutoDiffXd]) None
AddNamedSystem(self: pydrake.systems.framework.DiagramBuilder_[AutoDiffXd], name: str, system: pydrake.systems.framework.System_[AutoDiffXd]) pydrake.systems.framework.System_[AutoDiffXd]

Takes ownership of system, applies name to it, and adds it to the builder. Returns a bare pointer to the System, which will remain valid for the lifetime of the Diagram built by this builder.

Click to expand C++ code...
DiagramBuilder<T> builder;
  auto bar = builder.AddNamedSystem("bar", std::make_unique<Bar<T>>());
Template parameter S:

The type of system to add.

Postcondition:

The system’s name is name.

AddSystem(self: pydrake.systems.framework.DiagramBuilder_[AutoDiffXd], system: pydrake.systems.framework.System_[AutoDiffXd]) pydrake.systems.framework.System_[AutoDiffXd]

Takes ownership of system and adds it to the builder. Returns a bare pointer to the System, which will remain valid for the lifetime of the Diagram built by this builder.

If the system’s name is unset, sets it to System::GetMemoryObjectName() as a default in order to have unique names within the diagram.

Click to expand C++ code...
DiagramBuilder<T> builder;
  auto foo = builder.AddSystem(std::make_unique<Foo<T>>());
Template parameter S:

The type of system to add.

already_built(self: pydrake.systems.framework.DiagramBuilder_[AutoDiffXd]) bool

Returns true iff Build() or BuildInto() has been called on this Builder, in which case it’s an error to call any member function other than the the destructor.

Build(self: pydrake.systems.framework.DiagramBuilder_[AutoDiffXd]) pydrake.systems.framework.Diagram_[AutoDiffXd]

Builds the Diagram that has been described by the calls to Connect, ExportInput, and ExportOutput.

Raises

RuntimeError if the graph is not buildable.

See DiagramBuilder_feedthrough “Building large Diagrams” for tips on improving runtime performance of this function.

BuildInto(self: pydrake.systems.framework.DiagramBuilder_[AutoDiffXd], target: pydrake.systems.framework.Diagram_[AutoDiffXd]) None

Configures target to have the topology that has been described by the calls to Connect, ExportInput, and ExportOutput.

Raises

RuntimeError if the graph is not buildable.

Only Diagram subclasses should call this method. The target must not already be initialized.

Connect(self: pydrake.systems.framework.DiagramBuilder_[AutoDiffXd], arg0: pydrake.systems.framework.OutputPort_[AutoDiffXd], arg1: pydrake.systems.framework.InputPort_[AutoDiffXd]) None

Declares that input port dest is connected to output port src.

Note

The connection created between src and dest via a call to this method can be effectively overridden by any subsequent call to InputPort::FixValue(). That is, calling InputPort::FixValue() on an already connected input port causes the resultant FixedInputPortValue to override any other value present on that port.

ConnectInput(*args, **kwargs)

Overloaded function.

  1. ConnectInput(self: pydrake.systems.framework.DiagramBuilder_[AutoDiffXd], diagram_port_name: str, input: pydrake.systems.framework.InputPort_[AutoDiffXd]) -> None

Connects an input to the entire Diagram, indicated by diagram_port_name, to the given input port of a constituent system.

Precondition:

The Diagram input indicated by diagram_port_name must have been previously built via ExportInput().

Postcondition:

input is connected to the indicated Diagram input port.

  1. ConnectInput(self: pydrake.systems.framework.DiagramBuilder_[AutoDiffXd], diagram_port_index: pydrake.systems.framework.InputPortIndex, input: pydrake.systems.framework.InputPort_[AutoDiffXd]) -> None

Connects an input to the entire Diagram, indicated by diagram_port_index, to the given input port of a constituent system.

Precondition:

The Diagram input indicated by diagram_port_index must have been previously built via ExportInput().

Postcondition:

input is connected to the indicated Diagram input port.

connection_map(self: pydrake.systems.framework.DiagramBuilder_[AutoDiffXd]) dict

(Advanced) Returns a reference to the map of connections between Systems. The reference becomes invalid upon any call to Build or BuildInto.

ConnectToSame(self: pydrake.systems.framework.DiagramBuilder_[AutoDiffXd], exemplar: pydrake.systems.framework.InputPort_[AutoDiffXd], dest: pydrake.systems.framework.InputPort_[AutoDiffXd]) bool

Connects dest to the same source as exemplar is connected to.

If exemplar was connected to an output port, then dest is connected to that same output. Or, if exemplar was exported as an input of this diagram, then dest will be connected to that same diagram input. Or, if exemplar was neither connected or exported, then this function is a no-op.

Both exemplar and dest must be ports of constituent systems that have already been added to this diagram.

Returns

True iff any connection or was made; or false when a no-op.

empty(self: pydrake.systems.framework.DiagramBuilder_[AutoDiffXd]) bool

Returns whether any Systems have been added yet.

ExportInput(self: pydrake.systems.framework.DiagramBuilder_[AutoDiffXd], input: pydrake.systems.framework.InputPort_[AutoDiffXd], name: Union[str, pydrake.systems.framework.UseDefaultName] = kUseDefaultName) pydrake.systems.framework.InputPortIndex

Declares that the given input port of a constituent system is connected to a new input to the entire Diagram. name is an optional name for the new input port; if it is unspecified, then a default name will be provided.

Precondition:

If supplied at all, name must not be empty.

Precondition:

A port indicated by the resolution of name must not exist.

Postcondition:

input is connected to the new exported input port.

Returns

The index of the exported input port of the entire diagram.

ExportOutput(self: pydrake.systems.framework.DiagramBuilder_[AutoDiffXd], output: pydrake.systems.framework.OutputPort_[AutoDiffXd], name: Union[str, pydrake.systems.framework.UseDefaultName] = kUseDefaultName) pydrake.systems.framework.OutputPortIndex

Declares that the given output port of a constituent system is an output of the entire diagram. name is an optional name for the output port; if it is unspecified, then a default name will be provided.

Precondition:

If supplied at all, name must not be empty.

Returns

The index of the exported output port of the entire diagram.

GetMutableSubsystemByName(self: pydrake.systems.framework.DiagramBuilder_[AutoDiffXd], name: str) pydrake.systems.framework.System_[AutoDiffXd]

Retrieves a mutable reference to the subsystem with name name returned by get_name().

Raises

RuntimeError if a unique match cannot be found.

See also

System<T>::get_name()

See also

GetSubsystemByName()

See also

GetMutableDowncastSubsystemByName()

GetMutableSystems(self: pydrake.systems.framework.DiagramBuilder_[AutoDiffXd]) list[pydrake.systems.framework.System_[AutoDiffXd]]

Returns the list of contained Systems.

See also

GetMutableSubsystemByName()

See also

GetSystems()

GetSubsystemByName(self: pydrake.systems.framework.DiagramBuilder_[AutoDiffXd], name: str) pydrake.systems.framework.System_[AutoDiffXd]

Retrieves a const reference to the subsystem with name name returned by get_name().

Raises

RuntimeError if a unique match cannot be found.

See also

System<T>::get_name()

See also

GetMutableSubsystemByName()

See also

GetDowncastSubsystemByName()

GetSystems(self: pydrake.systems.framework.DiagramBuilder_[AutoDiffXd]) list[pydrake.systems.framework.System_[AutoDiffXd]]

Returns the list of contained Systems.

See also

GetSubsystemByName()

See also

GetMutableSystems()

HasSubsystemNamed(self: pydrake.systems.framework.DiagramBuilder_[AutoDiffXd], name: str) bool

Returns true iff this contains a subsystem with the given name.

See also

GetSubsystemByName()

IsConnectedOrExported(self: pydrake.systems.framework.DiagramBuilder_[AutoDiffXd], port: pydrake.systems.framework.InputPort_[AutoDiffXd]) bool

Returns true iff the given input port of a constituent system is either connected to another constituent system or exported as a diagram input.

num_input_ports(self: pydrake.systems.framework.DiagramBuilder_[AutoDiffXd]) int

Returns the current number of diagram input ports. The count may change as more ports are exported.

num_output_ports(self: pydrake.systems.framework.DiagramBuilder_[AutoDiffXd]) int

Returns the current number of diagram output outputs. The count may change as more ports are exported.

RemoveSystem(self: pydrake.systems.framework.DiagramBuilder_[AutoDiffXd], system: pydrake.systems.framework.System_[AutoDiffXd]) None

Removes the given system from this builder and disconnects any connections or exported ports associated with it.

Note that un-exporting this system’s ports might have a ripple effect on other exported port index assignments. The relative order will remain intact, but any “holes” created by this removal will be filled in by decrementing the indices of all higher-numbered ports that remain.

Warning

Because a DiagramBuilder owns the objects it contains, the system will be deleted.

class pydrake.systems.framework.DiagramBuilder_[Expression]

DiagramBuilder is a factory class for Diagram.

It is single use: after calling Build or BuildInto, DiagramBuilder gives up ownership of the constituent systems, and should therefore be discarded; all member functions will throw an exception after this point.

When a Diagram (or DiagramBuilder) that owns systems is destroyed, the systems will be destroyed in the reverse of the order they were added.

A system must be added to the DiagramBuilder with AddSystem or AddNamedSystem before it can be wired up in any way. Every system must have a unique, non-empty name.

When building large Diagrams with many added systems and input-output port connections, the runtime performance of DiagramBuilder::Build() might become relevant.

As part of its correctness checks, the DiagramBuilder::Build() function performs a graph search of the diagram’s dependencies. In the graph, the nodes are the child systems that have been added to the diagram, and the edges are the diagram connections from one child’s output port to another child’s input port(s). The builder must confirm that the graph is acyclic; a cycle would imply an infinite loop in an output calculation function. With a large graph, this check can be computationally expensive. To speed it up, ensure that your output ports do not gratuitously depend on irrelevant input ports.

The dependencies are supplied via the prerequisites_of_calc argument to DeclareOutputPort family of functions. If the default value is used (i.e., when no prerequisites are provided), the default is to assume the output port value is dependent on all possible sources.

Refer to the DeclareLeafOutputPort_feedthrough “Direct feedthrough” documentation for additional details and examples. In particular, the SystemBase::all_sources_except_input_ports_ticket() is a convenient shortcut for outputs that do not depend on any inputs.

__init__(self: pydrake.systems.framework.DiagramBuilder_[Expression]) None
AddNamedSystem(self: pydrake.systems.framework.DiagramBuilder_[Expression], name: str, system: pydrake.systems.framework.System_[Expression]) pydrake.systems.framework.System_[Expression]

Takes ownership of system, applies name to it, and adds it to the builder. Returns a bare pointer to the System, which will remain valid for the lifetime of the Diagram built by this builder.

Click to expand C++ code...
DiagramBuilder<T> builder;
  auto bar = builder.AddNamedSystem("bar", std::make_unique<Bar<T>>());
Template parameter S:

The type of system to add.

Postcondition:

The system’s name is name.

AddSystem(self: pydrake.systems.framework.DiagramBuilder_[Expression], system: pydrake.systems.framework.System_[Expression]) pydrake.systems.framework.System_[Expression]

Takes ownership of system and adds it to the builder. Returns a bare pointer to the System, which will remain valid for the lifetime of the Diagram built by this builder.

If the system’s name is unset, sets it to System::GetMemoryObjectName() as a default in order to have unique names within the diagram.

Click to expand C++ code...
DiagramBuilder<T> builder;
  auto foo = builder.AddSystem(std::make_unique<Foo<T>>());
Template parameter S:

The type of system to add.

already_built(self: pydrake.systems.framework.DiagramBuilder_[Expression]) bool

Returns true iff Build() or BuildInto() has been called on this Builder, in which case it’s an error to call any member function other than the the destructor.

Build(self: pydrake.systems.framework.DiagramBuilder_[Expression]) pydrake.systems.framework.Diagram_[Expression]

Builds the Diagram that has been described by the calls to Connect, ExportInput, and ExportOutput.

Raises

RuntimeError if the graph is not buildable.

See DiagramBuilder_feedthrough “Building large Diagrams” for tips on improving runtime performance of this function.

BuildInto(self: pydrake.systems.framework.DiagramBuilder_[Expression], target: pydrake.systems.framework.Diagram_[Expression]) None

Configures target to have the topology that has been described by the calls to Connect, ExportInput, and ExportOutput.

Raises

RuntimeError if the graph is not buildable.

Only Diagram subclasses should call this method. The target must not already be initialized.

Connect(self: pydrake.systems.framework.DiagramBuilder_[Expression], arg0: pydrake.systems.framework.OutputPort_[Expression], arg1: pydrake.systems.framework.InputPort_[Expression]) None

Declares that input port dest is connected to output port src.

Note

The connection created between src and dest via a call to this method can be effectively overridden by any subsequent call to InputPort::FixValue(). That is, calling InputPort::FixValue() on an already connected input port causes the resultant FixedInputPortValue to override any other value present on that port.

ConnectInput(*args, **kwargs)

Overloaded function.

  1. ConnectInput(self: pydrake.systems.framework.DiagramBuilder_[Expression], diagram_port_name: str, input: pydrake.systems.framework.InputPort_[Expression]) -> None

Connects an input to the entire Diagram, indicated by diagram_port_name, to the given input port of a constituent system.

Precondition:

The Diagram input indicated by diagram_port_name must have been previously built via ExportInput().

Postcondition:

input is connected to the indicated Diagram input port.

  1. ConnectInput(self: pydrake.systems.framework.DiagramBuilder_[Expression], diagram_port_index: pydrake.systems.framework.InputPortIndex, input: pydrake.systems.framework.InputPort_[Expression]) -> None

Connects an input to the entire Diagram, indicated by diagram_port_index, to the given input port of a constituent system.

Precondition:

The Diagram input indicated by diagram_port_index must have been previously built via ExportInput().

Postcondition:

input is connected to the indicated Diagram input port.

connection_map(self: pydrake.systems.framework.DiagramBuilder_[Expression]) dict

(Advanced) Returns a reference to the map of connections between Systems. The reference becomes invalid upon any call to Build or BuildInto.

ConnectToSame(self: pydrake.systems.framework.DiagramBuilder_[Expression], exemplar: pydrake.systems.framework.InputPort_[Expression], dest: pydrake.systems.framework.InputPort_[Expression]) bool

Connects dest to the same source as exemplar is connected to.

If exemplar was connected to an output port, then dest is connected to that same output. Or, if exemplar was exported as an input of this diagram, then dest will be connected to that same diagram input. Or, if exemplar was neither connected or exported, then this function is a no-op.

Both exemplar and dest must be ports of constituent systems that have already been added to this diagram.

Returns

True iff any connection or was made; or false when a no-op.

empty(self: pydrake.systems.framework.DiagramBuilder_[Expression]) bool

Returns whether any Systems have been added yet.

ExportInput(self: pydrake.systems.framework.DiagramBuilder_[Expression], input: pydrake.systems.framework.InputPort_[Expression], name: Union[str, pydrake.systems.framework.UseDefaultName] = kUseDefaultName) pydrake.systems.framework.InputPortIndex

Declares that the given input port of a constituent system is connected to a new input to the entire Diagram. name is an optional name for the new input port; if it is unspecified, then a default name will be provided.

Precondition:

If supplied at all, name must not be empty.

Precondition:

A port indicated by the resolution of name must not exist.

Postcondition:

input is connected to the new exported input port.

Returns

The index of the exported input port of the entire diagram.

ExportOutput(self: pydrake.systems.framework.DiagramBuilder_[Expression], output: pydrake.systems.framework.OutputPort_[Expression], name: Union[str, pydrake.systems.framework.UseDefaultName] = kUseDefaultName) pydrake.systems.framework.OutputPortIndex

Declares that the given output port of a constituent system is an output of the entire diagram. name is an optional name for the output port; if it is unspecified, then a default name will be provided.

Precondition:

If supplied at all, name must not be empty.

Returns

The index of the exported output port of the entire diagram.

GetMutableSubsystemByName(self: pydrake.systems.framework.DiagramBuilder_[Expression], name: str) pydrake.systems.framework.System_[Expression]

Retrieves a mutable reference to the subsystem with name name returned by get_name().

Raises

RuntimeError if a unique match cannot be found.

See also

System<T>::get_name()

See also

GetSubsystemByName()

See also

GetMutableDowncastSubsystemByName()

GetMutableSystems(self: pydrake.systems.framework.DiagramBuilder_[Expression]) list[pydrake.systems.framework.System_[Expression]]

Returns the list of contained Systems.

See also

GetMutableSubsystemByName()

See also

GetSystems()

GetSubsystemByName(self: pydrake.systems.framework.DiagramBuilder_[Expression], name: str) pydrake.systems.framework.System_[Expression]

Retrieves a const reference to the subsystem with name name returned by get_name().

Raises

RuntimeError if a unique match cannot be found.

See also

System<T>::get_name()

See also

GetMutableSubsystemByName()

See also

GetDowncastSubsystemByName()

GetSystems(self: pydrake.systems.framework.DiagramBuilder_[Expression]) list[pydrake.systems.framework.System_[Expression]]

Returns the list of contained Systems.

See also

GetSubsystemByName()

See also

GetMutableSystems()

HasSubsystemNamed(self: pydrake.systems.framework.DiagramBuilder_[Expression], name: str) bool

Returns true iff this contains a subsystem with the given name.

See also

GetSubsystemByName()

IsConnectedOrExported(self: pydrake.systems.framework.DiagramBuilder_[Expression], port: pydrake.systems.framework.InputPort_[Expression]) bool

Returns true iff the given input port of a constituent system is either connected to another constituent system or exported as a diagram input.

num_input_ports(self: pydrake.systems.framework.DiagramBuilder_[Expression]) int

Returns the current number of diagram input ports. The count may change as more ports are exported.

num_output_ports(self: pydrake.systems.framework.DiagramBuilder_[Expression]) int

Returns the current number of diagram output outputs. The count may change as more ports are exported.

RemoveSystem(self: pydrake.systems.framework.DiagramBuilder_[Expression], system: pydrake.systems.framework.System_[Expression]) None

Removes the given system from this builder and disconnects any connections or exported ports associated with it.

Note that un-exporting this system’s ports might have a ripple effect on other exported port index assignments. The relative order will remain intact, but any “holes” created by this removal will be filled in by decrementing the indices of all higher-numbered ports that remain.

Warning

Because a DiagramBuilder owns the objects it contains, the system will be deleted.

class pydrake.systems.framework.DiscreteStateIndex
__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: pydrake.systems.framework.DiscreteStateIndex) -> None

Default constructor; the result is an invalid index. This only exists to serve applications which require a default constructor.

  1. __init__(self: pydrake.systems.framework.DiscreteStateIndex, arg0: int) -> None

Construction from a non-negative int value. The value must lie in the range of [0, 2³¹). Constructor only promises to test validity in Debug build.

is_valid(self: pydrake.systems.framework.DiscreteStateIndex) bool

Reports if the index is valid–the only operation on an invalid index that doesn’t throw an exception in Debug builds.

class pydrake.systems.framework.DiscreteUpdateEvent

Bases: pydrake.systems.framework.Event

This class represents a discrete update event. It has an optional callback function to do custom handling of this event, and that can write updates to a mutable, non-null DiscreteValues object.

See also

LeafSystem for more convenient interfaces to discrete update events via the Declare*DiscreteUpdateEvent() methods.

Note

This class is templated; see DiscreteUpdateEvent_ for the list of instantiations.

__init__(*args, **kwargs)
template pydrake.systems.framework.DiscreteUpdateEvent_

Instantiations: DiscreteUpdateEvent_[float], DiscreteUpdateEvent_[AutoDiffXd], DiscreteUpdateEvent_[Expression]

class pydrake.systems.framework.DiscreteUpdateEvent_[AutoDiffXd]

Bases: pydrake.systems.framework.Event_[AutoDiffXd]

This class represents a discrete update event. It has an optional callback function to do custom handling of this event, and that can write updates to a mutable, non-null DiscreteValues object.

See also

LeafSystem for more convenient interfaces to discrete update events via the Declare*DiscreteUpdateEvent() methods.

__init__(*args, **kwargs)
class pydrake.systems.framework.DiscreteUpdateEvent_[Expression]

Bases: pydrake.systems.framework.Event_[Expression]

This class represents a discrete update event. It has an optional callback function to do custom handling of this event, and that can write updates to a mutable, non-null DiscreteValues object.

See also

LeafSystem for more convenient interfaces to discrete update events via the Declare*DiscreteUpdateEvent() methods.

__init__(*args, **kwargs)
class pydrake.systems.framework.DiscreteValues

%DiscreteValues is a container for numerical but non-continuous state and parameters. It may own its underlying data, for use with leaf Systems, or not, for use with Diagrams.

DiscreteValues is an ordered collection xd of BasicVector “groups” so xd = [xd₀, xd₁…], where each group xdᵢ is a contiguous vector. Requesting a specific group index from this collection is the most granular way to retrieve discrete values from the Context, and thus is the unit of cache invalidation. System authors are encouraged to partition their DiscreteValues such that each cacheable computation within the System may depend on only the elements of DiscreteValues that it needs.

None of the contained vectors (groups) may be null, although any of them may be zero-length.

Note

This class is templated; see DiscreteValues_ for the list of instantiations.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: pydrake.systems.framework.DiscreteValues, datum: pydrake.systems.framework.BasicVector) -> None

Constructs a one-group DiscreteValues object that owns a single datum vector which may not be null.

  1. __init__(self: pydrake.systems.framework.DiscreteValues, data: list[pydrake.systems.framework.BasicVector]) -> None

Constructs a DiscreteValues that owns the underlying data. Every entry must be non-null.

  1. __init__(self: pydrake.systems.framework.DiscreteValues) -> None

Constructs an empty DiscreteValues object containing no groups.

Clone(self: pydrake.systems.framework.DiscreteValues) pydrake.systems.framework.DiscreteValues
get_data(self: pydrake.systems.framework.DiscreteValues) list[pydrake.systems.framework.BasicVector]
get_mutable_value(self: pydrake.systems.framework.DiscreteValues, index: int = 0) numpy.ndarray[numpy.float64[m, 1], flags.writeable]

Returns the entire vector for the indicated group as a mutable Eigen::VectorBlock, which allows mutation of the values, but does not allow resize() to be called on the vector.

get_mutable_vector(self: pydrake.systems.framework.DiscreteValues, index: int = 0) pydrake.systems.framework.BasicVector

(Advanced) Returns a mutable reference to the BasicVector holding data for the indicated group. Prefer get_mutable_value() to get the underlying Eigen object unless you really need the BasicVector wrapping it.

get_value(self: pydrake.systems.framework.DiscreteValues, index: int = 0) numpy.ndarray[numpy.float64[m, 1]]

(Don’t use this in new code) Returns the entire vector as a const Eigen::VectorBlock for the indicated group. Prefer value() which returns direct access to the underlying VectorX rather than wrapping it in a VectorBlock.

get_vector(self: pydrake.systems.framework.DiscreteValues, index: int = 0) pydrake.systems.framework.BasicVector

(Advanced) Returns a const reference to the BasicVector holding data for the indicated group. Prefer value(index) to get the underlying VectorX directly unless you really need the BasicVector wrapping it.

num_groups(self: pydrake.systems.framework.DiscreteValues) int
set_value(*args, **kwargs)

Overloaded function.

  1. set_value(self: pydrake.systems.framework.DiscreteValues, value: numpy.ndarray[numpy.float64[m, 1]]) -> None

Sets the vector to the given value for the only group.

  1. set_value(self: pydrake.systems.framework.DiscreteValues, index: int, value: numpy.ndarray[numpy.float64[m, 1]]) -> None

Sets the vector to the given value for the indicated group.

SetFrom(self: pydrake.systems.framework.DiscreteValues, arg0: pydrake.systems.framework.DiscreteValues) None

Resets the values in this DiscreteValues from the values in other, possibly writing through to unowned data. Throws if the dimensions don’t match.

size(self: pydrake.systems.framework.DiscreteValues) int

Returns the number of elements in the only DiscreteValues group.

value(self: pydrake.systems.framework.DiscreteValues, index: int = 0) numpy.ndarray[numpy.float64[m, 1]]

Returns a const reference to the underlying VectorX containing the values for the indicated group. This is the preferred method for examining the value of a group.

template pydrake.systems.framework.DiscreteValues_

Instantiations: DiscreteValues_[float], DiscreteValues_[AutoDiffXd], DiscreteValues_[Expression]

class pydrake.systems.framework.DiscreteValues_[AutoDiffXd]

%DiscreteValues is a container for numerical but non-continuous state and parameters. It may own its underlying data, for use with leaf Systems, or not, for use with Diagrams.

DiscreteValues is an ordered collection xd of BasicVector “groups” so xd = [xd₀, xd₁…], where each group xdᵢ is a contiguous vector. Requesting a specific group index from this collection is the most granular way to retrieve discrete values from the Context, and thus is the unit of cache invalidation. System authors are encouraged to partition their DiscreteValues such that each cacheable computation within the System may depend on only the elements of DiscreteValues that it needs.

None of the contained vectors (groups) may be null, although any of them may be zero-length.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: pydrake.systems.framework.DiscreteValues_[AutoDiffXd], datum: pydrake.systems.framework.BasicVector_[AutoDiffXd]) -> None

Constructs a one-group DiscreteValues object that owns a single datum vector which may not be null.

  1. __init__(self: pydrake.systems.framework.DiscreteValues_[AutoDiffXd], data: list[pydrake.systems.framework.BasicVector_[AutoDiffXd]]) -> None

Constructs a DiscreteValues that owns the underlying data. Every entry must be non-null.

  1. __init__(self: pydrake.systems.framework.DiscreteValues_[AutoDiffXd]) -> None

Constructs an empty DiscreteValues object containing no groups.

Clone(self: pydrake.systems.framework.DiscreteValues_[AutoDiffXd]) pydrake.systems.framework.DiscreteValues_[AutoDiffXd]
get_data(self: pydrake.systems.framework.DiscreteValues_[AutoDiffXd]) list[pydrake.systems.framework.BasicVector_[AutoDiffXd]]
get_mutable_value(self: pydrake.systems.framework.DiscreteValues_[AutoDiffXd], index: int = 0) numpy.ndarray[object[m, 1], flags.writeable]

Returns the entire vector for the indicated group as a mutable Eigen::VectorBlock, which allows mutation of the values, but does not allow resize() to be called on the vector.

get_mutable_vector(self: pydrake.systems.framework.DiscreteValues_[AutoDiffXd], index: int = 0) pydrake.systems.framework.BasicVector_[AutoDiffXd]

(Advanced) Returns a mutable reference to the BasicVector holding data for the indicated group. Prefer get_mutable_value() to get the underlying Eigen object unless you really need the BasicVector wrapping it.

get_value(self: pydrake.systems.framework.DiscreteValues_[AutoDiffXd], index: int = 0) numpy.ndarray[object[m, 1]]

(Don’t use this in new code) Returns the entire vector as a const Eigen::VectorBlock for the indicated group. Prefer value() which returns direct access to the underlying VectorX rather than wrapping it in a VectorBlock.

get_vector(self: pydrake.systems.framework.DiscreteValues_[AutoDiffXd], index: int = 0) pydrake.systems.framework.BasicVector_[AutoDiffXd]

(Advanced) Returns a const reference to the BasicVector holding data for the indicated group. Prefer value(index) to get the underlying VectorX directly unless you really need the BasicVector wrapping it.

num_groups(self: pydrake.systems.framework.DiscreteValues_[AutoDiffXd]) int
set_value(*args, **kwargs)

Overloaded function.

  1. set_value(self: pydrake.systems.framework.DiscreteValues_[AutoDiffXd], value: numpy.ndarray[object[m, 1]]) -> None

Sets the vector to the given value for the only group.

  1. set_value(self: pydrake.systems.framework.DiscreteValues_[AutoDiffXd], index: int, value: numpy.ndarray[object[m, 1]]) -> None

Sets the vector to the given value for the indicated group.

SetFrom(self: pydrake.systems.framework.DiscreteValues_[AutoDiffXd], arg0: pydrake.systems.framework.DiscreteValues) None

Resets the values in this DiscreteValues from the values in other, possibly writing through to unowned data. Throws if the dimensions don’t match.

size(self: pydrake.systems.framework.DiscreteValues_[AutoDiffXd]) int

Returns the number of elements in the only DiscreteValues group.

value(self: pydrake.systems.framework.DiscreteValues_[AutoDiffXd], index: int = 0) numpy.ndarray[object[m, 1]]

Returns a const reference to the underlying VectorX containing the values for the indicated group. This is the preferred method for examining the value of a group.

class pydrake.systems.framework.DiscreteValues_[Expression]

%DiscreteValues is a container for numerical but non-continuous state and parameters. It may own its underlying data, for use with leaf Systems, or not, for use with Diagrams.

DiscreteValues is an ordered collection xd of BasicVector “groups” so xd = [xd₀, xd₁…], where each group xdᵢ is a contiguous vector. Requesting a specific group index from this collection is the most granular way to retrieve discrete values from the Context, and thus is the unit of cache invalidation. System authors are encouraged to partition their DiscreteValues such that each cacheable computation within the System may depend on only the elements of DiscreteValues that it needs.

None of the contained vectors (groups) may be null, although any of them may be zero-length.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: pydrake.systems.framework.DiscreteValues_[Expression], datum: pydrake.systems.framework.BasicVector_[Expression]) -> None

Constructs a one-group DiscreteValues object that owns a single datum vector which may not be null.

  1. __init__(self: pydrake.systems.framework.DiscreteValues_[Expression], data: list[pydrake.systems.framework.BasicVector_[Expression]]) -> None

Constructs a DiscreteValues that owns the underlying data. Every entry must be non-null.

  1. __init__(self: pydrake.systems.framework.DiscreteValues_[Expression]) -> None

Constructs an empty DiscreteValues object containing no groups.

Clone(self: pydrake.systems.framework.DiscreteValues_[Expression]) pydrake.systems.framework.DiscreteValues_[Expression]
get_data(self: pydrake.systems.framework.DiscreteValues_[Expression]) list[pydrake.systems.framework.BasicVector_[Expression]]
get_mutable_value(self: pydrake.systems.framework.DiscreteValues_[Expression], index: int = 0) numpy.ndarray[object[m, 1], flags.writeable]

Returns the entire vector for the indicated group as a mutable Eigen::VectorBlock, which allows mutation of the values, but does not allow resize() to be called on the vector.

get_mutable_vector(self: pydrake.systems.framework.DiscreteValues_[Expression], index: int = 0) pydrake.systems.framework.BasicVector_[Expression]

(Advanced) Returns a mutable reference to the BasicVector holding data for the indicated group. Prefer get_mutable_value() to get the underlying Eigen object unless you really need the BasicVector wrapping it.

get_value(self: pydrake.systems.framework.DiscreteValues_[Expression], index: int = 0) numpy.ndarray[object[m, 1]]

(Don’t use this in new code) Returns the entire vector as a const Eigen::VectorBlock for the indicated group. Prefer value() which returns direct access to the underlying VectorX rather than wrapping it in a VectorBlock.

get_vector(self: pydrake.systems.framework.DiscreteValues_[Expression], index: int = 0) pydrake.systems.framework.BasicVector_[Expression]

(Advanced) Returns a const reference to the BasicVector holding data for the indicated group. Prefer value(index) to get the underlying VectorX directly unless you really need the BasicVector wrapping it.

num_groups(self: pydrake.systems.framework.DiscreteValues_[Expression]) int
set_value(*args, **kwargs)

Overloaded function.

  1. set_value(self: pydrake.systems.framework.DiscreteValues_[Expression], value: numpy.ndarray[object[m, 1]]) -> None

Sets the vector to the given value for the only group.

  1. set_value(self: pydrake.systems.framework.DiscreteValues_[Expression], index: int, value: numpy.ndarray[object[m, 1]]) -> None

Sets the vector to the given value for the indicated group.

SetFrom(self: pydrake.systems.framework.DiscreteValues_[Expression], arg0: pydrake.systems.framework.DiscreteValues) None

Resets the values in this DiscreteValues from the values in other, possibly writing through to unowned data. Throws if the dimensions don’t match.

size(self: pydrake.systems.framework.DiscreteValues_[Expression]) int

Returns the number of elements in the only DiscreteValues group.

value(self: pydrake.systems.framework.DiscreteValues_[Expression], index: int = 0) numpy.ndarray[object[m, 1]]

Returns a const reference to the underlying VectorX containing the values for the indicated group. This is the preferred method for examining the value of a group.

class pydrake.systems.framework.Event

Abstract base class that represents an event. The base event contains two main pieces of information: an enum trigger type and an optional attribute that can be used to explain why the event is triggered.

Concrete derived classes contain a function pointer to an optional callback that handles the event. No-op is the default handling behavior. The System framework supports three concrete event types: PublishEvent, DiscreteUpdateEvent, and UnrestrictedUpdateEvent distinguished by their callback functions’ write access level to the State.

The most common and convenient use of events and callbacks will happen via the LeafSystem Declare*Event() methods. To that end, the callback signature always passes the const System<T>& as the first argument, so that LeafSystem does not need to capture this into the lambda; typically only a pointer-to-member- function is captured. Capturing any more than that would defeat std::function’s small buffer optimization and cause heap allocations when scheduling events.

Event handling occurs during a simulation of a system. The logic that describes when particular event types are handled is described in the class documentation for Simulator.

Note

This class is templated; see Event_ for the list of instantiations.

__init__(*args, **kwargs)
get_trigger_type(self: pydrake.systems.framework.Event) pydrake.systems.framework.TriggerType

Returns the trigger type.

template pydrake.systems.framework.Event_

Instantiations: Event_[float], Event_[AutoDiffXd], Event_[Expression]

class pydrake.systems.framework.Event_[AutoDiffXd]

Abstract base class that represents an event. The base event contains two main pieces of information: an enum trigger type and an optional attribute that can be used to explain why the event is triggered.

Concrete derived classes contain a function pointer to an optional callback that handles the event. No-op is the default handling behavior. The System framework supports three concrete event types: PublishEvent, DiscreteUpdateEvent, and UnrestrictedUpdateEvent distinguished by their callback functions’ write access level to the State.

The most common and convenient use of events and callbacks will happen via the LeafSystem Declare*Event() methods. To that end, the callback signature always passes the const System<T>& as the first argument, so that LeafSystem does not need to capture this into the lambda; typically only a pointer-to-member- function is captured. Capturing any more than that would defeat std::function’s small buffer optimization and cause heap allocations when scheduling events.

Event handling occurs during a simulation of a system. The logic that describes when particular event types are handled is described in the class documentation for Simulator.

__init__(*args, **kwargs)
get_trigger_type(self: pydrake.systems.framework.Event_[AutoDiffXd]) pydrake.systems.framework.TriggerType

Returns the trigger type.

class pydrake.systems.framework.Event_[Expression]

Abstract base class that represents an event. The base event contains two main pieces of information: an enum trigger type and an optional attribute that can be used to explain why the event is triggered.

Concrete derived classes contain a function pointer to an optional callback that handles the event. No-op is the default handling behavior. The System framework supports three concrete event types: PublishEvent, DiscreteUpdateEvent, and UnrestrictedUpdateEvent distinguished by their callback functions’ write access level to the State.

The most common and convenient use of events and callbacks will happen via the LeafSystem Declare*Event() methods. To that end, the callback signature always passes the const System<T>& as the first argument, so that LeafSystem does not need to capture this into the lambda; typically only a pointer-to-member- function is captured. Capturing any more than that would defeat std::function’s small buffer optimization and cause heap allocations when scheduling events.

Event handling occurs during a simulation of a system. The logic that describes when particular event types are handled is described in the class documentation for Simulator.

__init__(*args, **kwargs)
get_trigger_type(self: pydrake.systems.framework.Event_[Expression]) pydrake.systems.framework.TriggerType

Returns the trigger type.

class pydrake.systems.framework.EventStatus

Holds the return status from execution of an event handler function, or the effective status after a series of handler executions due to dispatching of simultaneous events. Drake API users will typically use only the four factory methods below to return status, and optionally a human-readable message, from their event handlers.

__init__(*args, **kwargs)
static DidNothing() pydrake.systems.framework.EventStatus

Returns “did nothing” status, with no message.

static Failed(system: drake::systems::SystemBase, message: str) pydrake.systems.framework.EventStatus

Returns “failed” status, with a message explaining why.

KeepMoreSevere(self: pydrake.systems.framework.EventStatus, candidate: pydrake.systems.framework.EventStatus) pydrake.systems.framework.EventStatus

(Advanced) Replaces the contents of this with the more-severe status if candidate is a more severe status than this one. Does nothing if candidate severity is less than or equal to this severity. This method is for use in event dispatchers for accumulating status returns from a series of event handlers for a set of simultaneous events.

message(self: pydrake.systems.framework.EventStatus) str

Returns the optionally-provided human-readable message supplied by the event handler that produced the current status. Returns an empty string if no message was provided.

static ReachedTermination(system: drake::systems::SystemBase, message: str) pydrake.systems.framework.EventStatus

Returns “reached termination” status, with a message explaining why.

class Severity

The numerical values are ordered, with did_nothing < success < terminate < fatal.

Members:

kDidNothing : Successful, but nothing happened; no state update needed.

kSucceeded : Handler executed successfully; state may have been updated.

kReachedTermination : Handler succeeded but detected a normal termination condition (has

message). Intended primarily for internal use by the Simulator.

kFailed : Handler was unable to perform its job (has message).

__init__(self: pydrake.systems.framework.EventStatus.Severity, value: int) None
kDidNothing = <Severity.kDidNothing: 0>
kFailed = <Severity.kFailed: 3>
kReachedTermination = <Severity.kReachedTermination: 2>
kSucceeded = <Severity.kSucceeded: 1>
property name
property value
severity(self: pydrake.systems.framework.EventStatus) pydrake.systems.framework.EventStatus.Severity

Returns the severity of the current status.

static Succeeded() pydrake.systems.framework.EventStatus

Returns “succeeded” status, with no message.

system(self: pydrake.systems.framework.EventStatus) drake::systems::SystemBase

Returns the optionally-provided subsystem that generated a status return that can include a message (reached termination or failed). Returns nullptr if no subsystem was provided.

class pydrake.systems.framework.FixedInputPortValue

A FixedInputPortValue encapsulates a vector or abstract value for use as an internal value source for one of a System’s input ports. The semantics are identical to a Parameter. We assign a DependencyTracker to this object and subscribe the InputPort to it when that port is fixed. Any modification to the value here issues a notification to its dependent, and increments a serial number kept here.

__init__(*args, **kwargs)
GetMutableData(self: pydrake.systems.framework.FixedInputPortValue) pydrake.common.value.AbstractValue

Returns a pointer to the data inside this FixedInputPortValue, and notifies the dependent input port that the value has changed.

To ensure invalidation notifications are delivered, callers should call this method every time they wish to update the stored value. In particular, callers MUST NOT write through the returned pointer if there is any possibility this FixedInputPortValue has been accessed since the last time this method was called.

class pydrake.systems.framework.InputPort

An InputPort is a System resource that describes the kind of input a System accepts, on a given port. It does not directly contain any runtime input port data; that is always contained in a Context. The actual value will be either the value of an OutputPort to which this is connected, or a fixed value set in a Context.

Note

This class is templated; see InputPort_ for the list of instantiations.

__init__(*args, **kwargs)
Allocate(self: pydrake.systems.framework.InputPort) pydrake.common.value.AbstractValue

Allocates a concrete object suitable for holding the value to be provided by this input port, and returns that as an AbstractValue. The returned object will never be null.

Eval(self: pydrake.systems.framework.InputPort, arg0: pydrake.systems.framework.Context) object
EvalAbstract(self: pydrake.systems.framework.InputPort, context: pydrake.systems.framework.Context) pydrake.common.value.AbstractValue

(Advanced.) Returns the value of this input port, typed as an AbstractValue. Most users should call Eval() instead. This method is only needed when the result will be passed into some other API that only accepts an AbstractValue.

EvalBasicVector(self: pydrake.systems.framework.InputPort, context: pydrake.systems.framework.Context) object

(Advanced.) Returns the value of this input port, typed as a BasicVector. Most users should call Eval() instead. This method is only needed when the result will be passed into some other API that only accepts a BasicVector.

FixValue(*args, **kwargs)

Overloaded function.

  1. FixValue(self: pydrake.systems.framework.InputPort, context: pydrake.systems.framework.Context, value: pydrake.common.value.AbstractValue) -> pydrake.systems.framework.FixedInputPortValue

Provides a fixed value for this InputPort in the given Context. If the port is already connected, this value will override the connected source value. (By “connected” we mean that the port appeared in a DiagramBuilder::Connect() call.)

For vector-valued input ports, you can provide an Eigen vector expression, a BasicVector object, or a scalar (treated as a Vector1). In each of these cases the value is copied into a Value<BasicVector>. If the original value was a BasicVector-derived object, its concrete type is maintained although the stored type is still Value<BasicVector>. The supplied vector must have the right size for the vector port or an RuntimeError is thrown.

For abstract-valued input ports, you can provide any ValueType that is compatible with the model type provided when the port was declared. If the type has a copy constructor it will be copied into a Value<ValueType> object for storage. Otherwise it must have an accessible Clone() method and it is stored using the type returned by that method, which must be ValueType or a base class of ValueType. Eigen objects and expressions are not accepted directly, but you can store then in abstract ports by providing an already-abstract object like Value<MatrixXd>(your_matrix).

The returned FixedInputPortValue reference may be used to modify the input port’s value subsequently using the appropriate FixedInputPortValue method, which will ensure that cache invalidation notifications are delivered.

Template parameter ValueType:

The type of the supplied value object. This will be inferred so no template argument need be specified. The type must be copy constructible or have an accessible Clone() method.

Parameter context:

A Context that is compatible with the System that owns this port.

Parameter value:

The fixed value for this port. Must be convertible to the input port’s data type.

Returns

a reference to the FixedInputPortValue object in the Context that contains this port’s value.

Precondition:

context is compatible with the System that owns this InputPort.

Precondition:

value is compatible with this InputPort’s data type.

  1. FixValue(self: pydrake.systems.framework.InputPort, context: pydrake.systems.framework.Context, value: object) -> pydrake.systems.framework.FixedInputPortValue

Provides a fixed value for this InputPort in the given Context. If the port is already connected, this value will override the connected source value. (By “connected” we mean that the port appeared in a DiagramBuilder::Connect() call.)

For vector-valued input ports, you can provide an Eigen vector expression, a BasicVector object, or a scalar (treated as a Vector1). In each of these cases the value is copied into a Value<BasicVector>. If the original value was a BasicVector-derived object, its concrete type is maintained although the stored type is still Value<BasicVector>. The supplied vector must have the right size for the vector port or an RuntimeError is thrown.

For abstract-valued input ports, you can provide any ValueType that is compatible with the model type provided when the port was declared. If the type has a copy constructor it will be copied into a Value<ValueType> object for storage. Otherwise it must have an accessible Clone() method and it is stored using the type returned by that method, which must be ValueType or a base class of ValueType. Eigen objects and expressions are not accepted directly, but you can store then in abstract ports by providing an already-abstract object like Value<MatrixXd>(your_matrix).

The returned FixedInputPortValue reference may be used to modify the input port’s value subsequently using the appropriate FixedInputPortValue method, which will ensure that cache invalidation notifications are delivered.

Template parameter ValueType:

The type of the supplied value object. This will be inferred so no template argument need be specified. The type must be copy constructible or have an accessible Clone() method.

Parameter context:

A Context that is compatible with the System that owns this port.

Parameter value:

The fixed value for this port. Must be convertible to the input port’s data type.

Returns

a reference to the FixedInputPortValue object in the Context that contains this port’s value.

Precondition:

context is compatible with the System that owns this InputPort.

Precondition:

value is compatible with this InputPort’s data type.

get_data_type(self: pydrake.systems.framework.InputPort) pydrake.systems.framework.PortDataType

Returns the port data type.

get_index(self: pydrake.systems.framework.InputPort) pydrake.systems.framework.InputPortIndex

Returns the index of this input port within the owning System. For a Diagram, this will be the index within the Diagram, not the index within a LeafSystem whose input port was exported.

get_name(self: pydrake.systems.framework.InputPort) str

Get port name.

get_system(self: pydrake.systems.framework.InputPort) drake::systems::System<double>

Returns a reference to the System that owns this input port. Note that for a Diagram input port this will be the Diagram, not the LeafSystem whose input port was exported.

GetFullDescription(self: pydrake.systems.framework.InputPort) str

Returns a verbose human-readable description of port. This is useful for error messages or debugging.

HasValue(self: pydrake.systems.framework.InputPort, context: pydrake.systems.framework.Context) bool

Returns true iff this port is connected or has had a fixed value provided in the given Context. Beware that at the moment, this could be an expensive operation, because the value is brought up-to-date as part of this operation.

size(self: pydrake.systems.framework.InputPort) int

Returns the fixed size expected for a vector-valued port. Not meaningful for abstract-valued ports.

ticket(self: pydrake.systems.framework.InputPort) pydrake.systems.framework.DependencyTicket

(Advanced.) Returns the DependencyTicket for this port within the owning System.

template pydrake.systems.framework.InputPort_

Instantiations: InputPort_[float], InputPort_[AutoDiffXd], InputPort_[Expression]

class pydrake.systems.framework.InputPort_[AutoDiffXd]

An InputPort is a System resource that describes the kind of input a System accepts, on a given port. It does not directly contain any runtime input port data; that is always contained in a Context. The actual value will be either the value of an OutputPort to which this is connected, or a fixed value set in a Context.

__init__(*args, **kwargs)
Allocate(self: pydrake.systems.framework.InputPort_[AutoDiffXd]) pydrake.common.value.AbstractValue

Allocates a concrete object suitable for holding the value to be provided by this input port, and returns that as an AbstractValue. The returned object will never be null.

Eval(self: pydrake.systems.framework.InputPort_[AutoDiffXd], arg0: pydrake.systems.framework.Context_[AutoDiffXd]) object
EvalAbstract(self: pydrake.systems.framework.InputPort_[AutoDiffXd], context: pydrake.systems.framework.Context_[AutoDiffXd]) pydrake.common.value.AbstractValue

(Advanced.) Returns the value of this input port, typed as an AbstractValue. Most users should call Eval() instead. This method is only needed when the result will be passed into some other API that only accepts an AbstractValue.

EvalBasicVector(self: pydrake.systems.framework.InputPort_[AutoDiffXd], context: pydrake.systems.framework.Context_[AutoDiffXd]) object

(Advanced.) Returns the value of this input port, typed as a BasicVector. Most users should call Eval() instead. This method is only needed when the result will be passed into some other API that only accepts a BasicVector.

FixValue(*args, **kwargs)

Overloaded function.

  1. FixValue(self: pydrake.systems.framework.InputPort_[AutoDiffXd], context: pydrake.systems.framework.Context_[AutoDiffXd], value: pydrake.common.value.AbstractValue) -> pydrake.systems.framework.FixedInputPortValue

Provides a fixed value for this InputPort in the given Context. If the port is already connected, this value will override the connected source value. (By “connected” we mean that the port appeared in a DiagramBuilder::Connect() call.)

For vector-valued input ports, you can provide an Eigen vector expression, a BasicVector object, or a scalar (treated as a Vector1). In each of these cases the value is copied into a Value<BasicVector>. If the original value was a BasicVector-derived object, its concrete type is maintained although the stored type is still Value<BasicVector>. The supplied vector must have the right size for the vector port or an RuntimeError is thrown.

For abstract-valued input ports, you can provide any ValueType that is compatible with the model type provided when the port was declared. If the type has a copy constructor it will be copied into a Value<ValueType> object for storage. Otherwise it must have an accessible Clone() method and it is stored using the type returned by that method, which must be ValueType or a base class of ValueType. Eigen objects and expressions are not accepted directly, but you can store then in abstract ports by providing an already-abstract object like Value<MatrixXd>(your_matrix).

The returned FixedInputPortValue reference may be used to modify the input port’s value subsequently using the appropriate FixedInputPortValue method, which will ensure that cache invalidation notifications are delivered.

Template parameter ValueType:

The type of the supplied value object. This will be inferred so no template argument need be specified. The type must be copy constructible or have an accessible Clone() method.

Parameter context:

A Context that is compatible with the System that owns this port.

Parameter value:

The fixed value for this port. Must be convertible to the input port’s data type.

Returns

a reference to the FixedInputPortValue object in the Context that contains this port’s value.

Precondition:

context is compatible with the System that owns this InputPort.

Precondition:

value is compatible with this InputPort’s data type.

  1. FixValue(self: pydrake.systems.framework.InputPort_[AutoDiffXd], context: pydrake.systems.framework.Context_[AutoDiffXd], value: object) -> pydrake.systems.framework.FixedInputPortValue

Provides a fixed value for this InputPort in the given Context. If the port is already connected, this value will override the connected source value. (By “connected” we mean that the port appeared in a DiagramBuilder::Connect() call.)

For vector-valued input ports, you can provide an Eigen vector expression, a BasicVector object, or a scalar (treated as a Vector1). In each of these cases the value is copied into a Value<BasicVector>. If the original value was a BasicVector-derived object, its concrete type is maintained although the stored type is still Value<BasicVector>. The supplied vector must have the right size for the vector port or an RuntimeError is thrown.

For abstract-valued input ports, you can provide any ValueType that is compatible with the model type provided when the port was declared. If the type has a copy constructor it will be copied into a Value<ValueType> object for storage. Otherwise it must have an accessible Clone() method and it is stored using the type returned by that method, which must be ValueType or a base class of ValueType. Eigen objects and expressions are not accepted directly, but you can store then in abstract ports by providing an already-abstract object like Value<MatrixXd>(your_matrix).

The returned FixedInputPortValue reference may be used to modify the input port’s value subsequently using the appropriate FixedInputPortValue method, which will ensure that cache invalidation notifications are delivered.

Template parameter ValueType:

The type of the supplied value object. This will be inferred so no template argument need be specified. The type must be copy constructible or have an accessible Clone() method.

Parameter context:

A Context that is compatible with the System that owns this port.

Parameter value:

The fixed value for this port. Must be convertible to the input port’s data type.

Returns

a reference to the FixedInputPortValue object in the Context that contains this port’s value.

Precondition:

context is compatible with the System that owns this InputPort.

Precondition:

value is compatible with this InputPort’s data type.

get_data_type(self: pydrake.systems.framework.InputPort_[AutoDiffXd]) pydrake.systems.framework.PortDataType

Returns the port data type.

get_index(self: pydrake.systems.framework.InputPort_[AutoDiffXd]) pydrake.systems.framework.InputPortIndex

Returns the index of this input port within the owning System. For a Diagram, this will be the index within the Diagram, not the index within a LeafSystem whose input port was exported.

get_name(self: pydrake.systems.framework.InputPort_[AutoDiffXd]) str

Get port name.

get_system(self: pydrake.systems.framework.InputPort_[AutoDiffXd]) drake::systems::System<Eigen::AutoDiffScalar<Eigen::Matrix<double, -1, 1, 0, -1, 1> > >

Returns a reference to the System that owns this input port. Note that for a Diagram input port this will be the Diagram, not the LeafSystem whose input port was exported.

GetFullDescription(self: pydrake.systems.framework.InputPort_[AutoDiffXd]) str

Returns a verbose human-readable description of port. This is useful for error messages or debugging.

HasValue(self: pydrake.systems.framework.InputPort_[AutoDiffXd], context: pydrake.systems.framework.Context_[AutoDiffXd]) bool

Returns true iff this port is connected or has had a fixed value provided in the given Context. Beware that at the moment, this could be an expensive operation, because the value is brought up-to-date as part of this operation.

size(self: pydrake.systems.framework.InputPort_[AutoDiffXd]) int

Returns the fixed size expected for a vector-valued port. Not meaningful for abstract-valued ports.

ticket(self: pydrake.systems.framework.InputPort_[AutoDiffXd]) pydrake.systems.framework.DependencyTicket

(Advanced.) Returns the DependencyTicket for this port within the owning System.

class pydrake.systems.framework.InputPort_[Expression]

An InputPort is a System resource that describes the kind of input a System accepts, on a given port. It does not directly contain any runtime input port data; that is always contained in a Context. The actual value will be either the value of an OutputPort to which this is connected, or a fixed value set in a Context.

__init__(*args, **kwargs)
Allocate(self: pydrake.systems.framework.InputPort_[Expression]) pydrake.common.value.AbstractValue

Allocates a concrete object suitable for holding the value to be provided by this input port, and returns that as an AbstractValue. The returned object will never be null.

Eval(self: pydrake.systems.framework.InputPort_[Expression], arg0: pydrake.systems.framework.Context_[Expression]) object
EvalAbstract(self: pydrake.systems.framework.InputPort_[Expression], context: pydrake.systems.framework.Context_[Expression]) pydrake.common.value.AbstractValue

(Advanced.) Returns the value of this input port, typed as an AbstractValue. Most users should call Eval() instead. This method is only needed when the result will be passed into some other API that only accepts an AbstractValue.

EvalBasicVector(self: pydrake.systems.framework.InputPort_[Expression], context: pydrake.systems.framework.Context_[Expression]) object

(Advanced.) Returns the value of this input port, typed as a BasicVector. Most users should call Eval() instead. This method is only needed when the result will be passed into some other API that only accepts a BasicVector.

FixValue(*args, **kwargs)

Overloaded function.

  1. FixValue(self: pydrake.systems.framework.InputPort_[Expression], context: pydrake.systems.framework.Context_[Expression], value: pydrake.common.value.AbstractValue) -> pydrake.systems.framework.FixedInputPortValue

Provides a fixed value for this InputPort in the given Context. If the port is already connected, this value will override the connected source value. (By “connected” we mean that the port appeared in a DiagramBuilder::Connect() call.)

For vector-valued input ports, you can provide an Eigen vector expression, a BasicVector object, or a scalar (treated as a Vector1). In each of these cases the value is copied into a Value<BasicVector>. If the original value was a BasicVector-derived object, its concrete type is maintained although the stored type is still Value<BasicVector>. The supplied vector must have the right size for the vector port or an RuntimeError is thrown.

For abstract-valued input ports, you can provide any ValueType that is compatible with the model type provided when the port was declared. If the type has a copy constructor it will be copied into a Value<ValueType> object for storage. Otherwise it must have an accessible Clone() method and it is stored using the type returned by that method, which must be ValueType or a base class of ValueType. Eigen objects and expressions are not accepted directly, but you can store then in abstract ports by providing an already-abstract object like Value<MatrixXd>(your_matrix).

The returned FixedInputPortValue reference may be used to modify the input port’s value subsequently using the appropriate FixedInputPortValue method, which will ensure that cache invalidation notifications are delivered.

Template parameter ValueType:

The type of the supplied value object. This will be inferred so no template argument need be specified. The type must be copy constructible or have an accessible Clone() method.

Parameter context:

A Context that is compatible with the System that owns this port.

Parameter value:

The fixed value for this port. Must be convertible to the input port’s data type.

Returns

a reference to the FixedInputPortValue object in the Context that contains this port’s value.

Precondition:

context is compatible with the System that owns this InputPort.

Precondition:

value is compatible with this InputPort’s data type.

  1. FixValue(self: pydrake.systems.framework.InputPort_[Expression], context: pydrake.systems.framework.Context_[Expression], value: object) -> pydrake.systems.framework.FixedInputPortValue

Provides a fixed value for this InputPort in the given Context. If the port is already connected, this value will override the connected source value. (By “connected” we mean that the port appeared in a DiagramBuilder::Connect() call.)

For vector-valued input ports, you can provide an Eigen vector expression, a BasicVector object, or a scalar (treated as a Vector1). In each of these cases the value is copied into a Value<BasicVector>. If the original value was a BasicVector-derived object, its concrete type is maintained although the stored type is still Value<BasicVector>. The supplied vector must have the right size for the vector port or an RuntimeError is thrown.

For abstract-valued input ports, you can provide any ValueType that is compatible with the model type provided when the port was declared. If the type has a copy constructor it will be copied into a Value<ValueType> object for storage. Otherwise it must have an accessible Clone() method and it is stored using the type returned by that method, which must be ValueType or a base class of ValueType. Eigen objects and expressions are not accepted directly, but you can store then in abstract ports by providing an already-abstract object like Value<MatrixXd>(your_matrix).

The returned FixedInputPortValue reference may be used to modify the input port’s value subsequently using the appropriate FixedInputPortValue method, which will ensure that cache invalidation notifications are delivered.

Template parameter ValueType:

The type of the supplied value object. This will be inferred so no template argument need be specified. The type must be copy constructible or have an accessible Clone() method.

Parameter context:

A Context that is compatible with the System that owns this port.

Parameter value:

The fixed value for this port. Must be convertible to the input port’s data type.

Returns

a reference to the FixedInputPortValue object in the Context that contains this port’s value.

Precondition:

context is compatible with the System that owns this InputPort.

Precondition:

value is compatible with this InputPort’s data type.

get_data_type(self: pydrake.systems.framework.InputPort_[Expression]) pydrake.systems.framework.PortDataType

Returns the port data type.

get_index(self: pydrake.systems.framework.InputPort_[Expression]) pydrake.systems.framework.InputPortIndex

Returns the index of this input port within the owning System. For a Diagram, this will be the index within the Diagram, not the index within a LeafSystem whose input port was exported.

get_name(self: pydrake.systems.framework.InputPort_[Expression]) str

Get port name.

get_system(self: pydrake.systems.framework.InputPort_[Expression]) drake::systems::System<drake::symbolic::Expression>

Returns a reference to the System that owns this input port. Note that for a Diagram input port this will be the Diagram, not the LeafSystem whose input port was exported.

GetFullDescription(self: pydrake.systems.framework.InputPort_[Expression]) str

Returns a verbose human-readable description of port. This is useful for error messages or debugging.

HasValue(self: pydrake.systems.framework.InputPort_[Expression], context: pydrake.systems.framework.Context_[Expression]) bool

Returns true iff this port is connected or has had a fixed value provided in the given Context. Beware that at the moment, this could be an expensive operation, because the value is brought up-to-date as part of this operation.

size(self: pydrake.systems.framework.InputPort_[Expression]) int

Returns the fixed size expected for a vector-valued port. Not meaningful for abstract-valued ports.

ticket(self: pydrake.systems.framework.InputPort_[Expression]) pydrake.systems.framework.DependencyTicket

(Advanced.) Returns the DependencyTicket for this port within the owning System.

class pydrake.systems.framework.InputPortIndex
__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: pydrake.systems.framework.InputPortIndex) -> None

Default constructor; the result is an invalid index. This only exists to serve applications which require a default constructor.

  1. __init__(self: pydrake.systems.framework.InputPortIndex, arg0: int) -> None

Construction from a non-negative int value. The value must lie in the range of [0, 2³¹). Constructor only promises to test validity in Debug build.

is_valid(self: pydrake.systems.framework.InputPortIndex) bool

Reports if the index is valid–the only operation on an invalid index that doesn’t throw an exception in Debug builds.

class pydrake.systems.framework.InputPortSelection

Members:

kNoInput

kUseFirstInputIfItExists

__init__(self: pydrake.systems.framework.InputPortSelection, value: int) None
kNoInput = <InputPortSelection.kNoInput: -1>
kUseFirstInputIfItExists = <InputPortSelection.kUseFirstInputIfItExists: -2>
property name
property value
class pydrake.systems.framework.LeafContext

Bases: pydrake.systems.framework.Context

LeafContext contains all prerequisite data necessary to uniquely determine the results of computations performed by the associated LeafSystem.

See also

Context for more information.

Note

This class is templated; see LeafContext_ for the list of instantiations.

__init__(*args, **kwargs)
template pydrake.systems.framework.LeafContext_

Instantiations: LeafContext_[float], LeafContext_[AutoDiffXd], LeafContext_[Expression]

class pydrake.systems.framework.LeafContext_[AutoDiffXd]

Bases: pydrake.systems.framework.Context_[AutoDiffXd]

LeafContext contains all prerequisite data necessary to uniquely determine the results of computations performed by the associated LeafSystem.

See also

Context for more information.

__init__(*args, **kwargs)
class pydrake.systems.framework.LeafContext_[Expression]

Bases: pydrake.systems.framework.Context_[Expression]

LeafContext contains all prerequisite data necessary to uniquely determine the results of computations performed by the associated LeafSystem.

See also

Context for more information.

__init__(*args, **kwargs)
class pydrake.systems.framework.LeafOutputPort

Bases: pydrake.systems.framework.OutputPort

(Advanced.) Implements an output port whose value is managed by a cache entry in the same LeafSystem as the port. This is intended for internal use in implementing the DeclareOutputPort() variants in LeafSystem.

Note

This class is templated; see LeafOutputPort_ for the list of instantiations.

__init__(*args, **kwargs)
cache_entry(self: pydrake.systems.framework.LeafOutputPort) pydrake.systems.framework.CacheEntry

Returns the cache entry associated with this output port.

disable_caching_by_default(self: pydrake.systems.framework.LeafOutputPort) None

(Debugging) Specifies that caching should be disabled for this output port when a Context is first allocated. This is useful if you have observed different behavior with caching on or off and would like to determine if the problem is caused by this port.

See also

CacheEntry::disable_caching_by_default()

template pydrake.systems.framework.LeafOutputPort_

Instantiations: LeafOutputPort_[float], LeafOutputPort_[AutoDiffXd], LeafOutputPort_[Expression]

class pydrake.systems.framework.LeafOutputPort_[AutoDiffXd]

Bases: pydrake.systems.framework.OutputPort_[AutoDiffXd]

(Advanced.) Implements an output port whose value is managed by a cache entry in the same LeafSystem as the port. This is intended for internal use in implementing the DeclareOutputPort() variants in LeafSystem.

__init__(*args, **kwargs)
cache_entry(self: pydrake.systems.framework.LeafOutputPort_[AutoDiffXd]) pydrake.systems.framework.CacheEntry

Returns the cache entry associated with this output port.

disable_caching_by_default(self: pydrake.systems.framework.LeafOutputPort_[AutoDiffXd]) None

(Debugging) Specifies that caching should be disabled for this output port when a Context is first allocated. This is useful if you have observed different behavior with caching on or off and would like to determine if the problem is caused by this port.

See also

CacheEntry::disable_caching_by_default()

class pydrake.systems.framework.LeafOutputPort_[Expression]

Bases: pydrake.systems.framework.OutputPort_[Expression]

(Advanced.) Implements an output port whose value is managed by a cache entry in the same LeafSystem as the port. This is intended for internal use in implementing the DeclareOutputPort() variants in LeafSystem.

__init__(*args, **kwargs)
cache_entry(self: pydrake.systems.framework.LeafOutputPort_[Expression]) pydrake.systems.framework.CacheEntry

Returns the cache entry associated with this output port.

disable_caching_by_default(self: pydrake.systems.framework.LeafOutputPort_[Expression]) None

(Debugging) Specifies that caching should be disabled for this output port when a Context is first allocated. This is useful if you have observed different behavior with caching on or off and would like to determine if the problem is caused by this port.

See also

CacheEntry::disable_caching_by_default()

class pydrake.systems.framework.LeafSystem

Bases: pydrake.systems.framework.System

A superclass template that extends System with some convenience utilities that are not applicable to Diagrams.

Note

This class is templated; see LeafSystem_ for the list of instantiations.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: pydrake.systems.framework.LeafSystem) -> None

Default constructor that declares no inputs, outputs, state, parameters, events, nor scalar-type conversion support (AutoDiff, etc.). To enable AutoDiff support, use the SystemScalarConverter-based constructor.

  1. __init__(self: pydrake.systems.framework.LeafSystem, converter: pydrake.systems.framework.SystemScalarConverter) -> None

Constructor that declares no inputs, outputs, state, parameters, or events, but allows subclasses to declare scalar-type conversion support (AutoDiff, etc.).

The scalar-type conversion support will use converter. To enable scalar-type conversion support, pass a SystemTypeTag<S>{} where S must be the exact class of this being constructed.

See system_scalar_conversion for detailed background and examples related to scalar-type conversion support.

DeclareAbstractInputPort(self: pydrake.systems.framework.LeafSystem, name: str, model_value: pydrake.common.value.AbstractValue) pydrake.systems.framework.InputPort

Declares an abstract-valued input port using the given model_value. This is the best way to declare LeafSystem abstract input ports.

Any port connected to this input, and any call to FixValue for this input, must provide for values whose type matches this model_value.

See also

System::DeclareInputPort() for more information.

DeclareAbstractOutputPort(self: pydrake.systems.framework.LeafSystem, name: str, alloc: Callable[[], pydrake.common.value.AbstractValue], calc: Callable[[pydrake.systems.framework.Context, pydrake.common.value.AbstractValue], None], prerequisites_of_calc: set[pydrake.systems.framework.DependencyTicket] = {DependencyTicket(15)}) pydrake.systems.framework.OutputPort

(Advanced) Declares an abstract-valued output port using the given allocator and calculator functions provided in their most generic forms. If you have a member function available use one of the other signatures.

See also

LeafOutputPort::AllocCallback, LeafOutputPort::CalcCallback

DeclareAbstractParameter(self: pydrake.systems.framework.LeafSystem, model_value: pydrake.common.value.AbstractValue) int

Declares an abstract parameter using the given model_value. LeafSystem’s default implementation of SetDefaultParameters() will reset parameters to their model values. Returns the index of the new parameter.

DeclareAbstractState(self: pydrake.systems.framework.LeafSystem, model_value: pydrake.common.value.AbstractValue) pydrake.systems.framework.AbstractStateIndex

Declares an abstract state variable and provides a model value for it. A Context obtained with CreateDefaultContext() will contain this abstract state variable initially set to a clone of the model_value given here. The actual concrete type is always preserved.

Parameter model_value:

The abstract state model value to be cloned as needed.

Returns

index of the declared abstract state variable.

DeclareContinuousState(*args, **kwargs)

Overloaded function.

  1. DeclareContinuousState(self: pydrake.systems.framework.LeafSystem, num_state_variables: int) -> pydrake.systems.framework.ContinuousStateIndex

Declares that this System should reserve continuous state with num_state_variables state variables, which have no second-order structure.

Returns

index of the declared state (currently always zero).

  1. DeclareContinuousState(self: pydrake.systems.framework.LeafSystem, num_q: int, num_v: int, num_z: int) -> pydrake.systems.framework.ContinuousStateIndex

Declares that this System should reserve continuous state with num_q generalized positions, num_v generalized velocities, and num_z miscellaneous state variables.

Returns

index of the declared state (currently always zero).

  1. DeclareContinuousState(self: pydrake.systems.framework.LeafSystem, model_vector: pydrake.systems.framework.BasicVector) -> pydrake.systems.framework.ContinuousStateIndex

Declares that this System should reserve continuous state with model_vector.size() miscellaneous state variables, stored in a vector cloned from model_vector.

Returns

index of the declared state (currently always zero).

  1. DeclareContinuousState(self: pydrake.systems.framework.LeafSystem, model_vector: pydrake.systems.framework.BasicVector, num_q: int, num_v: int, num_z: int) -> pydrake.systems.framework.ContinuousStateIndex

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. Aborts if model_vector has the wrong size. If the model_vector declares any VectorBase::GetElementBounds() constraints, they will be re-declared as inequality constraints on this system (see DeclareInequalityConstraint()).

Returns

index of the declared state (currently always zero).

DeclareDiscreteState(*args, **kwargs)

Overloaded function.

  1. DeclareDiscreteState(self: pydrake.systems.framework.LeafSystem, model_vector: pydrake.systems.framework.BasicVector) -> pydrake.systems.framework.DiscreteStateIndex

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

  1. DeclareDiscreteState(self: pydrake.systems.framework.LeafSystem, vector: numpy.ndarray[numpy.float64[m, 1]]) -> pydrake.systems.framework.DiscreteStateIndex

Declares a discrete state group with vector.size() state variables, stored in a BasicVector initialized with the contents of vector.

  1. DeclareDiscreteState(self: pydrake.systems.framework.LeafSystem, num_state_variables: int) -> pydrake.systems.framework.DiscreteStateIndex

Declares a discrete state group with num_state_variables state variables, stored in a BasicVector initialized to be all-zero. If you want non-zero initial values, use an alternate DeclareDiscreteState() signature that accepts a model_vector parameter.

Precondition:

num_state_variables must be non-negative.

DeclareForcedDiscreteUpdateEvent(self: pydrake.systems.framework.LeafSystem, update: Callable[[pydrake.systems.framework.Context, pydrake.systems.framework.DiscreteValues], Optional[pydrake.systems.framework.EventStatus]]) None

Declares a function that is called whenever a user directly calls CalcForcedDiscreteVariableUpdate(const Context&, DiscreteValues<T>*). Multiple calls to DeclareForcedDiscreteUpdateEvent() will cause multiple handlers to be called upon a call to CalcForcedDiscreteVariableUpdate(); these handlers will be called with the same const Context in arbitrary order. The handler should be a class member function (method) with this signature:

Click to expand C++ code...
EventStatus MySystem::MyDiscreteVariableUpdates(const Context<T>&,
DiscreteValues<T>*);

where MySystem is a class derived from LeafSystem<T> and the method name is arbitrary.

See declare_forced_events “Declare forced events” for more information.

Precondition:

this must be dynamic_cast-able to MySystem.

Precondition:

update must not be null.

DeclareForcedPublishEvent(self: pydrake.systems.framework.LeafSystem, publish: Callable[[pydrake.systems.framework.Context], Optional[pydrake.systems.framework.EventStatus]]) None

Declares a function that is called whenever a user directly calls ForcedPublish(const Context&). Multiple calls to DeclareForcedPublishEvent() will cause multiple handlers to be called upon a call to ForcedPublish(); these handlers which will be called with the same const Context in arbitrary order. The handler should be a class member function (method) with this signature:

Click to expand C++ code...
EventStatus MySystem::MyPublish(const Context<T>&) const;

where MySystem is a class derived from LeafSystem<T> and the method name is arbitrary.

See declare_forced_events “Declare forced events” for more information.

Precondition:

this must be dynamic_cast-able to MySystem.

Precondition:

publish must not be null.

DeclareForcedUnrestrictedUpdateEvent(self: pydrake.systems.framework.LeafSystem, update: Callable[[pydrake.systems.framework.Context, pydrake.systems.framework.State], Optional[pydrake.systems.framework.EventStatus]]) None

Declares a function that is called whenever a user directly calls CalcForcedUnrestrictedUpdate(const Context&, State<T>*). Multiple calls to DeclareForcedUnrestrictedUpdateEvent() will cause multiple handlers to be called upon a call to CalcForcedUnrestrictedUpdate(); these handlers which will be called with the same const Context in arbitrary order.The handler should be a class member function (method) with this signature:

Click to expand C++ code...
EventStatus MySystem::MyUnrestrictedUpdates(const Context<T>&,
State<T>*);

where MySystem is a class derived from LeafSystem<T> and the method name is arbitrary.

See declare_forced_events “Declare forced events” for more information.

Precondition:

this must be dynamic_cast-able to MySystem.

Precondition:

update must not be null.

DeclareInitializationDiscreteUpdateEvent(self: pydrake.systems.framework.LeafSystem, update: Callable[[pydrake.systems.framework.Context, pydrake.systems.framework.DiscreteValues], Optional[pydrake.systems.framework.EventStatus]]) None

Declares that a DiscreteUpdate event should occur at initialization and that it should invoke the given event handler method. The handler should be a class member function (method) with this signature:

Click to expand C++ code...
EventStatus MySystem::MyUpdate(const Context<T>&,
DiscreteValues<T>*) const;

where MySystem is a class derived from LeafSystem<T> and the method name is arbitrary.

See declare_initialization_events “Declare initialization events” for more information.

Precondition:

this must be dynamic_cast-able to MySystem.

Precondition:

update must not be null.

See also

DeclareInitializationPublishEvent()

See also

DeclareInitializationUnrestrictedUpdateEvent()

See also

DeclareInitializationEvent()

DeclareInitializationEvent(self: pydrake.systems.framework.LeafSystem, event: pydrake.systems.framework.Event) None

(Advanced) Declares that a particular Event object should be dispatched at initialization. This is the most general form for declaring initialization events and most users should use one of the other methods in this group instead.

See also

DeclareInitializationPublishEvent()

See also

DeclareInitializationDiscreteUpdateEvent()

See also

DeclareInitializationUnrestrictedUpdateEvent()

See declare_initialization_events “Declare initialization events” for more information.

Depending on the type of event, on initialization it will be passed to the Publish, DiscreteUpdate, or UnrestrictedUpdate event dispatcher. If the event object contains a handler function, Drake’s default dispatchers will invoke that handler. If not, then no further action is taken. Thus an event with no handler has no effect unless its dispatcher has been overridden. We strongly recommend that you do not override the dispatcher and instead do supply a handler.

The given event object is deep-copied (cloned), and the copy is stored internally so you do not need to keep the object around after this call.

Precondition:

event’s associated trigger type must be TriggerType::kUnknown or already set to TriggerType::kInitialization.

DeclareInitializationPublishEvent(self: pydrake.systems.framework.LeafSystem, publish: Callable[[pydrake.systems.framework.Context], Optional[pydrake.systems.framework.EventStatus]]) None

Declares that a Publish event should occur at initialization and that it should invoke the given event handler method. The handler should be a class member function (method) with this signature:

Click to expand C++ code...
EventStatus MySystem::MyPublish(const Context<T>&) const;

where MySystem is a class derived from LeafSystem<T> and the method name is arbitrary.

See declare_initialization_events “Declare initialization events” for more information.

Precondition:

this must be dynamic_cast-able to MySystem.

Precondition:

publish must not be null.

See also

DeclareInitializationDiscreteUpdateEvent()

See also

DeclareInitializationUnrestrictedUpdateEvent()

See also

DeclareInitializationEvent()

DeclareInitializationUnrestrictedUpdateEvent(self: pydrake.systems.framework.LeafSystem, update: Callable[[pydrake.systems.framework.Context, pydrake.systems.framework.State], Optional[pydrake.systems.framework.EventStatus]]) None

Declares that an UnrestrictedUpdate event should occur at initialization and that it should invoke the given event handler method. The handler should be a class member function (method) with this signature:

Click to expand C++ code...
EventStatus MySystem::MyUpdate(const Context<T>&,
State<T>*) const;

where MySystem is a class derived from LeafSystem<T> and the method name is arbitrary.

See declare_initialization_events “Declare initialization events” for more information.

Precondition:

this must be dynamic_cast-able to MySystem.

Precondition:

update must not be null.

See also

DeclareInitializationPublishEvent()

See also

DeclareInitializationDiscreteUpdateEvent()

See also

DeclareInitializationEvent()

DeclareNumericParameter(self: pydrake.systems.framework.LeafSystem, model_vector: pydrake.systems.framework.BasicVector) int

Declares a numeric parameter using the given model_vector. LeafSystem’s default implementation of SetDefaultParameters() will reset parameters to their model vectors. If the model_vector declares any VectorBase::GetElementBounds() constraints, they will be re-declared as inequality constraints on this system (see DeclareInequalityConstraint()). Returns the index of the new parameter.

DeclarePeriodicDiscreteUpdateEvent(self: pydrake.systems.framework.LeafSystem, period_sec: float, offset_sec: float, update: Callable[[pydrake.systems.framework.Context, pydrake.systems.framework.DiscreteValues], Optional[pydrake.systems.framework.EventStatus]]) None

Declares that a DiscreteUpdate event should occur periodically and that it should invoke the given event handler method. The handler should be a class member function (method) with this signature:

Click to expand C++ code...
EventStatus MySystem::MyUpdate(const Context<T>&,
DiscreteValues<T>*) const;

where MySystem is a class derived from LeafSystem<T> and the method name is arbitrary.

See declare_periodic_events “Declare periodic events” for more information.

Precondition:

this must be dynamic_cast-able to MySystem.

Precondition:

update must not be null.

See also

DeclarePeriodicPublishEvent()

See also

DeclarePeriodicUnrestrictedUpdateEvent()

See also

DeclarePeriodicEvent()

DeclarePeriodicEvent(self: pydrake.systems.framework.LeafSystem, period_sec: float, offset_sec: float, event: pydrake.systems.framework.Event) None

(Advanced) Declares that a particular Event object should be dispatched periodically. This is the most general form for declaring periodic events and most users should use one of the other methods in this group instead.

See also

DeclarePeriodicPublishEvent()

See also

DeclarePeriodicDiscreteUpdateEvent()

See also

DeclarePeriodicUnrestrictedUpdateEvent()

See declare_periodic_events “Declare periodic events” for more information.

Depending on the type of event, when triggered it will be passed to the Publish, DiscreteUpdate, or UnrestrictedUpdate event dispatcher. If the event object contains a handler function, Drake’s default dispatchers will invoke that handler. If not, then no further action is taken. Thus an event with no handler has no effect unless its dispatcher has been overridden. We strongly recommend that you do not override the dispatcher and instead do supply a handler.

The given event object is deep-copied (cloned), and the copy is stored internally so you do not need to keep the object around after this call.

Precondition:

event’s associated trigger type must be TriggerType::kUnknown or already set to TriggerType::kPeriodic.

DeclarePeriodicPublishEvent(self: pydrake.systems.framework.LeafSystem, period_sec: float, offset_sec: float, publish: Callable[[pydrake.systems.framework.Context], Optional[pydrake.systems.framework.EventStatus]]) None

Declares that a Publish event should occur periodically and that it should invoke the given event handler method. The handler should be a class member function (method) with this signature:

Click to expand C++ code...
EventStatus MySystem::MyPublish(const Context<T>&) const;

where MySystem is a class derived from LeafSystem<T> and the method name is arbitrary.

See declare_periodic_events “Declare periodic events” for more information.

Precondition:

this must be dynamic_cast-able to MySystem.

Precondition:

publish must not be null.

See also

DeclarePeriodicDiscreteUpdateEvent()

See also

DeclarePeriodicUnrestrictedUpdateEvent()

See also

DeclarePeriodicEvent()

DeclarePeriodicUnrestrictedUpdateEvent(self: pydrake.systems.framework.LeafSystem, period_sec: float, offset_sec: float, update: Callable[[pydrake.systems.framework.Context, pydrake.systems.framework.State], Optional[pydrake.systems.framework.EventStatus]]) None

Declares that an UnrestrictedUpdate event should occur periodically and that it should invoke the given event handler method. The handler should be a class member function (method) with this signature:

Click to expand C++ code...
EventStatus MySystem::MyUpdate(const Context<T>&, State<T>*) const;

where MySystem is a class derived from LeafSystem<T> and the method name is arbitrary.

See declare_periodic_events “Declare periodic events” for more information.

Precondition:

this must be dynamic_cast-able to MySystem.

Precondition:

update must not be null.

See also

DeclarePeriodicPublishEvent()

See also

DeclarePeriodicDiscreteUpdateEvent()

See also

DeclarePeriodicEvent()

DeclarePerStepDiscreteUpdateEvent(self: pydrake.systems.framework.LeafSystem, update: Callable[[pydrake.systems.framework.Context, pydrake.systems.framework.DiscreteValues], Optional[pydrake.systems.framework.EventStatus]]) None

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. The handler should be a class member function (method) with this signature:

Click to expand C++ code...
EventStatus MySystem::MyUpdate(const Context<T>&,
DiscreteValues<T>*) const;

where MySystem is a class derived from LeafSystem<T> and the method name is arbitrary.

See declare_per-step_events “Declare per-step events” for more information.

Precondition:

this must be dynamic_cast-able to MySystem.

Precondition:

update must not be null.

See also

DeclarePerStepPublishEvent()

See also

DeclarePerStepUnrestrictedUpdateEvent()

See also

DeclarePerStepEvent()

DeclarePerStepEvent(self: pydrake.systems.framework.LeafSystem, event: pydrake.systems.framework.Event) None

(Advanced) Declares that a particular Event object should be dispatched at every trajectory-advancing step. Publish events are dispatched at the end of initialization and at the end of each step. Discrete- and unrestricted update events are dispatched at the start of each step. This is the most general form for declaring per-step events and most users should use one of the other methods in this group instead.

See also

DeclarePerStepPublishEvent()

See also

DeclarePerStepDiscreteUpdateEvent()

See also

DeclarePerStepUnrestrictedUpdateEvent()

See declare_per-step_events “Declare per-step events” for more information.

Depending on the type of event, at each step it will be passed to the Publish, DiscreteUpdate, or UnrestrictedUpdate event dispatcher. If the event object contains a handler function, Drake’s default dispatchers will invoke that handler. If not, then no further action is taken. Thus an event with no handler has no effect unless its dispatcher has been overridden. We strongly recommend that you do not override the dispatcher and instead do supply a handler.

The given event object is deep-copied (cloned), and the copy is stored internally so you do not need to keep the object around after this call.

Precondition:

event’s associated trigger type must be TriggerType::kUnknown or already set to TriggerType::kPerStep.

DeclarePerStepPublishEvent(self: pydrake.systems.framework.LeafSystem, publish: Callable[[pydrake.systems.framework.Context], Optional[pydrake.systems.framework.EventStatus]]) None

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. The handler should be a class member function (method) with this signature:

Click to expand C++ code...
EventStatus MySystem::MyPublish(const Context<T>&) const;

where MySystem is a class derived from LeafSystem<T> and the method name is arbitrary.

Warning

These per-step publish events are independent of the Simulator’s optional “publish every time step” and “publish at initialization” features. Generally if you are declaring per-step publish events yourself you should turn off those Simulation options.

See declare_per-step_events “Declare per-step events” for more information.

Precondition:

this must be dynamic_cast-able to MySystem.

Precondition:

publish must not be null.

See also

DeclarePerStepDiscreteUpdateEvent()

See also

DeclarePerStepUnrestrictedUpdateEvent()

See also

DeclarePerStepEvent()

See also

Simulator::set_publish_at_initialization()

See also

Simulator::set_publish_every_time_step()

DeclarePerStepUnrestrictedUpdateEvent(self: pydrake.systems.framework.LeafSystem, update: Callable[[pydrake.systems.framework.Context, pydrake.systems.framework.State], Optional[pydrake.systems.framework.EventStatus]]) None

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. The handler should be a class member function (method) with this signature:

Click to expand C++ code...
EventStatus MySystem::MyUpdate(const Context<T>&,
State<T>*) const;

where MySystem is a class derived from LeafSystem<T> and the method name is arbitrary.

See declare_per-step_events “Declare per-step events” for more information.

Precondition:

this must be dynamic_cast-able to MySystem.

Precondition:

update must not be null.

See also

DeclarePerStepPublishEvent()

See also

DeclarePerStepDiscreteUpdateEvent()

See also

DeclarePerStepEvent()

DeclareStateOutputPort(*args, **kwargs)

Overloaded function.

  1. DeclareStateOutputPort(self: pydrake.systems.framework.LeafSystem, name: Union[str, pydrake.systems.framework.UseDefaultName], state_index: pydrake.systems.framework.ContinuousStateIndex) -> pydrake.systems.framework.LeafOutputPort

Declares a vector-valued output port whose value is the continuous state of this system.

Parameter state_index:

must be ContinuousStateIndex(0) for now, since LeafSystem only supports a single continuous state group at the moment.

  1. DeclareStateOutputPort(self: pydrake.systems.framework.LeafSystem, name: Union[str, pydrake.systems.framework.UseDefaultName], state_index: pydrake.systems.framework.DiscreteStateIndex) -> pydrake.systems.framework.LeafOutputPort

Declares a vector-valued output port whose value is the given discrete state group of this system.

  1. DeclareStateOutputPort(self: pydrake.systems.framework.LeafSystem, name: Union[str, pydrake.systems.framework.UseDefaultName], state_index: pydrake.systems.framework.AbstractStateIndex) -> pydrake.systems.framework.LeafOutputPort

Declares an abstract-valued output port whose value is the given abstract state of this system.

DeclareVectorInputPort(*args, **kwargs)

Overloaded function.

  1. DeclareVectorInputPort(self: pydrake.systems.framework.LeafSystem, name: str, model_vector: pydrake.systems.framework.BasicVector, random_type: Optional[pydrake.common.RandomDistribution] = None) -> pydrake.systems.framework.InputPort

Declares a vector-valued input port using the given model_vector. This is the best way to declare LeafSystem input ports that require subclasses of BasicVector. The port’s size and type will be the same as model_vector. If the port is intended to model a random noise or disturbance input, random_type can (optionally) be used to label it as such. If the model_vector declares any VectorBase::GetElementBounds() constraints, they will be re-declared as inequality constraints on this system (see DeclareInequalityConstraint()).

See also

System::DeclareInputPort() for more information.

  1. DeclareVectorInputPort(self: pydrake.systems.framework.LeafSystem, name: str, size: int, random_type: Optional[pydrake.common.RandomDistribution] = None) -> pydrake.systems.framework.InputPort

Declares a vector-valued input port with type BasicVector and size size. If the port is intended to model a random noise or disturbance input, random_type can (optionally) be used to label it as such.

See also

System::DeclareInputPort() for more information.

DeclareVectorOutputPort(*args, **kwargs)

Overloaded function.

  1. DeclareVectorOutputPort(self: pydrake.systems.framework.LeafSystem, name: str, model_value: pydrake.systems.framework.BasicVector, calc: Callable[[pydrake.systems.framework.Context, pydrake.systems.framework.BasicVector], None], prerequisites_of_calc: set[pydrake.systems.framework.DependencyTicket] = {DependencyTicket(15)}) -> pydrake.systems.framework.OutputPort

(Advanced) Declares a vector-valued output port using the given model_vector and a function for calculating the port’s value at runtime. The port’s size will be model_vector.size(), and the default allocator for the port will be model_vector.Clone(). Note that this takes the calculator function in its most generic form; if you have a member function available use one of the other signatures.

See also

LeafOutputPort::CalcVectorCallback

  1. DeclareVectorOutputPort(self: pydrake.systems.framework.LeafSystem, name: str, size: int, calc: Callable[[pydrake.systems.framework.Context, pydrake.systems.framework.BasicVector], None], prerequisites_of_calc: set[pydrake.systems.framework.DependencyTicket] = {DependencyTicket(15)}) -> pydrake.systems.framework.OutputPort

(Advanced) Declares a vector-valued output port with type BasicVector<T> and size size, using the drake::dummy_value<T>, which is NaN when T = double. vector_calc_function is a function for calculating the port’s value at runtime. Note that this takes the calculator function in its most generic form; if you have a member function available use one of the other signatures.

See also

LeafOutputPort::CalcVectorCallback

DoCalcTimeDerivatives(self: pydrake.systems.framework.LeafSystem, arg0: pydrake.systems.framework.Context, arg1: pydrake.systems.framework.ContinuousState) None
MakeWitnessFunction(*args, **kwargs)

Overloaded function.

  1. MakeWitnessFunction(self: pydrake.systems.framework.LeafSystem, description: str, direction_type: pydrake.systems.framework.WitnessFunctionDirection, calc: Callable[[pydrake.systems.framework.Context], Optional[float]]) -> pydrake.systems.framework.WitnessFunction

Constructs the witness function with the given description (used primarily for debugging and logging), direction type, and calculator function; and with no event object.

Note

In order for the witness function to be used, you MUST overload System::DoGetWitnessFunctions().

  1. MakeWitnessFunction(self: pydrake.systems.framework.LeafSystem, description: str, direction_type: pydrake.systems.framework.WitnessFunctionDirection, calc: Callable[[pydrake.systems.framework.Context], float], e: pydrake.systems.framework.Event) -> pydrake.systems.framework.WitnessFunction

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. Example types of event objects are publish, discrete variable update, unrestricted update events. A clone of the event will be owned by the newly constructed WitnessFunction.

Note

In order for the witness function to be used, you MUST overload System::DoGetWitnessFunctions().

template pydrake.systems.framework.LeafSystem_

Instantiations: LeafSystem_[float], LeafSystem_[AutoDiffXd], LeafSystem_[Expression]

class pydrake.systems.framework.LeafSystem_[AutoDiffXd]

Bases: pydrake.systems.framework.System_[AutoDiffXd]

A superclass template that extends System with some convenience utilities that are not applicable to Diagrams.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: pydrake.systems.framework.LeafSystem_[AutoDiffXd]) -> None

Default constructor that declares no inputs, outputs, state, parameters, events, nor scalar-type conversion support (AutoDiff, etc.). To enable AutoDiff support, use the SystemScalarConverter-based constructor.

  1. __init__(self: pydrake.systems.framework.LeafSystem_[AutoDiffXd], converter: pydrake.systems.framework.SystemScalarConverter) -> None

Constructor that declares no inputs, outputs, state, parameters, or events, but allows subclasses to declare scalar-type conversion support (AutoDiff, etc.).

The scalar-type conversion support will use converter. To enable scalar-type conversion support, pass a SystemTypeTag<S>{} where S must be the exact class of this being constructed.

See system_scalar_conversion for detailed background and examples related to scalar-type conversion support.

DeclareAbstractInputPort(self: pydrake.systems.framework.LeafSystem_[AutoDiffXd], name: str, model_value: pydrake.common.value.AbstractValue) pydrake.systems.framework.InputPort_[AutoDiffXd]

Declares an abstract-valued input port using the given model_value. This is the best way to declare LeafSystem abstract input ports.

Any port connected to this input, and any call to FixValue for this input, must provide for values whose type matches this model_value.

See also

System::DeclareInputPort() for more information.

DeclareAbstractOutputPort(self: pydrake.systems.framework.LeafSystem_[AutoDiffXd], name: str, alloc: Callable[[], pydrake.common.value.AbstractValue], calc: Callable[[pydrake.systems.framework.Context_[AutoDiffXd], pydrake.common.value.AbstractValue], None], prerequisites_of_calc: set[pydrake.systems.framework.DependencyTicket] = {DependencyTicket(15)}) pydrake.systems.framework.OutputPort_[AutoDiffXd]

(Advanced) Declares an abstract-valued output port using the given allocator and calculator functions provided in their most generic forms. If you have a member function available use one of the other signatures.

See also

LeafOutputPort::AllocCallback, LeafOutputPort::CalcCallback

DeclareAbstractParameter(self: pydrake.systems.framework.LeafSystem_[AutoDiffXd], model_value: pydrake.common.value.AbstractValue) int

Declares an abstract parameter using the given model_value. LeafSystem’s default implementation of SetDefaultParameters() will reset parameters to their model values. Returns the index of the new parameter.

DeclareAbstractState(self: pydrake.systems.framework.LeafSystem_[AutoDiffXd], model_value: pydrake.common.value.AbstractValue) pydrake.systems.framework.AbstractStateIndex

Declares an abstract state variable and provides a model value for it. A Context obtained with CreateDefaultContext() will contain this abstract state variable initially set to a clone of the model_value given here. The actual concrete type is always preserved.

Parameter model_value:

The abstract state model value to be cloned as needed.

Returns

index of the declared abstract state variable.

DeclareContinuousState(*args, **kwargs)

Overloaded function.

  1. DeclareContinuousState(self: pydrake.systems.framework.LeafSystem_[AutoDiffXd], num_state_variables: int) -> pydrake.systems.framework.ContinuousStateIndex

Declares that this System should reserve continuous state with num_state_variables state variables, which have no second-order structure.

Returns

index of the declared state (currently always zero).

  1. DeclareContinuousState(self: pydrake.systems.framework.LeafSystem_[AutoDiffXd], num_q: int, num_v: int, num_z: int) -> pydrake.systems.framework.ContinuousStateIndex

Declares that this System should reserve continuous state with num_q generalized positions, num_v generalized velocities, and num_z miscellaneous state variables.

Returns

index of the declared state (currently always zero).

  1. DeclareContinuousState(self: pydrake.systems.framework.LeafSystem_[AutoDiffXd], model_vector: pydrake.systems.framework.BasicVector_[AutoDiffXd]) -> pydrake.systems.framework.ContinuousStateIndex

Declares that this System should reserve continuous state with model_vector.size() miscellaneous state variables, stored in a vector cloned from model_vector.

Returns

index of the declared state (currently always zero).

  1. DeclareContinuousState(self: pydrake.systems.framework.LeafSystem_[AutoDiffXd], model_vector: pydrake.systems.framework.BasicVector_[AutoDiffXd], num_q: int, num_v: int, num_z: int) -> pydrake.systems.framework.ContinuousStateIndex

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. Aborts if model_vector has the wrong size. If the model_vector declares any VectorBase::GetElementBounds() constraints, they will be re-declared as inequality constraints on this system (see DeclareInequalityConstraint()).

Returns

index of the declared state (currently always zero).

DeclareDiscreteState(*args, **kwargs)

Overloaded function.

  1. DeclareDiscreteState(self: pydrake.systems.framework.LeafSystem_[AutoDiffXd], model_vector: pydrake.systems.framework.BasicVector_[AutoDiffXd]) -> pydrake.systems.framework.DiscreteStateIndex

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

  1. DeclareDiscreteState(self: pydrake.systems.framework.LeafSystem_[AutoDiffXd], vector: numpy.ndarray[object[m, 1]]) -> pydrake.systems.framework.DiscreteStateIndex

Declares a discrete state group with vector.size() state variables, stored in a BasicVector initialized with the contents of vector.

  1. DeclareDiscreteState(self: pydrake.systems.framework.LeafSystem_[AutoDiffXd], num_state_variables: int) -> pydrake.systems.framework.DiscreteStateIndex

Declares a discrete state group with num_state_variables state variables, stored in a BasicVector initialized to be all-zero. If you want non-zero initial values, use an alternate DeclareDiscreteState() signature that accepts a model_vector parameter.

Precondition:

num_state_variables must be non-negative.

DeclareForcedDiscreteUpdateEvent(self: pydrake.systems.framework.LeafSystem_[AutoDiffXd], update: Callable[[pydrake.systems.framework.Context_[AutoDiffXd], pydrake.systems.framework.DiscreteValues_[AutoDiffXd]], Optional[pydrake.systems.framework.EventStatus]]) None

Declares a function that is called whenever a user directly calls CalcForcedDiscreteVariableUpdate(const Context&, DiscreteValues<T>*). Multiple calls to DeclareForcedDiscreteUpdateEvent() will cause multiple handlers to be called upon a call to CalcForcedDiscreteVariableUpdate(); these handlers will be called with the same const Context in arbitrary order. The handler should be a class member function (method) with this signature:

Click to expand C++ code...
EventStatus MySystem::MyDiscreteVariableUpdates(const Context<T>&,
DiscreteValues<T>*);

where MySystem is a class derived from LeafSystem<T> and the method name is arbitrary.

See declare_forced_events “Declare forced events” for more information.

Precondition:

this must be dynamic_cast-able to MySystem.

Precondition:

update must not be null.

DeclareForcedPublishEvent(self: pydrake.systems.framework.LeafSystem_[AutoDiffXd], publish: Callable[[pydrake.systems.framework.Context_[AutoDiffXd]], Optional[pydrake.systems.framework.EventStatus]]) None

Declares a function that is called whenever a user directly calls ForcedPublish(const Context&). Multiple calls to DeclareForcedPublishEvent() will cause multiple handlers to be called upon a call to ForcedPublish(); these handlers which will be called with the same const Context in arbitrary order. The handler should be a class member function (method) with this signature:

Click to expand C++ code...
EventStatus MySystem::MyPublish(const Context<T>&) const;

where MySystem is a class derived from LeafSystem<T> and the method name is arbitrary.

See declare_forced_events “Declare forced events” for more information.

Precondition:

this must be dynamic_cast-able to MySystem.

Precondition:

publish must not be null.

DeclareForcedUnrestrictedUpdateEvent(self: pydrake.systems.framework.LeafSystem_[AutoDiffXd], update: Callable[[pydrake.systems.framework.Context_[AutoDiffXd], pydrake.systems.framework.State_[AutoDiffXd]], Optional[pydrake.systems.framework.EventStatus]]) None

Declares a function that is called whenever a user directly calls CalcForcedUnrestrictedUpdate(const Context&, State<T>*). Multiple calls to DeclareForcedUnrestrictedUpdateEvent() will cause multiple handlers to be called upon a call to CalcForcedUnrestrictedUpdate(); these handlers which will be called with the same const Context in arbitrary order.The handler should be a class member function (method) with this signature:

Click to expand C++ code...
EventStatus MySystem::MyUnrestrictedUpdates(const Context<T>&,
State<T>*);

where MySystem is a class derived from LeafSystem<T> and the method name is arbitrary.

See declare_forced_events “Declare forced events” for more information.

Precondition:

this must be dynamic_cast-able to MySystem.

Precondition:

update must not be null.

DeclareInitializationDiscreteUpdateEvent(self: pydrake.systems.framework.LeafSystem_[AutoDiffXd], update: Callable[[pydrake.systems.framework.Context_[AutoDiffXd], pydrake.systems.framework.DiscreteValues_[AutoDiffXd]], Optional[pydrake.systems.framework.EventStatus]]) None

Declares that a DiscreteUpdate event should occur at initialization and that it should invoke the given event handler method. The handler should be a class member function (method) with this signature:

Click to expand C++ code...
EventStatus MySystem::MyUpdate(const Context<T>&,
DiscreteValues<T>*) const;

where MySystem is a class derived from LeafSystem<T> and the method name is arbitrary.

See declare_initialization_events “Declare initialization events” for more information.

Precondition:

this must be dynamic_cast-able to MySystem.

Precondition:

update must not be null.

See also

DeclareInitializationPublishEvent()

See also

DeclareInitializationUnrestrictedUpdateEvent()

See also

DeclareInitializationEvent()

DeclareInitializationEvent(self: pydrake.systems.framework.LeafSystem_[AutoDiffXd], event: pydrake.systems.framework.Event_[AutoDiffXd]) None

(Advanced) Declares that a particular Event object should be dispatched at initialization. This is the most general form for declaring initialization events and most users should use one of the other methods in this group instead.

See also

DeclareInitializationPublishEvent()

See also

DeclareInitializationDiscreteUpdateEvent()

See also

DeclareInitializationUnrestrictedUpdateEvent()

See declare_initialization_events “Declare initialization events” for more information.

Depending on the type of event, on initialization it will be passed to the Publish, DiscreteUpdate, or UnrestrictedUpdate event dispatcher. If the event object contains a handler function, Drake’s default dispatchers will invoke that handler. If not, then no further action is taken. Thus an event with no handler has no effect unless its dispatcher has been overridden. We strongly recommend that you do not override the dispatcher and instead do supply a handler.

The given event object is deep-copied (cloned), and the copy is stored internally so you do not need to keep the object around after this call.

Precondition:

event’s associated trigger type must be TriggerType::kUnknown or already set to TriggerType::kInitialization.

DeclareInitializationPublishEvent(self: pydrake.systems.framework.LeafSystem_[AutoDiffXd], publish: Callable[[pydrake.systems.framework.Context_[AutoDiffXd]], Optional[pydrake.systems.framework.EventStatus]]) None

Declares that a Publish event should occur at initialization and that it should invoke the given event handler method. The handler should be a class member function (method) with this signature:

Click to expand C++ code...
EventStatus MySystem::MyPublish(const Context<T>&) const;

where MySystem is a class derived from LeafSystem<T> and the method name is arbitrary.

See declare_initialization_events “Declare initialization events” for more information.

Precondition:

this must be dynamic_cast-able to MySystem.

Precondition:

publish must not be null.

See also

DeclareInitializationDiscreteUpdateEvent()

See also

DeclareInitializationUnrestrictedUpdateEvent()

See also

DeclareInitializationEvent()

DeclareInitializationUnrestrictedUpdateEvent(self: pydrake.systems.framework.LeafSystem_[AutoDiffXd], update: Callable[[pydrake.systems.framework.Context_[AutoDiffXd], pydrake.systems.framework.State_[AutoDiffXd]], Optional[pydrake.systems.framework.EventStatus]]) None

Declares that an UnrestrictedUpdate event should occur at initialization and that it should invoke the given event handler method. The handler should be a class member function (method) with this signature:

Click to expand C++ code...
EventStatus MySystem::MyUpdate(const Context<T>&,
State<T>*) const;

where MySystem is a class derived from LeafSystem<T> and the method name is arbitrary.

See declare_initialization_events “Declare initialization events” for more information.

Precondition:

this must be dynamic_cast-able to MySystem.

Precondition:

update must not be null.

See also

DeclareInitializationPublishEvent()

See also

DeclareInitializationDiscreteUpdateEvent()

See also

DeclareInitializationEvent()

DeclareNumericParameter(self: pydrake.systems.framework.LeafSystem_[AutoDiffXd], model_vector: pydrake.systems.framework.BasicVector_[AutoDiffXd]) int

Declares a numeric parameter using the given model_vector. LeafSystem’s default implementation of SetDefaultParameters() will reset parameters to their model vectors. If the model_vector declares any VectorBase::GetElementBounds() constraints, they will be re-declared as inequality constraints on this system (see DeclareInequalityConstraint()). Returns the index of the new parameter.

DeclarePeriodicDiscreteUpdateEvent(self: pydrake.systems.framework.LeafSystem_[AutoDiffXd], period_sec: float, offset_sec: float, update: Callable[[pydrake.systems.framework.Context_[AutoDiffXd], pydrake.systems.framework.DiscreteValues_[AutoDiffXd]], Optional[pydrake.systems.framework.EventStatus]]) None

Declares that a DiscreteUpdate event should occur periodically and that it should invoke the given event handler method. The handler should be a class member function (method) with this signature:

Click to expand C++ code...
EventStatus MySystem::MyUpdate(const Context<T>&,
DiscreteValues<T>*) const;

where MySystem is a class derived from LeafSystem<T> and the method name is arbitrary.

See declare_periodic_events “Declare periodic events” for more information.

Precondition:

this must be dynamic_cast-able to MySystem.

Precondition:

update must not be null.

See also

DeclarePeriodicPublishEvent()

See also

DeclarePeriodicUnrestrictedUpdateEvent()

See also

DeclarePeriodicEvent()

DeclarePeriodicEvent(self: pydrake.systems.framework.LeafSystem_[AutoDiffXd], period_sec: float, offset_sec: float, event: pydrake.systems.framework.Event_[AutoDiffXd]) None

(Advanced) Declares that a particular Event object should be dispatched periodically. This is the most general form for declaring periodic events and most users should use one of the other methods in this group instead.

See also

DeclarePeriodicPublishEvent()

See also

DeclarePeriodicDiscreteUpdateEvent()

See also

DeclarePeriodicUnrestrictedUpdateEvent()

See declare_periodic_events “Declare periodic events” for more information.

Depending on the type of event, when triggered it will be passed to the Publish, DiscreteUpdate, or UnrestrictedUpdate event dispatcher. If the event object contains a handler function, Drake’s default dispatchers will invoke that handler. If not, then no further action is taken. Thus an event with no handler has no effect unless its dispatcher has been overridden. We strongly recommend that you do not override the dispatcher and instead do supply a handler.

The given event object is deep-copied (cloned), and the copy is stored internally so you do not need to keep the object around after this call.

Precondition:

event’s associated trigger type must be TriggerType::kUnknown or already set to TriggerType::kPeriodic.

DeclarePeriodicPublishEvent(self: pydrake.systems.framework.LeafSystem_[AutoDiffXd], period_sec: float, offset_sec: float, publish: Callable[[pydrake.systems.framework.Context_[AutoDiffXd]], Optional[pydrake.systems.framework.EventStatus]]) None

Declares that a Publish event should occur periodically and that it should invoke the given event handler method. The handler should be a class member function (method) with this signature:

Click to expand C++ code...
EventStatus MySystem::MyPublish(const Context<T>&) const;

where MySystem is a class derived from LeafSystem<T> and the method name is arbitrary.

See declare_periodic_events “Declare periodic events” for more information.

Precondition:

this must be dynamic_cast-able to MySystem.

Precondition:

publish must not be null.

See also

DeclarePeriodicDiscreteUpdateEvent()

See also

DeclarePeriodicUnrestrictedUpdateEvent()

See also

DeclarePeriodicEvent()

DeclarePeriodicUnrestrictedUpdateEvent(self: pydrake.systems.framework.LeafSystem_[AutoDiffXd], period_sec: float, offset_sec: float, update: Callable[[pydrake.systems.framework.Context_[AutoDiffXd], pydrake.systems.framework.State_[AutoDiffXd]], Optional[pydrake.systems.framework.EventStatus]]) None

Declares that an UnrestrictedUpdate event should occur periodically and that it should invoke the given event handler method. The handler should be a class member function (method) with this signature:

Click to expand C++ code...
EventStatus MySystem::MyUpdate(const Context<T>&, State<T>*) const;

where MySystem is a class derived from LeafSystem<T> and the method name is arbitrary.

See declare_periodic_events “Declare periodic events” for more information.

Precondition:

this must be dynamic_cast-able to MySystem.

Precondition:

update must not be null.

See also

DeclarePeriodicPublishEvent()

See also

DeclarePeriodicDiscreteUpdateEvent()

See also

DeclarePeriodicEvent()

DeclarePerStepDiscreteUpdateEvent(self: pydrake.systems.framework.LeafSystem_[AutoDiffXd], update: Callable[[pydrake.systems.framework.Context_[AutoDiffXd], pydrake.systems.framework.DiscreteValues_[AutoDiffXd]], Optional[pydrake.systems.framework.EventStatus]]) None

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. The handler should be a class member function (method) with this signature:

Click to expand C++ code...
EventStatus MySystem::MyUpdate(const Context<T>&,
DiscreteValues<T>*) const;

where MySystem is a class derived from LeafSystem<T> and the method name is arbitrary.

See declare_per-step_events “Declare per-step events” for more information.

Precondition:

this must be dynamic_cast-able to MySystem.

Precondition:

update must not be null.

See also

DeclarePerStepPublishEvent()

See also

DeclarePerStepUnrestrictedUpdateEvent()

See also

DeclarePerStepEvent()

DeclarePerStepEvent(self: pydrake.systems.framework.LeafSystem_[AutoDiffXd], event: pydrake.systems.framework.Event_[AutoDiffXd]) None

(Advanced) Declares that a particular Event object should be dispatched at every trajectory-advancing step. Publish events are dispatched at the end of initialization and at the end of each step. Discrete- and unrestricted update events are dispatched at the start of each step. This is the most general form for declaring per-step events and most users should use one of the other methods in this group instead.

See also

DeclarePerStepPublishEvent()

See also

DeclarePerStepDiscreteUpdateEvent()

See also

DeclarePerStepUnrestrictedUpdateEvent()

See declare_per-step_events “Declare per-step events” for more information.

Depending on the type of event, at each step it will be passed to the Publish, DiscreteUpdate, or UnrestrictedUpdate event dispatcher. If the event object contains a handler function, Drake’s default dispatchers will invoke that handler. If not, then no further action is taken. Thus an event with no handler has no effect unless its dispatcher has been overridden. We strongly recommend that you do not override the dispatcher and instead do supply a handler.

The given event object is deep-copied (cloned), and the copy is stored internally so you do not need to keep the object around after this call.

Precondition:

event’s associated trigger type must be TriggerType::kUnknown or already set to TriggerType::kPerStep.

DeclarePerStepPublishEvent(self: pydrake.systems.framework.LeafSystem_[AutoDiffXd], publish: Callable[[pydrake.systems.framework.Context_[AutoDiffXd]], Optional[pydrake.systems.framework.EventStatus]]) None

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. The handler should be a class member function (method) with this signature:

Click to expand C++ code...
EventStatus MySystem::MyPublish(const Context<T>&) const;

where MySystem is a class derived from LeafSystem<T> and the method name is arbitrary.

Warning

These per-step publish events are independent of the Simulator’s optional “publish every time step” and “publish at initialization” features. Generally if you are declaring per-step publish events yourself you should turn off those Simulation options.

See declare_per-step_events “Declare per-step events” for more information.

Precondition:

this must be dynamic_cast-able to MySystem.

Precondition:

publish must not be null.

See also

DeclarePerStepDiscreteUpdateEvent()

See also

DeclarePerStepUnrestrictedUpdateEvent()

See also

DeclarePerStepEvent()

See also

Simulator::set_publish_at_initialization()

See also

Simulator::set_publish_every_time_step()

DeclarePerStepUnrestrictedUpdateEvent(self: pydrake.systems.framework.LeafSystem_[AutoDiffXd], update: Callable[[pydrake.systems.framework.Context_[AutoDiffXd], pydrake.systems.framework.State_[AutoDiffXd]], Optional[pydrake.systems.framework.EventStatus]]) None

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. The handler should be a class member function (method) with this signature:

Click to expand C++ code...
EventStatus MySystem::MyUpdate(const Context<T>&,
State<T>*) const;

where MySystem is a class derived from LeafSystem<T> and the method name is arbitrary.

See declare_per-step_events “Declare per-step events” for more information.

Precondition:

this must be dynamic_cast-able to MySystem.

Precondition:

update must not be null.

See also

DeclarePerStepPublishEvent()

See also

DeclarePerStepDiscreteUpdateEvent()

See also

DeclarePerStepEvent()

DeclareStateOutputPort(*args, **kwargs)

Overloaded function.

  1. DeclareStateOutputPort(self: pydrake.systems.framework.LeafSystem_[AutoDiffXd], name: Union[str, pydrake.systems.framework.UseDefaultName], state_index: pydrake.systems.framework.ContinuousStateIndex) -> pydrake.systems.framework.LeafOutputPort_[AutoDiffXd]

Declares a vector-valued output port whose value is the continuous state of this system.

Parameter state_index:

must be ContinuousStateIndex(0) for now, since LeafSystem only supports a single continuous state group at the moment.

  1. DeclareStateOutputPort(self: pydrake.systems.framework.LeafSystem_[AutoDiffXd], name: Union[str, pydrake.systems.framework.UseDefaultName], state_index: pydrake.systems.framework.DiscreteStateIndex) -> pydrake.systems.framework.LeafOutputPort_[AutoDiffXd]

Declares a vector-valued output port whose value is the given discrete state group of this system.

  1. DeclareStateOutputPort(self: pydrake.systems.framework.LeafSystem_[AutoDiffXd], name: Union[str, pydrake.systems.framework.UseDefaultName], state_index: pydrake.systems.framework.AbstractStateIndex) -> pydrake.systems.framework.LeafOutputPort_[AutoDiffXd]

Declares an abstract-valued output port whose value is the given abstract state of this system.

DeclareVectorInputPort(*args, **kwargs)

Overloaded function.

  1. DeclareVectorInputPort(self: pydrake.systems.framework.LeafSystem_[AutoDiffXd], name: str, model_vector: pydrake.systems.framework.BasicVector_[AutoDiffXd], random_type: Optional[pydrake.common.RandomDistribution] = None) -> pydrake.systems.framework.InputPort_[AutoDiffXd]

Declares a vector-valued input port using the given model_vector. This is the best way to declare LeafSystem input ports that require subclasses of BasicVector. The port’s size and type will be the same as model_vector. If the port is intended to model a random noise or disturbance input, random_type can (optionally) be used to label it as such. If the model_vector declares any VectorBase::GetElementBounds() constraints, they will be re-declared as inequality constraints on this system (see DeclareInequalityConstraint()).

See also

System::DeclareInputPort() for more information.

  1. DeclareVectorInputPort(self: pydrake.systems.framework.LeafSystem_[AutoDiffXd], name: str, size: int, random_type: Optional[pydrake.common.RandomDistribution] = None) -> pydrake.systems.framework.InputPort_[AutoDiffXd]

Declares a vector-valued input port with type BasicVector and size size. If the port is intended to model a random noise or disturbance input, random_type can (optionally) be used to label it as such.

See also

System::DeclareInputPort() for more information.

DeclareVectorOutputPort(*args, **kwargs)

Overloaded function.

  1. DeclareVectorOutputPort(self: pydrake.systems.framework.LeafSystem_[AutoDiffXd], name: str, model_value: pydrake.systems.framework.BasicVector_[AutoDiffXd], calc: Callable[[pydrake.systems.framework.Context_[AutoDiffXd], pydrake.systems.framework.BasicVector_[AutoDiffXd]], None], prerequisites_of_calc: set[pydrake.systems.framework.DependencyTicket] = {DependencyTicket(15)}) -> pydrake.systems.framework.OutputPort_[AutoDiffXd]

(Advanced) Declares a vector-valued output port using the given model_vector and a function for calculating the port’s value at runtime. The port’s size will be model_vector.size(), and the default allocator for the port will be model_vector.Clone(). Note that this takes the calculator function in its most generic form; if you have a member function available use one of the other signatures.

See also

LeafOutputPort::CalcVectorCallback

  1. DeclareVectorOutputPort(self: pydrake.systems.framework.LeafSystem_[AutoDiffXd], name: str, size: int, calc: Callable[[pydrake.systems.framework.Context_[AutoDiffXd], pydrake.systems.framework.BasicVector_[AutoDiffXd]], None], prerequisites_of_calc: set[pydrake.systems.framework.DependencyTicket] = {DependencyTicket(15)}) -> pydrake.systems.framework.OutputPort_[AutoDiffXd]

(Advanced) Declares a vector-valued output port with type BasicVector<T> and size size, using the drake::dummy_value<T>, which is NaN when T = double. vector_calc_function is a function for calculating the port’s value at runtime. Note that this takes the calculator function in its most generic form; if you have a member function available use one of the other signatures.

See also

LeafOutputPort::CalcVectorCallback

DoCalcTimeDerivatives(self: pydrake.systems.framework.LeafSystem_[AutoDiffXd], arg0: pydrake.systems.framework.Context_[AutoDiffXd], arg1: pydrake.systems.framework.ContinuousState_[AutoDiffXd]) None
MakeWitnessFunction(*args, **kwargs)

Overloaded function.

  1. MakeWitnessFunction(self: pydrake.systems.framework.LeafSystem_[AutoDiffXd], description: str, direction_type: pydrake.systems.framework.WitnessFunctionDirection, calc: Callable[[pydrake.systems.framework.Context_[AutoDiffXd]], Optional[pydrake.autodiffutils.AutoDiffXd]]) -> pydrake.systems.framework.WitnessFunction_[AutoDiffXd]

Constructs the witness function with the given description (used primarily for debugging and logging), direction type, and calculator function; and with no event object.

Note

In order for the witness function to be used, you MUST overload System::DoGetWitnessFunctions().

  1. MakeWitnessFunction(self: pydrake.systems.framework.LeafSystem_[AutoDiffXd], description: str, direction_type: pydrake.systems.framework.WitnessFunctionDirection, calc: Callable[[pydrake.systems.framework.Context_[AutoDiffXd]], pydrake.autodiffutils.AutoDiffXd], e: pydrake.systems.framework.Event_[AutoDiffXd]) -> pydrake.systems.framework.WitnessFunction_[AutoDiffXd]

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. Example types of event objects are publish, discrete variable update, unrestricted update events. A clone of the event will be owned by the newly constructed WitnessFunction.

Note

In order for the witness function to be used, you MUST overload System::DoGetWitnessFunctions().

class pydrake.systems.framework.LeafSystem_[Expression]

Bases: pydrake.systems.framework.System_[Expression]

A superclass template that extends System with some convenience utilities that are not applicable to Diagrams.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: pydrake.systems.framework.LeafSystem_[Expression]) -> None

Default constructor that declares no inputs, outputs, state, parameters, events, nor scalar-type conversion support (AutoDiff, etc.). To enable AutoDiff support, use the SystemScalarConverter-based constructor.

  1. __init__(self: pydrake.systems.framework.LeafSystem_[Expression], converter: pydrake.systems.framework.SystemScalarConverter) -> None

Constructor that declares no inputs, outputs, state, parameters, or events, but allows subclasses to declare scalar-type conversion support (AutoDiff, etc.).

The scalar-type conversion support will use converter. To enable scalar-type conversion support, pass a SystemTypeTag<S>{} where S must be the exact class of this being constructed.

See system_scalar_conversion for detailed background and examples related to scalar-type conversion support.

DeclareAbstractInputPort(self: pydrake.systems.framework.LeafSystem_[Expression], name: str, model_value: pydrake.common.value.AbstractValue) pydrake.systems.framework.InputPort_[Expression]

Declares an abstract-valued input port using the given model_value. This is the best way to declare LeafSystem abstract input ports.

Any port connected to this input, and any call to FixValue for this input, must provide for values whose type matches this model_value.

See also

System::DeclareInputPort() for more information.

DeclareAbstractOutputPort(self: pydrake.systems.framework.LeafSystem_[Expression], name: str, alloc: Callable[[], pydrake.common.value.AbstractValue], calc: Callable[[pydrake.systems.framework.Context_[Expression], pydrake.common.value.AbstractValue], None], prerequisites_of_calc: set[