Skip to content
LumenaryAcademy
Systems 70 min

Autonomous vehicles and field robots

Robots that drive among people, and robots that work on farms, in mines and around industrial plants. The driving stack, the SAE levels, a path-tracking controller built and tested, sensors, safety cases, where robotaxis stand in 2026, and the field robots already at work.

Code tested · 5AI-draftedAwaiting review by a roboticist

Your guides: Chloe · The Builder, Margaret · The Experimenter, Gideon · The Safety Engineer

MotivationH

The hardest everyday robot

Road crashes kill about 1.19 million people a year, according to the World Health Organization's 2023 report, and most crashes involve human error: distraction, fatigue, alcohol, speed. A car that drives itself and never tires is one of the oldest dreams in robotics, and one of the hardest to realise, because a road is an open world. It has rain and glare, roadworks and police officers waving people through red lights, children chasing balls and drivers who break the rules. A robot arm in a cage meets a handful of situations; a car meets millions, and the rare ones are the dangerous ones.

The same technology also works far from public roads, where the world is easier to control. Tractors have steered themselves along crop rows by satellite for two decades; driverless haul trucks have carried ore in Chilean and Australian mines since the late 2000s; legged robots and drones inspect plants where people would rather not go. These field robots are often the most successful mobile robots of all.

This lesson describes how an autonomous vehicle is organised, the vocabulary used to say what it can do, one of its controllers in working code, how its safety is argued, and where robotaxis and field robots stand in 2026. It assumes the bicycle model of Wheeled robots, localisation from Particle filters and localisation and planning from the Planning level.

IntuitionH

The driving stack

Most autonomous-driving systems are organised as a pipeline of modules, each a large engineering effort in itself.

sensorscamera, radar,lidar, GNSS, IMUperceptionlocalisationpredictionplanningroute, behaviour,motioncontrolvehiclesteer, brakemap: lanes, signs, speed limits
A modular autonomous-driving stack. Sensors feed perception and localisation; prediction forecasts what other road users will do; planning chooses a route, a behaviour and a trajectory; control turns the trajectory into steering, throttle and brake. A map supplies prior knowledge to most stages.
  • Perception turns raw sensor data into a description of the scene: other vehicles, pedestrians and cyclists with their positions, sizes and velocities (usually as tracked 3-D boxes), lane markings, traffic lights and signs, free space, and anything unrecognised but solid. It uses the methods of Cameras and vision and Depth and point clouds, mostly deep networks, with tracking by the filters of the Perception level.
  • Localisation places the car on a map to about ten centimetres, by matching lidar or camera features to a prior map and fusing GNSS, IMU and wheel odometry. Many systems use detailed HD maps of lanes, kerbs and signs; others build more of the picture online.
  • Prediction forecasts what each other road user is likely to do over the next few seconds, as several possible futures with probabilities: will that cyclist turn, will that car let us merge?
  • Planning works at three scales: a route through the road network (graph search, as in Planning on graphs and grids), a behaviour (follow, change lane, yield, stop), and a trajectory for the next several seconds that is smooth, comfortable and keeps clear of everyone's predicted motion (Trajectory optimisation).
  • Control makes the vehicle follow that trajectory with steering, throttle and brake, many times a second.

Since about 2020 a second architecture has grown in importance: end-to-end driving, an idea as old as Carnegie Mellon's ALVINN (1989), in which one large neural network maps sensor data (and often a route) directly to a trajectory, trained on very large amounts of human driving. Tesla describes its recent driver-assistance software this way, the British company Wayve was founded on the approach, and comma.ai's open-source openpilot uses a learned driving model. Modular systems are easier to test piece by piece and to explain after an incident; end-to-end systems avoid hand-designed interfaces that lose information. Many 2026 systems mix the two, for instance a learned planner checked by a rule-based safety layer.

DefinitionsH

SAE J3016 and the levels of automation

