Skip to content

Degrees of freedom and kinematic chains

Stage 1 · Foundations · ~30 min · Before this: nothing (start here, or see the map) · Maths: angles, sine and cosine · numbers from the repository as of 2026-11-02

A humanoid is a tree of hinges. Before you can reason about balance, torque or learning, you need to know what each hinge can do, how hinges add up along a leg, and why Marvin Bot has exactly 27 of them in the order it does.

Hold your arm out and bend only the elbow: your hand moves along an arc. One number, the elbow angle, says where it is. That number is one degree of freedom (DOF): one independent quantity you need to describe a configuration.[1] Each of Marvin Bot’s motors turns one hinge, a revolute joint, so each motor adds one DOF.

Three words for turning come up on every page of this guide. Use your own head: nodding “yes” is pitch (about a side-to-side axis), shaking “no” is yaw (about a vertical axis), and tipping an ear towards a shoulder is roll (about a front-to-back axis). A hip pitch joint swings the thigh forwards and back; a hip roll joint swings it out to the side; a hip yaw joint turns the leg about its own length, so the toes point in or out.

A leg is hinges in series: pelvis, hip, thigh, knee, shin, ankle, foot. That is a serial kinematic chain: each link is carried by the one before it, so turning the hip moves everything below it. The playground below is a side view of Marvin Bot’s leg with its real lengths and its real joint limits.

Why this comes first. Every later page leans on it: balance (page 02) needs to know where the feet and body are, motor sizing (page 04) needs to know which joint carries which load, and the learned controller (page 16) outputs one target angle per joint, 27 of them.

Start here: press Marvin Bot today, then drag the three sliders one at a time and watch which parts of the leg move. Side view (the sagittal plane, the vertical front-to-back plane you see when looking at someone from the side): x forward, z up, the hip pitch axis at the origin. Thigh 0.325 m, shin 0.315 m, ankle axis 0.060 m above the sole, foot 0.24 m long with the ankle 0.09 m from the heel (description/robot.yaml, description/skeleton.yaml).

Presets

Joint angles

+ = thigh forward (flexion). Range −30° to 120°.
+ = bend. Range 0° to 130° (beyond it the upper ankle motor meets the thigh shell).
+ = toes up (dorsiflexion). Range ±40°.

Show

Each dot is one place the ankle can reach (every hip and knee angle in range, 3° apart). Green: the ankle joint can still turn the foot flat on the floor. Grey: it would need more than ±40°.
Sets ankle = knee − hip, the rule for a flat foot under an upright pelvis.
Ankle from hip (x, z)
–
Hip axis above sole
–
Foot pitch (toe up +)
–
Hip–ankle distance
–
thighshinfootankle can reach, foot flat possibleankle can reach, foot cannot lie flat

A rigid body floating in space has 6 DOF: three to say where it is (x, y, z) and three to say which way it faces (roll, pitch, yaw). A revolute joint removes 5 of the 6 relative freedoms between two links and leaves 1, the rotation about its axis. So a chain of n revolute joints from a fixed base has n DOF.[1] Counting joints this way is the simplest case of a general counting rule (Grübler’s formula); it only becomes subtle for closed loops, such as Marvin Bot’s ankle, where two motors and two push rods together still give the foot 2 DOF (see 06 The parallel-linkage ankle).

A walking robot is not bolted down. Its pelvis is a floating base with 6 DOF of its own that no motor drives directly: the robot moves its pelvis only by pushing on the ground. That is why legged robots are called underactuated: there are more DOF (27 + 6 = 33 for Marvin Bot’s body) than motors (27).[2]

Forward kinematics answers: given the joint angles, where is the foot? The equations below are just the playground’s picture written as sums of sines and cosines; you can skip them and come back. In the side view, measure each link’s angle from straight down, positive when its lower end swings forward. With hip pitch qh, knee qk (bend positive) and ankle qa (toes up positive):

φthigh = qh φshin = qh − qk φfoot = qh − qk + qa
knee = hip + L1·(sin φthigh, −cos φthigh)
ankle = knee + L2·(sin φshin, −cos φshin)
sole point = ankle + R(φfoot)·(0, −ha)

