Inverse Kinematics Library for Browser-Based Motion Solving

Where to Find the Library

This library can be found on GitHub here.

Overview of Inverse Kinematics

Inverse kinematics is a common problem in robotics and animation. Given a chain of joints and a desired position, inverse kinematics is the problem of determining the set of joint configurations that result in the chain's end effector reaching the desired position.

For example, think of a human arm: the chain of joints includes the shoulder, the elbow, and the wrist. When a person reaches towards a desired position or target, they are solving the problem of inverse kinematics internally and actuating their joints to carry out the reach. Their brain is figuring out how to move the arm in order to get the hand where it needs to go.


This project is an implementation of FABRIK, which was introduced in a paper by Andreas Aristidou and Joan Lasenby. FABRIK stands for Forwards And Backwards Reaching Inverse Kinematics. It is a fast, iterative solver for the inverse kinematics (IK) problem.

No actual movement is carried out on the real chain until a solution is found, however a virtual chain is used for performing calculations. Think of a kinematic chain as a sequence of points connected by line segments. At one end of the chain is the base point. That base point should not move. In the case of a robot arm, the base point is quite literally bolted to the floor. At the other end of the chain is the end effector. For a robot arm the end effector is the tip of the tool that it is holding.

FABRIK performs two operations. It walks forwards and backwards, up and down the kinematic chain.

First, it starts at the end effector's side of the chain. It begins by moving the end effector to the desired position. However, this would be like moving your hand without moving your elbow. Your hand is constrained by the length of your forearm and can not move farther or closer to the wrist. To account for this, FABRIK walks down the chain to the next point. In the arm example, it would walk from the wrist to the elbow. It now accounts for the length of the forearm, or more abstractly the distance constraint between the end effector and the next point on the chain. The current point (wrist) is moved in the direction of the new hand position until the distance constraint is satisfied. Then FABRIK walks to the next point in the chain and continues this behavior of adjusting for the distance constraints between the points.

Second, it starts at the base side of the chain. If the base has moved from it's original position, it moves it back to that position. However, now that the base point was moved, the next point out on the chain has to be adjusted so the distance constraint between it and the base point is not violated. So FABRIK moves to the inner point, calculates the direction from it to the new base position and moves the inner point in that direction until the distance constraint is satisfied. However, because this point moved, it goes to the next point on the chain and moves it and so on as it walks out the chain.

When the end effector is adjusted for the distance constraint between it and the point before it, it may drift off from the original desired position. To account for this drifting, FABRIK starts again. It moves the end effector back to the desired position and walks back down the chain towards the base as it did in the first step. In this way FABRIK loops. It walks forwards and backwards up and down the chain moving the end effector to the desired position and the base back to its original position and adjusts for constraints in between.

FABRIK Library by Noah Trueblood example
One of the great things about FABRIK is that it can be applied to kinematic chains of arbitrary length. The same code that performs the IK calculations for the simple three point chain above is used for the more complex chains below:

FABRIK Library by Noah Trueblood example
FABRIK Library by Noah Trueblood example
FABRIK Library by Noah Trueblood example
FABRIK Library by Noah Trueblood example
The library is written in JavaScript and I included helper functions for easy use with Threejs, which is a JavaScript 3D library for the browser. However, the IK solving portions are in their own module so you can take just that module and use it for use cases outside of the browser as well.

Use Case

This is a concept for a photo gallery website that utilizes the IK library.

By Noah Trueblood