The industry's vocabulary for "how automated" comes from the standard SAE J3016, written by SAE International with ISO. It rests on three ideas.

Definition— Dynamic driving task, operational design domain, fallback

The dynamic driving task (DDT) is everything a driver does in real time: steering, braking and accelerating, and watching the road and responding to what happens. The operational design domain (ODD) is the set of conditions a system is designed to work in: which roads, speeds, times of day, weather, and so on. The fallback is whoever deals with a failure or with leaving the ODD: a human, or the system itself by reaching a minimal risk condition such as stopping safely at the roadside.

In our own words, the six levels are:

LevelNameWho drivesWho must watch and take over
0No driving automationthe human (warnings and brief emergency help allowed)the human
1Driver assistancethe human, with the system steering or controlling speedthe human
2Partial automationthe system steers and controls speedthe human, at every moment
3Conditional automationthe system, within its ODDthe human, when asked, with some warning
4High automationthe system, within its ODDthe system itself: no human needed
5Full automationthe system, everywhere a human could drivethe system itself

Adaptive cruise control is Level 1; adaptive cruise plus lane centring, including "hands-off" motorway systems, is Level 2, and the driver remains responsible even when the hands are off the wheel. Level 3 systems let the driver look away within a narrow ODD, typically a motorway traffic jam: Honda offered one in Japan in 2021, and Mercedes-Benz's Drive Pilot was approved in Germany in 2021 and in Nevada and California in 2023. Driverless robotaxis are Level 4: no one needs to be in the driver's seat, but only inside a mapped service area and in conditions the operator has validated. No Level 5 system exists.

ComputationC

How far must a car see?

A car must notice a hazard, decide, and stop before reaching it. Stopping distance is the distance covered during the reaction time, v trv\,t_r, plus the braking distance, v2/(2a)v^2/(2a) for a deceleration aa. The program compares a human driver (reaction 1.5 s) with an automated system (0.5 s from sensing to braking) on dry and wet roads, and then asks how much of a pedestrian the sensors see at those distances.

python
import numpy as np

def stopping_distance(v_kmh, reaction_s, decel):
    """Distance travelled while reacting, plus braking distance v^2 / (2a), in metres."""
    v = v_kmh / 3.6
    return v * reaction_s + v ** 2 / (2 * decel)

print("speed      human, dry   automated, dry   automated, wet")
print("(km/h)     1.5 s, 6     0.5 s, 6         0.5 s, 4 m/s^2")
for v in [30, 50, 80, 100, 130]:
    print(f"{v:5d}    {stopping_distance(v, 1.5, 6):8.1f} m   {stopping_distance(v, 0.5, 6):8.1f} m"
          f"       {stopping_distance(v, 0.5, 4):8.1f} m")

# What does each sensor see of a pedestrian (0.5 m wide, 1.7 m tall) at these ranges?
lidar_h, lidar_v = 0.1, 0.2        # lidar angular spacing between points, degrees (horizontal, vertical)
cam_deg_per_px = 60 / 1920         # a camera with a 60-degree field of view, 1920 pixels across
print("\nrange    lidar points on a pedestrian    camera pixels (w x h)")
for d in [20, 50, 100, 150]:
    w_deg = np.degrees(0.5 / d)
    h_deg = np.degrees(1.7 / d)
    points = int(w_deg / lidar_h) * int(h_deg / lidar_v)
    print(f"{d:4d} m    {points:12d}                   {w_deg / cam_deg_per_px:5.1f} x {h_deg / cam_deg_per_px:5.1f}")
Runs entirely in your browser, in an isolated worker. Nothing is sent to a server.

At 50 km/h, a typical city limit, the automated system needs 23 m on a dry road; at 130 km/h on a wet motorway it needs 181 m. Over those distances the data thin out fast: at 20 m a pedestrian returns 336 lidar points and fills 46 by 156 camera pixels, but at 100 m only 8 lidar points and a 9 by 31 pixel patch, and at 150 m just 3 points. That is why motorway driving at speed needs long-range sensors, why detection range is quoted so prominently in sensor datasheets, and why every system must slow down when it cannot see far enough: in fog, round a bend, over a crest.

