model module

class dynamapp.model.Model(Imats: list, dhparams: list, gravity=-9.81, dampings: list = None)[source]

Bases: object

Base class definition for multi-joint models. This class supports only serial mechanisms. All algorithms are based on [1], and the Python implementation is inspired by [2].

Args:
  • dhparams: Model DH parameters.

  • Imats: Links' inertia tensors, provided as a list of JAX arrays.

  • q (np.ndarray): Joint position vector.

  • v (np.ndarray): Joint velocity vector.

  • a (np.ndarray): Joint acceleration vector.

  • dampings: List of joint damping coefficients.

  • gravity: Gravity vector applied to the system.

Examples:
>>> model = Model(Imats, dhparams, -9.81, dampings)  
References:

Note

This module needs better input validation for data, tensor sizes, and computation algorithms. It may be refactored in future versions.

damping_tensor() jax.numpy.ndarray[source]

Get the diagonal velocity damping matrix of size (ndof, ndof).

Returns:
jnp.ndarray: A diagonal matrix with damping values.

If no damping values are given, returns a zero matrix.

inertia_tensor(q)[source]

Computes the mass matrix M(q) for the system.

Returns:

jnp.ndarray: Mass matrix of shape (ndof, ndof).

Note

This implementation is based on the RNEA algorithm using the Jacobian tensor. It is not very robust and may change in future versions.

Todo

Implement the inertia tensor computation using the method described in: https://www.researchgate.net/publication/343098270_Analytical_Inverse_of_the_Joint_Space_Inertia_Matrix

coriolis_tensor(q, qp)[source]

Computes the Coriolis matrix C(q, qp) using automatic differentiation in JAX.

Args:

q (jnp.ndarray): Joint positions (ndof,) qp (jnp.ndarray): Joint velocities (ndof,)

Returns:

jnp.ndarray: Coriolis matrix C(q, qp) of shape (ndof, ndof)

gravity_torques(q: jax.numpy.ndarray = None)[source]

Computes the joints gravity torques given a configuration vector.

Args:
  • q : joints position vector (nq * 1)

Returns:
  • tau_g : numpy.ndarray.

generalized_forces(q=None, qp=None, qpp=None) jax.numpy.ndarray[source]

Compute the genralized forces for each link using the recursive netwon euler alogrithm.

Args:
  • q : Joints position vector. ( nq * 1 )

  • qp : Joints velocity vector. ( nq * 1 )

  • qpp : Joints acceleration vector. ( nq * 1 )

Returns:
  • f : (rotation + translation) compennat forces

generalized_torques(q=None, qp=None, qpp=None) jax.numpy.ndarray[source]

Return the genralized torques compennat using the recursive netwon euler alogrithm.

generalized_torque(i: int, q=None, qp=None, qpp=None) jax.numpy.ndarray[source]

Return the genralized torque for a given link i

full_forces(alpha: jax.numpy.array, beta: jax.numpy.array, gamma: jax.numpy.array, dampings, q=None, qp=None, qpp=None) jax.numpy.ndarray[source]

Compute the joint torques given the friction effects and damping

full_torques(alpha: jax.numpy.array, beta: jax.numpy.array, gamma: jax.numpy.array, dampings, q=None, qp=None, qpp=None) jax.numpy.ndarray[source]

Compute the joint torques given the friction effects and damping