This is a DiffTune toolset for controller auto-tuning using sensitivity propagation. This toolset is intended to facilitate users' DiffTune applications in two ways. First, it enables the automatic generation of the partial derivatives required for sensitivity propagation. In this way, a user only needs to specify the dynamics and controller, eliminating the need to manually provide partial derivatives. Second, we provide examples that demonstrate the applications of DiffTune and a template to facilitate quick deployment to other applications.
Details of the DiffTune can be found in:
DiffTune: Auto-Tuning through Auto-Differentiation
DiffTune+: Hyperparameter-Free Auto-Tuning using Auto-Differentiation
If you think this toolset is helpful to your research/application, please cite:
@article{cheng2022difftune,
title={DiffTune: Auto-Tuning through Auto-Differentiation},
author={Cheng, Sheng and Kim, Minkyung and Song, Lin and Wu, Zhuohuan and Wang, Shenlong and Hovakimyan, Naira},
journal={arXiv preprint arXiv:2209.10021},
year={2022}
}
@article{cheng2023difftunePlus,
title={DiffTune+: Hyperparameter-Free Auto-Tuning using Auto-Differentiation},
author={Cheng, Sheng and Song, Lin and Kim, Minkyung and Wang, Shenlong and Hovakimyan, Naira},
journal={accepted by 5th Annual Learning for Dynamics and Control Conference},
year={2023}
}
You need to install CasAdi on your computer (Make sure you add CasADi's directory to your MATLAB's path by
addpath('<yourpath>/<casadi-folder-name>');savepath;
). We will use the autogenerated C code by CasAdi and compile it into mex in MATLAB. Make sure to configure your MATLAB's C compiler by
mex -setup c
.
We offer two examples: a quadrotor model and a Dubin's car model. Simply navigate to one of the folders under /examples
. Take the quadrotor case as an illustrative example, first run QuadrotorAutoGeneration.m
. This script automatically generates the C code for evaluating the Jacobians in sensitivity propagation and compiles it into mex files, which are available under the subfolder /mex
once the script finishes. Now you can run runDiffTune.m
under /examples/quadrotor
. You should be able to see the loss is printed out at each iteration while a figure updates the tracking performance and RMSE of the controller. You can turn on the video generation option that will record the tracking performance and RMSE reduction at run time (as illustrated below). We use the geometric controller by Taeyoung Lee et al and modified the source code to our use case.
quadrotor.mp4
A template for the usage of DiffTune on custom systems and controllers is provided in /template
. Users are recommended to fill in the dynamics.m
and controllers.m
first and run the runDiffTune.m
(with the DiffTune-related components commented out) to make sure the basic simulation can run as expected. The next step is to fill in the templateAutoGeneration.m
with discretized dynamics and run this script to generate and compile the functions for online Jacobians evaluation. Once done, you should see *.mex
and *.c
files under the directory /template/mex
. Now, you can retain the commented-out sections in runDiffTune.m
and run this script for your own DiffTune application.
Feel free to open up an issue if you run into trouble.
Sheng Cheng Lin Song Minkyung Kim
This project is licensed under the GPL-3.0 License - see the LICENSE file for details