Hey there!
If you’ve ever wondered how a robot like Tesla’s Optimus or Figure 01 knows exactly where to move its arm to pick up a cup, or how it positions its foot perfectly during a step,you’re about to discover the magic behind it.
The answer lies in two powerful concepts: Forward Kinematics and Inverse Kinematics. Don’t let the fancy names scare you. I’ll explain them like we’re chatting over coffee, with simple examples and actual Python code you can try yourself.
What Is Kinematics Anyway?
Kinematics is basically the math of motion,without worrying about forces or motors. For humanoid robots, we use it to answer two very practical questions:
- Forward Kinematics (FK):
Given all the joint angles, where is the end of the arm or leg in space?
- Inverse Kinematics (IK):
Given a desired position (like “I want the hand here”), what joint angles should I use to reach it?
Think of it like this:
Your arm is a chain of links (upper arm -> forearm -> hand). Forward kinematics is measuring all the joint angles and calculating where your fingertip ends up. Inverse kinematics is saying “I want my hand on that doorknob” and figuring out how much to bend your elbow and shoulder.
Why This Matters for Humanoids
Tesla Optimus needs to reach for objects at different heights. Boston Dynamics Atlas performs dynamic movements. Figure 01 must place its feet accurately while walking. All of these rely heavily on good kinematics.
Poor kinematics = jerky, inaccurate, or impossible movements.
Good kinematics = smooth, natural, and reliable motion.
The Tool We Use: Denavit-Hartenberg (DH) Parameters
The most common way to describe robot arms and legs is using DH parameters. It’s a standard method that turns a chain of joints and links into a clean mathematical model.
Each joint gets four numbers: θ (theta),the joint angle (what we usually control), d,the offset along the joint axis, a,the length of the link, α (alpha),the twist angle between joints
Simple Example: A 2D Arm (Super Beginner Friendly)
Let’s start with a very simple 2-link arm (like an elbow + shoulder).
Python Code for Forward Kinematics
import numpy as np
import math
def forward_kinematics(theta1, theta2, l1=0.3, l2=0.25):
"""Calculate end-effector position of 2-link arm"""
x = l1 * math.cos(theta1) + l2 * math.cos(theta1 + theta2)
y = l1 * math.sin(theta1) + l2 * math.sin(theta1 + theta2)
return x, y
# shoulder 30°, elbow 45°
x, y = forward_kinematics(math.radians(30), math.radians(45))
print(f"Hand position: ({x:.3f}, {y:.3f}) meters")
Try changing the angles and see how the hand moves!
Moving to 3D with DH Parameters (More Realistic for Humanoids)
For real humanoid arms and legs, we use full 6-DOF (or more) chains. Here’s a simplified DH table for a humanoid arm (shoulder to wrist):
| Joint | θ (variable) | d | a | α |
| 1 | θ1 | 0 | 0 | 90° |
| 2 | θ2 | 0 | l1 | 0° |
| 3 | θ3 | 0 | 0 | 90° |
| 4 | θ4 | l2 | 0 | -90° |
| 5 | θ5 | 0 | 0 | 90° |
| 6 | θ6 | 0 | l3 | 0° |
Inverse Kinematics, The Harder (But More Useful) Part
Inverse Kinematics is trickier because there can be multiple solutions (or none at all). For a simple 2D arm, we can solve it analytically.
Python Codefor Simple Inverse Kinematics (2-link arm)
def inverse_kinematics(x, y, l1=0.3, l2=0.25):
"""Calculate joint angles reach (x, y), theta1 = shoulder, theta = angle"""
cos_theta2 = (x2 + y2 - l12 - l22) / (2 * l1 * l2)
theta2 = math.acos(np.clip(cos_theta2, -1.0, 1.0))
k1 = l1 + l2 * cos_theta2
k2 = l2 * math.sin(theta2)
theta1 = math.atan2(y, x) - math.atan2(k2, k1)
return math.degrees(theta1), math.degrees(theta2)
# reach point (0.4, 0.3)
theta1, theta2 = inverse_kinematics(0.4, 0.3)
print(f"Joint angles -> Shoulder: {theta1:.1f}°, Elbow: {theta2:.1f}°")
Real-World Use in Humanoids
- Legs: Inverse kinematics helps calculate exact joint angles so the foot lands in the right spot during walking.
- Arms: Used for reaching, grasping, and manipulation. Optimus and Figure 01 combine IK with machine learning to make movements look more natural and avoid obstacles.
- Whole Body: Modern robots often solve kinematics for the entire body at once (whole-body control).
My Personal Take
Kinematics is the bridge between what we want the robot to do and how its motors actually move. Once you understand forward and inverse kinematics, you start seeing why articulated toes, compliant joints, and good weight distribution matter so much,they all affect how easy or hard it is to solve these equations in real time.
It’s not the most glamorous topic, but mastering kinematics is what separates robots that look cool in videos from robots that can actually work reliably beside us.
Start with the simple 2-link examples above. Play with the numbers. Once you’re comfortable, you can move on to full 6-DOF arms using libraries like ikpy or ROS.