Drake
OutputPort< T > Class Template Referenceabstract

An OutputPort belongs to a System and represents the properties of one of that System's output ports. More...

#include <systems/framework/output_port.h>

Inheritance diagram for OutputPort< T >:
[legend]

Public Member Functions

virtual ~OutputPort ()=default
 
std::unique_ptr< AbstractValueAllocate (const Context< T > &context) const
 Allocates a concrete object suitable for holding the value to be exposed by this output port, and returns that as an AbstractValue. More...
 
void Calc (const Context< T > &context, AbstractValue *value) const
 Unconditionally computes the value of this output port with respect to the given context, into an already-allocated AbstractValue object whose concrete type must be exactly the same as the type returned by this port's allocator. More...
 
const AbstractValueEval (const Context< T > &context) const
 Returns a reference to the value of this output port contained in the given Context. More...
 
const System< T > & get_system () const
 Returns a reference to the System that owns this output port. More...
 
OutputPortIndex get_index () const
 Returns the index of this output port within the owning System. More...
 
PortDataType get_data_type () const
 Gets the port data type specified at port construction. More...
 
int size () const
 Returns the fixed size expected for a vector-valued output port. More...
 
Does not allow copy, move, or assignment
 OutputPort (const OutputPort &)=delete
 
OutputPortoperator= (const OutputPort &)=delete
 
 OutputPort (OutputPort &&)=delete
 
OutputPortoperator= (OutputPort &&)=delete
 

Protected Member Functions

 OutputPort (const System< T > &system, PortDataType data_type, int size)
 Provides derived classes the ability to set the base class members at construction. More...
 
virtual std::unique_ptr< AbstractValueDoAllocate (const Context< T > &context) const =0
 A concrete OutputPort must provide a way to allocate a suitable object for holding the runtime value of this output port. More...
 
virtual void DoCalc (const Context< T > &context, AbstractValue *value) const =0
 A concrete OutputPort must implement this method to calculate the value this output port should have, given the supplied Context. More...
 
virtual const AbstractValueDoEval (const Context< T > &context) const =0
 A concrete OutputPort must provide access to the current value of this output port stored within the given Context. More...
 
std::string GetPortIdString () const
 This is useful for error messages and produces "output port \<#\> of GetSystemIdString()" with whatever System identification string is produced by that method. More...
 

Detailed Description

template<typename T>
class drake::systems::OutputPort< T >

An OutputPort belongs to a System and represents the properties of one of that System's output ports.

OutputPort objects are assigned OutputPortIndex values in the order they are declared; these are unique within a single System.

An output port can be considered a "window" into a System that permits controlled exposure of one of the values contained in that System's Context at run time. Input ports of other subsystems may be connected to an output port to construct system diagrams with carefully managed interdependencies.

The exposed value may be the result of an output computation, or it may simply expose some other value contained in the Context, such as the values of state variables. The Context handles caching of output port values and tracks dependencies to ensure that the values are valid with respect to their prerequisites. Leaf systems provide for the production of output port values, by computation or forwarding from other values within the associated leaf context. A diagram's output ports, on the other hand, are exported from output ports of its contained subsystems.

An output port's value is always stored as an AbstractValue, but we also provide special handling for output ports known to have numeric (vector) values. Vector-valued ports may specify a particular vector length, or may leave that to be determined at runtime.

OutputPort objects support three important operations:

  • Allocate() returns an object that can hold the port's value.
  • Calc() unconditionally computes the port's value.
  • Eval() updates a cached value if necessary.
Template Parameters
TThe vector element type, which must be a valid Eigen scalar.

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

They are already available to link against in the containing library. No other values for T are currently supported.

Constructor & Destructor Documentation

OutputPort ( const OutputPort< T > &  )
delete

Here is the caller graph for this function:

OutputPort ( OutputPort< T > &&  )
delete
virtual ~OutputPort ( )
virtualdefault
OutputPort ( const System< T > &  system,
PortDataType  data_type,
int  size 
)
protected

