Dynamics API Reference — ManipulaPy 1.1.0 Documentation
Description: This page documents``ManipulaPy.dynamics``, the module that adds full rigid-body dynamics to:pyclass:`~ManipulaPy.kinematics.SerialManipulator`. Unknown interpreted text role “pyclass”. Quick Navig...

# Dynamics API Reference

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

System Message: ERROR/3 (/home/abo/Desktop/ManipulaPy/docs/source/api/dynamics.rst, line 7); backlink

Unknown interpreted text role “pyclass”.

Tip

Looking for a conceptual tour? See Dynamics User Guide.

## Quick Navigation

### ManipulatorDynamics Class

## 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

System Message: WARNING/2 (/home/abo/Desktop/ManipulaPy/docs/source/api/dynamics.rst, line 116)

Title overline too short.

    -------------
    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

- Kinematics API Reference – forward kinematics & Jacobians

- Control API Reference – model-based controllers that rely on this API

- Path Planning API Reference – trajectory generation with dynamics constraints

- Dynamics User Guide – physics background and best-practice tips