Each sensor type has different strengths, so most vehicles combine several.

  • Cameras are cheap and see colour, texture, lane paint, signs and traffic lights, but measure range only indirectly (from stereo, motion or learned depth) and suffer in darkness, glare and heavy rain.
  • Radar (usually at 77 GHz) measures range and, through the Doppler shift, relative speed directly, and works in rain, fog and darkness, but with coarse angular resolution; newer "imaging" radars improve that.
  • Lidar measures range to millions of points a second with centimetre precision, day or night, but costs more and degrades in heavy precipitation. Lidar makers span many countries, including Hesai and RoboSense in China, Ouster and Luminar in the United States, Valeo in France and Innoviz in Israel.
  • Ultrasonic sensors handle parking distances; GNSS with an IMU and wheel odometry support localisation.

Robotaxi developers such as Waymo, Baidu and Pony.ai use all of these together, for redundancy and diversity: two sensors that fail in different conditions are worth more than two that fail together. Tesla has bet on cameras alone, arguing that people drive with vision. Which approach reaches a given level of safety at a given cost is an open question, to be settled by evidence rather than argument.

Worked examplesH

Following a path: pure pursuit

Control is the stage nearest the wheels, and its simplest well-tested algorithm is a lovely piece of geometry. Pure pursuit, from Carnegie Mellon's autonomous vehicles of the 1980s, chooses a point on the path a fixed lookahead distance LdL_d ahead of the vehicle and steers along the circular arc that reaches it.

PG (target)L_dαRcentreheadingpath
Pure-pursuit geometry, seen from above. The rear axle is at P, heading along the arrow. The target point G lies on the path a distance L_d away, at angle α to the heading. The steered arc is the circle tangent to the heading at P that passes through G; its radius R satisfies L_d = 2R sin α.

Theorem— The pure-pursuit arc

Let the rear axle be at PP with heading θ\theta, and let the target point GG be at distance LdL_d from PP, at angle α\alpha to the heading. The circle tangent to the heading at PP and passing through GG has curvature

κ=1R=2sin⁡αLd,\kappa = \frac{1}{R} = \frac{2\sin\alpha}{L_d},

so a vehicle with wheelbase LL following it, in the bicycle model, steers at δ=arctan⁡(Lκ)=arctan⁡ ⁣(2Lsin⁡α/Ld)\delta = \arctan(L\kappa) = \arctan\!\big(2L\sin\alpha/L_d\big).

Proof

The chord PGPG of a circle of radius RR makes an angle α\alpha with the tangent at PP. By the tangent–chord angle theorem, the chord subtends an angle 2α2\alpha at the centre, so the isosceles triangle formed by the centre, PP and GG has sides RR, RR and Ld=2Rsin⁡αL_d = 2R\sin\alpha. Hence 1/R=2sin⁡α/Ld1/R = 2\sin\alpha/L_d. The bicycle model of Wheeled robots turns with curvature tan⁡δ/L\tan\delta/L, and equating the two gives δ\delta.

∎

On a circle of constant radius the arc through the target is the circle, so in steady state pure pursuit tracks a circular path exactly. Errors come where curvature changes: the lookahead point reaches the bend first, so the car starts turning early and cuts the corner. The program drives a car with a 2.7 m wheelbase round a path of 50 m of straight, a 90° bend of radius 40 m and another straight, starting 1 m off the line, with the controller running at 20 Hz and a steering actuator that lags its command by 0.15 s.

python
import numpy as np

L = 2.7                                   # wheelbase (m)
delta_max = np.radians(35)                # steering limit
tau_steer = 0.15                          # the steering actuator lags its command (s)