φ (phi) is each link’s tilt from vertical, so (sin φ, −cos φ) is a step of length 1 along that link: forward by sin φ, down by cos φ. L1 = 0.325 m (thigh), L2 = 0.315 m (shin), ha = 0.060 m (ankle axis to sole), R(φ) turns a point by φ in the plane, and φfoot is the foot’s pitch (toe up positive). Angles add along the chain because each joint turns everything after it. The foot is flat when φfoot = 0, so with an upright pelvis a flat foot needs qa = qk − qh. At the stance (6°, 15°, 9°) that holds exactly: 15 − 6 = 9.

In 3-D the idea is the same, done one joint at a time from the pelvis down: turn by the first joint’s angle, step along to the next joint, turn by its angle, step again, and so on to the sole. Order matters, because turns about different axes do not commute: try it with a book. Tip it forwards 90° then turn it 90° to the left, and compare with doing the two turns the other way round; it ends up facing a different way. The same is true of a leg: rolling then pitching leaves the foot somewhere different from pitching then rolling.

Go deeper: the matrix form

Each joint’s turn is written as a 3 × 3 rotation matrix (or a 4 × 4 transform that also carries the offset to the next joint). The foot’s pose is the product of all the transforms from the pelvis down: Tfoot = T1(q1) T2(q2) … T6(q6) Tsole, where q1 … q6 are the six joint angles. Matrix products, like turns, depend on order. Robotics texts write the same product either with Denavit–Hartenberg parameters[4] or as a product of matrix exponentials; Modern Robotics uses the latter.[1]

Marvin Bot’s description lists each joint’s axis and offset (description/skeleton.yaml), and a generator script turns them into a URDF (Unified Robot Description Format) file, the standard file simulators read, which holds exactly this chain (page 13).

A foot on the ground has a full 3-D pose: 3 positions and 3 angles. To place a foot anywhere within reach, at any heading and tilt, the leg needs at least 6 independent DOF between pelvis and sole. Marvin Bot uses 3 at the hip (roll, pitch, yaw), 1 at the knee and 2 at the ankle (pitch, roll). With fewer, some foot poses become impossible: drop the hip yaw and the robot can only turn by scuffing; drop the ankle roll and the foot cannot sit flat on a sideways slope. Inverse kinematics (from a desired foot pose back to joint angles) has a finite set of answers when there are exactly 6 joints, and none outside the workspace or the joint ranges.

A real joint stops where parts collide or a cable runs out. Ranges are design decisions: Marvin Bot’s knee stops at 130° because the upper ankle motor then meets the thigh shell, hip extension stops at −30° because the thigh yoke meets the hip roll motor, and the ankle got 40° of dorsiflexion (toes up) because a stair check (a calculation of the robot standing still on a step) could not climb 17 cm with 35° (docs/decisions.md, 2026-10-26). In the playground, the grey part of the cloud is the price of the ankle’s ±40°: places the ankle reaches but where the foot cannot lie flat.

Singularities and the order of the hip joints

Section titled “Singularities and the order of the hip joints”

Three hip joints whose axes meet near one point act like a ball joint built from three hinges: a gimbal (like the rings that hold a ship’s compass level). When two of the three axes line up, the gimbal loses a direction it can turn in. That is a singularity (gimbal lock): one motor’s rotation duplicates another’s, and small turns in the lost direction need huge joint speeds.[1] Which pose is singular depends on the order of the axes:

  • Roll, pitch, yaw (Marvin Bot): singular at hip pitch ±90°, when the yaw axis along the thigh points forward, parallel to the roll axis. Reached when sitting or on a very high step.
  • Pitch, roll, yaw: singular at hip roll ±90°, far outside any useful range.
  • Yaw, roll, pitch: singular at hip roll ±90°, also far outside the range.

The singularity analysis above is ours, derived from the axis order; the repo chose the order for mechanical reasons (next section). Playground C shows it.

The tree lists every joint from the pelvis outwards: each joint is carried by the one above it. Click a joint to see its axis, range, actuator (motor) and bus (the shared data cable its motor talks over; page 10). Shift-click (or use the lock button) to lock a joint, as if it were welded solid, and watch the DOF count, and whether each foot can still be placed at any position and any angle within reach (“posed in 6-D”: 3 positions plus 3 angles).

Degrees of freedom

