How tumftm/global_racetrajectory_optimization works
Project Type and Purpose
• The project is primarily a trajectory planning and optimization tool for race cars. It generates optimal racelines based on different objectives (shortest path, minimum curvature, minimum time, and minimum time with powertrain effects). It also handles friction map generation and includes a powertrain model for more detailed simulation.
• The README clearly describes various components (friction mapping, trajectory helpers, and powertrain behavior) that are all essential to computing an optimal racing trajectory.
Analyzing the File Structure for Architectural Clues
• Top-Level Components:
• Core modules: The primary source directories are “frictionmap”, “helper_funcs_glob”, and “opt_mintime_traj”. Each has its own submodules and “src” directories, suggesting a modular design.
• Inputs and Parameters: The “inputs” folder gathers various racing track files, friction maps, and vehicle dynamic information, while the “params” folder contains configuration files (e.g., racecar.ini) needed for the optimization routines.
• Execution Scripts: The main scripts (e.g., main_gen_frictionmap.py and main_globaltraj.py) tie together the disparate packages to run friction map generation or the global trajectory optimization.
• Design Patterns:
• Functional separation is apparent: one module for friction maps, one for helper functions common to the trajectory planning, and one for the optimization (which even contains a subcomponent for modeling the powertrain).
• The presence of configuration, input, and output files (e.g., CSV export formats) suggests clear separation between data ingestion, processing, and export layers.
a. Data/Configuration Layer:
• Inputs: "inputs/frictionmaps", "inputs/tracks", and "inputs/veh_dyn_info"
• Parameters: "params/racecar.ini" and any configuration values in "requirements.txt".
• These are consumed by the main execution scripts and various modules.
b. Friction Map Module:
• Package: "frictionmap"
• Functions: Creation and plotting of friction maps (e.g., plot_frictionmap_data.py, plot_frictionmap_grid.py).
• Role: To process raw friction map files and generate visualization or intermediate data for trajectory planning.
c. Global Helper Functions:
• Package: "helper_funcs_glob"
• Functions: A variety of helper routines including data import, track interpolation, exported trajectory formatting (LTPL and race trajectory), and plotting functions.
• Role: To provide reusable code that supports both curvature and time-optimal trajectory planning.
d. Global Trajectory Optimization Module:
• Main scripts: "main_globaltraj.py" and functions within "opt_mintime_traj/src"
• Core components:
• Base trajectory planning algorithms (minimum curvature and time-optimal planning).
• Output formatting modules that generate two distinct trajectory output formats (Race Trajectory and LTPL Trajectory).
• Interaction: Consumes data from friction maps, reference track inputs, and vehicle dynamics; processes them using optimization techniques; and passes results to export routines.
e. Powertrain Optimization Component (Optional/Integrated):
• Package inside "opt_mintime_traj/powertrain_src"
• Functions: Modeling of battery, electric motor, inverter, and radiators to provide powertrain behavior simulation.
• Interaction: Directly integrated within the minimum time optimal trajectory operations when detailed powertrain dynamics are needed.
f. Execution and Integration Layer:
• Main entry points: "main_gen_frictionmap.py" for friction map generation and "main_globaltraj.py" for global trajectory optimization.
• Role: Coordinate process execution: parameter setup, data ingestion, function calls across modules, and final output generation.
Relationships and Data Flow
• This feeds into the Friction Map Module where friction data is processed and visualized (if needed).
• Helper functions offer support services (track interpolation, preprocessing) to the Global Trajectory Optimization Module.
• In the Global Trajectory Module, if the powertrain option is enabled in the parameters, data flows into the Powertrain submodule; otherwise, optimization proceeds with simplified assumptions.
• Finally, the computed trajectories are exported in either Race Trajectory or LTPL Trajectory formats, ready for subsequent use by another system (like a graph-based local trajectory planner).