Sunday, January 1, 2017

Heuristic Inverse Kinematics with FABRIK

Inverse kinematics (IK for short) is the problem of computing end-positions for a chain of joints . FABRIK is a heuristic technique for solving an IK system. In the figure below, the joint $p_0$ is fixed and the joint $p_n$ is free. $p_n$ is also called an end-effector. We would like to be able to move the end-effector freely and the system should compute locations for the joints $p_1,\dots,p_{n}$ so that the end-effector reaches a target position. Think of it as a robotic arm trying to reach a target.

[figure]

Before describing the technique, I invite you to watch this demo FABRIK solver that I created.

There are several ways to solve an IK system. Some give exact solutions but require a lot of time to calculate the joint positions; these are preferred techniques when precision matters. If you are going to write a simulation or an IK solver for a video game, for example, then you might consider using FABRIK; the results are by far the best in terms of realism and the algorithm is very fast.

The overall idea is simple. We iteratively improve upon the current joint positions until the distance between the end-effector and the target position is good enough. We also set an upper-bound on the number of iterations (this is a small number in practice) to avoid looping forever.

In a single iteration we perform a forward pass in which the joints get closer to the target (this shifts the fixed joint as well) and a backwards pass in which the joints get closer to the fixed joint (this gets the fixed joint back to its position). After every iteration, the calculated new joint positions are improved. How are the new joint positions calculated ? This is where the heuristic part comes in.