/C3M-new

A reimplementation of the CoRL'20 paper "Learning Certified Control Using Contraction Metric", by Dawei Sun, Susmit Jha, and Chuchu Fan.

Primary LanguagePythonMIT LicenseMIT

C3M-new

A reimplementation of the CoRL'20 paper "Learning Certified Control Using Contraction Metric", by Dawei Sun, Susmit Jha, and Chuchu Fan. Code is based on the origin repo. Reimplemented by Songyuan Zhang.

Dependencies

You need to have the following libraries with Python3:

To install requirements:

conda create -n c3m python=3.8
conda activate c3m
pip install -r requirements.txt

Run

Available environments

  • DubinsCarTracking

Creating a new tracking environment is pretty easy. You can create a new file in model/env, and create a new class as a child of .base.TrackingEnv. Then you just need to re-implement all the abstract methods and properties.

Training

You can train the C3M using the following command:

python train_c3m.py --env DubinsCarTracking

This will create a new folder with time stamp in the log/[ENV] folder, with models, summary, and settings.yaml inside. The trained models will be saved in models, the training log will be saved in summary, and the settings for training will be saved in settings.yaml.

Here are some options for training:

  • --env: The environment to be trained in.
  • --n-iter: Number of training iterations.
  • --batch-size: Sample batch size of the states.
  • --no-cuda: Disable cuda.

Testing

After training, you can easily test the controller using:

python test_c3m_policy.py --path [PATH-TO-THE-LOG]

Note that [PATH-TO-THE-LOG] means the path to the folder with time stamp. This will print the reward of each episode, and create a new videos folder in [PATH-TO-THE-LOG], containing the animations.

If you want to see the log of the training process, use:

tensorboard --logdir [PATH-TO-THE-SUMMARY]

Acknowledgement

Thank Dawei Sun for the origin code and Glen Chou for the helpful discussion on the training process.