model_state module
- class dynamapp.model_state.ModelState(Imats: list, dhparams: list, gravity=-9.81, dampings: list = None, x_init: jax.numpy.ndarray = None)[source]
Bases:
object
Base class for state space mutijoint models, these model are typically complex because, the base matrices A, B, C and D is a function of the state vector x. which is not the case for the classical state space model, these model are called state depend state space models, these property makes all derived equations (eg Riccati, observer, etc) to be state dependant as the following equation:
\[\begin{split}\begin{cases} x_{k+1} &= A(x_k) x_k + B(x_k) u_k + K e_k \\ y_k &= C(x_k) x_k + D(x_k) u_k + e_k \end{cases}\end{split}\]- Args:
model - multijoint base model
model_state_space - state space representation of the model
- Examples:
>>> model = ModelState(file_path, x_init) >>> y = model.output(x, u)
- output(x: jax.numpy.ndarray, u: jax.numpy.ndarray, e: jax.numpy.ndarray) jax.numpy.ndarray [source]
Compute the system output vector given the state vector x and the input vector u with repect to the equation :
\[y_k = C x_k + D u_k + e_k\]- Returns:
y_k - np.ndarray (2.ndof * 1) the output vector of the system at time t
- step(u: jax.numpy.ndarray = None, e: jax.numpy.ndarray = None) jax.numpy.ndarray [source]
Compute the output of the state-space model and returns it at time t+1 Updates the internal state of the model as well.
- Args:
u input vector
e : noise vector
- compute_eigvals(x: jax.numpy.ndarray) jax.numpy.ndarray [source]
Computes the system eigvalues at time t given the state vector x.
- lsim(u: jax.numpy.ndarray, e: jax.numpy.ndarray) jax.numpy.ndarray [source]
Simulate the system response with a given input u subject to the noise e Args:
u : input vector (ndof * NSamples)
e : noise vector (ndof * NSamples)
- Return:
xs : numpy-ndarry store iteration states vectors. ( 2.ndof * NSamples)
- compute_obs_matrix(x: jax.numpy.ndarray) jax.numpy.ndarray [source]
Compute the observaliblite matrix of the system at time t given the state vector x The observability matrix is given by the following equation:
\[O =[ C , CA, CA^2, ..., CA^{n-1}]\]- Args:
x : state vector (2.ndof * 1)
- Returns:
obs_matrix : numpy-ndarry (2.ndof * 2.ndof)