📚 Detailed Project Documentation

This document provides a comprehensive technical breakdown of every module in the Swerve Drive Physics & Path Planning repository.

📋 Table of Contents


1. Main Application: Path Tracking (path_tracking_lookahead.py)

Description

This is the flagship script of the repository. It integrates the Maze Generator, Path Planner, and Physics Robot into a single autonomous loop. The robot navigates from a random Start point to a Goal point while dynamically avoiding obstacles added by the user.

Key Classes

How to Run

python path_tracking_lookahead.py

Controls

Technical Flow

  1. Init: Generates Maze → Calculates Cost Map → Plans Path.
  2. Loop:
    • Robot gets position from Physics Engine.
    • Controller calculates command vector (Vx, Vy).
    • Physics Engine applies forces to wheels to achieve (Vx, Vy).
    • If User Clicks: Adds wall rect to list → Recalculates Cost Map → Updates Controller.

2. Physics Engine (d2.py)

Description

A high-fidelity simulator that models a robot with mass, inertia, and friction. Unlike simple geometric simulations, this robot will "drift" if it turns too fast and takes time to accelerate.

Key Classes

3. Kinematics Engine (k2.py)

Description

Handles the geometric math required to translate chassis movement into individual wheel movements and vice versa. This module is stateless and purely mathematical.

Key Functions

4. Path Planner (planner.py)

Description

Responsible for finding the optimal route from Point A to Point B within the grid. It works closely with the Cost Map generated by the grid simulator.

Key Algorithms

5. Grid & Maze Generator (sim_grid.py)

Description

Manages the environment data, including the binary obstacle map (Wall vs. Empty) and the gradient cost map (Heatmap) used for safety.

Key Features

6. Configuration (robot_config.py)

Description

A central file for tuning simulation parameters. Changing values here affects physics, kinematics, and graphics instantly.

Parameters