Nonlinear Model Predictive Control with Recurrent Neural Networks
This page describes the implementation of a learning-based nonlinear model predictive control (NMPC) using recurrent neural networks (RNNs), which is experimentally validated with SPONGE. The RNNs are trained in PyTorch, and their hyperparameters are optimized via ASHA. They are then integrated into Simulink and used as models within NMPC. For this purpose, CasADi is integrated into Simulink as an S-function, enabling its use on a real-time computer. The code is based on the test-bench code. It is therefore recommended that you familiarize yourself with this code. The hardware setup remains the same - only the software components are added.
The code for neural-network training, hyperparameter optimization and learning-based NMPC with RNNs can be found in the git repository.
Additional Requirements
- CasaDI v3.6.6 installed as a source build
- IPOPT
- yaml-cpp v0.6.0
- CMake 3.30.3
- YAMLMatlab_0.4.3
Usage
- Set up the test bench following these instructions.
- Dev-PC: Copy all files from this repository to the test-bench folder. Overwrite any files with duplicate names.
- Dev-PC: Compile the shared library by running
$ ./build.sh 1
- Dev-PC: Initialize parameters and open Simulink model via
init.m
- Dev-PC: If necessary, modify Simulink model
- Dev-PC: Compile/create the model by executing
build.m
(If the S-function block needs to be reinserted: In./Extern/MPCcasadiSFunction/mFiles/generateslblock.m
, set a breakpoint in the last line beforeclose_system('untitled', 0)
) - Dev-PC: Compile ROS-Workspace and copy to RT-PC via
$ ./build.sh && ./sync.sh
- Connect to RT-PC via SSH and run the following commands on RT-PC:
$ sudo /etc/init.d/ethercat start
(start EtherCAT master) and$ ~/app_interface/ros_install/scripts/autostart.sh && tmux attach-session -t app
(start compiled model) - Dev-PC: Start external mode in Simulink model via
Connect To Target
to visualize/record data or alter settings - After the experiment on RT-PC:
Ctrl+C
in tmux windows,$ tmux kill-session
and$ sudo /etc/init.d/ethercat stop
to stop the EtherCAT master
Citing
The paper is freely available via arXiv. If you use parts of this project for your research, please cite the following publication:
Learning-based Nonlinear Model Predictive Control of Articulated Soft Robots using Recurrent Neural Networks
H. Schäfke, T.-L. Habich, C. Muhmann, S. F. G. Ehlers, T. Seel and M. Schappler
IEEE Robotics and Automation Letters (RA-L) 2024
DOI: 10.1109/LRA.2024.3495579