Drake
AbstractSystem3 Class Referenceabstract

An abstract superclass for dynamical systems, encapsulating functionality that is independent of the numerical scalar type in use. More...

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

Inheritance diagram for AbstractSystem3:

Public Member Functions

virtual ~AbstractSystem3 ()
 
std::string get_name () const
 Returns the name of this system. More...
 
DRAKESYSTEMFRAMEWORK_EXPORT std::unique_ptr< AbstractContext3CreateDefaultContext () const
 Returns a default context, initialized with run time mutable memory for the correct number and type of InputPort3, OutputPort3, and state variable objects, as well as time, parameters, and basic computations. More...
 
DRAKESYSTEMFRAMEWORK_EXPORT const AbstractValueEvalOutputPort (const AbstractContext3 &context, int port_num) const
 Obtain an up-to-date value for one of this system's output ports. More...
 
const InputPortFinderget_input_port_finder (int port_num) const
 
const OutputPortFinderget_output_port_finder (int port_num) const
 
CacheEntry::Calculator get_output_port_calculator (int port_num) const
 Given an output port number, return a function that knows how to calculate the value of that port when given a system and context. More...
 
void CalcOutputPort (const AbstractContext3 &context, int port_num, AbstractValue *result) const
 Unconditionally calculate what would be the output port value into an already-allocated appropriate result object. More...
 
Methods useful for any System

These provide the ability to specify input and output ports, which are common to all dynamic systems.

int AddInputPort (std::unique_ptr< InputPort3 > port)
 Add an input port that is to be owned by this system. More...
 
int AddOutputPort (std::unique_ptr< OutputPort3 > port)
 Add an output port that is to be owned by this System. More...
 
int get_num_input_ports () const
 Returns the current number of input ports in this system. More...
 
const InputPort3get_input_port (int port_num) const
 Returns a const reference to the InputPort3 with the given port number. More...
 
InputPort3get_mutable_input_port (int port_num)
 Returns a mutable pointer to the InputPort3 with the given port number. More...
 
int get_num_output_ports () const
 Returns the current number of output ports in this system. More...
 
const OutputPort3get_output_port (int port_num) const
 Returns a const reference to the OutputPort3 with the given port number. More...
 
OutputPort3get_mutable_output_port (int port_num)
 Returns a mutable pointer to the OutputPort3 with the given port number. More...
 
System diagram methods

These methods are useful for any system that contains subsystems.

template<class ConcreteSystem >
ConcreteSystem * AddSubsystem (std::unique_ptr< ConcreteSystem > subsystem)
 Takes ownership of the given system and returns an unowned, raw pointer to the concrete type for convenient access. More...
 
int InheritInputPort (AbstractSystem3 *child_subsystem, int input_port_num)
 The given subsystem's InputPort3 becomes the next InputPort3 of this system diagram. More...
 
int InheritOutputPort (AbstractSystem3 *child_subsystem, int output_port_num)
 The given subsystem's OutputPort3 becomes the next OutputPort3 of this system diagram. More...
 
void Connect (AbstractSystem3 *source_subsystem, int output_port_num, AbstractSystem3 *sink_subsystem, int input_port_num)
 Connect the given output port of subsystem 1 into the given input port of subsystem 2. More...
 
int get_num_subsystems () const
 Returns the current number of subsystems contained in this system diagram. More...
 
const AbstractSystem3get_subsystem (int index) const
 Returns a const reference to one of the contained subsystems, using the index reflecting the order in which it was added. More...
 
AbstractSystem3get_mutable_subsystem (int index)
 Returns a mutable pointer to one of the contained subsystems, using the index reflecting the order in which it was added. More...
 
const AbstractSystem3get_parent_system () const
 Returns a const pointer to the parent system that owns this one, or nullptr if this is a root system. More...
 
AbstractSystem3get_mutable_parent_system ()
 Returns a mutable pointer to the parent system that owns this one, or nullptr if this is a root system. More...
 
int get_subsystem_num () const
 If this system is a subsystem of a parent system, return the subsystem number by which that parent knows us. More...
 
std::string GetSubsystemPathName () const
 Determine the full path name of this subsystem in a form like /rootname/parentname/myname. More...
 
const AbstractContext3find_my_subcontext (const AbstractContext3 &some_subcontext) const
 Get const access to this subsystem's subcontext given const access to any other subsystem's subcontext in the same context diagram. More...
 
AbstractContext3find_my_mutable_subcontext (AbstractContext3 *some_subcontext) const
 Get mutable access to this subsystem's subcontext given mutable access to any other subsystem's subcontext in the same context diagram. More...
 
const AbstractSystem3get_root_system () const
 Find the root system of the tree of which this subsystem is a member. More...
 
AbstractSystem3get_mutable_root_system ()
 Get a mutable pointer to the root system of the tree of which this subsystem is a member. More...
 

Protected Member Functions

 AbstractSystem3 (const std::string &name)
 
DRAKESYSTEMFRAMEWORK_EXPORT const AbstractValueEvalInputPort (const AbstractContext3 &context, int port_num) const
 Obtain an up-to-date value for one of this system's input ports. More...
 
