Python-Based Reinforcement Learning on Simulink Models

Georg Schäfer,Max Schirl,Jakob Rehrl,Stefan Huber,Simon Hirlaender
2024-05-14
Abstract:This paper proposes a framework for training Reinforcement Learning agents using Python in conjunction with Simulink models. Leveraging Python's superior customization options and popular libraries like Stable Baselines3, we aim to bridge the gap between the established Simulink environment and the flexibility of Python for training bleeding edge agents. Our approach is demonstrated on the Quanser Aero 2, a versatile dual-rotor helicopter. We show that policies trained on Simulink models can be seamlessly transferred to the real system, enabling efficient development and deployment of Reinforcement Learning agents for control tasks. Through systematic integration steps, including C-code generation from Simulink, DLL compilation, and Python interface development, we establish a robust framework for training agents on Simulink models. Experimental results demonstrate the effectiveness of our approach, surpassing previous efforts and highlighting the potential of combining Simulink with Python for Reinforcement Learning research and applications.
Machine Learning,Systems and Control
What problem does this paper attempt to address?
The problem this paper attempts to address is how to train a Reinforcement Learning (RL) agent using Python on a Simulink model and seamlessly transfer the trained policy to a real system. Specifically, the authors propose a framework that combines Python with Simulink models to control tasks in both the simulated environment and the actual system of the Quanser Aero 2 twin-rotor helicopter. This framework aims to leverage Python's advanced customization options and popular libraries (such as Stable Baselines3) to compensate for the traditional Simulink environment's lack of flexibility, thereby promoting the development and deployment of cutting-edge RL agents. The core contribution of the paper lies in establishing a systematic approach that effectively integrates Simulink models with Python RL libraries through steps such as generating C code, compiling it into a dynamic link library (DLL), embedding it in Python, and creating custom Gymnasium environments. Experimental results show that this method not only performs well in the simulated environment but can also be effectively applied to real systems, demonstrating the great potential of combining Simulink with Python for RL research and applications.