From 9a9f993e7335eb7b1dee88501b8ae8d29cd91431 Mon Sep 17 00:00:00 2001 From: huxiaoyi-ovo Date: Tue, 3 Nov 2026 08:13:40 -0500 Subject: [PATCH] docs(ik): add a worked Panda IK example with one joint locked Addresses petercorke/robotics-toolbox-python#825. Co-authored-by: ChatGPT (OpenAI GPT-6) --- docs/source/IK/numerical.rst | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/docs/source/IK/numerical.rst b/docs/source/IK/numerical.rst index 660f93f96..821941047 100644 --- a/docs/source/IK/numerical.rst +++ b/docs/source/IK/numerical.rst @@ -261,3 +261,32 @@ In the following example, we create a :py:class:`~roboticstoolbox.models.URDF.Pa >>> ets = panda.ets() # Get the ETS >>> Tep = ets.fkine([0, -0.3, 0, -2.2, 0, 2, 0.7854]) # Make a goal pose >>> ets.ikine_LM(Tep) # Solve the IK problem + +.. rubric:: IK with a locked joint + +An arm with seven joints can still reach a six-dimensional end-effector pose +while one joint is held at a specified angle. :meth:`~roboticstoolbox.ETS.fixjoint` +replaces that joint by a constant transform and returns a new ETS; the original +robot and its seven-joint ETS are unchanged. The initial guess for IK has +only six coordinates, with the locked joint omitted. + +This example starts from a reachable Panda pose, locks joint 2 (counted from +zero), then solves the resulting six-joint IK problem. + +.. runblock:: pycon + + >>> import numpy as np + >>> import roboticstoolbox as rtb + >>> panda = rtb.models.ETS.Panda() + >>> ets = panda.ets() + >>> q_goal = np.array([0.2, -0.4, 0.3, -1.5, 0.25, 1.6, -0.2]) + >>> target = ets.fkine(q_goal) + >>> reduced = ets.fixjoint(2, q_goal[2]) + >>> reduced.n + 6 + >>> seed = np.delete(q_goal, 2) + 0.02 + >>> sol = reduced.ikine_LM(target, q0=seed) + >>> sol.success + True + >>> np.allclose(reduced.fkine(sol.q).A, target.A, atol=1e-5) + True