# The path: 50 m straight east, a 90-degree left turn of radius 40 m, then 40 m straight north.
s1 = np.arange(0, 50, 0.1)
arc = np.arange(0, np.pi / 2, 0.1 / 40)
s3 = np.arange(0.1, 40, 0.1)
path = np.vstack([np.c_[s1, np.zeros_like(s1)],
                  np.c_[50 + 40 * np.sin(arc), 40 - 40 * np.cos(arc)],
                  np.c_[np.full_like(s3, 90.0), 40 + s3]])

def cross_track_error(x, y):
    """Distance from (x, y) to the path, using its exact shape."""
    if x < 50:
        return abs(y)
    if y < 40:
        return abs(np.hypot(x - 50, y - 40) - 40)
    return abs(x - 90)

def lookahead_point(x, y, i_near, Ld):
    """First path point at least Ld from the rear axle, searching forward from the nearest point."""
    d = np.hypot(path[i_near:, 0] - x, path[i_near:, 1] - y)
    ahead = np.nonzero(d >= Ld)[0]
    return path[i_near + ahead[0]] if ahead.size else path[-1]

def pure_pursuit(x, y, th, target):
    dx, dy = target[0] - x, target[1] - y
    alpha = np.arctan2(dy, dx) - th                       # angle to the target, seen from the car
    ld = np.hypot(dx, dy)
    return np.arctan2(2 * L * np.sin(alpha), ld)          # steer onto the circle through the target

def drive(v, Ld, T=None, dt=0.01, control_dt=0.05):
    x, y, th, delta, cmd = 0.0, -1.0, 0.0, 0.0, 0.0       # start 1 m to the right of the path
    T = T or (50 + 40 * np.pi / 2 + 35) / v
    i_near, errs, turn_errs = 0, [], []
    for k in range(int(round(T / dt))):
        lo = i_near
        i_near = lo + int(np.argmin(np.hypot(path[lo:lo + 300, 0] - x, path[lo:lo + 300, 1] - y)))
        e = cross_track_error(x, y)
        errs.append(e)
        if x > 50 and y < 40:
            turn_errs.append(e)
        if k % round(control_dt / dt) == 0:               # the controller runs at 20 Hz
            cmd = np.clip(pure_pursuit(x, y, th, lookahead_point(x, y, i_near, Ld)), -delta_max, delta_max)
        delta += (cmd - delta) * dt / tau_steer           # first-order steering actuator
        x += v * np.cos(th) * dt
        y += v * np.sin(th) * dt
        th += v * np.tan(delta) / L * dt
    errs = np.array(errs)
    settle = int(3.0 / dt)                                # ignore the first 3 s (initial offset)
    return np.sqrt(np.mean(errs[settle:] ** 2)), max(turn_errs)

print("speed   lookahead   RMS error after 3 s   worst error in the turn")
for v in [5.0, 12.0]:
    for Ld in [2.0, 5.0, 10.0, 20.0]:
        rms, turn = drive(v, Ld)
        print(f"{v:4.0f} m/s   {Ld:5.1f} m        {100 * rms:6.1f} cm           {100 * turn:6.1f} cm")
print("\nspeed-scheduled lookahead Ld = 0.8 s x v (at least 3 m):")
for v in [4.0, 8.0, 12.0]:
    rms, turn = drive(v, max(3.0, 0.8 * v))
    print(f"{v:4.0f} m/s   {max(3.0, 0.8 * v):5.1f} m        {100 * rms:6.1f} cm           {100 * turn:6.1f} cm")
Runs entirely in your browser, in an isolated worker. Nothing is sent to a server.