Provides derived classes the ability to set the base class members at construction.

Parameters
systemThe System that will own this new output port. This port will be assigned the next available output port index in this system.
data_typeWhether the port described is vector or abstract valued.
sizeIf the port described is vector-valued, the number of elements expected, otherwise ignored.

Member Function Documentation

std::unique_ptr< AbstractValue > Allocate ( const Context< T > &  context) const

Allocates a concrete object suitable for holding the value to be exposed by this output port, and returns that as an AbstractValue.

The returned object will never be null. If Drake assertions are enabled (typically only in Debug builds), validates for a vector-valued port that the returned AbstractValue is actually a BasicVector-derived type and that it has an acceptable size.

Note
If this is a vector-valued port, the underlying type is Value<BasicVector<T>>; downcast to BasicVector<T> before downcasting to the specific BasicVector subclass.

Here is the caller graph for this function:

void Calc ( const Context< T > &  context,
AbstractValue value 
) const

Unconditionally computes the value of this output port with respect to the given context, into an already-allocated AbstractValue object whose concrete type must be exactly the same as the type returned by this port's allocator.

If Drake assertions are enabled (typically only in Debug builds), validates that the given value has exactly the same concrete type as is returned by the Allocate() method.

Here is the caller graph for this function:

virtual std::unique_ptr<AbstractValue> DoAllocate ( const Context< T > &  context) const
protectedpure virtual

A concrete OutputPort must provide a way to allocate a suitable object for holding the runtime value of this output port.

The particulars may depend on values and types of objects in the given Context.

Parameters
contextA Context that has already been validated as compatible with the System whose output port this is.
Returns
A unique_ptr to the new value-holding object as an AbstractValue.

Here is the caller graph for this function:

virtual void DoCalc ( const Context< T > &  context,
AbstractValue value 
) const
protectedpure virtual

A concrete OutputPort must implement this method to calculate the value this output port should have, given the supplied Context.

The value may be determined by computation or by copying from a source value in the Context.

Parameters
contextA Context that has already been validated as compatible with the System whose output port this is.
valueA pointer that has already be validated as non-null and pointing to an object of the right type to hold a value of this output port.

Here is the caller graph for this function:

virtual const AbstractValue& DoEval ( const Context< T > &  context) const
protectedpure virtual

A concrete OutputPort must provide access to the current value of this output port stored within the given Context.

If the value is already up to date with respect to its prerequisites in context, no computation should be performed. Otherwise, the implementation should arrange for the value to be computed, typically but not necessarily by invoking DoCalc().

Parameters
contextA Context that has already been validated as compatible with the System whose output port this is.

Here is the caller graph for this function:

const AbstractValue & Eval ( const Context< T > &  context) const

Returns a reference to the value of this output port contained in the given Context.

If that value is not up to date with respect to its prerequisites, the Calc() method above is used first to update the value before the reference is returned. (Not implemented yet.)

PortDataType get_data_type ( ) const
inline

Gets the port data type specified at port construction.

Here is the caller graph for this function:

OutputPortIndex get_index ( ) const
inline

Returns the index of this output port within the owning System.

Here is the caller graph for this function:

const System<T>& get_system ( ) const
inline

Returns a reference to the System that owns this output port.

Note that for a diagram output port this will be the diagram, not the leaf system whose output port was forwarded.

Here is the caller graph for this function:

std::string GetPortIdString ( ) const
protected

This is useful for error messages and produces "output port \<#\> of GetSystemIdString()" with whatever System identification string is produced by that method.

Here is the call graph for this function:

Here is the caller graph for this function:

OutputPort& operator= ( OutputPort< T > &&  )
delete
OutputPort& operator= ( const OutputPort< T > &  )
delete
int size ( ) const
inline

Returns the fixed size expected for a vector-valued output port.

Not meaningful for abstract output ports.

Here is the caller graph for this function:


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