Self-Driving Cars
Topic 3 · Part 1: How a self-driving car works · ⏱ about 2 h

How a Car Moves: The Bicycle Model

Describe a car with a few numbers, predict how it moves with the kinematic bicycle model, see why steering angle sets the turning radius, and learn the limits that matter for control: steering rate, grip and understeer.

Softmaxima Simulator StudioWrite your car in Python, with as many files and trained networks as it needs, and watch it drive. In your browser, nothing to install.Open
Show:
In this topic
Beginner

In plain words

A car cannot slide sideways like a shopping trolley: it can only roll the way its wheels point. Turn the wheels and it follows a circle; the harder you turn, the smaller the circle. That one fact, written down as a few lines of maths, is enough to predict where a car will go.

By the end of this topic you will be able to predict how tightly a car turns at a given steering angle, and explain why cars slide when they corner too fast.

Start with: the demo Try it: steering angle and turning radius.

Beginner

The state of a car

To control something, you first need a model: equations that predict what it will do. For a car moving on a flat road, four numbers describe it at any moment. This is its state:

  • x, y: its position in metres (we use the middle of the rear axle);
  • θ (theta): its heading, the direction it points, in radians;
  • v: its speed in metres per second.

The controller chooses two inputs: the steering angle δ (delta) of the front wheels, and the acceleration a (from the throttle or brake).

Beginner

Going deeper

The sections marked Intermediate · Maths, Code or Advanced go deeper: the equations, the code and the finer details. They are worth it when you are ready, but you can follow the whole idea without them. To hide them, press those buttons next to Show at the top of the page; the Beginner explanations and Try it demos stay.

Intermediate · Maths

The kinematic bicycle model

A car has four wheels, but at normal speeds we can merge the two front wheels into one and the two rear wheels into one: a bicycle with the same wheelbase L (the distance between the axles, 2.7 m for a typical car). Assuming the wheels roll without sliding, the state changes like this:

x˙=vcos⁡θ,y˙=vsin⁡θ,θ˙=vLtan⁡δ,v˙=a\dot x = v\cos\theta,\qquad \dot y = v\sin\theta,\qquad \dot\theta = \frac{v}{L}\tan\delta,\qquad \dot v = a

The dot means "rate of change per second". The first two equations say the car moves in the direction it points. The third is the interesting one: how fast the car turns grows with speed and with the steering angle, and is smaller for a longer car.

Holding δ fixed, the car drives in a circle of radius

R=Ltan⁡δR = \frac{L}{\tan\delta}

To simulate the model on a computer, we take small time steps Δt and add rate × Δt each time. This is Euler integration, and it is exactly what the simulator does 30 times a second.

Try it

Try it: steering angle and turning radius

Change the steering angle and the wheelbase, and watch the circle the rear axle follows.

Interactive: this part runs in your browser.

Code

Code: simulate the bicycle model

Here is the whole model in a few lines of Python. Run it: in 10 seconds at 10 m/s the car travels 100 m, which is about one lap of a 15.3 m circle (circumference 96 m), so it ends up almost where it started.

Python
import math

L = 2.7          # wheelbase in metres
dt = 0.1         # time step in seconds

def step(x, y, heading, speed, steer):
    """Move a kinematic bicycle forward by one time step."""
    x += speed * math.cos(heading) * dt
    y += speed * math.sin(heading) * dt
    heading += speed / L * math.tan(steer) * dt
    return x, y, heading

# drive at 10 m/s (36 km/h) with the wheels turned 10 degrees left, for 10 seconds
x, y, heading = 0.0, 0.0, 0.0
steer = math.radians(10)
for _ in range(100):
    x, y, heading = step(x, y, heading, 10.0, steer)

R = L / math.tan(steer)
print(f"turning radius: {R:.1f} m")
print(f"after 10 s the car is at ({x:.1f}, {y:.1f}), facing {math.degrees(heading) % 360:.0f} degrees")
print(f"distance from the circle's centre (0, {R:.1f}): {math.hypot(x, y - R):.1f} m")
Open in playground ↗

