Drake
SystemSymbolicInspector Class Reference

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

#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
 
Eigen::VectorBlock< const VectorX< symbolic::Variable > > input (int i) const
 Returns a reference to the symbolic representation of the input. More...
 
Eigen::VectorBlock< const VectorX< symbolic::Variable > > continuous_state () const
 Returns a reference to the symbolic representation of the continuous state. More...
 
Eigen::VectorBlock< const VectorX< symbolic::Variable > > discrete_state (int i) const
 Returns a reference to the symbolic representation of the discrete state. More...
 
Eigen::VectorBlock< 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...
 
Eigen::VectorBlock< const VectorX< symbolic::Expression > > discrete_update (int i) const
 Returns a reference to the symbolic representation of the discrete-time dynamics. More...
 
Eigen::VectorBlock< 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...
 

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.

Constructor & Destructor Documentation

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.

Here is the call graph for this function:

Member Function Documentation

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

Returns a reference to the symbolic representation of the constraints.

Eigen::VectorBlock<const VectorX<symbolic::Variable> > continuous_state ( ) const
inline

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

VectorX<symbolic::Expression> derivatives ( ) const
inline

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

Eigen::VectorBlock<const VectorX<symbolic::Variable> > discrete_state ( int  i) const
inline

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

Parameters
iThe discrete state group number.
Eigen::VectorBlock<const VectorX<symbolic::Expression> > discrete_update ( int  i) const
inline

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

Parameters
iThe discrete state group number.
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).

Here is the call graph for this function:

Eigen::VectorBlock<const VectorX<symbolic::Variable> > input ( int  i) const
inline

Returns a reference to the symbolic representation of the input.

Parameters
iThe input port number.
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.

Here is the call graph for this function:

bool IsTimeInvariant ( ) const

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

Eigen::VectorBlock<const VectorX<symbolic::Variable> > numeric_parameters ( int  i) const
inline

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

Parameters
iThe numeric parameter group number.
SystemSymbolicInspector& operator= ( const SystemSymbolicInspector )
delete
Eigen::VectorBlock<const VectorX<symbolic::Expression> > output ( int  i) const
inline

Returns a reference to the symbolic representation of the output.

Parameters
iThe output port number.
const symbolic::Variable& time ( ) const
inline

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