Skip to main content

Fast 6-DOF Inverse Kinematics and Rigid Body Dynamics (C++ accelerated)

Project description

robot-toolkit

CI codecov Python License

Fast 6-DOF serial manipulator toolkit with IK, rigid body dynamics, trajectory planning, collision detection, RRT* path planning, and URDF parsing. C++ accelerated.

Key features:

  • DH parameter forward kinematics
  • Damped least-squares IK (Levenberg-Marquardt)
  • Geometric Jacobian computation
  • Rigid body dynamics (RNEA, CRBA)
  • Trajectory planning (linear, cubic, quintic, trapezoidal, S-curve, Cartesian, waypoints)
  • Collision detection (sphere, box, capsule)
  • RRT* path planning
  • URDF parser
  • 3D visualization (matplotlib + meshcat)
  • Hardware abstraction layer
  • C++ extensions (137x faster IK, 358x faster dynamics)

Quick Start

pip install -e .

# Run tests
pytest tests/ -v

Usage

from robot_ik import six_dof_articulated
import numpy as np

robot = six_dof_articulated()

# Define target pose as 4x4 homogeneous transform
target = np.array([
    [0, -1,  0, 0.5],
    [0,  0, -1, 0.2],
    [1,  0,  0, 0.4],
    [0,  0,  0, 1.0],
])

# Solve IK
success, joint_angles, iterations, errors = robot.ik_solve(target)
print(f"Solved in {iterations} iterations, angles: {joint_angles}")

# Verify
T = robot.forward_kinematics(joint_angles)
print(f"Position error: {np.linalg.norm(T[:3,3] - target[:3,3]):.6f} m")

Custom Robot

from robot_ik import RobotModel, DHParam
import numpy as np

my_robot = RobotModel([
    DHParam(a=0,   alpha=-np.pi/2, d=0.35, theta=0),
    DHParam(a=0.6, alpha=0,        d=0,    theta=0),
    DHParam(a=0.1, alpha=-np.pi/2, d=0,    theta=0),
    DHParam(a=0,   alpha=np.pi/2,  d=0.4,  theta=0),
    DHParam(a=0,   alpha=-np.pi/2, d=0,    theta=0),
    DHParam(a=0,   alpha=0,        d=0.08, theta=0),
], joint_limits=[(-3.14, 3.14)] * 6)

Performance

Metric Value
Avg solve time ~3 ms
P50 solve time ~2 ms
P95 solve time ~8 ms
Typical iterations 5-15
Position accuracy <0.1 mm
Orientation accuracy <0.001 rad

Benchmarked on 6-DOF articulated robot, 200 random target poses.

Project Structure

src/robot_ik/               # Source (src layout)
├── __init__.py             # Backward-compat re-exports
├── ik/                     # IK solver + C++ wrapper
├── dynamics/               # Rigid body dynamics
├── trajectory/             # Trajectory planning
├── collision/              # Collision detection
├── path_planning/          # RRT* path planning
├── urdf/                   # URDF parsing
├── visualization/          # matplotlib + meshcat
└── hardware/               # Hardware abstraction layer

tests/                       # Tests by module (67 tests)
csrc/                        # C++ extension sources
docs/tutorial/               # 8 standalone tutorials
examples/                    # Project demos

C++ Extension (137x faster)

python setup.py build_ext --inplace
from robot_ik.ik import FastIKSolver

solver = FastIKSolver(dh_params, joint_limits)
success, angles, iters, errors = solver.ik_solve(target_pose)
# Average: 0.09 ms (vs 12.6 ms pure Python)
Metric Python C++ Speedup
Avg solve 12.6 ms 0.09 ms 137x
P50 solve 5.4 ms 0.03 ms 180x
P95 solve 36.9 ms 0.56 ms 66x

License

MIT — see LICENSE file.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

robot_ik-0.3.0.tar.gz (49.4 kB view details)

Uploaded Source

File details

Details for the file robot_ik-0.3.0.tar.gz.

File metadata

  • Download URL: robot_ik-0.3.0.tar.gz
  • Upload date:
  • Size: 49.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for robot_ik-0.3.0.tar.gz
Algorithm Hash digest
SHA256 9e1b63a2564c37e2233cc71f97bb2afa56ddd66b6b4b387ac7fdf15e1d4551f4
MD5 4bb47caee82a00e82ce1f21953f06f26
BLAKE2b-256 401244425ecc36d4a4aa63e768747b69f29f302a717284c36ea962ebfb1b8164

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page