newton.ik.IKSolver#

class newton.ik.IKSolver(model, n_problems, objectives, *, optimizer=IKOptimizer.LM, jacobian_mode=IKJacobianType.AUTODIFF, sampler=IKSampler.NONE, n_seeds=1, noise_std=0.1, rng_seed=12345, lambda_initial=0.1, lambda_factor=2.0, lambda_min=1e-5, lambda_max=1e10, rho_min=1e-3, history_len=10, h0_scale=1.0, line_search_alphas=None, wolfe_c1=1e-4, wolfe_c2=0.9)[source]#

Bases: object

High-level inverse-kinematics front end with optional multi-seed sampling.

IKSolver expands each base problem into one or more candidate seeds, delegates optimization to IKOptimizerLM or IKOptimizerLBFGS, and keeps the lowest-cost candidate for each base problem.

Parameters:
  • model (Model) – Shared articulation model.

  • n_problems (int) – Number of base IK problems solved together.

  • objectives (Sequence[IKObjective]) – Ordered IK objectives shared by all problems.

  • optimizer (IKOptimizer | str) – Optimizer backend to use.

  • jacobian_mode (IKJacobianType | str) – Jacobian backend to use inside the optimizer.

  • sampler (IKSampler | str) – Initial-seed sampling strategy.

  • n_seeds (int) – Number of candidate seeds generated per base problem.

  • noise_std (float) – Standard deviation used by GAUSS [m or rad].

  • rng_seed (int) – Seed for stochastic samplers.

  • lambda_initial (float) – Initial LM damping factor.

  • lambda_factor (float) – LM damping update factor.

  • lambda_min (float) – Minimum LM damping value.

  • lambda_max (float) – Maximum LM damping value.

  • rho_min (float) – Minimum LM acceptance ratio.

  • history_len (int) – Number of correction pairs retained by L-BFGS.

  • h0_scale (float) – Initial inverse-Hessian scale for L-BFGS.

  • line_search_alphas (Sequence[float] | None) – Candidate line-search step sizes for L-BFGS.

  • wolfe_c1 (float) – Armijo constant for the L-BFGS line search.

  • wolfe_c2 (float) – Curvature constant for the L-BFGS line search.

__init__(model, n_problems, objectives, *, optimizer=IKOptimizer.LM, jacobian_mode=IKJacobianType.AUTODIFF, sampler=IKSampler.NONE, n_seeds=1, noise_std=0.1, rng_seed=12345, lambda_initial=0.1, lambda_factor=2.0, lambda_min=1e-5, lambda_max=1e10, rho_min=1e-3, history_len=10, h0_scale=1.0, line_search_alphas=None, wolfe_c1=1e-4, wolfe_c2=0.9)#
reset()#

Reset optimizer state, selected seeds, and the sampler RNG.

step(joint_q_in, joint_q_out, iterations=50, step_size=1.0)#

Solve all base problems and write the best result for each one.

Parameters:
  • joint_q_in (array(ndim=2, dtype=float32)) – Input joint coordinates [m or rad] for the base problems, shape [n_problems, joint_coord_count].

  • joint_q_out (array(ndim=2, dtype=float32)) – Output joint coordinates [m or rad] for the selected solution of each base problem, shape [n_problems, joint_coord_count]. It may alias joint_q_in.

  • iterations (int) – Number of optimizer iterations to run for each sampled seed.

  • step_size (float) – Unitless LM step scale. Ignored by the L-BFGS backend.

property costs: array(ndim=1, dtype=float32)#

Expanded per-seed objective costs from the most recent solve.

property joint_q: array(ndim=2, dtype=float32)#

Expanded joint-coordinate buffer that stores all sampled seeds.