Design a basic algorithm for a self-driving car to perform lane keeping on a straight road.

Instruction: Outline the steps your algorithm would take to ensure the vehicle stays within its lane, considering inputs from cameras and/or sensors. Simulation-only fixture: lateral error e is positive to the left, heading error psi is positive counterclockwise, and positive steering turns left. At a fixed low simulated speed, use raw steering delta=-0.2e-0.5psi, clamp to ±0.3 rad, and limit change to 0.05 rad per tick. Previous command is 0; e=0.4 m and psi=0.1 rad. Compute one command. If lane confidence is below the stipulated 0.8 threshold, terminate this simulation episode; do not continue using a guessed lane.

Context: This question evaluates the candidate's understanding of algorithmic thinking in the context of autonomous driving systems. It assesses the ability to integrate sensor data to maintain lane discipline, highlighting foundational knowledge in autonomous vehicle navigation and control systems.

Updated

Example Answer

For a simulation-only lane-keeping exercise, I would estimate a lane centerline in a calibrated road frame, then compute lateral and heading error for a bounded controller. An image midpoint alone is not a metric road error because perspective and camera pose matter. Limit steering and rate of change, specify the speed range, and handle missing or unreliable lane estimates explicitly. This educational controller is not a road-ready autonomous driving system.

Make it your own

Illustrative simulation cases: centered vehicle, lateral offset, heading offset, one missing boundary and saturated steering. Record the controller response and the condition that ends the exercise safely.

Why this works

The coordinate frame and limits make the algorithm testable without implying public-road suitability. Follow-up: why can zero lateral error still require steering when heading error is nonzero?

Sources: OpenCV camera calibration, NHTSA ADS safety guidance.

Worked practice case

The raw command is -0.2×0.4-0.5×0.1=-0.13 rad. It is inside ±0.3, but the rate limiter allows only a -0.05 rad change from zero, so this tick commands -0.05 rad. Apply amplitude then slew limits consistently and retain previous command as explicit state.

At zero lateral error with nonzero heading error, the heading term still commands a correction. If confidence is below 0.8 or inputs are invalid, the contract terminates the simulation episode and records failure; it does not prove a physical safe stop. Test saturation, sign conventions, stale measurements and step-size changes. These supplied gains and thresholds are arithmetic fixtures, not calibrated vehicle-control recommendations or a stability guarantee.

Related Questions