dasGringuen / assetto_corsa_gym

Assetto Corsa OpenAI Gym Environment
https://assetto-corsa-gym.github.io/
MIT License
65 stars 6 forks source link
assetto-corsa gym-environment learning-from-demonstration mpc-control openai-gym racing racing-simulator reinforcement-learning reinforcement-learning-environments

Assetto Corsa Gym

Official implementation of the paper: A Simulation Benchmark for Autonomous Racing with Large-Scale Human Data

[Website] [Dataset] [ROS2 interface] [Paper]


Overview

Gym interfaces with Assetto Corsa for Autonomous Racing. This repository integrates the Assetto Corsa racing simulator with the OpenAI's Gym interface, providing a high-fidelity environment for developing and testing Autonomous Racing algorithms in realistic racing scenarios.

Features:

This repository contains all the necessary code to run the Gym interface for Assetto Corsa and RL benchmarks. For the ROS2 interface, refer to ROS2 interface

We base our SAC code on this implementation.

Source Code Tree:

Getting started

  1. Install the AC plug-in Follow the instructions in INSTALL.md

  2. Install Python in Windows

    • Install Visual Studio Compiler

      • To compile the necessary components for the plugin, download and install the Visual Studio compiler from: Visual Studio C++ Build Tools
      • Make sure to install the C++ build tools component
    • Install Python using Anaconda

      conda create -n p309 python=3.9.13
      conda activate p309
      pip install setuptools==65.5.0
      pip install -r requirements.txt
      conda install pytorch==1.12.1 cudatoolkit=11.6 -c pytorch -c conda-forge
  3. Download the tracks occupancy grid

    • Get the files from here tracks.

    • Optionally, download them using the Huggingface Hub interface:

      • Install it: conda install -c conda-forge huggingface_hub
      • And run:
        python -c "from huggingface_hub import snapshot_download; snapshot_download(repo_id='dasgringuen/assettoCorsaGym', repo_type='dataset', local_dir='AssettoCorsaGymDataSet', allow_patterns='AssettoCorsaConfigs/tracks/*')"
      • Move the pickle files to assetto_corsa_gym/AssettoCorsaConfigs/tracks.
    • To create a new track:

      • Each track needs an occupancy grid (pickle), a reference line (can be the one from AC but also something else), and the track bounds. These files are located in assetto_corsa_gym/AssettoCorsaConfigs/tracks.
      • The reference line and the occupancy grid are needed to run the Gym interface.
      • Create the occupancy grid, the reference path and the track bounds:
      • Start Assetto Corsa and set the new track.
      • Run assetto_corsa_gym/AssettoCorsaConfigs/tracks/generate_track.ipynb to create a new track. This script creates a pickle file with the occupancy grid, downloads the AC reference path, and visualizes the track. Make sure to update the assetto_corsa_gym/AssettoCorsaConfigs/tracks/config.yaml file.

Demos

Benchmarks

Experiments and parameters are configured via config.yml and executed with python train.py. Optionally, a different config file can be specified using python train.py config=<config_file>. To enable logging to Weights and Biases, appropriate values should be set in the config file. Each parameter in the config file can be modified directly from the terminal using <field>=<value>. For instance, to change the car, use AssettoCorsa.car=<car>.

Download Datasets


Contributing

You are very welcome to contribute to this project. Feel free to open an issue or pull request if you have any suggestions or bug reports, but please review our guidelines first. Our goal is to build a codebase that can easily be extended to new environments and tasks, and we would love to hear about your experience!


License

This project is licensed under the MIT License - see the LICENSE file for details. Note that the repository relies on third-party code, which is subject to their respective licenses.