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
RobotModelowns the immutable full URDF model, whileRobotStatecarries a complete named-joint configuration. - A
KinematicGroupdeclares ordered active joints, a base frame, one or more tip frames, and optional permanently locked joints. KinematicsContextowns mutable Pinocchio evaluation storage. Contexts are per-thread; each IK solve creates and reuses one private context.IKRequestgroups the seed, targets, full context state, dynamic fixed joints, options, and an optional state-validity callback.KinematicsSolveris the backend-independent solver protocol implemented byPinocchioDlsSolverandPinocchioBoundedLeastSquaresSolver.- Public joint vectors always follow the caller-declared group order, independently of Pinocchio's internal
q/vlayout. - FK returns
T_base_tip; Jacobians are expressed in base-aligned coordinates with linear rows followed by angular rows. PinocchioDlsSolverperforms one deterministic seed-based solve. It does not perform random restarts or silently accept approximate results.PinocchioBoundedLeastSquaresSolverminimizes 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.
Metadata
Release files for forge-kinematics 2.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| forge_kinematics-2.0.0.tar.gz | 32.3 kB | Without provenance | Details for forge_kinematics-2.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| forge_kinematics-2.0.0-py3-none-any.whl | Python 3 | none | any | Details for forge_kinematics-2.0.0-py3-none-any.whl |
Total release size: 70.4 kB
Release files / forge_kinematics-2.0.0.tar.gz
| Download URL | forge_kinematics-2.0.0.tar.gz |
|---|---|
| Size | 32.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cf9f2cef261db3a1de918cff6de271a9801dab7ca2ba6a4c1c470d8f8dbd08f0
|
|
BLAKE2b-256 checksum How to use checksums |
03d1ebbe84e3d11b737f67e048ba3b8736ef9fcb83c04bf115d588d398bf1fdb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.9 {"installer":{"name":"uv","version":"0.12.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","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.0.0-py3-none-any.whl
| Download URL | forge_kinematics-2.0.0-py3-none-any.whl |
|---|---|
| Size | 38.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
eba0d7a248f474509f1e9bed1d1c00b56dcab3bfd751570a80892e7b59ca3a48
|
|
BLAKE2b-256 checksum How to use checksums |
b9e3c65782012650d1865c431462e5e71470ec4e211a4c32a3fca1a700a638a5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.9 {"installer":{"name":"uv","version":"0.12.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","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.0.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.