Inverse Kinematics Calculator Back
Robotics · IK Solver

Robot Arm Inverse Kinematics Calculator (2/3-DOF)

Compute joint angles θ₁, θ₂ (and θ₃) from a target end-effector position for 2R planar or 3R spatial arms. Visualizes elbow-up/down solutions, reachable workspace, and singularity in real time.

Parameters
Mode
Link Lengths
L₁ Link 1
mm
L₂ Link 2
mm
L₃ Link 3
mm
Target Position
Target X
mm
Target Y
mm
Target Z
mm
Joint Limits
θ₁: ±150°, θ₂: ±170°, θ₃: ±170°
Results
θ₁ [deg]
θ₂ [deg]
EE Error [mm]
det(J)
Reachability
Singularity Dist.
Ik
Theory & Key Formulas

Solve for both configurations from the cosine rule:

$$c_2 = \frac{x^2+y^2-L_1^2-L_2^2}{2L_1 L_2}, \quad s_2 = \pm\sqrt{1-c_2^2}$$ $$\theta_2 = \text{atan2}(s_2, c_2)$$ $$\theta_1 = \text{atan2}(y,x) - \text{atan2}(L_2 s_2,\ L_1+L_2 c_2)$$

Reachability: $|L_1-L_2| \le \sqrt{x^2+y^2} \le L_1+L_2$

What is Inverse Kinematics?

🙋
What exactly is "inverse kinematics"? I know a robot arm moves, but what's the "inverse" part?
🎓
Great question! Think of it like this: "Forward" kinematics asks, "If I know the joint angles, where is the robot's hand?" The "inverse" problem flips it: "I want the hand here—what joint angles do I need?" It's the essential math for telling a robot where to go. Try moving the Target X and Y sliders in the simulator above; the tool is solving this inverse problem in real-time to find the angles that place the tip at your chosen point.
🙋
Wait, really? So for one target point, there can be two different arm configurations? I see "elbow-up" and "elbow-down" in the simulator.
🎓
Exactly! For a simple 2-link arm, most points within its reach can be achieved in two distinct poses, like how your own elbow can be up or down when touching a spot on a table. The simulator calculates both. The key is the $\pm$ sign when calculating the sine of the second joint angle ($s_2$). Changing the L₁ and L₂ link lengths will affect which points are reachable and how different these two solutions look.
🙋
That makes sense. But what if the point is out of reach? The simulator shows a "Not Reachable" warning.
🎓
Precisely! The arm has a limited workspace. The check is based on the geometry of a triangle: the target distance from the base must be between $|L_1 - L_2|$ and $(L_1 + L_2)$. If you set a Target X that's too large, you'll see this fail. This is the "cosine rule" check, and it's the first step in any robust IK solver to avoid mathematical errors.

Physical Model & Key Equations

The core problem is solving for the joint angles ($\theta_1$, $\theta_2$) of a 2-link planar arm so its end-effector reaches a target point $(x, y)$. We use geometry, specifically the law of cosines, to find the angle of the second joint.

$$c_2 = \frac{x^2 + y^2 - L_1^2 - L_2^2}{2 L_1 L_2}$$

Here, $c_2$ is the cosine of the second joint angle $\theta_2$. $L_1$ and $L_2$ are the link lengths, and $x^2 + y^2$ is the squared distance from the base to the target. For a solution to exist, we must have $-1 \le c_2 \le 1$; otherwise, the point is unreachable.

Once $c_2$ is known, we find the sine $s_2$, which has two possible signs, leading to the elbow-up and elbow-down configurations. The angles are then computed using the two-argument arctangent function for correctness across all quadrants.

$$ \begin{align*}s_2 &= \pm \sqrt{1 - c_2^2}\\ \theta_2 &= \text{atan2}(s_2, c_2) \\ \theta_1 &= \text{atan2}(y, x) - \text{atan2}(L_2 s_2, L_1 + L_2 c_2) \end{align*}$$

