Skip to content

Physical AI Engineering from Scratch

EXP_000 · 44 LESSONS · 10 PARTS · 2026OPEN SOURCE · MIT + CC BY 4.0

PHYSICAL AIFROM SCRATCH

44 lessons from a physics engine to a robot that picks up what you ask for. Every lesson has a runnable experiment; every number comes from a real run.

Simulation, kinematics, control, perception, planning, imitation learning, RL, sim-to-real and robot foundation models. Runs on a laptop.

LEARN IN YOUR TERMINAL
npx skills add fport/physical-ai-from-scratch
> Use start-learning to get a study plan.
CLAUDE CODE · CODEX · CURSOR · + ANY SKILL.MD AGENT

Your coding agent becomes your tutor: a short placement quiz, a plan, then one lesson at a time with the experiments run on your machine.

FIG_001 · INVERSE KINEMATICSbrowser sketch, not MuJoCo
A two-link arm solves IK every frame to reach, grasp and place a cube. Lessons 08–10, 16.

FIG_PD · INTERACTIVE SIMULATION

Inside a joint controller

A motor holds an arm against gravity with two numbers: stiffness Kp and damping Kd. Turn them down and the arm sags; remove damping and it rings; switch on gravity feedforward and the sag disappears.

BREAK IT IN THE LESSON →

Browser toy model, not MuJoCo. Measured results are in the lesson.

sag overshoot damping ratio

FIG_DT · INTERACTIVE SIMULATION

Inside a simulation step

A physics engine jumps time forward in steps and only checks for collisions at those instants. Make the step larger and a falling cube can end up on the other side of a thin table.

BREAK IT IN THE LESSON →

Browser toy model, not MuJoCo. Measured results are in the lesson.

jump per step

FIG_FLT · INTERACTIVE SIMULATION

Inside a sensor filter

Averaging the last n readings calms a noisy sensor but reports where the joint was, not where it is. Find the window where noise and lag cost the same.

BREAK IT IN THE LESSON →

Browser toy model, not MuJoCo. Measured results are in the lesson.

noise left lag total RMS error

A complete, open curriculum for the engineering behind robots that act in the physical world: simulation, spatial math, kinematics, dynamics and control, perception, planning, imitation learning, reinforcement learning, sim-to-real, and robot foundation models. Every lesson has a runnable experiment and every number comes from a run or a linked primary source.

Engineers and students who can program in Python and want to build robot software end to end. General math, machine learning, deep learning and reinforcement-learning basics are not re-taught here: each lesson links the matching lesson of the free AI Engineering from Scratch course under Learn first, and this book teaches the robotics-specific part on top of it.

  • 44 lessons in 10 parts and a capstone, in strict prerequisite order. Each lesson is 30–90 minutes.
  • One template: the problem → core idea → experiment → break it → on the real robot → check yourself → takeaways and sources.
  • Runnable on a laptop. Almost every experiment runs on a Mac or Colab CPU with MuJoCo; the few that need a GPU or the real arm say so in their metadata (run type CPU / GPU / ART / HW).
  • Recurring robots: the SO-101 arm, the Franka Panda and the Unitree Go2, using the MuJoCo Menagerie models.
Terminal window
npx skills add fport/physical-ai-from-scratch

This installs four skills from skills/ into your coding agent (Claude Code, Codex, Cursor or any agent that reads SKILL.md): start-learning (a short placement quiz and a study plan in PHYSICAL-AI-LEARNING.md), learn (one lesson per session: intuition, diagram, code, a prediction, the experiment run on your machine, exercises), check-understanding (a quiz on a part or lesson) and course-guide (where is a topic taught, what to read first). In Claude Code start with /start-learning.

Terminal window
git clone https://github.com/fport/physical-ai-from-scratch.git
cd physical-ai-from-scratch
uv sync # Python 3.14 + locked dependencies
uv run python experiments/02-timestep/experiment.py
uv run python experiments/09-jacobians/build.py # a lesson's Build it steps, checked against MuJoCo
uv run pytest # tests for physai/, the library you build in the lessons

To read the book as a website locally: cd site && npm install && npm run dev (site/README.md).

Every number in the book comes either from an experiment in experiments/ (its exact output is saved next to it) or from a linked primary source. Nothing that was not run is presented as a result; hardware steps that have not been run on the real arm are labelled as such. Rules: Numbers and sources.

The Turkish short-video series Koddan Kasa summarizes lessons from this book; see Videos and lessons.

The lesson format and the “raw version before the framework” principle are inspired by Rohit Ghumare and contributors’ AI Engineering from Scratch (MIT), which this book also uses as its prerequisite course. No text or code was copied.

Code (experiments/, notebooks/, tools/, site/) is MIT (LICENSE); the lesson text is CC BY 4.0 (LICENSE-CONTENT). Robot models are downloaded from MuJoCo Menagerie under their own licenses.