Inverse kinematics: choosing joint positions and wheel speeds to reach a goal
Atlasbot · 17/8/2026 · 11 min read
The article Forward Kinematics answers "know the joint angle and location?" — a direct trigonometric calculation, always giving exactly the same result. Inverse Kinematics (inverse kinematics) asks the opposite: "If you want the manipulator/robot head to reach this exact position, what joint angle/wheel speed should you set?" — and the answer isn't always simple, or even existential.
Key concepts
Continuing the 2-segment manipulator example from the previous lesson — knowing the desired target position (x, y), need to find θ1, θ2. Use the cosine function theorem (law of cosines) on the triangle created by the two arm segments and the straight line to the destination:
r² = x² + y²
cos(θ2) = (r² − L1² − L2²) / (2·L1·L2)
θ2 = ± arccos(...) ← ± sign gives 2 different solutions
The mark ± reflects a physical fact: there are two different joint placements so that the machine arm touches exactly the same point (x, y) — called the "elbow-up" and "elbow-down" configurations. Both are mathematically correct; Which one to choose depends on the actual constraints (avoiding collisions, or being closer to the current position).
In short: Forward Kinematics always gives the exact same result. Inverse Kinematics can give multiple solutions, exactly 1 solution (differential-drive robot), or no solution at all (if the target point is out of physical reach).
How it works
The article Differential Drive actually uses inverse kinematics without naming names: knowing v, ω desired, deducing v_L, v_R — just algebraically inverting two linear equations, giving exactly one unique solution:
v_L = v − ω·L/2
v_R = v + ω·L/2
Fundamental difference: the equation system of differential-drive robots is linear, while the equation system of multi-joint manipulators is usually nonlinear (nested sin/cos) — the difficulty of inverse kinematics depends directly on the number of joints and geometric complexity.
With more jointed manipulators (5-6 degrees of freedom or more), direct algebraic solution becomes very complicated or impossible. Practical approach: use an iterative numerical algorithm (Jacobian-based, starting from any matching configuration, gradually adjusting in the direction of reducing error) - exchanging "absolutely correct" solutions for solutions "close enough to the target, calculated in real time".
Technical details
Formulas
The formula θ2 above is not enough — we need to add θ1 to get a complete solution for a 2-joint manipulator:
θ1 = atan2(y, x) − atan2(L2·sin(θ2), L1 + L2·cos(θ2))
For example: target (x,y) = (0.279, 0.443), L1=0.3, L2=0.25 (reverse Forward Kinematics example)
r² = 0.279² + 0.443² ≈ 0.274
cos(θ2) = (0.274 − 0.09 − 0.0625) / (2×0.3×0.25) ≈ 0.5 → θ2 ≈ 30° (or −30°, elbow-up/down)
θ1 calculated according to the above formula ≈ 45° (the elbow-up solution matches the Forward Kinematics lesson)
Parameters
Conditions for inverse kinematics to have a solution — the target must be within the "workspace" of the manipulator, limited by both the outer and inner boundaries:
| Conditions | Meaning |
|---|---|
r > L1 + L2 | The destination is too far, the "straightened" robot arm doesn't reach it - there is no solution |
r < |L1 − L2| | The target is too close, even when folding it all the way it won't shorten it enough — there's no solution |
|L1−L2| ≤ r ≤ L1+L2 | There is a solution, usually 2 solutions (elbow-up/down) |
Practical applications
In the ROS2 ecosystem, MoveIt is a standard motion planning framework for manipulators, using the correct iterative numerical approach mentioned in the Principle of Operation section to solve inverse kinematics for 6+ DOF manipulators in real time — users only need to declare the desired target position/direction for the end-effector, MoveIt automatically calculates the feasible joint angle trajectory, avoiding collisions with the robot body or known obstacles in the process. scene. scene. In contrast, the inverse kinematics of the differential/mecanum AMR robot (converting cmd_vel to each wheel speed) is much simpler because it is a linear system with an instantaneous closed-form solution — this is why every AMR motor driver can be calculated automatically right on the MCU without the need for an iterative numerical algorithm like a manipulator.
Practical example
import math
def inverse_kinematics(x, y, L1, L2, elbow_up=True):
r2 = x**2 + y**2
cos_theta2 = (r2 - L1**2 - L2**2) / (2 * L1 * L2)
theta2 = math.acos(cos_theta2) if elbow_up else -math.acos(cos_theta2)
theta1 = math.atan2(y, x) - math.atan2(L2*math.sin(theta2), L1 + L2*math.cos(theta2))
return math.degrees(theta1), math.degrees(theta2)
theta1, theta2 = inverse_kinematics(0.279, 0.443, 0.3, 0.25, elbow_up=True)
print(f"theta1={theta1:.1f} do, theta2={theta2:.1f} do")
Output:
theta1=45.0 do, theta2=30.0 do
The result matches exactly the original input value of the Forward Kinematics example in the previous lesson (θ1=45°, θ2=30°) — confirming that IK and FK are two exact inverses of each other: take the position out from FK, put it back into IK, get the correct original joint angle.
Common mistakes
- Destination is outside the workspace but not checking before — as mentioned in the Parameters section,
rmust be in the range[|L1-L2|, L1+L2]— not checking before calculatingarccoscauses a domain error (input outside the range[-1, 1]) becausecos(θ2)is calculated outside the valid range. - Choosing the wrong solution branch (elbow-up/down) — both are mathematically correct but can lead to physical collisions with obstacles or the robot body itself — always check the actual constraints before choosing a branch, do not default to taking the first branch that can be calculated.
- Numerical IK does not converge near the singularity — when the manipulator arm is nearly fully extended, the iterative algorithm may oscillate and not converge to the solution, similar to the gimbal lock problem learned in the Rotation lesson — cases near the workspace edge need to be handled separately.
- Ignore the physical joint angle limit — the mathematical solution is valid but exceeds the actual rotation limit of the mechanical joint (eg: the joint can only rotate 0-180° but the solution requires 200°) — always check and clamp the IK result according to the actual mechanical limit of the robot before sending the command.
Conclusion
Inverse kinematics is the "difficult" problem of robotic kinematics — there can be many solutions, one solution, or no solution depending on the structure's geometry, in contrast to forward kinematics, which always has exactly one easy-to-calculate result. With a simple linear system (differential-drive robot), solve by direct algebra; With complex nonlinear systems (multi-joint manipulators), numerical methods such as those used by MoveIt are needed. The next article in the category is about Mecanum robot kinematics — a more complex wheel configuration than differential drive, allowing horizontal movement without having to rotate the robot body.
Get new articles and lessons by email
When a new technical article or course module is published, Atlas Robotics sends you a short email. No spam.
Unsubscribe any time with the link in each email. See our Privacy policy.