virtual std::unique_ptr< AbstractContext3DoCreateEmptyContext () const =0
 Allocate a concrete Context type that is appropropriate for your concrete System. More...
 
virtual void DoAcquireContextResources (AbstractContext3 *context) const
 Acquire any private Context resources your concrete System needs, and assign them default values. More...
 
virtual void DoCalcOutputPort (const AbstractContext3 &context, int port_num, AbstractValue *value) const =0
 Unconditionally compute the given output port's value. More...
 

Friends

class AbstractContext3
 

Detailed Description

An abstract superclass for dynamical systems, encapsulating functionality that is independent of the numerical scalar type in use.

That includes the concepts of input and output, containment of subsystems, and connections among the subsystems' inputs and outputs. A system that contains subsystems is called a "system diagram", one without subsystems is called a "leaf system", and the topmost system diagram is the "root system".

This class is intended to be paired with a compatible AbstractContext3 object whose internal tree structure of subcontexts is identical to the structure of the tree of subsystems.

Input values are presented to a System3 through zero or more InputPort3 objects; output values are delivered through zero or more OutputPort3 objects. Systems are composed by connecting compatible OutputPort3 and InputPort3 objects together into a system diagram. These connections are established during extended construction of a system diagram and must be completed prior to run time execution (and are hence independent of context). InputPort3 objects contain information about their requirements for OutputPort3 mates.

Most systems should not inherit directly from AbstractSystem3. If your system involves any numerical computations it should instead, inherit from System3<T>.

Constructor & Destructor Documentation

virtual ~AbstractSystem3 ( )
inlinevirtual
AbstractSystem3 ( const std::string &  name)
inlineexplicitprotected

Member Function Documentation

int AddInputPort ( std::unique_ptr< InputPort3 port)
inline

Add an input port that is to be owned by this system.

The assigned port number is returned and can be used to retrieve this port later, and to locate its value in a compatible context.

Here is the caller graph for this function:

int AddOutputPort ( std::unique_ptr< OutputPort3 port)
inline

Add an output port that is to be owned by this System.

The assigned port number is returned and can be used to retrieve this port later, and to locate its value in a compatible context.

Here is the caller graph for this function:

ConcreteSystem* AddSubsystem ( std::unique_ptr< ConcreteSystem >  subsystem)
inline

Takes ownership of the given system and returns an unowned, raw pointer to the concrete type for convenient access.

This subsystem is assigned the next available index, as given by get_num_subsystems() prior to making this call.

Here is the caller graph for this function:

void CalcOutputPort ( const AbstractContext3 context,
int  port_num,
AbstractValue result 
) const
inline

Unconditionally calculate what would be the output port value into an already-allocated appropriate result object.

Here is the call graph for this function:

Here is the caller graph for this function:

void Connect ( AbstractSystem3 source_subsystem,
int  output_port_num,
AbstractSystem3 sink_subsystem,
int  input_port_num 
)
inline

Connect the given output port of subsystem 1 into the given input port of subsystem 2.

Both subsystems must be immediate children of this system. The input port must be able to accept the type and sampling rate of the output port.

Exceptions
std::logic_errorThe input port does not accept the type or sampling rate of the output port.

Here is the call graph for this function:

Here is the caller graph for this function:

std::unique_ptr< AbstractContext3 > CreateDefaultContext ( ) const

Returns a default context, initialized with run time mutable memory for the correct number and type of InputPort3, OutputPort3, and state variable objects, as well as time, parameters, and basic computations.

This will contain one subcontext corresponding to each subsystem of this System.

Here is the call graph for this function:

Here is the caller graph for this function:

virtual void DoAcquireContextResources ( AbstractContext3 context) const
inlineprotectedvirtual

Acquire any private Context resources your concrete System needs, and assign them default values.

The supplied context is in the process of being constructed and you may assume it already contains resources for your input and output ports. The default implementation acquires no resources.

Here is the caller graph for this function:

virtual void DoCalcOutputPort ( const AbstractContext3 context,
int  port_num,
AbstractValue value 
) const
protectedpure virtual

Unconditionally compute the given output port's value.

When implementing this method, you may assume that error checking has been performed to validate the Context and port number, and that the output value is of the same type as that port's model value.

virtual std::unique_ptr<AbstractContext3> DoCreateEmptyContext ( ) const
protectedpure virtual

Allocate a concrete Context type that is appropropriate for your concrete System.

Here is the caller graph for this function:

const AbstractValue & EvalInputPort ( const AbstractContext3 context,
int  port_num 
) const
protected

Obtain an up-to-date value for one of this system's input ports.

If necessary this triggers the computation of whatever value source this input port is connected to, typically an output port.

Parameters
[in,out]contextA Context that is compatible with this System.
[in]port_numThe index number of the input port to be evaluated.
Return values
valueA reference into context containing the current value for this output port.

Here is the call graph for this function:

const AbstractValue & EvalOutputPort ( const AbstractContext3 context,
int  port_num 
) const

Obtain an up-to-date value for one of this system's output ports.

