Shubham Vyas
Shubham Vyas

Reputation: 165

How to create Polynomial Trajectories of Linear/Affine Systems in Python? i.e Time varying A and B Matrices

I am trying to create a Trajectory of a linear system for use in TrajectoryAffineSystem. But I am not able to understand the type of NumPy arrays needed for this.

For a simple Pendulum system, the state trajectory is a 2xN NumPy array where row 1 is theta, row 2 is theta_dot, and column k is the state at time t[k]. This NumPy array is clear/easy to create. Similarly, systems with a 1-D state vector are easy to create. However, this is not as clear when the state matrix itself is a 2D matrix.

For a linear pendulum system, the A matrix is a 2x2 matrix and A[k] is the (linearized) state at t[k]. Which type of NumPy array should then be used for representing this A[0-N]? Is it 2x2xN or Nx2x2 or another way of representing the time-varying linear dynamics that can be used to create an object of the Trajectory class?

Reproduction of the problem on google colab here

Upvotes: 1

Views: 206

Answers (1)

Russ Tedrake
Russ Tedrake

Reputation: 5533

You cannot pass a numpy array directly into the TrajectoryAffineSystem constructor. Those constructors need a trajectory object, for instance a PiecewisePolynomial see here. There are a number of static methods on PiecewisePolynomial, like FirstOrderHold, that will provide the semantics you need to go from a list of A matrices into a trajectory.

Upvotes: 1

Related Questions