27

Presets

Select a joint.

Playground C: the same three angles, three hip orders

Section titled “Playground C: the same three angles, three hip orders”

Three hips side by side, each given the same roll, pitch and yaw angles, but stacked in a different order from the pelvis. The thick line is the straight leg (hip to sole), the short orange line is the toe direction, and the coloured lines are the three joint axes (red roll, green pitch, blue yaw) where they sit in this pose. “Axis spread” says how well the three axes still point in three different directions: 1 when they are all at right angles to each other (good), 0 when two have lined up (gimbal lock, bad). For the mathematically minded it is |det[a1 a2 a3]|, the volume of the box the three unit axes span.

How to read this picture: each panel is a 3-D sketch seen from the front-left, pelvis at the top, the grey square is the floor. Compare where the orange toe line points in the three panels.

Presets

Hip angles

+ = leg away from the midline (left leg shown).
+ = thigh forward.
+ = toes turn in.
roll axispitch axisyaw axistoe direction

Why roll first. The hip used to be pitch, roll, yaw. Then the hip roll motor (an RS04, 1.42 kg) rode on the leg behind the hip and swung with every step; it also stopped the knee at 125°. With roll first, both roll motors are fixed in the pelvis behind the hips, so 1.4 kg per leg stops swinging, and the knee now reaches 130° (docs/decisions.md, 2026-10-26). Less moving mass in a leg means less torque to swing it and a lighter-feeling leg for the policy (the learned controller that walks the robot, page 16).

Why not yaw first. A yaw-roll-pitch stack with the yaw motor in the pelvis was ruled out because it needs about 60 mm more height above the hips, which at the time pushed past the height limit or below the leg length the stairs need (same entry).

Hip order (from pelvis) What stays still Singular at Notes
Roll, pitch, yaw (Marvin Bot) Both roll motors in the pelvis Hip pitch ±90° (sitting) 1.4 kg less swinging per leg; knee to 130°; the singularity is inside the hip pitch range, so sitting poses lose one way to turn the thigh
Pitch, roll, yaw (Marvin Bot until 2026-10-26) Pitch motors Hip roll ±90° (unused) Deep flexion is clean; the roll motor swings with the leg
Yaw, roll, pitch Yaw motors in the pelvis Hip roll ±90° (unused) Common in open humanoids; ~60 mm more stack height above the hip

Other DOF choices the repo records: a knee motor near the hip with a linkage (lower leg inertia, more parts; deferred), serial ankle pitch and roll motors (heavier shin; rejected in favour of the parallel linkage), and the arm’s wrist pitch on a small servo to carry the bought hands (docs/decisions.md).

  • Joint ranges: each extra degree of range may need a different bracket, and each lost degree may make a task (stairs, sitting, getting up) impossible. Check the green and grey regions before cutting a range.
  • Hip order: roll-first keeps mass off the leg but has a singularity at 90° hip pitch; check that tasks like sitting or climbing very high steps do not need to turn the thigh about its long axis at that pose.
  • DOF count: removing a joint saves an actuator (~$140–255 and 0.3–1.4 kg) but removes a direction of motion; the 6-per-leg minimum is not negotiable for full foot placement.
Your decision note

Built from your settings above. Paste it into an issue, a design discussion or an AI assistant session.

Where this leads. You now know where the feet are for given joint angles. Page 02 asks the next question: with the feet there, where must the body’s weight be so the robot does not fall over? Page 06 returns to the ankle’s two-motor linkage.

  1. K. M. Lynch and F. C. Park, Modern Robotics: Mechanics, Planning, and Control, Cambridge University Press, 2017 (preprint) — used for: DOF definition and Grübler’s formula (ch. 2), forward kinematics as a product of transforms (ch. 4), singularities (ch. 5).
  2. R. Tedrake, Underactuated Robotics, MIT 6.832 course notes, chapter “Humanoid robots” — used for: floating base and why legged robots are underactuated.
  3. RobStride, Product_Information (actuator manuals) — used for: actuator models named in the joint tree.
  4. J. Denavit and R. S. Hartenberg, “A kinematic notation for lower-pair mechanisms based on matrices”, J. Applied Mechanics, 1955 — used for: the classic joint-parameter convention for serial chains.