← Projects/P-10
ABB IRB120: kinematics and trajectory control
Two lab practicals of Industrial Robotics, in the first year of my master's at ICAI, in autumn 2024. In the first, ROB1, we modeled ABB's six-axis IRB120 with Denavit–Hartenberg parameters and wrote its forward kinematics and closed-form inverse kinematics in MATLAB, adapting the PUMA formulation from the course notes. A reachable pose has up to eight joint solutions, and three sign flags choose which one the inverse returns. In the second, ROB2, the robot held a pen and drew straight lines, and we compared the path error of joint-interpolated motion computed in MATLAB with the error measured on the board. Both ran on the lab's real IRB120. The lab group had four members, and I did nearly all of the work.
- 8
- joint solutions for a reachable pose: arm × elbow × wrist
- 2 × 10⁻¹¹ mm
- worst round-trip position error over 16,000 solutions
- 374 / 630 mm
- flange x / z with the upper arm vertical and the forearm horizontal
- 107 → 28 mm
- pen path off the line at midway, measured: one joint move vs. with one via point
01Modeling the arm
We started from the dimensioned drawing of the robot that came with the lab brief, placed the frames and described the IRB120 with Denavit–Hartenberg parameters: d1 = 290, a2 = 270, a3 = −70, d4 = 302 and d6 = 72 mm, with twists of −90°, 0, +90°, −90°, +90° and 0. The chain was built symbolically first. One MATLAB live script multiplies the six link transforms for any set of parameters, and a second copy fixes them to the IRB120's values. For the lab, this became two plain functions.
The forward function takes six joint angles in degrees. It returns the flange position in millimeters and its ZYX Euler angles, and treats the Ey = ±90° singularity as a separate case. With the upper arm vertical and the forearm horizontal, which is θ = (0, −90°, 180°, 0, 0, 0) in these D-H angles, it puts the flange at x = 374, z = 630 mm. ABB's own joint angles are offset by 90° on axis 2 and by 180° on axis 3, so the D-H angles had to be converted before jogging the real arm.
02Eight answers to one pose
The inverse function goes the other way: a target position and ZYX Euler angles in, six joint angles out. As the lab brief required, it adapts the closed-form PUMA solution from the course notes to the IRB120 by separating the wrist from the arm:
- Step back 72 mm from the flange along the approach vector to find the wrist center.
- Get θ1 from the bearing of the wrist center. Get θ2 and θ3 from the law of cosines, on the triangle formed by the 270 mm upper arm and the 310 mm effective forearm, √(70² + 302²).
- Get θ4–θ6 from the remaining orientation, by projecting the target's n, s and a vectors onto the frames of joints 3 to 5.
Three ±1 flags pick the branch: arm right or left, elbow up or down, wrist flipped or not. Together they cover all eight solutions of a reachable pose. The function returns one solution per call and does not check joint limits. It rejects malformed inputs. At the wrist singularity, where joint 4's axis lines up with the approach vector, it warns and sets θ4 = θ5 = 0.
These two functions were the pre-lab work for the practical. In the lab session we used them on our assigned test points (two forward, one inverse) and compared the results with RobotStudio and the real IRB120, and they matched both. The first forward test, θ = (0, −45°, −180°, 0, 0, 0), puts the flange at (504.87, 0, 265.96) mm. The group also discussed whether the inverse point could be reached in a different configuration. For this page, I ran a round-trip check on the original code in MATLAB: 2,000 random joint configurations with all eight flag combinations each, 16,000 solutions in total. Fed back through the forward function, every solution lands on its starting pose. The worst position error is 2 × 10−11 mm.
03Drawing a straight line
The second practical, in November 2024, put a pen on the flange. The holder places the pen tip 43 mm (L) and 91 mm (H) from the flange, with the tool frame turned 90° from the flange frame. I added that tool transform to both kinematics functions, plus two helpers that convert a pose between tool and flange coordinates.
The task was a straight line on the board, from A = (360, −250, 0) to B = (500, 250, 0) mm. In a joint move, each joint goes from its start angle to its end angle and the pen traces a curve instead of the line. The course's bounded-deviation method (BDJP) measures that curve at the midpoint: average the joint angles of the two ends, run the forward kinematics, and compare the result with the true Cartesian midpoint. If the gap is too large, the Cartesian midpoint becomes a via point and each half is checked the same way.
- Orientation midpoint: half of the axis-angle rotation between the two end orientations, a slerp at one half.
- Joint midpoint: a circular mean of each joint's two angles (atan2 of the mean sine and cosine), so angles on either side of ±180° average correctly.
- Not required by the brief: a recursive function that keeps bisecting segments until every joint-interpolated midpoint is within 1 mm and 2° of the line, and returns the full list of points.
On the real robot the pen drew the path in one joint move, then through the midpoint M1, then through M2, M1 and M3, and we measured the deviations on the board. In one joint move the pen passed 107 mm from the line at the midpoint, measured on the board. With M1 as a via point, the midpoints of the two halves measured 28 and 27.5 mm off: halving the segments cut the deviation to about a quarter, close to what the MATLAB model predicted. The joint-interpolated path also leaves the plane of the board slightly, but over a line this short the pen kept drawing.