juanmanzanero / fastest-lap

Fastest-lap is a vehicle dynamics simulator. It can be used to understand vehicle dynamics, to learn about driving techniques, to design car prototypes, or just for fun!
MIT License
575 stars 43 forks source link
circuit cpp dynamics formula1 ipopt modeling motogp optimal-control python racecar racing simulator vehicle

Fastest-lap 🏁🏎

Fastest-lap is a vehicle dynamics simulator. It can be used to understand vehicle dynamics, to learn about driving techniques, to design car prototypes, or just for fun!

MacOS Linux Windows Documentation Status codecov

test

What can be done

https://user-images.githubusercontent.com/26557659/163474269-5c195f4b-2109-419d-af49-7b7fa86a603d.mp4

The approach

The core of the software is a C++ library, that can be used through a Python API. Full documentation is not yet available but some examples can be found in examples/python. Fastest-lap is very efficient, being able to compute a full optimal lap in less than 1 minute.

Dynamic models

The code implements two car models:

Circuits

Circuits are modeled from paths created from google earth, for example, the right track limit of Catalunya is included in this repository (database/google_earth/Catalunya_right.kml). Circuits are then preprocessed with a tool included herein to extract a reference line, its curvature, and the distance to the left/right track limits (database/catalunya_discrete.xml).

Dependencies

Fastest-lap uses several open-source libraries:

Installation

Windows 10

Precompiled binaries are available to download for every release.

Download and unzip. The contents of the zip folder are:

Mac and Linux

This project uses CMake to build the source code and produce the binaries.

The canonical steps to compile a CMake project are: (assume $FASTESTLAP is the source code top level.)

  1. Create a build folder.
mkdir ${FASTESTLAP}/build
  1. From the build folder, run cmake
cd ${FASTESTLAP}/build && cmake ..

The options available for cmake are:

-DCMAKE_BUILD_TYPE=Debug/Release
-DCMAKE_INSTALL_PREFIX=/path/to/install/dir
-DCODE_COVERAGE=Yes/No: enables code coverage (if so, use with -DCMAKE_BUILD_TYPE=Debug)
-DBUILD_DOC=Yes/No: builds doxygen documentation

At this stage, CMake will download and install all the thirdparty dependencies.

  1. Compile
make
  1. Test (optional but recommended)
ctest --verbose
  1. Install (optional)
make install

Linux

A Docker build environment is provided and can be used to compile the shared library and generate the Python bindings.

sh ./src/scripts/linux/docker_compile.sh

Documentation

Read the latest fastest-lap online documentation

References

[1] Tremlett, A. J., and D. J. N. Limebeer. "Optimal tyre usage for a formula one car." Vehicle System Dynamics 54.10 (2016): 1448-1473.
[2] Lot, Roberto, and Nicola Dal Bianco. "Lap time optimisation of a racing go-kart." Vehicle System Dynamics 54.2 (2016): 210-230.
[3] Dal Bianco, Nicola, Roberto Lot, and Marco Gadola. "Minimum time optimal control simulation of a GP2 race car." Proceedings of the Institution of Mechanical Engineers, Part D: Journal of Automobile Engineering 232.9 (2018): 1180-1195.
[4] Lot, Roberto, and Matteo Massaro. "A symbolic approach to the multibody modeling of road vehicles." International Journal of Applied Mechanics 9.05 (2017): 1750068.
[5] Kelly, Daniel P., and Robin S. Sharp. "Time-optimal control of the race car: a numerical method to emulate the ideal driver." Vehicle System Dynamics 48.12 (2010): 1461-1474.
[6] Piccinini, Mattia. "Path planning and control of self-driving vehicles at the limits of handling"
[7] Casanova, D. "On minimum time vehicle manoeuvring: the theoretical optimal lap"
[8] Perantoni, G. et al. "Optimal Control for a Formula One Car with Variable Parameters"