Skip to content

Modeling Differential Drive Wheels and Casters in URDF: Continuous Joints, Rotation Axes, and Friction

Model differential drive wheels and casters in ROS 2 Jazzy URDF using continuous joints, Y-axis cylinder rotation, Gazebo friction, and ros2_control mapping.

Contents

Key takeaways

  1. Because a URDF cylinder primitive defaults to aligning its length along the Z-axis, both visual and collision origins must apply a 90-degree roll rotation (rpy=‘1.5708 0 0’) to orient the wheel axle along the Y-axis.
  2. Both left and right wheel joints must share the identical rotation axis vector (axis xyz=‘0 1 0’) so that positive angular velocity commands drive both wheels forward.
  3. Drive wheels require continuous joints without angle limits, paired with explicit effort, velocity, and damping parameters to keep physics solvers stable.
  4. Modeling the passive caster as a fixed sphere with near-zero Gazebo friction coefficients (mu1 and mu2 between 0.0 and 0.02) establishes a stable support triangle without lateral scrubbing drag.
  5. Regardless of whether links are named wheel_left_link or left_wheel, the joint names in ros2_control and diff_drive_controller YAML files must match the URDF joint names character for character.

When a newly assembled differential drive robot veers off course or spins in circles upon receiving a straight-line velocity command, hardware builders often suspect motor wiring or encoder polarity first. In ROS 2 simulation and ros2_control deployments, however, the root cause frequently lies inside the URDF: an inverted joint <axis>, an unrotated cylinder primitive, or a caster Z-offset that lifts the drive tires slightly off the floor. Having established the package layout and elevated base_link to axle height (z = 0.0325 m) in URDF Project Skeleton: Structuring myros_sketch and Aligning base_link, chassis, and base_footprint and reviewed tag syntax in the URDF XML Syntax Guide, we can now attach the drive wheels and caster with physical precision.

This tutorial covers differential drive kinematics, orienting cylinder primitives along the Y-axis, unifying left and right continuous joint axes, calculating rotational inertia and Gazebo contact friction for spherical casters, and matching joint identifiers with diff_drive_controller.

Connecting Differential Drive Kinematics to URDF Geometry

A differential drive platform steers solely by varying the angular velocities of its left and right drive wheels ($\omega_L$ and $\omega_R$). Given a wheel radius $r$ and a wheel separation (track width) $L$ between the left and right tire contact centers, the forward linear velocity $v$ and yaw angular velocity $\omega$ of the robot’s kinematic center (base_link) are governed by forward kinematics:

v=r(ωR+ωL)2,ω=r(ωR−ωL)Lv = \frac{r(\omega_R + \omega_L)}{2}, \qquad \omega = \frac{r(\omega_R - \omega_L)}{L}

Conversely, when Nav2 or a teleoperation node publishes a /cmd_vel twist command ($v, \omega$), diff_drive_controller computes the target angular velocities for each motor using the inverse kinematics equations:

ωR=v+ωL/2r,ωL=v−ωL/2r\omega_R = \frac{v + \omega L / 2}{r}, \qquad \omega_L = \frac{v - \omega L / 2}{r}

In myros_sketch, the physical parameters are $r = 0.0325\text{ m}$ and $L = 0.16\text{ m}$ (with wheels positioned at $y = \pm 0.08\text{ m}$):

  • Straight forward motion ($v = 0.2\text{ m/s}, \omega = 0$): $\omega_R = \omega_L = 0.2 / 0.0325 \approx 6.154\text{ rad/s}$ (roughly $58.8\text{ rpm}$).
  • In-place counter-clockwise rotation ($v = 0, \omega = 1.0\text{ rad/s}$): $\omega_R = +0.08 / 0.0325 \approx +2.462\text{ rad/s}$ and $\omega_L = -2.462\text{ rad/s}$.

