Web Simulation 

 

 

 

 

3D Serial Arm Forward Kinematics (DH) 

This tutorial visualizes Forward Kinematics (FK) for a 5-DOF serial robot arm using Denavit–Hartenberg (DH) parameters and the Modified DH (Craig's) convention. You see how each parameter (θ, d, a, α) moves the coordinate frame from one joint to the next.

 

Mathematical foundation

1. Denavit–Hartenberg parameters

For each link i, we define four numbers: θi (joint angle), di (link offset), ai (link length), αi (link twist). Frame i is attached to joint i. The homogeneous transform Ti from frame i−1 to frame i depends on these four values.

2. Modified DH (Craig's convention)

In Craig's convention, ai and αi describe the previous link. The order of operations is: (1) rotate about zi−1 by θi; (2) translate along zi−1 by di; (3) translate along xi by ai; (4) rotate about xi by αi. The resulting 4×4 matrix is:

Ti = [ cθ −sθ 0 a; sθcα cθcα −sαdsα; sθsα cθsα cα dcα; 0 0 0 1 ]

where c = cos, s = sin, and (θ, d, a, α) are the parameters for joint i.

3. Forward kinematics

The end-effector pose in the base frame is T0→n = T1 T2Tn. Position is read from the last column; orientation from the 3×3 rotation block. In this simulation we use a 3-DOF arm so n = 3.

4. Visual debugging

At each joint we draw an AxesHelper (RGB = XYZ). The Z-axis of each frame is the joint axis of rotation. Links are drawn as cylinders between frame origins. The trace shows the path of the end-effector over time.

0.0° 0 90.0°
0.0° 5 0.0°
0.0° 4 0.0°
0.0° 3 0.0°
0.0° 2 0.0°

DH Table (Modified, Craig)

1: θ=0° d=2 a=0 α=90°
2: θ=0° d=0 a=5 α=0°
3: θ=0° d=0 a=4 α=0°
4: θ=0° d=0 a=3 α=0°
5: θ=0° d=0 a=2 α=0°
EE: (0.00, 0.00, 0.00)
0.30

Ti (Local transform frame i−1 → i)

Joint positions (arm space)

 

Usage

Follow these steps to explore 3D serial arm Forward Kinematics:

  1. Sliders θ1–θ5: Each joint angle (0–360°) is applied in the Modified DH chain. The arm and coordinate axes update in real time. The DH Table shows current (θ, d, a, α) and EE shows end-effector position (x, y, z).
  2. Axes (RGB): Red = X, Green = Y, Blue = Z. The Z-axis of each frame is the joint axis. Frames are drawn at the base and at each joint.
  3. Trace: Check Trace to record the path of the end-effector as you move the sliders. Uncheck to clear. The trace is a green line.
  4. Phantom (θ=0): Check to show a semi-transparent arm in the zero configuration (all θ=0). Useful to compare with the current pose.
  5. Show joint limits: When checked, semi-transparent arc “pie slices” at each joint show the allowed θ range (min/max). Uncheck to hide.
  6. Pose: Select a preset pose (e.g. Home, Stretched Vertical, Folded) to animate the arm to that configuration over 0.5 s. With IK enabled, the target sphere moves to the new end-effector position at the end.
  7. Camera: Use Iso, Front, Top, Side and Zoom+ / Zoom− to change the view. Drag to rotate, scroll to zoom.
  8. Reset: Set all joint angles to 0° and clear the trace.

Tips: Move one slider at a time to see how each θ affects the chain. Turn on Phantom to see the zero pose. Use Trace and sweep the sliders to visualize the workspace.

Parameters

  • θ1–θ5: Joint angles in degrees (0–360). In radians they are used in the Modified DH matrix.
  • DH Table: (θ, d, a, α) per joint. This arm uses d1=2, a1=5, a2=4, a3=3, a4=2, α1=90°. Link lengths are 2, 5, 4, 3, 2 units.
  • End-effector (EE): World coordinates (x, y, z) from the last column of T0→5.
  • Grid: Ground plane (XZ) for reference.

Theoretical Framework of the Robot Arm Simulation

The tutorial integrates mechanical engineering principles with computer graphics to create an interactive learning environment for serial manipulators. Below are the core theoretical pillars used in the program:

1. Serial Link Kinematics

A serial manipulator consists of a chain of rigid bodies called links, connected by joints. In this simulation, we focus on revolute joints, where each joint provides a single degree of freedom (DOF) through rotation.

2. Modified Denavit-Hartenberg (DH) Convention

To mathematically describe the robot's configuration, we use the Modified DH Convention (Craig's version). Unlike the standard convention, Modified DH attaches the coordinate frame to joint i, making it more intuitive for many engineering applications.

The relative transformation between two successive links is defined by four parameters:

  • a (Link Length): The distance between zi−1 and zi measured along xi.
  • α (Link Twist): The angle between zi−1 and zi measured about xi.
  • d (Joint Offset): The distance from xi−1 to xi measured along zi−1.
  • θ (Joint Angle): The angle between xi−1 and xi measured about zi−1 (this is the variable for revolute joints).

3. Forward Kinematics (FK)

Forward Kinematics is the process of computing the pose (position and orientation) of the end-effector given the joint angles. This is achieved by multiplying the homogeneous transformation matrices (Ti) for each link:

T0→n = T1T2Tn

The resulting 4×4 matrix contains a 3×3 rotation sub-matrix and a 3×1 position vector relative to the base.

4. Inverse Kinematics (IK) via CCD

Inverse Kinematics determines the joint angles required to reach a specific target coordinate. This tutorial utilizes the Cyclic Coordinate Descent (CCD) algorithm, an iterative numerical solver.

  • Mechanism: The solver starts at the end-effector and moves toward the base, adjusting one joint at a time to minimize the error between the "hand" and the target.
  • Stability: To prevent "jumping" or erratic movement, the solver projects 3D target vectors onto the 2D plane of rotation for each specific joint, ensuring the movement is physically possible for that revolute axis.

5. Coordinate Space Transformations

A significant part of the theory involves mapping between different spaces:

  • World Space: The global 3D environment (the grid).
  • Local Space: The coordinate system of an individual link or joint.
  • Screen Space: Mapping the user's 2D mouse position to a 3D "target" on a plane using Raycasting.

Key Summary Table

ConceptEngineering UtilitySimulation Implementation
DH ParametersStandardized robot descriptionReal-time editable matrix logic
Homogeneous MatrixCombines rotation & translationTHREE.Matrix4
CCD AlgorithmReal-time IK solvingIterative vector alignment loop
Joint ClampingSafety and physical limitsAngle min/max constraints

Practical Engineering Considerations

To move from pure theory to a professional engineering tool, we must address the "reality gap"—the difference between a mathematical ideal and a physical machine. Here are the practical engineering considerations implemented in this simulation.

1. The Gravity and Collision Factor

In a textbook, a robot can be in any orientation. In practice, the arm has mass.

  • Floor Awareness: We implemented a "Below Floor" detection logic. If the Forward Kinematics result in a coordinate where y < 0, the link turns Red. This teaches students about Workspace Analysis and the physical boundary of the floor.
  • Singularity Visualization: When you drag the End Effector (EE) to its maximum reach, you'll notice the arm "locks" into a straight line. This is a Kinematic Singularity. In real robotics, moving near these points causes motors to spin at infinite speeds; in our sim, it demonstrates the physical limit of the DH chain.

2. The "Hand-Eye" Coordination (TCP Calibration)

In the simulation, the orange gripper represents the Tool Center Point (TCP).

  • Orientation Tracking: By using a "U-shaped" gripper instead of a sphere, we visualize the Tool Frame.
  • Approach Vector: The fingers align with the z axis of the final frame. In industrial tasks like welding or pick-and-place, the robot doesn't just need to be at (x, y, z); it must approach the object from the correct vector. Adjusting θ5 (Wrist Roll) shows how the tool rotates without changing the position.

3. Safety and "Soft" Limits

Real robots use limit switches and software encoders to prevent self-destruction.

  • Joint Clamping: We added minTheta and maxTheta. This prevents the "Shoulder" from spinning 360° and snapping internal cables.
  • Visual Constraints: The semi-transparent green "Pie Slices" (Range Rings) provide immediate feedback on the Degree of Freedom (DOF) available at any given moment.

4. The "Mouse-to-Machine" Interface (IK Stability)

Directly mapping a 2D mouse click to 3D joint angles is prone to "jitter."

  • Damping: Our IK solver uses a damping factor (e.g. 0.5). This ensures that even if you move the mouse fast, the arm moves with a smooth, non-instantaneous velocity. This mimics Interpolation used in real PLC (Programmable Logic Controller) systems.
  • Iterative Convergence: By running 15 iterations per frame, the sim balances "Real-time performance" with "Mathematical accuracy," ensuring the gripper "snaps" to the target without lagging the browser.

Practical Analysis Table

FeatureReal-World ApplicationSimulation Logic
Orange GripperHigh-visibility safety standardsHigh emissive material + scale
Modified DHEasier to model "Joint-on-Joint" hardwareCraig's Ti matrix logic
RaycastingHuman-Machine Interface (HMI) designTHREE.Raycaster on an invisible plane
Joint LimitsProtecting hardware/cablesMath.max/min clamping in the IK loop