Robot.ik_NR
- Robot.ik_NR(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 using Newton-Raphson optimization
- Parameters:
Tep (
ndarray|SE3) – The desired end-effector pose (a single pose only, for a trajectory useikine_NR())end (
str|Link|Gripper|None) – the link considered as the end-effectorstart (
str|Link|Gripper|None) – the link considered as the base frame, defaults to the robots’s base frameq0 (
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 searchslimit (
int) – maximum number of search attemptstol (
float) – final error tolerancemask (
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 respectivelyjoint_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 inversepinv_damping (
float) – Damping factor for the pseudo-inversetool (
ndarray|SE3|None) – a static tool transformation matrix to apply to the end ofend; defaults to the robot’s ownself.toolif not given
- Returns:
an IKSolution containing joint coordinates
q,successflag,iterations,searchesandresidualerror value (reasonis always empty – this fast C++ solver doesn’t produce a granular failure reason string, unlikeikine_NR())- Return type:
Warning
This method needs the compiled C++ extension. It raises
RuntimeErrorif 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 assympy.pi/2, or a joint with anoffset, which the compiled code cannot use. In all of these cases useikine_NR(), which has none of these limits.sol = ets.ik_NR(Tep)are the joint coordinates (n) corresponding to the robot end-effector poseTepwhich is anSE3orndarrayobject. 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),
pinvmust be set toTrueThe return value
solis anIKSolutionwith fields:Field
Type
Description
qndarray(n)
joint coordinates in units of radians or metres
successbool
whether a solution was found
iterationsint
total number of iterations
searchesint
total number of searches
residualfloat
final value of cost function
reasonstr
always empty for this C++ solver
If
success == Falsetheqvalues will be valid numbers, but the solution will be in error. The amount of error is indicated by theresidual.Each iteration uses the Newton-Raphson optimisation method
\[\vec{q}_{k+1} = \vec{q}_k + {^0\mat{J}(\vec{q}_k)}^{-1} \vec{e}_k\]Examples
The following example gets a
pandarobot object, makes a goal poseTep, and then solves for the joint coordinates which result in the poseTepusing theik_NRmethod.>>> import roboticstoolbox as rtb >>> panda = rtb.models.Panda() >>> Tep = panda.fkine([0, -0.3, 0, -2.2, 0, 2, 0.7854]) >>> panda.ik_NR(Tep) IKSolution: q=[-1.523, -0.9951, 1.071, -2.125, 0.8918, 1.593, 0.1073], success=True, iterations=223, searches=16, residual=3.55e-09
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).
See also