The lookahead is the only tuning knob, and the table shows both ways it can go wrong. Long lookaheads cut corners and recover slowly from the initial offset: with 20 m the car is still 0.5–0.6 m off the line on average and swings a metre inside the bend. Short lookaheads track tightly at low speed (0.2 cm RMS with 2 m at 5 m/s) but at 12 m/s the same 2 m lookahead, combined with the steering lag, makes the car weave across the road, up to 3.1 m off the line. The usual fix is to scale the lookahead with speed, here 0.8 s of travel, which keeps the worst error in the bend below 14 cm from 4 to 12 m/s.

Pure pursuit is still used, especially on slower vehicles and in agriculture, and a regulated variant of it is one of the standard path followers in ROS 2's Nav2. Stanford's Stanley, which won the 2005 DARPA Grand Challenge across the Mojave Desert, used a related controller steering on the front axle's cross-track and heading errors. Production vehicles mostly use model predictive control with a dynamic bicycle model that includes tyre slip, which handles speed, actuator limits and comfort together.

ExplanationH

Safety cases and validation

How do you show that a self-driving car is safe enough? The obvious answer, drive it a long way and count crashes, runs into statistics. In the United States in the early 2020s, people drove roughly a hundred million miles for every 1.3 road deaths. The program asks how many miles a fleet would need to drive to show, at 95% confidence, that it does better.

python
import math

def poisson_cdf(k, lam):
    """P(X <= k) for X ~ Poisson(lam)."""
    return sum(math.exp(i * math.log(lam) - lam - math.lgamma(i + 1)) for i in range(k + 1)) if lam > 0 else 1.0

def upper_bound(k, conf=0.95):
    """Exact one-sided upper confidence bound on a Poisson mean after observing k events."""
    lo, hi = 0.0, 10.0 + 10 * k
    for _ in range(100):                                  # bisection
        mid = (lo + hi) / 2
        lo, hi = (mid, hi) if poisson_cdf(k, mid) > 1 - conf else (lo, mid)
    return hi

human = 1.3e-8                                            # deaths per mile driven, roughly the US rate
print(f"zero events: 95% upper bound on the mean = {upper_bound(0):.3f} (the 'rule of three')")
print(f"miles with no death needed to show a rate below the human one: {upper_bound(0) / human / 1e6:.0f} million")

# Suppose the system really is 20% safer than people. How many miles until a 95% upper bound
# falls below the human rate, in 80% of possible histories (80% statistical power)?
def power(miles, true_rate):
    lam = true_rate * miles
    kmax = 0
    while upper_bound(kmax + 1) / miles < human:          # the largest count that still proves the claim
        kmax += 1
    return poisson_cdf(kmax, lam) if upper_bound(0) / miles < human else 0.0

for billions in [1, 5, 10, 15, 20]:
    print(f"{billions:3d} billion miles: chance of demonstrating 'safer than people' = {power(billions * 1e9, 0.8 * human):.2f}")
Runs entirely in your browser, in an isolated worker. Nothing is sent to a server.

With zero events, the 95% upper bound on the expected count is 3.0, the statistician's rule of three, so 230 million fatality-free miles are needed just to show a rate below the human one. To demonstrate that a system which really is 20% safer than people is safer, with an 80% chance of succeeding, takes about ten billion miles. Kalra and Paddock's RAND report reached a similar conclusion in 2016, and every software update partly resets the count. Mileage helps, especially for the much more frequent injury crashes, but it cannot carry the argument alone.

The industry's answer is a safety case: a structured argument, backed by evidence, that the system is acceptably safe for a defined ODD. Its evidence comes from several directions:

  • Functional safety, under ISO 26262, for faults in hardware and software (the methods of Embedded control and safety): redundant computers, braking and steering, so that no single failure removes control.
  • Safety of the intended functionality (SOTIF, ISO 21448) for hazards with no fault at all, where a working system misjudges a situation, such as a perception network that fails to recognise an unusual vehicle.
  • Scenario-based testing: catalogues of situations (cut-ins, jaywalkers, emergency vehicles) tested in simulation by the million, on closed tracks and on public roads, with special attention to the rare and dangerous tail. Simulators range from re-simulation of logged drives to open-source tools such as CARLA.
  • Standards for the safety case itself, such as UL 4600, and regulations such as the UNECE's rules for automated lane-keeping systems, applied in many countries.