For odometry integration and simulated physics to agree with these equations, the <cylinder radius="0.0325"> geometry and the <origin xyz="0 ±0.08 0"> joint offsets in the URDF must match the controller YAML parameters exactly.

Comparing Wheel and Caster Coordinate Conventions

Across ROS 2 repositories, you will encounter two common conventions for attaching wheels and casters: anchoring them directly to base_link (at axle height) or anchoring them to chassis (when chassis is offset above base_link).

Design ParameterConvention A (Parent: base_link, 3-Point Support)Convention B (Parent: chassis, 4-Point Support)Integration Rule for ros2_control & TF2
Wheel Link & Joint Nameswheel_left_link / wheel_left_jointleft_wheel / left_wheel_jointWhether named wheel_left_link or left_wheel, the joint name in diff_drive_controller YAML must match the URDF <joint name>
Wheel Dimensions & Origin$r=0.0325\text{ m}, w=0.026\text{ m}$, xyz="0 ±0.08 0" from base_link$r=0.033\text{ m}, w=0.020\text{ m}$, xyz="0 ±0.11 -0.03" from chassisThe wheel axle Z height above base_footprint must equal the wheel radius $r$
Caster Link & OriginSingle front caster_link ($r=0.0125\text{ m}$), xyz="0.075 0 -0.020"Front & rear front_caster, rear_caster ($r=0.015\text{ m}$), xyz="±0.10 0 -0.045"The lowest point of the caster sphere must lie on the exact same z=0 plane as the tires

Notice that whether links are named wheel_left_link/caster_link or left_wheel/front_caster, ros2_control and diff_drive_controller bind hardware interfaces strictly by the URDF <joint name="..."> string. Below, we implement Convention A because placing base_link at the wheel axle height sets the wheel joint Z coordinate cleanly to 0.

Rotating the Cylinder Primitive (rpy) and Aligning Wheel Inertia

In URDF, the default symmetry axis of a <cylinder> primitive points along the Z-axis (vertical). Under REP-0103 coordinate conventions, however, a forward-moving robot (+X) rolls its wheels around the Y-axis (lateral left). If you insert a cylinder without rotating its local origin, the wheel lies flat on its side like a coin.

To lay the cylinder along the Y-axis, apply a 90-degree rotation about the X-axis (rpy="1.5708 0 0", since $\pi / 2 \approx 1.570796\text{ rad}$) inside the <visual> and <collision> origin tags:

<link name="wheel_left_link">
  <visual>
    <origin xyz="0 0 0" rpy="1.5708 0 0"/>
    <geometry>
      <cylinder radius="0.0325" length="0.026"/>
    </geometry>
    <material name="rubber">
      <color rgba="0.15 0.15 0.15 1.0"/>
    </material>
  </visual>
  <collision>
    <origin xyz="0 0 0" rpy="1.5708 0 0"/>
    <geometry>
      <cylinder radius="0.0325" length="0.026"/>
    </geometry>
  </collision>
  <inertial>
    <origin xyz="0 0 0" rpy="0 0 0"/>
    <mass value="0.05"/>
    <inertia ixx="1.602e-5" ixy="0.0" ixz="0.0"
             iyy="2.641e-5" iyz="0.0" izz="1.602e-5"/>
  </inertial>
</link>

As emphasized in the ROS 2 Jazzy physical and collision properties tutorial, rotating the wheel geometry so its axle lies along the Y-axis means the principal moment of inertia about the spinning axle is $I_{yy}$, while $I_{xx}$ and $I_{zz}$ represent the transverse axes:

Iyy=12mr2,Ixx=Izz=112m(3r2+h2)I_{yy} = \frac{1}{2}mr^2, \qquad I_{xx} = I_{zz} = \frac{1}{12}m(3r^2 + h^2)

