Dynamics API Reference

This page documents ``ManipulaPy.dynamics``, the module that adds full rigid-body dynamics to :pyclass:`~ManipulaPy.kinematics.SerialManipulator`.

Tip

Looking for a conceptual tour? See Dynamics User Guide.

Quick Navigation

ManipulatorDynamics Class

class ManipulaPy.dynamics.ManipulatorDynamics(M_list, omega_list, r_list, b_list, S_list, B_list, Glist)[source]

Bases: SerialManipulator

Inheritance: derives from :pyclass:`~ManipulaPy.kinematics.SerialManipulator` and therefore exposes all forward-kinematics & Jacobian helpers.

Constructor

Parameters:
__init__(M_list, omega_list, r_list, b_list, S_list, B_list, Glist)[source]

Initialize the class with the given parameters.

Parameters:
  • M_list (list) – A list of M values.

  • omega_list (list) – A list of omega values.

  • r_list (list, optional) – A list of r values. Defaults to None.

  • b_list (list, optional) – A list of b values. Defaults to None.

  • S_list (list, optional) – A list of S values. Defaults to None.

  • B_list (list, optional) – A list of B values. Defaults to None.

  • G_list (list, optional) – A list of G values. Defaults to None.

  • joint_limits (list, optional) – A list of joint limits. Defaults to None.

  • Glist (List[ndarray[Any, dtype[float64]]] | ndarray[Any, dtype[float64]]) –

Return type:

None

Arguments

M_list

4 Γ— 4 home-configuration matrix \(\mathbf{M}\)

omega_list

3 Γ— n joint axes \(\boldsymbol{\omega}_i\)

r_list

3 Γ— n position vectors in the space frame

b_list

3 Γ— n position vectors in the body frame

S_list

6 Γ— n screw axes in the space frame

B_list

6 Γ— n screw axes in the body frame

Glist

list of 6 Γ— 6 spatial inertia matrices

Mass matrix \(\mathbf{M}(\boldsymbol{\theta})\)

mass_matrix(thetalist)[source]

Caching: results are memoised per joint configuration.

Parameters:

thetalist (ndarray[Any, dtype[float64]] | List[float]) –

Return type:

ndarray[Any, dtype[float64]]

Partial-derivative helper

partial_derivative(i, j, k, thetalist)[source]

Keep public API but serve results from the cached tensor so a single derivative never re-triggers mass matrix evaluation.

Parameters:
Return type:

float

Force components

velocity_quadratic_forces(thetalist, dthetalist)[source]
Parameters:
Return type:

ndarray[Any, dtype[float64]]

gravity_forces(thetalist, g=[0, 0, -9.81])[source]
Parameters:
Return type:

ndarray[Any, dtype[float64]]

Inverse Dynamics

inverse_dynamics(thetalist, dthetalist, ddthetalist, g, Ftip)[source]
Parameters:
Return type:

ndarray[Any, dtype[float64]]

Forward Dynamics

forward_dynamics(thetalist, dthetalist, taulist, g, Ftip)[source]
Parameters:
Return type:

ndarray[Any, dtype[float64]]

partial_derivative(i, j, k, thetalist)[source]

Keep public API but serve results from the cached tensor so a single derivative never re-triggers mass matrix evaluation.

Parameters:
Return type:

float

Full Equations

Inverse dynamics

\[\boldsymbol{\tau}\;=\; \mathbf{M}\!\bigl(\boldsymbol{\theta}\bigr)\, \ddot{\boldsymbol{\theta}} \;+\; \mathbf{C}\!\bigl(\boldsymbol{\theta},\dot{\boldsymbol{\theta}}\bigr)\, \dot{\boldsymbol{\theta}} \;+\; \mathbf{G}\!\bigl(\boldsymbol{\theta}\bigr) \;+\; \mathbf{J}^{\mathsf{T}}\!\bigl(\boldsymbol{\theta}\bigr)\, \mathbf{F}_{\text{ext}}\]

Forward dynamics

\[\ddot{\boldsymbol{\theta}} \;=\; \mathbf{M}^{-1}\!\bigl(\boldsymbol{\theta}\bigr) \Bigl( \boldsymbol{\tau} \;-\; \mathbf{C}\!\bigl(\boldsymbol{\theta},\dot{\boldsymbol{\theta}}\bigr)\, \dot{\boldsymbol{\theta}} \;-\; \mathbf{G}\!\bigl(\boldsymbol{\theta}\bigr) \;-\; \mathbf{J}^{\mathsf{T}}\!\bigl(\boldsymbol{\theta}\bigr)\, \mathbf{F}_{\text{ext}} \Bigr)\]

Usage Examples

Basic set-up

import numpy as np
from ManipulaPy.urdf_processor import URDFToSerialManipulator

# Load a URDF and grab its pre-built dynamics model
processor = URDFToSerialManipulator("robot.urdf")
dynamics  = processor.dynamics        # instance of ManipulatorDynamics

Mass matrix

M = dynamics.mass_matrix([0.1, 0.2, 0.3, 0, 0, 0])

Individual force terms

q   = np.array([0.1, 0.2, 0.3, 0, 0, 0])
dq  = np.array([0.05, 0.1, 0, 0, 0, 0])

C   = dynamics.velocity_quadratic_forces(q, dq)
G   = dynamics.gravity_forces(q)

Inverse dynamics

ddq = np.array([1.0, 0.5, 0, 0, 0, 0])
tau = dynamics.inverse_dynamics(q, dq, ddq,
                                g=[0, 0, -9.81],
                                Ftip=[0, 0, -10, 0, 0, 0])

Forward dynamics

ddq_sim = dynamics.forward_dynamics(
    q, dq, tau,
    g=[0, 0, -9.81],
    Ftip=[0, 0, 0, 0, 0, 0]
)

Key Features

  • Automatic caching of expensive mass-matrix evaluations

  • Complete force model (Coriolis, centrifugal, gravity, externals)

  • Gravity override for moon/Mars/zero-g simulations

  • Joint-limit aware helpers inherited from kinematics

  • Designed for GPU – the same formulas power the CUDA kernels

Troubleshooting

Large torques? Check your gravity vector and link inertias. Singularities? Watch the Jacobian condition number (see Kinematics guide). Slow first call? Numba JIT compiles on demand; subsequent calls are much faster.

See Also