Taylor Baum
Taylor Baum

Reputation: 37

Python Linearization with Symbolic System

So, I am trying to linearize my simple Symbolic System which has a nonlinear output equation and a linear state equation.

I am trying to figure out how to change the nominal value of my input, u. Aka, I want to set u0. I have figured out how to set the nominal value of the state vector, I think, below.

c_e = Variable('c_e')
c_2 = Variable('c_2')
u   = Variable('u')

x = [c_e, c_2]

sys = SymbolicVectorSystem(state = x, input = [u], dynamics = f(x, u), output = g(x))

context = sys.CreateDefaultContext()
context.get_continuous_state_vector().SetAtIndex(0, 10**-6)
linear_sys = Linearize(sys, context)

I am currently getting the error that my input port is not connected, but I am not sure what this means. What should I do to fix this error, and set my nominal point?

RuntimeError: InputPort::Eval(): required InputPort[0] (u0) of System ::_ (SymbolicVectorSystem<double>) is not connected

Upvotes: 1

Views: 615

Answers (1)

Russ Tedrake
Russ Tedrake

Reputation: 5533

The error message is pointing you in the right direction. To linearize a system with state and inputs, you need to specify not only the nominal state (x0) but also the nominal input (u0). You need to set both in the context.

You’ve set the nominal state, but need a line like

context.FixInputPort(0, [0])

to specify the nominal input.

(The particular error message was due to the linearization method calling the dynamics of your system, which needs to evaluate the input port... and failed)

Upvotes: 1

Related Questions