Robot.ik_GN

Robot.ik_GN(Tep, end=None, start=None, q0=None, ilimit=30, slimit=100, tol=1e-06, mask=None, joint_limits=True, pinv=True, pinv_damping=0.0, tool=None)

Fast numerical inverse kinematics by Gauss-Newton optimization

Parameters:
  • Tep (ndarray | SE3) – The desired end-effector pose (a single pose only, for a trajectory use ikine_GN())

  • end (str | Link | Gripper | None) – the link considered as the end-effector

  • start (str | Link | Gripper | None) – the link considered as the base frame, defaults to the robots’s base frame

  • q0 (ndarray | None) – initial joint configuration (default to random valid joint configuration constrained by the joint limits of the robot)

  • ilimit (int) – maximum number of iterations per search

  • slimit (int) – maximum number of search attempts

  • tol (float) – final error tolerance

  • mask (ndarray | None) – a mask vector which weights the end-effector error priority. Corresponds to translation in X, Y and Z and rotation about X, Y and Z respectively

  • joint_limits (bool) – constrain the solution to being within the joint limits of the robot (reject solution with invalid joint configurations and perform another search up to the slimit)

  • pinv (int) – Use the pseudo-inverse instead of the normal matrix inverse

  • pinv_damping (float) – Damping factor for the pseudo-inverse

  • tool (ndarray | SE3 | None) – a static tool transformation matrix to apply to the end of end; defaults to the robot’s own self.tool if not given

Returns:

an IKSolution containing joint coordinates q, success flag, iterations, searches and residual error value (reason is always empty – this fast C++ solver doesn’t produce a granular failure reason string, unlike ikine_GN())

Return type:

IKSolution

Warning

This method needs the compiled C++ extension. It raises RuntimeError if the extension is unavailable, for example in a pure-Python wheel or under Pyodide/JupyterLite, and if the sequence has a SymPy parameter, even a numeric one such as sympy.pi/2, or a joint with an offset, which the compiled code cannot use. In all of these cases use ikine_GN(), which has none of these limits.

sol = ets.ik_GN(Tep) are the joint coordinates (n) corresponding to the robot end-effector pose Tep which is an SE3 or ndarray object. This method can be used for robots with any number of degrees of freedom. This is a fast solver implemented in C++.

See the Inverse Kinematics Docs Page for more details and for a tutorial on numerical IK, see here.

Note

When using this method with redundant robots (>6 DoF), pinv must be set to True

The return value sol is an IKSolution with fields:

Field

Type

Description

q

ndarray(n)

joint coordinates in units of radians or metres

success

bool

whether a solution was found

iterations

int

total number of iterations

searches

int

total number of searches

residual

float

final value of cost function

reason

str

always empty for this C++ solver

If success == False the q values will be valid numbers, but the solution will be in error. The amount of error is indicated by the residual.

Each iteration uses the Gauss-Newton optimisation method

\[\begin{split}\vec{q}_{k+1} &= \vec{q}_k + \left( {\mat{J}(\vec{q}_k)}^\top \mat{W}_e \ {\mat{J}(\vec{q}_k)} \right)^{-1} \bf{g}_k \\ \bf{g}_k &= {\mat{J}(\vec{q}_k)}^\top \mat{W}_e \vec{e}_k\end{split}\]

where \(\mat{J} = {^0\mat{J}}\) is the base-frame manipulator Jacobian. If \(\mat{J}(\vec{q}_k)\) is non-singular, and \(\mat{W}_e = \mat{1}_n\), then the above provides the pseudoinverse solution. However, if \(\mat{J}(\vec{q}_k)\) is singular, the above can not be computed and the GN solution is infeasible.

Examples

The following example gets a panda robot object, makes a goal pose Tep, and then solves for the joint coordinates which result in the pose Tep using the ik_GN method.

>>> import roboticstoolbox as rtb
>>> panda = rtb.models.Panda()
>>> Tep = panda.fkine([0, -0.3, 0, -2.2, 0, 2, 0.7854])
>>> panda.ik_GN(Tep)
IKSolution: q=[-0.05341, -0.3011, 0.04819, -2.201, 0.01666, 2, 0.7724], success=True, iterations=53, searches=3, residual=8.46e-08

Notes

When using the this method, the initial joint coordinates \(q_0\), should correspond to a non-singular manipulator pose, since it uses the manipulator Jacobian.

References

  • J. Haviland, and P. Corke. “Manipulator Differential Kinematics Part I: Kinematics, Velocity, and Applications.” arXiv preprint arXiv:2207.01796 (2022).

  • J. Haviland, and P. Corke. “Manipulator Differential Kinematics Part II: Acceleration and Advanced Applications.” arXiv preprint arXiv:2207.01794 (2022).