Self-Models, Body Schemas, and Affordances › Worked Example: A Two-Link Arm Learns Its Own Body

Michael BrenndoerferJune 18, 20263 min read
World Models HandbookAll chapters
Part 3 of 12Representing Agents and Worlds
Chapter 18Self-Models, Body Schemas, and Affordances › Worked Example: A Two-Link Arm Learns Its Own Body
Reading section 6 of 11 · Worked Example: A Two-Link Arm Learns Its Own Body · 3 minSection 6 of 11 · 3 min

Book contents

Section 6 of 11 · 3 min read

Self-Models, Body Schemas, and Affordances › Worked Example: A Two-Link Arm Learns Its Own BodyOne section · Sections in this chapter6 / 11 ↓
Reading tools Definitions & inline links

Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.

Article links

Make inline references clickable

To make everything concrete, we will build a miniature of the full chapter in code. The body schema is a neural network fit to self-generated calibration data. The learned model itself consumes only sampled joint configurations and measured end-effector poses. Analytic kinematics, Jacobians, and workspace circles are retained separately as evaluator-only ground truth, which a real experiment would replace with calibration fixtures or held-out measurements. The Jacobian comparison tests one local derivative, the reachability raster estimates positional capability, and the corridor observer performs level-1 Bayesian goal inference on a behavioral stream.

The agent is a two-link planar arm with link lengths L1=1.0L_1 = 1.0 and L2=0.8L_2 = 0.8, shoulder at the origin, joint angles q=(q1,q2)q = (q_1, q_2), and end-effector position

x=L1cos⁡q1+L2cos⁡(q1+q2),y=L1sin⁡q1+L2sin⁡(q1+q2),\begin{aligned} x &= L_1 \cos q_1 + L_2 \cos(q_1 + q_2), \\ y &= L_1 \sin q_1 + L_2 \sin(q_1 + q_2), \end{aligned}

where:

  • x,yx, y: the Cartesian coordinates of the end-effector position in the plane
  • L1,L2L_1, L_2: the lengths of the first and second links
  • q1q_1: the shoulder angle, measured from the horizontal axis of the world frame
  • q2q_2: the elbow angle, measured relative to the first link

Each term projects one link onto the axis: the first link at angle q1q_1, the second at the accumulated angle q1+q2q_1 + q_2, because q2q_2 is measured relative to the first link rather than to the world.

The agent does not get this formula. It receives self-generated calibration pairs: joint configurations from proprioception and measured Cartesian end-effector poses from an external tracker, calibrated camera, or other pose sensor. Real robots do not generally obtain Cartesian end-effector position from proprioception alone. From these pairs we will:

  • Fit a neural forward-kinematics model: the learned body schema.
  • Extract a Jacobian from the learned model by finite differences and compare it with the analytic one at one posture, testing local derivative quality without claiming closed-loop control performance.
  • Compute a reachability map by sampling joint configurations and rasterizing end-effector positions: the positional affordance map, which should reveal the annulus with its inner hole.

Then, for theory of mind, we simulate a second agent in a one-dimensional corridor who walks toward one of two hidden goals, and build an observer that performs level-1 goal inference with Bayes' rule. The posterior should rise toward the selected goal; observing the agent stop at that goal makes the posterior exactly one because the alternative hypothesis assigns zero probability to that event. In this seeded run the posterior is already close to one before the stop, so the final update is mathematically decisive but visually small. The example is small enough to reason about exactly: its likelihood ratios, geometric bounds, and posterior values can be checked by hand.