Drake
Drake C++ Documentation
SystemSymbolicInspector Class Reference

Detailed Description

The SystemSymbolicInspector uses symbolic::Expressions to analyze various properties of the System, such as time invariance and input-to-output sparsity, along with many others.

A SystemSymbolicInspector is only interesting if the Context contains purely vector-valued elements. If any abstract-valued elements are present, the SystemSymbolicInspector will not be able to parse the governing equations reliably.

It would be possible to report system properties for a specific configuration of the abstract inputs, state, or parameters. We intentionally do not provide such an analysis, because it would invite developers to shoot themselves in the foot by accidentally overstating sparsity, for instance if a given input affects a given output in some modes, but not the mode tested.

Even with that limitation on scope, SystemSymbolicInspector has risks, if the System contains C++ native conditionals like "if" or "switch". symbolic::Expression does not provide an implicit conversion to bool, so it is unlikely that anyone will accidentally write a System that both uses native conditionals and compiles with a symbolic::Expression scalar type. However, it is possible, for instance using an explicit cast, or std::equal_to.

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

Public Member Functions

 SystemSymbolicInspector (const System< symbolic::Expression > &system)
 Constructs a SystemSymbolicInspector for the given system by initializing every vector-valued element in the Context with symbolic variables. More...
 
 ~SystemSymbolicInspector ()=default
 
bool IsConnectedInputToOutput (int input_port_index, int output_port_index) const
 Returns true if the input port at the given input_port_index is or might possibly be a term in the output at the given output_port_index. More...
 
bool IsTimeInvariant () const
 Returns true if there is no dependence on time in the dynamics (continuous nor discrete) nor the outputs. More...
 
bool HasAffineDynamics () const
 Returns true iff all of the derivatives and discrete updates have at most an affine dependence on state and input. More...
 
Does not allow copy, move, or assignment
 SystemSymbolicInspector (const SystemSymbolicInspector &)=delete
 
SystemSymbolicInspectoroperator= (const SystemSymbolicInspector &)=delete
 
 SystemSymbolicInspector (SystemSymbolicInspector &&)=delete
 
SystemSymbolicInspectoroperator= (SystemSymbolicInspector &&)=delete
 
Reference symbolic components

A set of accessor methods that provide direct access to the symbolic forms of the System.

This class carefully sets up and names all of the symbolic elements of the Context, and other methods should be able to reap the benefits.

Returns a reference to the symbolic representation of time.

const symbolic::Variabletime () const
 
const VectorX< symbolic::Variable > & input (int i) const
 Returns a reference to the symbolic representation of the input. More...
 
const VectorX< symbolic::Variable > & continuous_state () const
 Returns a reference to the symbolic representation of the continuous state. More...
 
const VectorX< symbolic::Variable > & discrete_state (int i) const
 Returns a reference to the symbolic representation of the discrete state. More...
 
const VectorX< symbolic::Variable > & numeric_parameters (int i) const
 Returns a reference to the symbolic representation of the numeric parameters. More...
 
VectorX< symbolic::Expressionderivatives () const
 Returns a copy of the symbolic representation of the continuous-time dynamics. More...
 
const VectorX< symbolic::Expression > & discrete_update (int i) const
 Returns a reference to the symbolic representation of the discrete-time dynamics. More...
 
const VectorX< symbolic::Expression > & output (int i) const
 Returns a reference to the symbolic representation of the output. More...
 
const std::set< symbolic::Formula > & constraints () const
 Returns a reference to the symbolic representation of the constraints. More...
 

Static Public Member Functions

static bool IsAbstract (const System< symbolic::Expression > &system, const Context< symbolic::Expression > &context)
 Returns true if any field in the context is abstract-valued. More...
 

Constructor & Destructor Documentation

◆ SystemSymbolicInspector() [1/3]

SystemSymbolicInspector ( const System< symbolic::Expression > &  system)
explicit

Constructs a SystemSymbolicInspector for the given system by initializing every vector-valued element in the Context with symbolic variables.

◆ ~SystemSymbolicInspector()

◆ SystemSymbolicInspector() [2/3]

◆ SystemSymbolicInspector() [3/3]

Member Function Documentation

◆ constraints()

const std::set<symbolic::Formula>& constraints ( ) const

Returns a reference to the symbolic representation of the constraints.

◆ continuous_state()

const VectorX<symbolic::Variable>& continuous_state ( ) const

Returns a reference to the symbolic representation of the continuous state.

◆ derivatives()

VectorX<symbolic::Expression> derivatives ( ) const

Returns a copy of the symbolic representation of the continuous-time dynamics.

◆ discrete_state()

const VectorX<symbolic::Variable>& discrete_state ( int  i) const

Returns a reference to the symbolic representation of the discrete state.

Parameters
iThe discrete state group number.

◆ discrete_update()

const VectorX<symbolic::Expression>& discrete_update ( int  i) const

Returns a reference to the symbolic representation of the discrete-time dynamics.

Parameters
iThe discrete state group number.

◆ HasAffineDynamics()

bool HasAffineDynamics ( ) const

Returns true iff all of the derivatives and discrete updates have at most an affine dependence on state and input.

Note that the return value does NOT depend on the output methods (they may be affine or not).

◆ input()

const VectorX<symbolic::Variable>& input ( int  i) const

Returns a reference to the symbolic representation of the input.

Parameters
iThe input port number.

◆ IsAbstract()

static bool IsAbstract ( const System< symbolic::Expression > &  system,
const Context< symbolic::Expression > &  context 
)
static

Returns true if any field in the context is abstract-valued.

◆ IsConnectedInputToOutput()

bool IsConnectedInputToOutput ( int  input_port_index,
int  output_port_index 
) const

Returns true if the input port at the given input_port_index is or might possibly be a term in the output at the given output_port_index.

◆ IsTimeInvariant()

bool IsTimeInvariant ( ) const

Returns true if there is no dependence on time in the dynamics (continuous nor discrete) nor the outputs.

◆ numeric_parameters()

const VectorX<symbolic::Variable>& numeric_parameters ( int  i) const

Returns a reference to the symbolic representation of the numeric parameters.

Parameters
iThe numeric parameter group number.

◆ operator=() [1/2]

◆ operator=() [2/2]

SystemSymbolicInspector& operator= ( const SystemSymbolicInspector )
delete

◆ output()

const VectorX<symbolic::Expression>& output ( int  i) const

Returns a reference to the symbolic representation of the output.

Parameters
iThe output port number.

◆ time()

const symbolic::Variable& time ( ) const

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