.ManualTracking.UsersGuide.PythonFunctions

Information

In addition to Modelca-based components, two additional capabilities are provided in the ManualTracking library: automatically tuning manual controller parameters, and performing real-time tracking experiments. These features are implemented in the Python programming language, version 2.7.

Diagr-SoftwareOverview

An overview of the software is shown above. In the Resources/ directory, there are 5 .py files. Four of these are function scripts that can be run from a terminal or Python IDE, and the fifth file is Options.py, where options are set by the user. The functions do not use input arguments, and instead look at Options.py. Variables in this file include: taskModel, the tracking task model to run; saveFormat, the format with which to save backup data files; and printVerbose, whether or not to print all runtime messages to the console. The user may also experiment with different framerates and optimization/simulation methods.

Options.py also contains Boolean input arguments for each of the four functions: useSaved makes the functions use most recent saved data (in Resources/Temp/ directory) instead of re-running an experiment; plotResults generates a figure with the resulting trajectories; and saveResults saves a backup results file in the Resources/Data/ directory. The results file contains values for the reference state, measured state, disturbance input, and control input at each sample time.

Each of the four main functions call mantra.py, which reads the ManualTracking.mo file for details of the tracking task, and then calls functions defined in fmi.py, game.py, and tools.py. These functions use standard Python modules, as well as OMPython, pyfmi, Pygame, and matplotlib. Note that OMPython requires an installation of OpenModelica. Additionally, pyfmi has many dependencies that must be installed first, and it may be more convenient to install JModelica.org instead of installing them individually.


Generated at 2024-11-22T19:25:38Z by OpenModelicaOpenModelica 1.24.2 using GenerateDoc.mos