Skip to content

Set Kinematics Settings ​

SUMMARY

Set Kinematics Settings updates the active IK solver's stored settings (tolerance, time budget, iteration limits, TRAC-IK mode) for subsequent inverse_kinematics() calls.

The Skill ​

python
robot.set_kinematics_settings(timeout_s=0.02)

The Code ​

python
"""
Change the stored settings of the active IK solver, then solve IK with them.

Supports Universal Robots (UR), Epson, and virtual.

Usage:
    python set_kinematics_settings.py
"""

from loguru import logger

from telekinesis.synapse.robots.manipulators import universal_robots


def main():
    """Tighten the CLIK settings and solve IK with the updated solver."""

    #===================== Create Robot ==========================================
    robot = universal_robots.UniversalRobotsUR10E(name='UR10e')

    # An IK solver must be active before its settings can be changed
    robot.setup_kinematics_solver(solver="clik")
    logger.info(f"Settings before: {robot.get_kinematics_settings()}")

    # ==================== Run Skill ============================================
    # Omitted settings keep their stored values
    robot.set_kinematics_settings(timeout_s=0.1, eps=1e-5, it_max=2000)
    logger.info(f"Settings after: {robot.get_kinematics_settings()}")

    # Later IK calls use the updated settings without passing them again
    target_pose = [0.5, 0.2, 0.3, 180.0, 0.0, 0.0]
    try:
        q = robot.inverse_kinematics(target_poses=[target_pose])[0]
        if q is None:
            logger.error(f"No IK solution for {target_pose}")
            return
        logger.success(f"IK solution: {q}")

        # ================ Visualization (Optional) ==============================
        robot.set_joint_positions(joint_positions=q)
        robot.visualize_rerun(live=False)
    except (RuntimeError, TypeError, ValueError) as e:
        logger.error(f"IK failed: {type(e).__name__}: {e}")
    finally:
        robot.shutdown()


if __name__ == "__main__":
    main()

Running the Example ​

bash
python set_kinematics_settings.py

For all options:

bash
python set_kinematics_settings.py --help

Parameter Configuration ​

ParameterTypeDefaultDescription
epsfloatunchangedConvergence tolerance. Smaller values request tighter convergence.
timeout_sfloatunchangedIK time budget in seconds.
it_maxintunchangedMaximum iterations per CLIK attempt (clik, multi_start_clik).
dtfloatunchangedIntegration step of each CLIK joint update.
dampfloatunchangedDamping factor of the CLIK Jacobian pseudo-inverse.
tracik_solve_typestrunchangedTRAC-IK search mode, such as "Speed" or "Distance" (tracik only).

Returns ​

TypeDescription
NoneThe stored settings are updated. Omitted values remain unchanged.

Raises ​

ExceptionCondition
TypeErrorUnknown key or wrong value type
ValueErrorInvalid range, non-finite value, or an invalid TRAC-IK solve type
RuntimeErrorNo active solver, or the replacement solver cannot be constructed. A failed update leaves the settings and solver unchanged

How to Tune the Parameters ​

Select a solver with Setup Kinematics Solver first. Lengthen timeout_s or raise it_max when IK fails on hard targets; tighten eps only if you need more accuracy, since it makes convergence harder. Read the result back with Get Kinematics Settings.

Where to Use the Skill ​

  • Hard targets - Give IK more time near the edge of the workspace.
  • Speed-sensitive loops - Shorten the budget when a fast, approximate answer is enough.

When Not to Use the Skill ​