For a wheel of mass $m = 0.05\text{ kg}$, radius $r = 0.0325\text{ m}$, and width $h = 0.026\text{ m}$, these formulas yield $I_{yy} = 2.641 \times 10^{-5}\text{ kg}\cdot\text{m}^2$ and $I_{xx} = I_{zz} = 1.602 \times 10^{-5}\text{ kg}\cdot\text{m}^2$.

Configuring Continuous Joints and Unifying Left/Right Axis Signs

According to the ROS Wiki URDF joint specification, type="continuous" describes an unbounded hinge joint around a single axis. Below are the left and right wheel joint declarations:

<joint name="wheel_left_joint" type="continuous">
  <parent link="base_link"/>
  <child link="wheel_left_link"/>
  <origin xyz="0 0.08 0" rpy="0 0 0"/>
  <axis xyz="0 1 0"/>
  <limit effort="1.5" velocity="20.0"/>
  <dynamics damping="0.05" friction="0.02"/>
</joint>

<joint name="wheel_right_joint" type="continuous">
  <parent link="base_link"/>
  <child link="wheel_right_link"/>
  <origin xyz="0 -0.08 0" rpy="0 0 0"/>
  <axis xyz="0 1 0"/>
  <limit effort="1.5" velocity="20.0"/>
  <dynamics damping="0.05" friction="0.02"/>
</joint>

Follow these four engineering steps when defining differential wheel joints:

  1. Set the joint Z coordinate to zero (z = 0): Because base_link is already elevated to z = 0.0325 m above base_footprint, placing the wheel joint at z = 0 relative to base_link puts the tire contact patch flush on the ground plane (z = 0).
  2. Keep both joint axes identical (axis xyz="0 1 0"): By the right-hand rule, pointing your thumb along +Y (to the left) curls your fingers in the direction of forward wheel roll. Applying a positive angular velocity (+$\omega$) to 0 1 0 rolls both the left and right wheels forward. Never flip the right wheel axis to 0 -1 0—doing so causes the right wheel to spin backward on a positive command.
  3. Specify physical <limit> and <dynamics> bounds: Even though a continuous joint has no angle limits, specifying effort="1.5" (N·m) and velocity="20.0" (rad/s, equivalent to 0.65 m/s linear speed) along with viscous damping="0.05" prevents simulation controllers from commanding infinite torque spikes.
  4. Encapsulate left/right symmetry in a xacro macro: Passing prefix (left/right) and y_reflect (1/-1) into <xacro:macro name="wheel" params="prefix y_reflect"> lets you compute origin xyz="0 ${y_reflect * wheel_separation / 2} 0" while keeping <axis xyz="0 1 0"/> invariant.
<xacro:macro name="drive_wheel" params="prefix y_reflect">
  <link name="wheel_${prefix}_link">
    <visual>
      <origin xyz="0 0 0" rpy="1.5708 0 0"/>
      <geometry>
        <cylinder radius="${wheel_radius}" length="0.026"/>
      </geometry>
      <material name="rubber"/>
    </visual>
    <collision>
      <origin xyz="0 0 0" rpy="1.5708 0 0"/>
      <geometry>
        <cylinder radius="${wheel_radius}" length="0.026"/>
      </geometry>
    </collision>
    <inertial>
      <origin xyz="0 0 0" rpy="0 0 0"/>
      <mass value="0.05"/>
      <inertia ixx="1.602e-5" ixy="0.0" ixz="0.0"
               iyy="2.641e-5" iyz="0.0" izz="1.602e-5"/>
    </inertial>
  </link>

  <joint name="wheel_${prefix}_joint" type="continuous">
    <parent link="base_link"/>
    <child link="wheel_${prefix}_link"/>
    <origin xyz="0 ${y_reflect * 0.08} 0" rpy="0 0 0"/>
    <axis xyz="0 1 0"/>
    <limit effort="1.5" velocity="20.0"/>
    <dynamics damping="0.05" friction="0.02"/>
  </joint>
</xacro:macro>

<xacro:drive_wheel prefix="left"  y_reflect="1"/>
<xacro:drive_wheel prefix="right" y_reflect="-1"/>

