---
name: differential-drive-model
description: 'Model a differential drive robot in URDF. Use when building base_link, wheel, caster, and drive joint definitions.'
---
# Differential Drive Model in URDF
## Required Links and Joints
A differential drive robot requires:
| Link | Purpose |
|---|---|
| `base_footprint` | Ground-plane frame (z=0), used by Nav2 for footprint projection |
| `base_link` | Robot body center, elevated by wheel radius |
| `left_wheel_link` | Left drive wheel |
| `right_wheel_link` | Right drive wheel |
| caster link(s) | Passive support wheels |
Frame hierarchy:
```
base_footprint → base_link → left_wheel_link
→ right_wheel_link
→ caster_link(s)
→ sensor frames
```
## base_footprint and base_link
`base_footprint` sits at ground level. `base_link` is offset upward by the wheel radius so the wheel axes are at the correct height:
```xml
```
## Wheel Joints
Drive wheels use `continuous` joints. The axis is `[0 1 0]` (rotation around the y-axis, which is the wheel's spinning axis when the joint origin places the wheel to the side):
```xml
```
Note the `rpy="${pi/2} 0 0"` on the visual/collision geometry: URDF cylinders extend along their z-axis, but we want the wheel disc facing sideways (y-axis). The π/2 roll rotation aligns the cylinder correctly.
## Wheel Separation
**Wheel separation** is the center-to-center distance between the two drive wheels. This is the most critical parameter for odometry accuracy:
```xml
```
If wheel separation is wrong, the robot will:
- Turn too much or too little for a given command
- Accumulate heading error during straight-line driving
- Have incorrect odometry-based localization
## Caster Wheels
### Ball Caster (Simple)
Model as a sphere on a fixed joint. The sphere collision provides passive ground contact:
```xml
```
Set the caster friction low in Gazebo so it doesn't resist chassis rotation:
```xml
0.010.01
```
### Swivel Caster (Realistic)
Two joints: revolute for swivel + continuous for wheel spin:
```xml
```
## Complete Differential Drive Properties
```xml
```
## Gazebo Diff-Drive Plugin
For simulation, attach the `gz-sim-diff-drive-system` plugin:
```xml
left_wheel_jointright_wheel_joint${wheel_separation}${wheel_radius}30cmd_velodomodombase_footprint
```
The plugin parameters `wheel_separation` and `wheel_radius` **must match** the URDF values exactly—otherwise simulated odometry diverges from the actual wheel motion.