After a deployment, safety is monitored: operators and regulators analyse every collision and near miss, and some jurisdictions (California, for example) publish crash and testing reports.

ExplanationH

Robotaxis as of 2026

This changes month by month; the companies' and regulators' own pages are the authority. As of 2026, the picture is as follows.

  • United States. Waymo (part of Alphabet) has run fully driverless rides for the public in the Phoenix area since 2020, opened San Francisco and Los Angeles to the public in 2024, and launched Austin and Atlanta in 2025 through Uber's app, with further cities announced; by its own count it passed 100 million driverless miles in 2025. Cruise, owned by General Motors, had its California permits suspended in October 2023 after a crash in which one of its cars dragged a pedestrian who had been thrown into its path by another vehicle; GM ended its robotaxi programme in December 2024. Tesla began a small robotaxi service in Austin in June 2025, initially with an employee in the passenger seat. Amazon's Zoox, whose vehicle has no steering wheel, began public rides in Las Vegas in 2025.
  • China. Baidu's Apollo Go, Pony.ai and WeRide run driverless commercial services in several cities, including Wuhan, Beijing, Guangzhou and Shenzhen, under local permits, and have expanded abroad, notably to the United Arab Emirates.
  • Elsewhere. The United Kingdom's Automated Vehicles Act (2024) set out a framework for self-driving vehicles, with pilots of self-driving taxi services planned; Germany's 2021 law allows Level 4 vehicles in approved operating areas; Japan has allowed Level 4 operation since April 2023, first used for a slow automated shuttle on a dedicated route in Eiheiji, Fukui.

The common thread is that every deployment is Level 4 with a bounded ODD: particular cities, mapped areas, speed ranges and weather, with remote human operators who can advise a vehicle that is stuck (typically without driving it). Robotaxis still struggle with some situations that people find easy, such as reading a police officer's gestures or a confusing construction zone, and their public acceptance varies from city to city.

ExplanationH

Field robots: farms, mines and inspection

Off public roads, autonomy arrived earlier, because the operator controls the site: access is restricted, speeds are low, routes are known, and machines can stop whenever anything unexpected appears.

Agriculture. GNSS auto-steering with RTK corrections, accurate to a couple of centimetres, has been routine on large farms for two decades; the driver turns at the end of the row and the tractor steers the rows itself. Fully driverless tractors followed: Kubota's Agri Robo tractors in Japan and John Deere's autonomous 8R, shown in 2022, among others. Smaller robots weed between crops, such as those of France's Naïo Technologies; spraying drones are common in East Asia; and milking robots, from Lely in the Netherlands and DeLaval in Sweden among others, have milked cows without a farmer present since the 1990s, one of robotics' quiet successes.

Mining. Driverless haul trucks, each carrying hundreds of tonnes, began commercial work with Komatsu's system at Codelco's Gabriela Mistral copper mine in Chile in 2008, and now operate in large numbers in Australia's Pilbara iron-ore mines and elsewhere, alongside Caterpillar's and other systems. Rio Tinto's AutoHaul trains have carried iron ore across the Pilbara without drivers since 2018–2019. These machines run in fenced, controlled sites with their own traffic management and safety standards such as ISO 17757.

Inspection. Quadrupeds such as ANYmal and Spot read gauges and listen for leaks on offshore platforms and in chemical plants; drones inspect power lines, wind turbines and bridges; wall-climbing and pipe-crawling robots check boilers, tanks and pipelines; and remotely operated robots have surveyed the damaged reactors at Fukushima Daiichi.

Note

