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 | |
SystemSymbolicInspector & | operator= (const SystemSymbolicInspector &)=delete |
SystemSymbolicInspector (SystemSymbolicInspector &&)=delete | |
SystemSymbolicInspector & | operator= (SystemSymbolicInspector &&)=delete |
Reference symbolic components | |
const symbolic::Variable & | time () 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::Expression > | derivatives () 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... | |
|
explicit |
Constructs a SystemSymbolicInspector for the given system
by initializing every vector-valued element in the Context with symbolic variables.
|
default |
|
delete |
|
delete |
const std::set<symbolic::Formula>& constraints | ( | ) | const |
Returns a reference to the symbolic representation of the constraints.
const VectorX<symbolic::Variable>& continuous_state | ( | ) | const |
Returns a reference to the symbolic representation of the continuous state.
VectorX<symbolic::Expression> derivatives | ( | ) | const |
Returns a copy of the symbolic representation of the continuous-time dynamics.
const VectorX<symbolic::Variable>& discrete_state | ( | int | i | ) | const |
Returns a reference to the symbolic representation of the discrete state.
i | The discrete state group number. |
const VectorX<symbolic::Expression>& discrete_update | ( | int | i | ) | const |
Returns a reference to the symbolic representation of the discrete-time dynamics.
i | The 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).
const VectorX<symbolic::Variable>& input | ( | int | i | ) | const |
Returns a reference to the symbolic representation of the input.
i | The input port number. |
|
static |
Returns true if any field in the context
is abstract-valued.
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
.
bool IsTimeInvariant | ( | ) | const |
Returns true if there is no dependence on time in the dynamics (continuous nor discrete) nor the outputs.
const VectorX<symbolic::Variable>& numeric_parameters | ( | int | i | ) | const |
Returns a reference to the symbolic representation of the numeric parameters.
i | The numeric parameter group number. |
|
delete |
|
delete |
const VectorX<symbolic::Expression>& output | ( | int | i | ) | const |
Returns a reference to the symbolic representation of the output.
i | The output port number. |
const symbolic::Variable& time | ( | ) | const |