Using y_reflect solely inside the Y-coordinate expression guarantees that both wheels remain geometrically mirrored across the sagittal (XZ) plane while sharing the exact same positive rotation vector.

Modeling the Spherical Caster, Ground Clearance, and Support Polygon

Two coaxial wheels alone cannot balance a chassis statically; the robot requires a third contact point to form a stable support polygon. Just as bipedal robots must keep their Zero Moment Point (ZMP) and Center of Mass projection inside the foot support polygon (see Humanoid Bipedal Locomotion and Whole-Body Control Fundamentals), a differential drive robot must keep its combined Center of Mass inside the triangle formed by the two drive wheels and the front caster.

Because myros_sketch mounts its Raspberry Pi 5, LiDAR, and camera toward the front, we place a spherical caster of radius $r_c = 0.0125\text{ m}$ at $x = +0.075\text{ m}$:

<joint name="caster_joint" type="fixed">
  <parent link="base_link"/>
  <child link="caster_link"/>
  <origin xyz="0.075 0 -0.020" rpy="0 0 0"/>
</joint>

<link name="caster_link">
  <visual>
    <geometry>
      <sphere radius="0.0125"/>
    </geometry>
    <material name="nylon">
      <color rgba="0.90 0.90 0.85 1.0"/>
    </material>
  </visual>
  <collision>
    <geometry>
      <sphere radius="0.0125"/>
    </geometry>
  </collision>
  <inertial>
    <origin xyz="0 0 0" rpy="0 0 0"/>
    <mass value="0.02"/>
    <inertia ixx="1.25e-6" ixy="0.0" ixz="0.0"
             iyy="1.25e-6" iyz="0.0" izz="1.25e-6"/>
  </inertial>
</link>

Look closely at the Z offset of caster_joint: z = -0.020 m.

  • base_link elevation above the floor = $+0.0325\text{ m}$
  • Center height of a sphere with radius $0.0125\text{ m}$ resting on the floor = $+0.0125\text{ m}$
  • Relative Z offset from base_link to caster_link = $0.0125 - 0.0325 = -0.020\text{ m}$

For a solid sphere of mass $m = 0.02\text{ kg}$ and radius $r_c = 0.0125\text{ m}$, the inertia tensor is isotropic: $I_{xx} = I_{yy} = I_{zz} = \frac{2}{5}mr_c^2 = 1.25 \times 10^{-6}\text{ kg}\cdot\text{m}^2$.

Because caster_joint is fixed, the sphere slides rather than rolls across the floor in Gazebo. If left at Gazebo’s default friction (1.0), lateral scrubbing during turns will cause severe yaw chatter. Configure high traction (mu1 = 0.9) on the rubber drive wheels and near-zero friction (mu1 = 0.01) on the caster:

<gazebo reference="wheel_left_link">
  <mu1>0.9</mu1>
  <mu2>0.9</mu2>
</gazebo>

<gazebo reference="wheel_right_link">
  <mu1>0.9</mu1>
  <mu2>0.9</mu2>
</gazebo>

<gazebo reference="caster_link">
  <mu1>0.01</mu1>
  <mu2>0.01</mu2>
  <kp>1000000.0</kp>
  <kd>1.0</kd>
</gazebo>

Validating Wheel Transforms and Troubleshooting Drive Faults

Launch the visualization environment and verify the wheel and caster transforms using tf2_echo:

ros2 launch myros_sketch display.launch.py

# In a second terminal, confirm wheel and caster positions
ros2 run tf2_ros tf2_echo base_link wheel_left_link
# Expected Translation: [0.000, 0.080, 0.000]

ros2 run tf2_ros tf2_echo base_footprint caster_link
# Expected Translation: [0.075, 0.000, 0.013] (0.0125 m above floor)