$\theta_1$ is the base joint angle. The term $\text{atan2}(L_2 s_2, L_1 + L_2 c_2)$ represents the angle of the triangle formed by the links relative to the first link. This geometric decomposition is what the simulator visualizes.

Frequently Asked Questions

In the calculation of the second joint angle θ₂, there is a choice of ± sign for the sine value s₂ in the law of cosines. When s₂ is positive, it is the elbow-up solution where the elbow bends upward; when negative, it is the elbow-down solution where the elbow bends downward. Both can reach the same target position, but the choice depends on obstacle avoidance and joint range of motion.
A singularity is a posture where the joint velocity becomes infinite, such as when the arm is fully extended (θ₂=0°) or fully folded (θ₂=180°). In this state, the inverse kinematics solution is not uniquely determined, and even a small target movement causes the joint to move abruptly, leading to loss of control or damage in actual hardware.
If the target position (x, y) is farther than the maximum reach (L₁+L₂) or closer than the minimum reach (|L₁-L₂|), the value c₂ in the law of cosines falls outside the range of -1 to 1, and no inverse kinematics solution exists. In the simulator, this results in an error display or a non-visualized state, prompting the user to adjust the target position.
For 3 degrees of freedom (L₁, L₂, L₃), first offset the wrist position from the target (x, y, z) by the length of the third link, then apply 2-link inverse kinematics to that point. After that, θ₃ is determined to match the wrist orientation. In iterative methods, numerical convergence calculations are performed, and the optimal solution is selected from multiple candidates.

Real-World Applications

Industrial Automation (Pick-and-Place): In assembly lines, a robot must move an item from a conveyor belt to a specific box location. Inverse kinematics calculates the precise joint motor commands needed for each point along that path. The choice between elbow-up or elbow-down might be made to avoid collisions with other machinery.

Robotic Welding & Painting: For welding a car chassis or painting a complex surface, the tool tip must follow an exact 3D trajectory. IK solvers work continuously along this path, often for 6-axis arms, ensuring consistent speed and orientation. The reachability check prevents commands that would strain the arm's limits.

Surgical Robotics: Systems like the da Vinci Surgical System use IK to translate a surgeon's hand movements at a console into precise motions of tiny instruments inside a patient's body. Here, accuracy and singularity avoidance (positions where control is lost) are critical for safety.

CAE & Digital Prototyping: Before building a physical robot, engineers use Multi-Body Dynamics (MBD) software to simulate its movement. Setting up these simulations requires defining initial joint positions via IK. It's also used in FEM analysis to apply forces at specific points on a flexible robotic component.

Common Misconceptions and Points to Note

First, there is a misconception that "longer link lengths are always better." While longer links do increase the reachable range, they also make the arm more prone to singularities (configurations where the arm becomes fully extended) and can lead to unstable control. For example, with an arm where L₁=5 and L₂=5 targeting point (9.9, 0), it can barely reach the point but approaches a perfect singularity. You can simulate a "violent jerk," where joints move rapidly due to a small position command. In practice, you should select the minimum arm length necessary for the workpiece size and design the workspace with a sufficient margin.

Next, there is the mindset that "finding a solution is good enough." Even if an angle is calculated mathematically, it often exceeds the robot's physical joint limits. For instance, if a joint has a movable range of -120° to 120° for θ₂ and the calculation yields 150°, you must judge that point as "unreachable." If, in this tool, switching between solutions still results in both poses violating joint limits, it means that position is effectively unreachable.

Finally, there is overconfidence that "with 3 degrees of freedom, you can freely reach anywhere in 2D space." Even with a 3-DOF arm that adds rotation about the Z-axis, you cannot control the end-effector's orientation (the tool's direction). Furthermore, adding a third joint can introduce infinite solutions to the inverse kinematics (redundancy). While this tool calculates a unique solution, in real robots, this evolves into a complex optimization problem of selecting "the solution with the least joint load" or "the smoothest motion" from infinite possibilities.