This project provides tools to compute the forward kinematics of serial robotic manipulators using Denavit-Hartenberg (DH) parameters. It supports both numerical and symbolic calculations, making it useful for both simulation and analytical studies.
- Compute forward kinematics numerically using NumPy
- Compute forward kinematics symbolically using SymPy
- Unified class interface for both calculation types
- Example scripts for quick testing
forward_kinematics_dh.py: Numeric DH forward kinematics functions (NumPy)forward_kinematics_dh_symbolic.py: Symbolic DH forward kinematics functions (SymPy)forward_kinematics_dh_class.py: Unified class with both numeric and symbolic methodsexample.py: Example usage of numeric and symbolic functions (separate functions)example2.py: Example usage of the unified class for both numeric and symbolic calculations
- Clone the repository
git clone <your-repo-url> cd dh_forward_kinematics_python
- Install dependencies This project requires
numpyandsympy. Install them with:pip install numpy sympy
- Run examples
- For basic function usage:
python example.py
- For class-based usage:
python example2.py
- For basic function usage:
- Numeric calculation:
- Provide a list of DH parameters (theta, d, a, alpha) for each joint as numbers.
- The code computes the transformation matrix using NumPy.
- Symbolic calculation:
- Provide DH parameters as SymPy symbols or expressions.
- The code computes the transformation matrix symbolically, allowing for analytical manipulation.
- Unified class:
- The
ForwardKinematicsDHclass provides bothnumeric()andsymbolic()static methods for easy switching between calculation types.
- The
from forward_kinematics_dh_class import ForwardKinematicsDH import numpy as np import sympy as sp # Numeric dh_params = [[np.pi/4, 0, 1, 0], [np.pi/4, 0, 1, 0]] H = ForwardKinematicsDH.numeric(dh_params) print(H) # Symbolic th1, th2 = sp.symbols('th1 th2') a1, a2 = sp.symbols('a1 a2') dh_params_sym = [[th1, 0, a1, 0], [th2, 0, a2, 0]] H_sym = ForwardKinematicsDH.symbolic(dh_params_sym) sp.pprint(H_sym) MIT