Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (14.3%) to scientific vocabulary
Last synced: 10 months ago · JSON representation ·

Repository

Basic Info
  • Host: GitHub
  • Owner: NVlabs
  • License: other
  • Language: Python
  • Default Branch: main
  • Homepage:
  • Size: 833 KB
Statistics
  • Stars: 104
  • Watchers: 7
  • Forks: 8
  • Open Issues: 1
  • Releases: 0
Created over 3 years ago · Last pushed almost 2 years ago
Metadata Files
Readme License Citation

README.md

NVIDIA Source Code License Python 3.9

DiffStack

drawing

This repository contains the code for DiffStack: A Differentiable and Modular Control Stack for Autonomous Vehicles a CoRL 2022 paper by Peter Karkus, Boris Ivanovic, Shie Mannor, Marco Pavone.

DiffStack is comprised of differentiable modules for prediction, planning, and control. Importantly, this means that gradients can propagate backwards all the way from the final planning objective, allowing upstream predictions to be optimized with respect to downstream decision making.

Disclaimer this code is for research purpose only. This is only an alpha release, not product quality code. Expect some rough edges and sparse documentation.

Credits: the code is built on Trajectron++, Differentiable MPC, Unified Trajctory Data Loader, and we utilize several other standard libraries.

Setup

Install

Create a conda or virtualenv environment and clone the repository

bash conda create -n diffstack python==3.9 conda activate diffstack git clone https://github.com/NVlabs/diffstack

Install diffstack (locally) with pip

bash cd diffstack pip install -e ./

This single step is sufficient to install all dependencies. For active development, you may prefer to clone and install Trajectron++, Differentiable MPC, and Unified Trajctory Data Loader manually.

Prepare data

Download and setup the NuScenes dataset following https://github.com/NVlabs/trajdata/blob/main/DATASETS.md

The path to the dataset can be specified with the --data_loc_dict argument, the default is --data_loc_dict={\"nusc_mini\": \"./data/nuscenes\"}

Usage

We currently support training and evaluation from two data sources.

  • Cached data source (--data_source=cache) corresponds to a custom preprocessed dataset that allows reproducing results in the paper.
  • Trajdata source (--data_source=trajdata) is an interface to the Unified Trajectory Data Loader that supports various data sources including nuScenes, Lyft, etc. This is the recommended way to train new models.

We provide a couple of example commands below. For more argument options use python ./diffstack/train.py --help or look at ./diffstack/argument_parser.py.

Training a new model

To train a new model we recommend using the trajdata data source and the following default arguments. See Unified Trajectory Data Loader for setting up different datasets.

An example for data-parallel training on the nuScenes mini dataset using 1 gpu. Remember to change the path to the dataset. Use the full training set instead of minival for meaningful results.

bash python -m torch.distributed.run --nproc_per_node=1 ./diffstack/train.py \ --data_loc_dict={\"nusc_mini\": \"./data/nuscenes\"} \ --train_data=nusc_mini-mini_train \ --eval_data=nusc_mini-mini_val \ --predictor=tpp \ --plan_cost=corl_default_angle_fix \ --plan_loss_scaler=100 \ --plan_loss_scaler2=10 \ --device=cuda:0

Reproducing published results

To reporduce results you will need to download our preprocessed dataset (nuScenes-minival, nuScenes-full) and optionally the pretrained models (checkpoints). Please only use the dataset and models if you have agreed to the terms for non-commercial use on https://www.nuscenes.org/nuscenes. The preprocessed dataset and pretrained models are under the CC BY-NC-SA 4.0 licence.

Evaluate a pretrained DiffStack model with jointly trained prediction-planning-control modules on the nuscenes minival dataset. Remember to update the path to the downloaded data and models. Use the full validation set to reproduce results in the paper.

bash python ./diffstack/train.py \ --data_source=cache \ --cached_data_dir=./data/cached_data/ \ --data_loc_dict={\"nusc_mini\": \"./data/nuscenes\"} \ --train_data=nusc_mini-mini_train \ --eval_data=nusc_mini-mini_val \ --predictor=tpp_cache \ --dynamic_edges=yes \ --plan_cost=corl_default \ --train_epochs=0 \ --load=./data/pretrained_models/diffstack_model.pt

Retrain a DiffStack model (on cpu) using our preprocessed dataset. Remember to update the path to the downloaded data. When training a new model you should expect semantically similar results as in the paper, but exact reproduction is not possible due to different random seeding of the public code base.

bash python ./diffstack/train.py \ --data_source=cache \ --cached_data_dir=./data/cached_data/ \ --data_loc_dict={\"nusc_mini\": \"./data/nuscenes\"} \ --train_data=nusc_mini-mini_train \ --eval_data=nusc_mini-mini_val \ --predictor=tpp_cache \ --dynamic_edges=yes \ --plan_cost=corl_default \ --plan_loss_scaler=100

To use 1 gpu and distributed data parallel pipeline use:

bash python -m torch.distributed.run --nproc_per_node=1 ./diffstack/train.py \ --data_source=cache \ --cached_data_dir=./data/cached_data/ \ --data_loc_dict={\"nusc_mini\": \"./data/nuscenes\"} \ --train_data=nusc_mini-mini_train \ --eval_data=nusc_mini-mini_val \ --predictor=tpp_cache \ --dynamic_edges=yes \ --plan_cost=corl_default \ --plan_loss_scaler=100 \ --device=cuda:0

Train a standard stack that only trains for a prediction objective by setting --plan_loss_scaler=0:

bash python -m torch.distributed.run --nproc_per_node=1 ./diffstack/train.py \ --data_source=cache \ --cached_data_dir=./data/cached_data/ \ --data_loc_dict={\"nusc_mini\": \"./data/nuscenes\"} \ --train_data=nusc_mini-mini_train \ --eval_data=nusc_mini-mini_val \ --predictor=tpp_cache \ --dynamic_edges=yes \ --plan_cost=corl_default \ --plan_loss_scaler=0 --device=cuda:0

Licence

The source code is released under the NSCL licence. The preprocessed dataset and pretrained models are under the CC BY-NC-SA 4.0 licence.

Owner

  • Name: NVIDIA Research Projects
  • Login: NVlabs
  • Kind: organization

Citation (CITATION.cff)

cff-version: 1.2.0
message: "If you use this software, please cite it as follows."
authors:
- family-names: "Karkus"
  given-names: "Peter"
  orcid: "https://orcid.org/0000-0002-1474-9771"
- family-names: "Ivanovic"
  given-names: "Boris"
  orcid: "https://orcid.org/0000-0002-8698-202X"
- family-names: "Mannor"
  given-names: "Shie"
  orcid: "https://orcid.org/0000-0003-4439-7647"    
- family-names: "Pavone"
  given-names: "Marco"
  orcid: "https://orcid.org/0000-0002-0206-4337"
title: "DiffStack: A Differentiable and Modular Control Stack for Autonomous Vehicles."
version: 0.0.1
date-released: 2022-12-02
url: "https://github.com/NVlabs/diffstack"

GitHub Events

Total
  • Watch event: 8
Last Year
  • Watch event: 8

Dependencies

pyproject.toml pypi
requirements.txt pypi
  • dill *
  • imageio ==2.9.0
  • matplotlib *
  • ncls ==0.0.57
  • numpy *
  • orjson ==3.5.1
  • pathos ==0.2.9
  • scipy *
  • torch ==1.12.1
  • tqdm *
  • wandb *