The last line is 15.4 m, not exactly 15.3: each Euler step goes straight along a tangent, so the path drifts slightly outwards. Smaller steps (try dt = 0.01 with 1,000 steps) shrink the error.

Code

Code: how the time step changes the error

Euler integration goes straight along the tangent for each step, so the path drifts slightly outside the true circle. This drives the same 10 seconds with smaller and smaller steps. Ten times smaller steps give about ten times smaller error.

Python
import math
L, speed, steer = 2.7, 10.0, math.radians(10)
R = L / math.tan(steer)

def drive(dt, seconds=10):
    x = y = heading = 0.0
    for _ in range(round(seconds / dt)):
        x += speed * math.cos(heading) * dt
        y += speed * math.sin(heading) * dt
        heading += speed / L * math.tan(steer) * dt
    return math.hypot(x, y - R) - R     # how far outside the true circle

for dt in [0.1, 1 / 30, 0.01, 0.001]:
    print(f"dt = {dt:.4f} s: {drive(dt) * 100:5.1f} cm outside the circle")
Open in playground ↗
Code

Code: grip and safe speeds

With the wheels at 10°, the car asks for a 15.3 m circle. Above about 11.4 m/s the tyres cannot give the sideways acceleration that needs, and the car drives a wider circle: understeer. The second loop prints the safe speed for bends of different sizes.

Python
import math
L, GRIP = 2.7, 8.5                       # metres; m/s² the tyres can give
steer = math.radians(10)
R = L / math.tan(steer)                  # the circle the wheels ask for

for v in [5, 10, 12, 15]:
    need = v ** 2 / R                    # sideways acceleration that circle needs
    r = max(R, v ** 2 / GRIP)            # the tyres cannot give more than GRIP
    note = "  understeer!" if need > GRIP else ""
    print(f"{v:2d} m/s: needs {need:4.1f} m/s², drives a {r:4.1f} m circle{note}")

for bend in [16, 25, 50, 100]:
    vmax = math.sqrt(GRIP * bend)
    print(f"bend of {bend:3d} m: safe up to {vmax:4.1f} m/s ({vmax * 3.6:.0f} km/h)")
Open in playground ↗
Beginner

The limits that make driving hard

  • Maximum steering angle: about 30° (0.55 rad) at the road wheels in our car.
  • Steering rate: the wheels cannot jump to a new angle; ours turn at most about 70° per second. So a controller always acts a little late, which is the main cause of wobbling.
  • Grip: in a turn of radius R at speed v, the tyres must push the car sideways with acceleration v²/R. Ordinary tyres on a dry road manage roughly 8–9 m/s² (about 0.85 g). Ask for more and the front tyres slide: the car runs wide even though the wheels are turned. This is understeer.
Intermediate · Maths

The limits that make driving hard: the maths

The grip limit sets a maximum safe speed for every bend:

vmax⁡=agrip Rv_{\max} = \sqrt{a_{\text{grip}}\, R}

For the tightest bend of the City loop (radius about 16 m) with 8.5 m/s² of grip, that is √(8.5 × 16) ≈ 11.7 m/s, or 42 km/h. Real cars and real controllers keep well below the limit, because grip drops on wet roads and passengers dislike strong sideways forces.

The kinematic model is accurate below about 0.5 g. For racing or emergency moves, engineers use a dynamic bicycle model that includes tyre forces and slip, which we meet in model predictive control.

Check yourself

Quiz

1. With the same steering angle, what happens to the turning radius if the wheelbase doubles?

2. At the same steering angle, what happens to how fast the car turns (θ̇) if the speed doubles?

3. The safe speed in a bend of radius 25 m with 8 m/s² of grip is about…

4. The wheels are turned fully left, but the car drifts wide on a fast bend. What is happening?

Go deeper

📚 Further reading

Trusted, mostly free sources: official documentation, well-known textbooks and courses. When you want to confirm or go deeper on anything here, start with these.

Ready