Skip to main content

forge-kinematics

Deterministic URDF forward kinematics, geometric Jacobians, and Pinocchio-based inverse kinematics with damped-least-squares and bounded nonlinear least-squares backends.

Scope

The package is a model and solver library. It does not depend on ROS, Dora, robot drivers, teleoperation policies, collision checking, or motion execution. The DLS solver uses Pinocchio's numerical API and NumPy directly. The bounded least-squares solver adds an optional SciPy dependency. Neither backend requires CasADi or Conda.

  • A RobotModel owns the immutable full URDF model, while RobotState carries a complete named-joint configuration.
  • A KinematicGroup declares ordered active joints, a base frame, one or more tip frames, and optional permanently locked joints.
  • KinematicsContext owns mutable Pinocchio evaluation storage. Contexts are per-thread; each IK solve creates and reuses one private context.
  • IKRequest groups the seed, targets, full context state, dynamic fixed joints, options, and an optional state-validity callback.
  • KinematicsSolver is the backend-independent solver protocol implemented by PinocchioDlsSolver and PinocchioBoundedLeastSquaresSolver.
  • Public joint vectors always follow the caller-declared group order, independently of Pinocchio's internal q/v layout.
  • FK returns T_base_tip; Jacobians are expressed in base-aligned coordinates with linear rows followed by angular rows.
  • PinocchioDlsSolver performs one deterministic seed-based solve. It does not perform random restarts or silently accept approximate results.
  • PinocchioBoundedLeastSquaresSolver minimizes the same weighted pose residual with analytic Pinocchio Jacobians, per-joint box constraints, optional neutral/seed regularization, and a strict function-evaluation budget.

The current release supports independent single-DoF revolute, continuous, and prismatic active joints. Floating, planar, mimic, collision-aware, and search IK are intentionally out of scope.

Install

From the Forge workspace:

uv sync --package forge-kinematics

Install the optional bounded least-squares backend with:

uv sync --package forge-kinematics --extra least-squares

The top-level forge meta package does not depend on forge-kinematics, so downstream projects opt into the Pinocchio dependency explicitly.

Distribution and platform support

Build both the wheel and source distribution from the Forge workspace root:

uv build --package forge-kinematics

The package uses the pin wheels published on PyPI. Those wheels are currently validated for Linux with glibc and for macOS; Windows and Linux with musl are not guaranteed. Neither Conda nor CasADi is required.

Example

import numpy as np

from forge_kinematics import (
    DlsConfig,
    IKOptions,
    IKRequest,
    PinocchioDlsSolver,
    PoseTarget,
    RobotModel,
)

model = RobotModel.from_urdf("robot.urdf")
arm = model.create_group(
    name="arm",
    joint_names=("joint1", "joint2", "joint3"),
    base_frame="base_link",
    tip_frames=("tool0",),
)

state = model.create_state()
context = model.create_context()
seed = arm.neutral_positions
current_pose = arm.forward(seed, state=state, context=context)
current_jacobian = arm.jacobian(seed, state=state, context=context)

target_pose = current_pose.copy()
target_pose[0, 3] += 0.05
target = PoseTarget(
    tip_frame="tool0",
    reference_frame="base_link",
    pose=target_pose,
    # xyz + rotation-vector axes; zero disables one task-space axis.
    task_weights=(1.0, 1.0, 1.0, 1.0, 0.0, 1.0),
    orientation_weight=0.1,
)
options = IKOptions(
    timeout_s=0.05,
    max_solution_joint_displacement=0.5,
)
dls_config = DlsConfig(
    max_iteration_joint_step=0.1,
    singularity_threshold=0.05,
    singularity_damping=0.2,
    joint_limit_avoidance_weight=0.05,
)
request = IKRequest(
    seed=seed,
    targets=(target,),
    options=options,
    context_state=state,
    # Dynamic hard constraints are applied per solve, without rebuilding the group.
    fixed_joint_positions={"joint1": 0.0},
    # Collision or application constraints remain outside the solver.
    state_validator=lambda candidate: True,
)
result = PinocchioDlsSolver(arm, config=dls_config).solve(request)
if not result.success:
    raise RuntimeError(result.message)
