Skip to content

MPC-Berkeley/SHIELD_mpc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SHIELD MPC

This repository contains the implementation of a Safe Hierarchical Inference for Lightweight Duality-Screened MPC (SHIELD) algorithm.

Hansung Kim (hansung@berkeley.edu)Siddharth Nair (siddharth_nair@berkeley.edu)Francesco Borrelli

We propose a hierarchical learning-and-verification architecture that rethinks how learning interacts with optimization. Instead of learning to predict the entire optimizer, our approach learns to predict the relevant structure of the optimization problem itself. A deep neural network (DNN) maps the current system state and environmental features to a reduced set of constraints and decision variables that are likely to be active or influential for the current control step. This yields a smaller, problem-specific MPC instance (SHIELD MPC) that captures only the essential local dynamics. Leveraging strong duality and convex sensitivity analysis, we derive a priori screening conditions that guarantee when such DNN-based eliminations are safe—that is, when removing a constraint or decision variable does not change the optimal cost or feasibility beyond a user-specified tolerance.

Example Simulation Results

Scenario 1: Unprotected Left Turn
Proposed: SHIELD MPC
Baseline: Full MPC
Scenario 2: Lane Merge
Proposed: SHIELD MPC
Baseline: Full MPC

> x35 Improvement in the total computation time!

Acknowledgement:

This implementation is built on nuPlan for simulation. Furthermore, for uncertain, multi-modal forecast generation, we use the opensource Wayformer implementation by UniTraj.

Downloading nuPlan mini v1.1 Dataset:

  1. Go to https://www.nuscenes.org/nuplan and download nuPlan mini v1.1 dataset.
  2. Follow the instructions in nuplan-devkit to set up the dataset

Installation:

Conda:

conda env create -f environment.yml
conda activate shield

UniTraj:

  1. Install UniTraj and its dependencies from here: https://github.com/vita-epfl/UniTraj?tab=readme-ov-file
  2. Do the data preparation step in UniTraj installation using ScenarioNet

Training the Classifier:

Collecting the Classifier Training Data

Create a folder named /expert_data in which the collected data and evaluation results will be saved.

export NUPLAN_ROOT_DIR="<directory of nuplan-devkit>"

Run ALL of the scripts from the tutorials directory

cd tutorials
python nuplan_data_collection.py

Preprocessing Training Data

python nuplan_process_data.py --filepath <dir to collected data>

Training the Clasifier using the collected data

python nuplan_RAIDNET_train_joint.py

Evaluating the Classifer

python nuplan_RAIDNET_evaluate_binary_joint.py

nuPlan Evaluation:

Evaluating the SHIELD algorithm in closedloop

python nuplan_closedloop_evaluate.py

After each simulation is completed, it saves the video and time snapshots in expert_data/video and saves a simulation log to expert_data folder

Printing the results of closedloop simulations

python nuplan_closedloop_eval_stats.py --filename <dir to the simulation log>

About

Implementation for SHIELD

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published