OpenRTDynamics -- A framework for the implementation of real-time controllers
OpenRTDynamics (ORTD) is a novel approach to the implementation of block / signal based schematics, as commonly used in control engineering and signal processing. The implementations are real-time capable (like the ones produced by Real-Time Workshop® or Scicos Code Generation). This framework is suitable for time discrete signal processing algorithms, using the same principles like in Scicos/Xcos or Simulink. However, schematics are described by combining special Scilab functions provided by the framework (a typical Scilab-file describing an ORTD-schematic is e.g. ), which enables advantageous features:
Additionally to standard approaches, ORTD features the ability to implement state machines represented by multiple, switching subsystems (each subsystem corresponds to one state)  . Subsystems (sub-simulations) can also run in the context of separated threads (with or without synchronisation to another one), e.g. to divide high- and low frequency portions  or to run computationally intensive tasks in the background. Because of a remote control interface  and the ability to include Scilab-Code (similar to Matlab S-functions) that could execute e.g. calibration routines , ORTD is also ideally suited for laboratory automation. Hereby, the ability to online-replace sub-schematics (sub-simulations) with replacements   removes the effort of restarting the main real-time program when new algorithms are designed.An example for automating experiments using these conceps: .
Because the real-time interpreter is implemented in a shared library, ORTD can also be easily integrated into other simulation frameworks e.g. Scicos or used within other software.
Some slides, which give a short introduction are now available: ortd_slides.pdf (updated 02.6.2014). For technical details please refer to the README. It also includes intructions on how to install ORTD on embedded ARM-systems, like the beaglebone. A tutorial and plenty of examples for each feature of ORTD are included in the package and finally, documentation for each individual block is available through the Scilab-Help.
Please Note: OpenRTDynamics does not depend on any part of Scicos/Xcos. ORTD algorithms for time-deterministic interpretation of simulations. Only the Scilab Scripting language is required for describing the schematics and only during development. During runtime, no more than standard C/C++ libraries are required, therefore ORTD is very uncomplicated to install and maintain, even on other platforms. Difficult and cryptic instructions for the installation of this framework were intentionally avoided.
Motivation for another real-time framework
Since I'm working in the field of biomedical control engineering, my expectations on the reliability & flexibility of the software controlling something that is acting on the human body are very high.
When doing experiments in clinical environments, only limited time is available. Faults in the operation are critical up to some high extend and technical inadequacies like instable software that requires several attempts to fully run can simply not be accepted. It shall be possible to re-calibrate and make individual adaptations to the implementation in the shortest time possible. Therefore, instead of code generation, this framework uses an interpreter (the Scilab description is assembled faster than generating and compiling C-Code). Additionally, new sub-implementations can be designed and loaded on-line while e.g. the data acquisition devices stay up and running.
Also I don't like complicated installation procedures where one has to edit files, adapt directory paths and install numerous other libraries from their sources by hand. ORTD compiles and installs itself automatically from its source files on the individual target system. If there is a library installed that could enable additional functionality for ORTD, it is used. If not installed, ORTD doesn't complain.
If you find a bug in the software or things that you just do not find so nice, it would be very cool if give me a short notice/comment by Email. Even complaints like "I have to type so much commands when doing ..." are REALLY welcome. Every time the user of this framework is subjected to an higher programing effort than theoretically necessary, something could be improved! Thus let me know. ORTD is supposed be as smart and relaxed as possible.
Tags: Realtime control implementation, Laboratory automation, Linux RT-Preempt, Signal-based simulation, Scilab, Embeddable C-Code libray, No code generation required
OpenRTDynamics is heavily used for implementing feedback controllers in biomedical engineering and research within the project MUNDUS funded by the European Commision in the 7th framework Program. It is actively developed at "Control Systems Group" www.control.tu-berlin.de of Technische-Universität Berlin and practically applied for setting up computer-controlled laboratory experiments.
Scientific publications on experiments that were implemented using this framework
Online replacement of controllers using OpenRTDynamicsIn this example, an ORTD simulation (real-time part) is communicating to a node.js script by UDP-packets. The node.js part provides a web-interface and streams the information from the real-time part to the web-interface. Additionally, parameter changes are forwarded from the web-interface to the real-time part. The source-code is available from .
Linux rt-preempt Benchmarks
A benchmark to evaluate the real-time capabilities is available: Cycletest
You could also consider this as an example on how to start multiple threads with different priorities and CPU assignments. Here are some test results, where the time durations between neighbouring samples is plotted for a thread that runns with real-time scheduling and for one that runns without any special priorities. The desired sample time is 0.002s which corresponds to a sampling frequency of 500Hz.
Test results for Ubuntu 12.04, Intel(R) Core(TM)2 Duo CPU, Linux 3.2 (no special patches) (PDF)
The latest news and added features are always found in the README
The intention is to create a framework for easy implementation of block/schematic based realtime controllers for (feedback / feed forward) control, without the need for using a C-Compiler to generate a new / change a controller. Unlike other concepts like Simulink or Scicos, no C-Compiler and the corresponding realtime framework has to be used on the development system during controller code generation. OpenRTDynamics is designed to reduce the complexity of realtime code generation by not using code compilation at all. Instead, schematics are interpreted in realtime by the libdyn interpreter library. The process of “compiling” control schematics is simple and lasts only seconds, since it is achieved by simply running a Scilab-Script that defines the blocks interconnections.
Controllers are encoded to integer and floating point vectors, saved to disk and / or transferred to the target and interpreted by a special simulator library. Redesigning your controller only requires executing your Scilab script and uploading it to the target. This could be also done online, due to the feature for online schematics replacement.
For these tasks, a Scilab toolbox (ld_toolbox) is used to set-up the signal driven simulation schematics by a sequence of easily understandable function calls. There is the possibility to connect blocks - like in Scicos/Xcos/Simulink - for example transfer functions, sums, multiplications and so on. Once an schematic is completed, it is written to a pair of files, which is loaded by the interpreter.
The libortd.so library may be embedded into the users software and into Scicos schematics or it is possible to use a provided standalone program ortd, which enables realtime control under ordinary Linux environments using the realtime preemption environment.
External hardware like sensors and / or actuators can be added by modules or plugins in form of new blocks available to ORTD.
Do to the description using Scilab, well structured code can be achieved, whereby i.e. the filter design could be included nearby the implementation for a better human-readability. Additionally, functional and object orientated design schemes can be realised. The latter feature enables the possibility to implement reusable parametrised sub-schematics that may also change in its structure based on parameters.
The figure shown below illustrates the possible integration with other systems.
Components / Modules
ORTD consists of multple parts. The main one is the libdyn simulator library. Additionally, there are modules i.e. for remote comunication or nesting simulations.
The latestest versions include highly advanced features like
- Online replacement of sub-controllers; Yes, can can exchange wires and blocks during the controller is running (modules/nested)
- State machines (modules/nested)
- Simulations running in threads (modules/nested)
- Mathematical formula parsing (modules/muparser)
- Vector handling blocks (modules/basic_ldblocks)
- Calling Scilab from the simulation (modules/scilab)
- Remote control interface (modules/rt_server)
- Starting external processes (modules/ext_process)
- Timer for simulations running in threads (pending) (modules/synchronisation)
- Scicos to ORTD block wrapper (modules/scicos_blocks)
- A framework for sending/receiving UDP-packets (modules/udp_communication)
• A noval and flexible way to describe schematics
• No effort is needed to compile schematics by a C-Compiler -- they are interpreted at runtime. Therefore, there is no need to have a running (cross-) compilation environment for the target system on the development system. It is needed only once to install ORTD on the target.
• For your own software written in C/C++, you can easily integrate ORTD and all its features
• Schematic development is done within Scilab, thus control design and implementation can be in one place
• Schematics may be effectively managed by subversion etc. as they are stored in plain text.
• Since it is only necessary to execute one Scilab-Script it is very efficient to change parameters, transfer functions and everything else.
Disadvantages / Shortcomings
• Only discrete time blocks (may be changed by introducing an ODE-solver)
• Less blocks than in Scicos or Simulink, however the basics are there as well as some advanced blocks.
Main author: Christian Klauer (Control-Systems-Group TU-Berlin)
Contributions thanks to: Arne Passon, Markus Valtin and Maximilian Irmer
If you need help in installing or development using ORTD, please don't hesitate to contact the main author. Let us know for what kind of project you are interessted to use ORTD.