$ show thomasfermi/Algorithms-for-Automated-Driving
This repository is an educational book and accompanying code for learning algorithms for automated driving, specifically lane detection, vehicle control, and camera calibration. It uses the CARLA simulator to provide a realistic environment. The code is organized into exercises with provided solutions, test notebooks, and utility modules. The lane detection pipeline uses a deep learning segmentation model (trained with fastai) to detect lane boundaries in camera images, then applies inverse perspective mapping to convert pixel coordinates to road coordinates and fits polynomials to the lane boundaries. The control module implements PID for longitudinal control and pure pursuit for lateral control. The camera calibration module uses vanishing points to estimate camera yaw and pitch. The repository is primarily educational but contains well-structured, reusable components for camera geometry, geometric computations, and control algorithms. It is hybrid in nature, blending research/educational content with software components that could be extracted for other projects.
The LLM identified 5 files worth highlighting for reuse:
Provides the CameraGeometry class that encapsulates camera intrinsics and extrinsics, and implements inverse perspective mapping to convert pixel coordinates to 3D road coordinates. This is a self-contained module that can be reused in any project requiring camera-to-road coordinate transformations, demonstrating clean linear algebra and numpy usage.
Implements a function to find the intersection point of a circle and a polyline, used to determine the target point for pure pursuit lateral control. The circle-line segment intersection algorithm is cleanly implemented and can be reused in any geometric application requiring such computations.
Contains implementations of Pure Pursuit lateral controller and PID controller for longitudinal control, combined into a PurePursuitPlusPID class. The controllers are well-structured and parameterized, making them reusable for other vehicle control projects or simulations.
Implements online extrinsic camera calibration using vanishing points from lane boundaries. The CalibratedLaneDetector class extends LaneDetector to estimate yaw and pitch over time, averaging results and handling curved roads. This demonstrates a practical calibration algorithm that could be adapted for real-world camera-vehicle systems.
Provides utility functions for computing distances from a point to a line segment and a polyline. These are generic geometric operations implemented efficiently with numpy, suitable for reuse in any project requiring point-to-polyline distance calculations.