In joint_state_publisher_gui, drag both wheel sliders toward positive values and confirm that both cylinders rotate forward around their Y-axes. If anomalous behavior appears during simulation, consult the diagnostic table below:

Observed SymptomTarget URDF Element to InspectRoot Cause and Corrective Action
Robot spins in place on straight /cmd_vel<axis xyz="..."/> on wheel_right_jointRight axis was inverted to 0 -1 0 → Set both wheel axes to 0 1 0
Wheels lie flat parallel to the floor<origin> inside wheel <visual> and <collision>Cylinder defaults to Z-axis → Add rpy="1.5708 0 0" to rotate 90° about X
Drive wheels slip without moving the chassisCaster joint Z offset and <gazebo> <mu1> tagsCaster Z is too low (< -0.020 m), lifting the drive tires off the ground
Chassis stutters or jerks during yaw turns<mu1> and <mu2> on caster_linkHigh friction on fixed sphere caster → Lower mu1 and mu2 to 0.0–0.02
Wheel sliders missing from joint_state_publisher_guitype="..." attribute on wheel jointsJoints declared as fixed → Change joint type to continuous

With the differential drivetrain and three-point support polygon verified, myros_sketch stands level on the ground plane. The next tutorial moves above the chassis deck to mount the onboard compute and microcontroller frames (rpi_base, rpi_frame, and esp32s3_frame).

Common mistakes

  • Omitting rpy=‘1.5708 0 0’ on the wheel cylinder geometry, leaving the wheels lying flat like pancakes parallel to the ground.
  • Setting the right wheel joint axis to 0 -1 0 in a misguided attempt at symmetry, causing the robot to spin in place when given a straight-line velocity command.
  • Miscalculating the caster Z offset relative to base_link so the caster either hangs in mid-air or lifts the drive wheels off the floor.

Pre-flight checklist

  • Do the wheel radius (0.0325 m), width (0.026 m), and wheel separation (0.16 m) match physical measurements, with wheel joint Z set to 0 relative to base_link?
  • Are both drive wheel joints declared as type=‘continuous’ with identical axis xyz=‘0 1 0’ vectors?
  • Does the wheel inertial tensor assign the solid cylinder axial formula (1/2 m r^2) to Iyy rather than Izz?
  • Does the bottom of the caster sphere touch z=0 in the base_footprint frame, with low mu1 and mu2 values configured for Gazebo?
  • Do the joint names in diff_drive_controller match the URDF continuous joint names?

Frequently asked questions

Why must drive wheels use continuous joints instead of revolute joints?
A revolute joint enforces lower and upper position bounds. As soon as a wheel rotates past 360 degrees (2π radians), the physics engine treats the limit as a hard mechanical stop, halting the wheel and creating discontinuities in wheel encoder odometry. A continuous joint removes position limits while still respecting effort and velocity bounds.
Why model a caster as a low-friction fixed sphere instead of a two-DOF swivel and wheel assembly?
A true swivel caster adds two unactuated continuous joints (vertical kingpin yaw plus wheel pitch) whose states must be published and solved at every simulation step. At low speeds, unactuated caster forks frequently suffer from numerical shimmy oscillations. A fixed sphere with near-zero friction provides the exact same vertical support height with zero extra degrees of freedom.
Is wheel separation measured between the inner edges, outer edges, or centerlines of the tires?
Wheel separation is the distance between the ground contact centerlines of the left and right tires. In myros_sketch, the wheels sit at y = +0.08 m and y = -0.08 m, giving a track width of 0.16 m. Using outer-edge measurements causes diff_drive_controller to miscalculate yaw angular velocity and accumulate heading drift.

Sources & verification

  1. ROS Wiki — urdf/XML/joint Specification
  2. ROS 2 Jazzy — Building a visual robot model with URDF from scratch
  3. ROS 2 Jazzy — Adding physical and collision properties to a URDF model
  4. REP-0103 — Standard Units of Measure and Coordinate Conventions

Last verified: