# Module 2.1: Kinematic Trees and Robot Description Formats

- Course: [Course 2: Robot Modeling, Velocities & Physical Structure](https://roboticsconcepts.dev/courses/robot-modeling-velocities-physical-structure.md)
- HTML Page: https://roboticsconcepts.dev/courses/robot-modeling-velocities-physical-structure/kinematic-trees-and-robot-descriptions/
- Key Concepts: Branched kinematic trees, URDF & MJCF XML structure, Joint origins, axes, and limits

In Course 1, every robot we drew was a single line of links connected end to end. The moment I opened my first real quadruped model, that mental picture broke: a torso doesn't lead to one tip — it branches out into four legs, each with three joints of its own, plus sensors bolted onto the nose and back.

## From single chains to branching trees

Think of a family tree or a folder directory on your laptop. You start at one root folder — usually the robot's torso or base chassis — and branch outward. Every branch splits cleanly into child folders, and no folder ever loops back to become its own parent.

In robotics software, that branching hierarchy is called a kinematic tree. A humanoid torso branches into two arms, two legs, and a head; a mobile manipulator branches from a wheeled base into an arm, a gripper, and an overhead camera mast. Why no loops? Because a tree guarantees that every piece of the robot has one unique path back to the root, so forward kinematics stays fast and unambiguous.

## Reading URDF and MJCF without getting lost in XML

When you load a robot into ROS, MuJoCo, Isaac, or Drake, it almost always arrives as an XML description file — either URDF (Unified Robot Description Format) or MuJoCo's MJCF. Both files look verbose at first, yet they only really say two things over and over:

- Links (`<link>` in URDF, `<body>` in MJCF): the rigid physical parts — a shin, a forearm, a camera housing — carrying mass, inertia, visual shape, and collision shape.
- Joints (`<joint>`): the moving connections tying one parent link to one child link, specifying the joint type (`revolute`, `continuous`, `prismatic`, or `fixed`), the 3D `<origin>` offset where the hinge sits, the spin `<axis>`, and safe `<limit>` bounds.

## Interactive Sandbox: URDF & Collision Capsule Inspector

Switch between the Articulated Arm and Branched Quadruped presets below. Drag the link length and capsule radius sliders, and watch how the live URDF XML updates each `<origin>` offset and `<geometry>` tag in real time.

## Why origin offsets and joint limits save hardware

Notice in the XML snippet how `<origin xyz="..." rpy="..."/>` places the child joint at the far tip of its parent link. Get one sign or meter-vs-millimeter scale wrong in that origin tag and a robot dog's knees will spawn floating three meters behind its hips.

Joint `<limit lower="..." upper="..." effort="..." velocity="..."/>` attributes matter just as much. Real servos hit mechanical hard stops and cables twist until they snap. Encoding those physical bounds right in the robot description lets planners and reinforcement learning policies respect hardware limits from day one.

## Parent-to-child transform along a tree edge

```text
T_parent←child(q) = T_origin(xyz, rpy) · T_joint(axis, q)
```

Each joint in a URDF or MJCF file combines one fixed mounting offset (where the bracket sits on the parent) with one variable motion along the joint axis.

## Check Your Intuition

**Question:** In a standard URDF kinematic tree for a quadruped robot, which parent-child relationship is valid?

- [✓] Torso (parent) → Front-Left Hip (child), and Front-Left Hip (parent) → Front-Left Thigh (child)
- [ ] Front-Left Foot (parent) → Torso (child) AND Torso (parent) → Front-Left Hip (child) forming a closed loop
- [ ] All four feet listed as parents of the torso simultaneously

**Explanation:** A kinematic tree is strictly acyclic: each link except the root has exactly one parent, branching outward from the torso toward the limbs.

## Where You'll See This in Modern Robotics

MJCF is increasingly popular in GPU-accelerated RL because it natively supports closed-loop tendons, contact friction parameters, and nested `<body>` tags, whereas URDF remains the universal exchange format across ROS and CAD exporters.

## Companion Python Notebook: 01 · Kinematic Trees & URDF Parsing Lab

Parse branched URDF XML descriptions in Python, inspect parent-child joint limits, and compute link poses across an articulated arm or quadruped leg.

- Open in molab (WASM): https://molab.marimo.io/github/alchemicduncan/robotics-concepts-dev/blob/main/notebooks/course-2/01_kinematic_trees_urdf.py/wasm
- Open in Google Colab: https://colab.research.google.com/github/alchemicduncan/robotics-concepts-dev/blob/main/notebooks/colab/course-2/01_kinematic_trees_urdf.ipynb
- Download .py: https://roboticsconcepts.dev/downloads/notebooks/course-2/01_kinematic_trees_urdf.py
- Download .ipynb: https://roboticsconcepts.dev/downloads/notebooks/colab/course-2/01_kinematic_trees_urdf.ipynb
- Run locally: `uvx marimo edit --sandbox notebooks/course-2/01_kinematic_trees_urdf.py`