Trying it safely. The ideas in this lesson are easy to try at small scale: a slow, battery-powered model car or wheeled robot following a taped path with pure pursuit, in a clear room, is a fine project. Full-size vehicles and agricultural or mining machines are heavy and fast, can kill, and are tested only by trained teams on closed sites with safety drivers, emergency stops and the permissions their regulators require.

Common misconceptionsH

Common misconceptions

Misconception

"Level 2 means the car can drive itself on the motorway." At Level 2 the human is driving, supervising the system at every moment, whatever the marketing name. Taking hands off the wheel does not change who is responsible.

Misconception

"Self-driving cars just need more miles to prove they are safe." Proving a fatality rate better than people's by mileage alone takes billions of miles per software version, as the calculation showed. Safety cases combine mileage with engineering analysis, simulation and scenario testing.

Misconception

"A shorter lookahead always tracks the path better." Only at low speed. With actuator delay, a short lookahead at speed makes the car oscillate; a longer one cuts corners. Good trackers schedule the lookahead with speed or use model predictive control.

Misconception

"Field robots are a simpler version of self-driving cars." They solve different problems: dust, mud, GNSS shadows from pit walls and long hours without maintenance, in exchange for controlled access and lower speeds. Many of the most widely deployed autonomous machines in the world are in fields and mines, not on streets.

Exercises

Exercises

1. Autonomous vehicles and field robots

Warm-upHuman

A driver travelling at 100100 km/h sees a hazard. Their reaction time is 1.51.5 s, and the car then brakes at a steady 77 m/s². How far does the car travel from the moment the hazard appears until it stops? Give the answer in metres, to the nearest metre.

2. Autonomous vehicles and field robots

Warm-upHuman

A car's system steers within its lane and keeps its distance from the car ahead on motorways. The driver may take their hands off the wheel, but must keep watching the road and be ready to take over at any moment. Which SAE J3016 level is it?

Choose one

3. Autonomous vehicles and field robots

CoreHuman

Suppose people's rate is exactly 11 death per 100100 million miles. A test fleet drives NN miles with no deaths. Using the exact Poisson upper bound (an expected count of ln⁡20≈3.0\ln 20 \approx 3.0 for zero events at 95% confidence), how large must NN be, in millions of miles, to show at 95% confidence that the fleet's rate is below people's? Round to the nearest million.

4. Autonomous vehicles and field robots

CoreHuman

Which of these statements about automotive sensors are correct? Select all that apply.

Choose all that apply

5. Autonomous vehicles and field robots

CoreHuman

A delivery robot follows its path with pure pursuit and a fixed lookahead of 1 m. At walking pace it tracks beautifully, but at its top speed it weaves from side to side. Which change is most likely to fix the weaving without spoiling slow-speed tracking?

Choose one

6. Autonomous vehicles and field robots

CoreComputational

Write pure_pursuit_steer(x, y, theta, gx, gy, L=2.7). The rear axle is at (x,y)(x, y) with heading theta (radians), and (gx,gy)(g_x, g_y) is the target point. Return the steering angle δ\delta that puts a bicycle-model car with wheelbase LL on the circular arc tangent to its heading through the target: δ=arctan⁡(2Lsin⁡α/Ld)\delta = \arctan\big(2L\sin\alpha/L_d\big), where LdL_d is the distance to the target and α\alpha its angle from the heading. The starter points the wheels straight at the target, a common first attempt; the tests show why that is wrong.

Runs entirely in your browser, in an isolated worker. Nothing is sent to a server.

7. Autonomous vehicles and field robots

CoreComputational

The other half of pure pursuit is choosing the target. Write lookahead_index(path, x, y, i_near, Ld): path is an array of shape (n,2)(n, 2) of points in order along the path, (x, y) is the rear axle, and i_near is the index of the path point nearest the car. Return the index of the first point at or after i_near whose distance from the car is at least Ld, or the last index, n−1n - 1, if there is none.

Runs entirely in your browser, in an isolated worker. Nothing is sent to a server.

Further reading and resources