|
| 1 | +--- |
| 2 | +sidebar_position: 21 |
| 3 | +--- |
| 4 | + |
| 5 | +# Lab 21: Run on OPAL-RT real-time targets |
| 6 | + |
| 7 | +## Introduction |
| 8 | + |
| 9 | +This guide aims to provide step-by-step instructions for using VILLASnode with OPAL-RT's real-time simulation targets. |
| 10 | +For didactic reasons, the example employed in this guide is build from scratch. |
| 11 | + |
| 12 | +However, a completed RT-LAB example model is provided as well in the VILLASnode Git-repository: **TODO**. |
| 13 | + |
| 14 | +### Orchestra |
| 15 | + |
| 16 | +OPAL-RT's Orchestra is a co-simulation environment allowing the integration and interoperability between heterogeneous models, written in different programming languages or generated by various tools. It is acting as a communication layer between OPAL-RT's HYPERSIM and RT-LAB software platforms and the external components. |
| 17 | + |
| 18 | +OPAL-RT's Orchestra consists of two main components: |
| 19 | + |
| 20 | +- **Framework:** An Orchestra _Framework_ provides publish-subscribe like broker functionality and is started as part of the real-time simulation model by HYPERSIM or RT-LAB. Each framework hosts a single Orchestra _Domain_. A _Domain_ describes the set of signals which are exchanged between the models and one-or-more connected _Clients_. |
| 21 | +- **Client:** An external / third-party component connecting to a Orchestra framework domain. Clients connect to the framework locally via a shared-memory segment or remotely via Ethernet (UDP or TCP), or Dolphin / Reflective memory fabrics. |
| 22 | + |
| 23 | +In this guide, VILLASnode takes the role of a _Client_. |
| 24 | +By doing so, we can utilize the large set of available [VILLASnode node-types](../nodes) to exchange signals with a real-time model. |
| 25 | + |
| 26 | +To limit the complexity of the setup, we run the VILLASnode gateway on the real-time simulation target itself. |
| 27 | +This is made possible by the OPAL-RT Linux Operation System which allows us to run standard Linux applications directly on the real-time target. |
| 28 | + |
| 29 | +It should be noted that thanks to the flexibility of Orchestra communication layer, VILLASnode could also be executed on a different Linux system and communicate with the _Framework_ over Ethernet (UDP / TCP). |
| 30 | +However, we do not recommend this approach as it increases communication overhead and adds additional latency and computation overhead. |
| 31 | + |
| 32 | +## Requirements |
| 33 | + |
| 34 | +This guide has been tested with the following software versions: |
| 35 | + |
| 36 | +- **VILLASnode:** v1.0.1 |
| 37 | +- **RT-LAB:** v2025.1.3.77 |
| 38 | +- **OPAL-RT Linux:** v3.5.4 |
| 39 | +- **Python:** v3.9 |
| 40 | +- **Real-time Target:** OP5033XG, OP5707XG or similar |
| 41 | + |
| 42 | +## Step-by-Step Guide |
| 43 | + |
| 44 | +### 1. Create a new RT-LAB Project |
| 45 | + |
| 46 | +1. **Enable Advanced User features:** RT-LAB Menubar -> Window -> Preferences -> RT-LAB -> Capabilities -> Check "Advanced User" |
| 47 | +2. **Create RT-LAB project:** RT-LAB Menubar -> File -> New -> RT-LAB Project |
| 48 | + - **Project name:** `Orchestra_VILLASnode_Loopback_simple` |
| 49 | + - **Use default location:** checked |
| 50 | + - **Template:** empty |
| 51 | +3. **Enable PyDev features in project:** RT-LAB Project Explorer -> Right-click on new Project -> PyDev -> Set as PyDev Project |
| 52 | +4. **Add project-wide Python scripts:** |
| 53 | + 1. **Create a new PyDev source directory:** RT-LAB Menubar -> New -> Other -> PyDev -> Source Folder |
| 54 | + - **Project:** `Orchestra_VILLASnode_Loopback_simple` (your new RT-LAB project) |
| 55 | + - **Name:** `scripts` |
| 56 | + 2. **Add package:** RT-LAB Menubar -> New -> Other -> PyDev -> PyDev Package |
| 57 | + - **Source Folder:** `Orchestra_VILLASnode_Loopback_simple/scripts` |
| 58 | + - **Name:** `orchestra` |
| 59 | + 3. **Copy contents new module (opened text editor):** |
| 60 | + - **Source:** TODO |
| 61 | + 4. **Create new PyDev "Launch Configuration":** RT-LAB Menubar -> Tools -> Python -> Run Configurations... |
| 62 | + 1. Select "Python Run" -> Click on "New" icon in upper-left corner of the dialog |
| 63 | + - **Name:** `Generate Orchestra DDF` |
| 64 | + - **Main Tab** |
| 65 | + - **Project:** `Orchestra_VILLASnode_Loopback_simple` (your new RT-LAB project) |
| 66 | + - **Main Module:** `${workspace_loc:VILLASnode_Orchestra_Loopback/scripts/orchestra/__init__.py}` |
| 67 | + - **Arguments Tab** |
| 68 | + - **Arguments**: `${workspace_loc:VILLASnode_Orchestra_Loopback/models/model/orchestra.conf}` (and possible more VILLASnode configuration files, if used) |
| 69 | + |
| 70 | +### 2. Create a new RT-LAB Model |
| 71 | + |
| 72 | +1. **Create RT-LAB model:** RT-LAB Menubar -> File -> New -> RT-LAB Model -> Finish |
| 73 | + - **Model name:** model |
| 74 | + - **Model type:** MATLAB/Simulink (.slx) |
| 75 | +2. **Add RT-LAB user script:** RT-LAB Menubar -> New -> Other -> General -> File |
| 76 | + - **Parent folder:** `VILLASnode_Orchestra_Loopback/models/model` |
| 77 | + - **File name:** `target_preload.py` |
| 78 | + - **Contents:** Copy from TODO |
| 79 | + |
| 80 | +### 3. Installation of VILLASnode |
| 81 | + |
| 82 | +The installation of VILLASnode on the real-time target is fully automated by the `target_preload.py` [user script](https://opal-rt.atlassian.net/wiki/spaces/PRD/pages/143985689/Executing+Models#User-script-files) created in the previous step. |
| 83 | +VILLASnode will be automatically installed during model load. |
| 84 | + |
| 85 | +To verify that the installation succeeded, you can login to the target via SSH and run the `villas node -V` command: |
| 86 | + |
| 87 | +```shell |
| 88 | +$ ssh root@<target-ip-address> |
| 89 | + |
| 90 | +root@rtserver:~# villas node -V |
| 91 | +13:12:35 info node This is VILLASnode 1.0.1 (built on Jan 1 1980, 00:00:00) |
| 92 | +13:12:35 info signals Initialize subsystem |
| 93 | +1.0.1 |
| 94 | +``` |
| 95 | + |
| 96 | +Alternative installation methods as documented on the [Installation page](../installation.md) are supported as well. |
| 97 | + |
| 98 | +### 4. Create a VILLASnode Configuration File: `orchestra.conf` |
| 99 | + |
| 100 | +Next, we create a [VILLASnode configuration file](../config/) named an place it into the RT-LAB model directory: |
| 101 | + |
| 102 | +```text url="external/node/clients/rtlab-orchestra/models/model/orchestra.conf" title="<RTLAB-PROJECT-ROOT>/models/model/orchestra.conf" |
| 103 | +
|
| 104 | +``` |
| 105 | + |
| 106 | +This configuration file defines how signals exchanged between VILLASnode and the simulation model over Orchestra are further processed in the VILLASnode gateway. |
| 107 | +In the example above, we simply perform a loopback over the VILLASnode [`socket`](../nodes/socket.md) node-type to localhost. |
| 108 | +This configuration file also include a defintition of all signals including their name and data-type which are exchanged with the simulation model. |
| 109 | + |
| 110 | +### 4. Generate an Orchestra Data Definition File: `orchestra.xml` |
| 111 | + |
| 112 | +Based in the VILLASnode config file prepared in the previous step, we now generate an Orchestra data-definition file (DDF): `orchestra.xml`. |
| 113 | +This file is used by the Orchestra Framework to specify which _Domains_ exist and which signals they contain. |
| 114 | +This step is automated using a Python script which we first add to our RT-LAB project: |
| 115 | + |
| 116 | + |
| 117 | +:::caution |
| 118 | +The VILLASnode config file (`orchestra.conf`) and the Orchestra data-definition file (`orchestra.xml`) must kept synchronized. |
| 119 | +Please repeat this step, whenever you change the VILLASnode config file. |
| 120 | +::: |
| 121 | + |
| 122 | +### 6. Build the RT-LAB Model on the Target |
| 123 | + |
| 124 | +### 7. Add an Orchestra Framework I/O Interface |
| 125 | + |
| 126 | +### 8. Create Connections between I/O Interface and Model |
| 127 | + |
| 128 | +### 9. Run Model |
0 commit comments