Skip to content

Differential Drive Kinematics

A differential drive robot has two independently driven wheels. The motion is fully described by the wheel velocities and .

Forward Kinematics

Where is the wheelbase (distance between wheels).

Inverse Kinematics

Given desired linear velocity and angular velocity :

ROS 2 Implementation

python
from geometry_msgs.msg import Twist

def cmd_vel_callback(msg: Twist):
    v = msg.linear.x
    w = msg.angular.z
    L = 0.3  # wheelbase in metres

    v_right = v + (w * L / 2)
    v_left  = v - (w * L / 2)

    # Send v_right, v_left to motor driver

Odometry

python
dx = v * cos(theta) * dt
dy = v * sin(theta) * dt
dtheta = omega * dt

WARNING

Wheel slip causes odometry drift. Fuse wheel odometry with an IMU using a Kalman filter or robot_localization package.

Released under the MIT License.