(Output ports may have distinct sample times so must be individually evaluatable.) If necessary, computation of this value is initiated with the result written into the supplied AbstractContext3's cache.

Parameters
[in,out]contextA context that is compatible with this System.
[in]port_numThe index number of the output port to be evaluated.
Return values
valueA reference into context containing the current value for this output port.

Here is the call graph for this function:

AbstractContext3* find_my_mutable_subcontext ( AbstractContext3 some_subcontext) const
inline

Get mutable access to this subsystem's subcontext given mutable access to any other subsystem's subcontext in the same context diagram.

Note that you don't need mutable access to the subsystem to get mutable access to its subcontext.

const AbstractContext3& find_my_subcontext ( const AbstractContext3 some_subcontext) const
inline

Get const access to this subsystem's subcontext given const access to any other subsystem's subcontext in the same context diagram.

Here is the call graph for this function:

const InputPort3& get_input_port ( int  port_num) const
inline

Returns a const reference to the InputPort3 with the given port number.

Here is the caller graph for this function:

const InputPortFinder& get_input_port_finder ( int  port_num) const
inline

Here is the caller graph for this function:

InputPort3* get_mutable_input_port ( int  port_num)
inline

Returns a mutable pointer to the InputPort3 with the given port number.

Here is the caller graph for this function:

OutputPort3* get_mutable_output_port ( int  port_num)
inline

Returns a mutable pointer to the OutputPort3 with the given port number.

Here is the caller graph for this function:

AbstractSystem3* get_mutable_parent_system ( )
inline

Returns a mutable pointer to the parent system that owns this one, or nullptr if this is a root system.

AbstractSystem3* get_mutable_root_system ( )
inline

Get a mutable pointer to the root system of the tree of which this subsystem is a member.

Never returns nullptr. See get_root_system() for more information.

AbstractSystem3* get_mutable_subsystem ( int  index)
inline

Returns a mutable pointer to one of the contained subsystems, using the index reflecting the order in which it was added.

std::string get_name ( ) const
inline

Returns the name of this system.

This is just an arbitrary string with no particular meaning attached.

int get_num_input_ports ( ) const
inline

Returns the current number of input ports in this system.

This is also the port number that will be assigned by the next call to AddInputPort().

Here is the caller graph for this function:

int get_num_output_ports ( ) const
inline

Returns the current number of output ports in this system.

This is also the port number that will be assigned by the next call to AddOutputPort().

Here is the caller graph for this function:

int get_num_subsystems ( ) const
inline

Returns the current number of subsystems contained in this system diagram.

This is also the index that will be assigned to the next subsystem that is added here.

Here is the caller graph for this function:

const OutputPort3& get_output_port ( int  port_num) const
inline

Returns a const reference to the OutputPort3 with the given port number.

Here is the caller graph for this function:

CacheEntry::Calculator get_output_port_calculator ( int  port_num) const
inline

Given an output port number, return a function that knows how to calculate the value of that port when given a system and context.

The signature is suitable for registering with a cache entry that can invoke this function when the entry is out of date and needs updating.

Here is the call graph for this function:

Here is the caller graph for this function:

const OutputPortFinder& get_output_port_finder ( int  port_num) const
inline

Here is the caller graph for this function:

const AbstractSystem3* get_parent_system ( ) const
inline

Returns a const pointer to the parent system that owns this one, or nullptr if this is a root system.

Here is the caller graph for this function:

const AbstractSystem3& get_root_system ( ) const
inline

Find the root system of the tree of which this subsystem is a member.

Searches up the tree so run time is roughly log(N) for an N-subsystem tree starting at a leaf.

Here is the call graph for this function:

Here is the caller graph for this function:

const AbstractSystem3& get_subsystem ( int  index) const
inline

Returns a const reference to one of the contained subsystems, using the index reflecting the order in which it was added.

Here is the call graph for this function:

Here is the caller graph for this function:

int get_subsystem_num ( ) const
inline

If this system is a subsystem of a parent system, return the subsystem number by which that parent knows us.

Returns -1 if this is a root system.

Here is the caller graph for this function:

std::string GetSubsystemPathName ( ) const
inline

Determine the full path name of this subsystem in a form like /rootname/parentname/myname.

This name will be unique if sibling subsystems have unique names within their parent system.

Here is the caller graph for this function:

int InheritInputPort ( AbstractSystem3 child_subsystem,
int  input_port_num 
)
inline

The given subsystem's InputPort3 becomes the next InputPort3 of this system diagram.

The diagram's input port number is returned; it will in general be different from the input port number in the subsystem from which it was inherited.

Here is the call graph for this function:

Here is the caller graph for this function:

int InheritOutputPort ( AbstractSystem3 child_subsystem,
int  output_port_num 
)
inline

The given subsystem's OutputPort3 becomes the next OutputPort3 of this system diagram.

The diagram's output port number is returned; it will in general be different from the output port number in the subsystem from which it was inherited.

Here is the call graph for this function:

Here is the caller graph for this function:

Friends And Related Function Documentation

friend class AbstractContext3
friend

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