CivilKit Calcs

Robot arm kinematics calculator

This is a worked example of the kinematics of a planar robot arm with three revolute joints: where the tool tip is for given joint angles (forward kinematics), how tip speed follows joint speed (the Jacobian), where the arm loses a direction of motion (singularities), and which angles reach a wanted point (inverse kinematics). It opens as a live sheet in CivilKit Calcs, and every formula is checked numerically in the sheet itself.

Open this sheet in Calcs Open a blank sheet

The arm

The links are 0.30 m, 0.25 m and 0.20 m long, so the arm stretched out reaches 0.75 m. All joints turn about the axis out of the page. The sheet sets angles to radians, so the base configuration of 0.5, 0.3 and 0.1 rad is about 29, 17 and 6 degrees. For a planar arm the Denavit-Hartenberg offset and twist are zero, so only each joint angle and link length matter.

Video: Your first calculation (about 85 seconds). Read the chapter Your first sheet in five minutes.

Try it

Open the sheet in Calcs or embed it.

Forward kinematics

The tip is the sum of three vectors, each turned by the sum of the joint angles up to it: x = L1 cos t1 + L2 cos(t1 + t2) + L3 cos(t1 + t2 + t3), and the same with sines for y. The tool points at t1 + t2 + t3. At the base configuration the engine gives:

QuantityResult
Tool angle (rad)0.9
Distance of the tip from the base0.739 m

The sheet prints a PASS line when that distance is within the reach.

The Jacobian

Differentiating the tip position with respect to each joint angle gives a 2 by 3 matrix mapping joint speeds to tip velocity. The sheet writes its six entries from the formulas, then checks them against central finite differences of the forward kinematics, and prints a PASS line if no entry differs by 1e-8 m or more. That check uses no derivative formula, so it can catch a sign error. The first row at the base configuration:

QuantityResult
J11 (m per rad)-0.48 m
J12-0.336 m
J13-0.157 m

Manipulability and singularities

The manipulability w is the square root of the determinant of J times its transpose. It is zero when the arm has lost a direction. The sheet derives a closed form from the 2 by 2 minors of J, which shows that w does not depend on the first joint angle and vanishes only when every link lies on one line, stretched out or folded back.

QuantityResult
w at the base configuration0.0539 m²
w stretched out0 m²
w, elbow at a right angle, wrist bent back0.103 m²

PASS lines check that the closed form equals the matrix value and that w is zero at the singular configurations. A plot shows w against the elbow angle.

Inverse kinematics

For links 1 and 2, a reachable target gives the elbow angle from the law of cosines and the first angle from two arctangents. The sign of the elbow angle is the choice of elbow: positive is elbow down, negative elbow up. The sheet builds a target from the tip at 0.5 and 0.3 rad and solves it back:

QuantityResult
Target x0.437 m
Target y0.323 m
Elbow down, joint 1 (rad)0.5
Elbow down, joint 2 (rad)0.3
Elbow up, joint 1 (rad)0.773
Elbow up, joint 2 (rad)-0.3

PASS lines check that both solutions land on the target and that elbow down returns the original angles.

Three joints, workspace and sliders

Three joints need a target point and a tool angle. A controller iterates with damped least squares, which stays well behaved near singularities. That iteration, a workspace plot coloured by manipulability, and a set of three joint sliders are Python blocks in the sheet. They need Python, which the app asks permission to run once per tab, so this page quotes no number from them. The sheet checks the iteration against its own forward kinematics and against the closed form, whose wrist point for the target (0.45, 0.30) m at 1.0 rad is:

QuantityResult
Wrist point x0.342 m
Wrist point y0.132 m

Try the singular configuration

Setting the second and third angles to zero stretches the arm out. The engine then gives a tip distance of 0.75 m and a manipulability of 0 m², and the sheet's regularity check prints FAIL, as it should.

What this is, and is not

This is a worked, self-checking example, not a design tool or a certified program. It prints PASS and FAIL lines for its own checks. It covers a planar arm only, with no dynamics and no collision checks. It is for learning and checking ideas, not for safety-critical use, and you should not run a real robot from it.

The problems follow the cookbook of the symplex library (MIT or Apache-2.0), rewritten for Calcs. Its public repository is github.com/cgorski/symplex.

Questions

Does the sheet need Python?

The forward kinematics, the Jacobian, the manipulability and the two-link inverse kinematics are sheet maths. The damped least squares iteration, the workspace plot and the sliders are Python blocks, which the app asks permission to run once per tab.

Are the angles in degrees or radians?

Radians. The engine defaults to degrees for trigonometric functions, so the sheet switches to radians at the top, and the base angles of 0.5, 0.3 and 0.1 are radians.

What is a singularity of the arm?

A configuration where the Jacobian loses rank and the tip cannot move in some direction. For this arm that is when every link lies on one line, stretched out or folded back, which is where the manipulability is zero.

Why are there two inverse kinematics solutions?

The elbow can be up or down for the same target. The sheet computes both and checks that each puts the tip on the target.

Can I use it to drive a real robot?

No. It is for learning and checking ideas, not for safety-critical use.

Open this sheet in Calcs Open a blank sheet