commanded_positions = result.solution

task_weights are per-axis and are multiplied by the overall position and orientation weights. This supports position-only, orientation-only, or partially constrained poses. Backend-independent request controls such as timeout, tolerances, approximate-result policy, and total displacement live in IKOptions. DLS algorithm controls such as damping, iteration step, singularity handling, and null-space avoidance live in the solver's immutable DlsConfig. max_iteration_joint_step limits each numerical update, while max_solution_joint_displacement independently limits each joint's total tangent displacement from the effective seed. The solver reports adaptive damping, singularity, joint-limit margin, and the null-space avoidance activation coefficient. Limit avoidance never moves an already satisfied target away from its seed.

Failed solves return no solution; callers must explicitly opt into approximate_solution through IKOptions. Dynamic fixed_joint_positions remain present in the caller-ordered result but are removed from the IK Jacobian for that solve. A converged candidate rejected by the validator returns REJECTED_BY_VALIDATOR and is never exposed as a solution; rejected approximate candidates are omitted while preserving the solve's original failure status.

For bounded solves, construct BoundedLeastSquaresConfig with optional joint_position_bounds or native-unit joint_limit_margins. These interior bounds apply only to free joints; dynamic fixed joints are still checked against the URDF hard limits. Absolute joint_position_bounds are intentionally rejected for continuous joints because a linear interval is ambiguous across the wrap boundary; use IKOptions.max_solution_joint_displacement for a seed-relative manifold bound instead. A free seed outside the effective box is projected before optimization and reported through IKResult.seed_was_projected. regularization_weight penalizes displacement from the group's neutral posture, while smooth_weight penalizes displacement from the effective seed. max_nfev strictly bounds model kinematics evaluations and IKOptions.timeout_s provides an independent soft deadline; on failure, the opt-in approximate result is the evaluated feasible candidate with the lowest pose residual, not merely SciPy's final regularized state.

Every target names its reference_frame, which must equal the group's base frame; frame transforms stay in the adapter layer. IKResult.raw_* errors describe the complete pose difference, while active_* errors include only enabled task axes and determine convergence. timeout_s is a soft deadline: native Pinocchio or linear-algebra calls already in progress cannot be preempted.

Calibrated frames, tree buffer, and straight Cartesian lines (2.1+)

  • CalibratedFrameSpec & load_calibrated_frames: load calibrated sensor mounts (nominal_from_urdf residual or parent-relative extrinsic) from dicts, JSON, or YAML.
  • KinematicTreeBuffer: bounded monotonic JointState history resolving interpolated whole-body T_target_source transforms and continuous stationary-window checks.
  • RobustIK & plan_cartesian_line: bounded multi-seed IK and branch-jump-guarded straight Cartesian line interpolation (CartesianLineResult).

Metadata

Release files for forge-kinematics 2.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for forge-kinematics 2.1.0
File Size Uploaded Provenance Actions
forge_kinematics-2.1.0.tar.gz 50.5 kB Without provenance Details for forge_kinematics-2.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for forge-kinematics 2.1.0
File Interpreter ABI Platform Actions
forge_kinematics-2.1.0-py3-none-any.whl Python 3 none any Details for forge_kinematics-2.1.0-py3-none-any.whl

Total release size: 108.6 kB

Release files / forge_kinematics-2.1.0.tar.gz

Download URL forge_kinematics-2.1.0.tar.gz
Size 50.5 kB
Tags Source
SHA-256 checksum
How to use checksums
a783e17fa6177b42b8e5635784e77eedc8555e305994a1632ff6db414a6d89ac
BLAKE2b-256 checksum
How to use checksums
e8e711b9e1a74bf11c78aba5d6e87dd4eb814aed04af5d1f2230637da190481c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / forge_kinematics-2.1.0-py3-none-any.whl

Download URL forge_kinematics-2.1.0-py3-none-any.whl
Size 58.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8545346a0ccfbd98ae3ada57e9a0af8af3bf178fc7c4b9c3cbb11bff1a0ab86b
BLAKE2b-256 checksum
How to use checksums
16112ce7c286e556cae28f27edec135b5329c424e6e7b35bc364ca8217351f01
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for forge-kinematics 2.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page