Unit 5: Inverse Kinematics
I. Orientation: Inverse Kinematics
Inverse kinematics (IK) determines the joint variables required to place a robot’s end-effector at a specified position and orientation. For a two-axis planar articulated robot, the problem is to calculate the two joint angles from a desired point ((x,y)), using the known link lengths (a_1) and (a_2). The same physical relationship can be expressed geometrically or systematically through the Denavit-Hartenberg (DH) algorithm.
- Governing principle: The desired Cartesian position is converted into joint coordinates by solving the robot’s forward-kinematics equations in reverse.
- Robot structure: A planar two-axis arm has two revolute joints, commonly called the shoulder or base joint (\theta_1) and elbow joint (\theta_2).
- Coordinate convention: The base is placed at the origin, the (x)-axis is horizontal, and the (y)-axis is vertical. Positive joint angles are normally measured counterclockwise.
- Known quantities: Link lengths (a_1) and (a_2), target coordinates (x) and (y), and the permitted joint-angle ranges.
- Unknown quantities: The joint angles (\theta_1) and (\theta_2).
- Multiple solutions: A reachable point generally has two configurations: elbow-up and elbow-down.
- Reachability condition: The target must satisfy
[
|a_1-a_2| \leq r \leq a_1+a_2,
]
where (r=\sqrt{x^2+y^2}) is the distance from the base to the target. - Practical convention: Real robot commands may use servo offsets, reversed directions, and degree units even though the mathematical derivation uses radians.
II. Geometric Approach to the Planar Arm
A. Inverse kinematics of two-axis planar articulated robot using geometric approach
The geometric approach treats the two links and the target point as a triangle, allowing the joint angles to be obtained from the cosine rule and basic trigonometry.
-
Target distance: The straight-line distance from the base to the target is
[
r=\sqrt{x^2+y^2}.
]
Here, (x) and (y) are target coordinates in the base frame, and (r) is measured in the same length unit as (a_1) and (a_2). -
Triangle formation: The links (a_1) and (a_2), together with the line from the base to ((x,y)), form a triangle. Its side lengths are (a_1), (a_2), and (r).
-
Elbow angle: Applying the cosine rule gives
[
\cos\theta_2=
\frac{x^2+y^2-a_1^2-a_2^2}{2a_1a_2}.
]
Therefore,
[
\theta_2=\operatorname{atan2}\left(\pm\sqrt{1-\cos^2\theta_2},\cos\theta_2\right).
]
The plus and minus signs produce the two elbow configurations. -
Shoulder angle: The angle from the positive (x)-axis to the target is
[
\alpha=\operatorname{atan2}(y,x).
]
The angle between the first link and the target line is
[
\beta=\operatorname{atan2}\left(a_2\sin\theta_2,\ a_1+a_2\cos\theta_2\right).
]
Hence,
[
\theta_1=\alpha-\beta.
] -
Meaning of
atan2: The two-argument function (\operatorname{atan2}(y,x)) preserves the correct quadrant. Using (\tan^{-1}(y/x)) alone can produce an incorrect shoulder angle when (x) is negative. -
Complete geometric solution:
TEXTr2 = x*x + y*y c2 = (r2 - a1*a1 - a2*a2) / (2*a1*a2) s2 = +/- sqrt(1 - c2*c2) theta2 = atan2(s2, c2) theta1 = atan2(y, x) - atan2(a2*s2, a1 + a2*c2)Here,
c2ands2are (\cos\theta_2) and (\sin\theta_2). The+value gives one elbow posture and the-value gives the other. -
Worked example: For (a_1=10\text{ cm}), (a_2=8\text{ cm}), and target ((x,y)=(12,6)\text{ cm}),
[
r^2=12^2+6^2=180,
]
[
\cos\theta_2=\frac{180-100-64}{160}=0.1.
]
Thus, (\theta_2\approx\pm84.3^\circ). For the positive-sine solution,
[
\theta_1=\operatorname{atan2}(6,12)-
\operatorname{atan2}(8\sin84.3^\circ,10+8\cos84.3^\circ),
]
giving approximately (\theta_1= -7.1^\circ). The negative-sine solution produces the corresponding elbow-down posture.
B. Reachability and solution selection
The geometric solution is useful only when the target lies inside the arm’s annular workspace and the resulting angles are acceptable for the hardware.
- Outer boundary: The maximum reach is (a_1+a_2), occurring when both links are fully extended.
- Inner boundary: If (a_1\neq a_2), the minimum reach is (|a_1-a_2|), occurring when the links fold over one another.
- Unreachable target: If
[
\left|\frac{x^2+y^2-a_1^2-a_2^2}{2a_1a_2}\right|>1,
]
no real elbow angle exists. - Numerical tolerance: Due to sensor or floating-point error, a value such as (1.000001) may be clamped to (1), but a substantially larger value indicates an invalid target.
- Configuration choice: The controller selects elbow-up or elbow-down according to joint limits, obstacle clearance, and the previous arm position.
- Singular posture: When (\sin\theta_2=0), the arm is fully stretched or folded. Small Cartesian movements can then require large changes in joint angles.
III. DH Algorithm for Inverse Kinematics
A. DH algorithm
The Denavit-Hartenberg algorithm represents a serial robot as a sequence of homogeneous transformations, providing a systematic route from joint variables to the end-effector pose and from that pose to inverse-kinematic equations.
-
Purpose: DH notation standardizes the placement of coordinate frames on robot links so that every joint transformation uses four parameters.
-
DH parameters: For link (i), the parameters are:
- (a_i): link length, measured along (x_i).
- (\alpha_i): link twist, the rotation about (x_i).
- (di): link offset, measured along (z{i-1}).
- (\thetai): joint angle, the rotation about (z{i-1}).
-
Standard DH transformation: The transformation from frame (i-1) to frame (i) is
[
{}^{i-1}T_i=
R_z(\theta_i)T_z(d_i)T_x(a_i)R_x(\alpha_i).
]
In matrix form,
[
{}^{i-1}T_i=
\begin{bmatrix}
c_i&-si c{\alpha i}&si s{\alpha i}&a_i c_i\
s_i&ci c{\alpha i}&-ci s{\alpha i}&a_i si\
0&s{\alpha i}&c_{\alpha i}&d_i\
0&0&0&1
\end{bmatrix},
]
where (c_i=\cos\theta_i), (s_i=\sin\thetai), (c{\alpha i}=\cos\alphai), and (s{\alpha i}=\sin\alpha_i). -
Planar simplification: For two revolute axes perpendicular to the (x)-(y) plane, (d_1=d_2=0) and (\alpha_1=\alpha_2=0). The transformations reduce to
[
{}^0T_1=R_z(\theta_1)T_x(a_1),\qquad
{}^1T_2=R_z(\theta_2)T_x(a_2).
] -
Forward position from DH multiplication:
[
{}^0T_2=
\begin{bmatrix}
\cos(\theta_1+\theta_2)&-\sin(\theta_1+\theta_2)&0&
a_1\cos\theta_1+a_2\cos(\theta_1+\theta_2)\
\sin(\theta_1+\theta_2)&\cos(\theta_1+\theta_2)&0&
a_1\sin\theta_1+a_2\sin(\theta_1+\theta_2)\
0&0&1&0\
0&0&0&1
\end{bmatrix}.
]
The final column gives the end-effector position. -
Inverse step: Equating the final-column entries to the target gives
[
x=a_1\cos\theta_1+a_2\cos(\theta_1+\theta_2),
]
[
y=a_1\sin\theta_1+a_2\sin(\theta_1+\theta_2).
]
Eliminating (\theta_1) produces the same cosine-rule expression for (\theta_2), followed by theatan2expression for (\theta_1).
B. DH algorithm with planar joint conventions
Correct frame assignment is essential because an incorrect axis or link-length convention changes the resulting equations even when the algebra is performed correctly.
- Joint axes: For a planar revolute arm, each (z)-axis is perpendicular to the plane of motion and passes through its associated joint.
- Frame origins: Frame ({0}) is attached to the base joint; frame ({1}) is attached to the elbow joint; frame ({2}) is attached to the end-effector or wrist reference point.
- Link parameters: With standard DH placement, the two physical link lengths appear as (a_1) and (a_2). Their measured values must include the actual distance between joint axes.
- Angle zero: The mathematical zero angle must be related to the physical servo zero. A calibration offset (\deltai) may be required:
[
\theta{i,\text{command}}=\theta_{i,\text{mathematical}}+\delta_i.
] - Orientation information: A two-axis planar arm controls (x), (y), and the tool orientation (\phi=\theta_1+\theta_2), but only two independent joint variables are available. Therefore, a complete pose cannot generally be prescribed arbitrarily; position or position plus a dependent orientation must be specified.
- Verification: Substitute the calculated angles into the DH forward equations. The position error is
[
e=\sqrt{(x-x_d)^2+(y-y_d)^2},
]
where ((x_d,y_d)) is the desired point and ((x,y)) is the computed point.
IV. Orangewood Robotic Arm
A. Orangewood Robotic Arm
The Orangewood Robotic Arm provides a physical platform for implementing and validating inverse kinematics by mapping calculated joint angles to motor commands and comparing the resulting end-effector position with the desired coordinates.
-
Laboratory purpose: The arm demonstrates the complete chain: measure geometry, define a target, calculate IK, command joints, and observe positioning error.
-
Model selection: For the two-axis planar experiment, isolate the shoulder and elbow revolute joints. Keep the base orientation, gripper orientation, and any out-of-plane motion fixed.
-
Required measurements: Measure (a_1) from the shoulder-axis center to the elbow-axis center and (a_2) from the elbow-axis center to the selected end-effector reference point.
-
Coordinate calibration: Establish the base origin and record the mathematical zero positions. A camera, ruler, or marked workspace can be used to identify ((x,y)) in centimetres or millimetres.
-
Command conversion: Convert radians to degrees before sending commands if the arm interface expects degrees:
[
\theta{\deg}=\theta{\rad}\frac{180}{\pi}.
]
Apply servo offsets and direction reversals after calculating the mathematical angles. -
Safe operation: Test targets inside the reachable workspace and within the manufacturer’s joint limits. Begin with low-speed motion and keep the gripper clear of obstructions.
-
Practical algorithm:
TEXTmeasure a1, a2 define target x, y compute c2 = (x*x + y*y - a1*a1 - a2*a2)/(2*a1*a2) reject target if c2 < -1 or c2 > 1 choose s2 = +sqrt(1-c2*c2) or -sqrt(1-c2*c2) theta2 = atan2(s2, c2) theta1 = atan2(y, x) - atan2(a2*s2, a1+a2*c2) convert angles to the arm's command convention enforce joint limits move gradually and measure the final position -
Error sources: Differences between theoretical and actual positions arise from inaccurate link measurements, backlash, servo resolution, flexible links, frame misalignment, gripper offset, and incorrect zero-angle calibration.
-
Performance measure: Compare the measured point ((x_m,y_m)) with the target using
[
e_m=\sqrt{(x_m-x_d)^2+(y_m-y_d)^2}.
]
A small (e_m) indicates agreement between the IK model and the physical arm. -
Geometric versus DH implementation: The geometric method is faster to derive and visualize for a two-link planar arm. DH notation is more systematic and extends naturally to robots with additional joints, offsets, and nonparallel axes.
-
Limitations: The two-axis model does not represent every Orangewood arm joint, tool offset, mechanical compliance, or three-dimensional motion. A complete model must add the remaining joints and their DH parameters when those motions are used.
Did this save you a night before the exam?
LPU Notes is free, and it stays free. Ads cover part of the server bill. The rest comes out of a student's own pocket: the domain, the storage, and keeping the site up through the weeks everyone needs it at once.
The payment button didn't load. An ad blocker or a filtered network is the usual reason. to try again.
Nothing here is ever locked, and nothing unlocks. Chip in only if it was worth it. What it pays for →