Skip to content

Commit

Permalink
Adds docs for desktop robotti with rabbitmq example
Browse files Browse the repository at this point in the history
  • Loading branch information
prasadtalasila committed Nov 16, 2023
1 parent c619d84 commit 7f8b6ca
Show file tree
Hide file tree
Showing 8 changed files with 306 additions and 29 deletions.
128 changes: 128 additions & 0 deletions docs/user/examples/drobotti-rmqfmu/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
# Desktop Robotti with RabbitMQ

## Overview

This example demonstrates bidirectional communication between
a mock physical twin and a digital twin of a mobile robot (Desktop Robotti).
The communication is enabled by RabbitMQ Broker.

![Desktop Robotti with RabbitMQ Broker and Digital Twin](system.png)

## Example Structure

The mock physical twin of mobile robot is created using two python scripts

1. data/drobotti_rmqfmu/rmq-publisher.py
1. data/drobotti_rmqfmu/consume.py

The mock physical twin sends its physical location in _(x,y)_ coordinates and
expects a cartesian distance $\sqrt(x^2 + y^2)$ calculated from digital twin.

![Desktop Robotti DT structure](dt-structure.png)

The _rmq-publisher.py_ reads the recorded _(x,y)_ physical coordinates of
mobile robot. The recorded values are stored in a data file.
These _(x,y)_ values are published to RabbitMQ Broker. The published
_(x,y)_ values are consumed by the digital twin.

The _consume.py_ subscribes to RabbitMQ Broker and waits for the calculated
distance value from the digital twin.

The digital twin consists of a FMI-based co-simulation, where Maestro is used
as co-orchestration engine.
In this case, the co-simulation is created by using two FMUs -
RMQ FMU (rabbitmq-vhost.fmu) and distance FMU (distance-from-zero.fmu).
The RMQ FMU receives the _(x,y)_ coordinates from _rmq-publisher.py_ and
sends calculated distance value to _consume.py_. The RMQ FMU uses
RabbitMQ broker for communication with the mock mobile robot, i.e.,
_rmq-publisher.py_ and _consume.py_.
The distance FMU is responsible for calculating the distance between
_(0,0)_ and _(x,y)_. The RMQ FMU and distance FMU exchange values
during co-simulation.

## Configuration of assets

This example uses two models, one tool, one data, and two scripts to create
mock physical twin. The specific assets used are:

| Asset Type | Names of Assets | Visibility | Reuse in Other Examples |
|:---|:---|:---|:---|
| Models | distance-from-zero.fmu | Private | No |
| | rmq-vhost.fmu | Private | Yes |
| Tool | maestro-2.3.0-jar-with-dependencies.jar | Common | Yes |
| Data | drobotti_playback_data.csv | private | No |
| Mock PT | rmq-publisher.py | Private | No |
| | consume.py | Private | No |

This DT has many configuration files.
The `coe.json` and `multimodel.json`
are two DT configuration files used for executing the digital twin.

The `rabbitMQ-credentials.json` provides RabbitMQ access credentials
for mock PT python scripts.

## Lifecycle Phases

| Lifecycle Phase | Completed Tasks |
| -------- | ------- |
| Create | Installs Java Development Kit for Maestro tool and pip packages for python scripts |
| Execute | Runs both DT and mock PT |
| Clean | Clears run logs and outputs |

## Run the example

To run the example, change your present directory.

```bash
cd workspace/examples/digital_twins/drobotti_rmqfmu
```

If required, change the execute permission of lifecycle scripts
you need to execute, for example:

```bash
chmod +x lifecycle/create
```

Now, run the following scripts:

### Create

Installs Open Java Development Kit 17 in the workspace. Also install
the required python pip packages for _rmq-publisher.py_ and
_consume.py_ scripts.

```bash
lifecycle/create
```

### Execute

Run the python scripts to start mock physical twin. Also run the co-simulation for
the digital twin.

```bash
lifecycle/execute
```

#### Examine the results

The results can be found in the
_workspace/examples/digital\_twins/drobotti\_rmqfmu directory_.

### Terminate phase

Terminate to clean up the debug files and co-simulation output files.

```bash
lifecycle/terminate
```

## References

More information about the case study is available in:

```txt
Frasheri, Mirgita, et al. "Addressing time discrepancy between digital
and physical twins." Robotics and Autonomous Systems 161 (2023): 104347.
```
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/user/examples/drobotti-rmqfmu/system.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
183 changes: 161 additions & 22 deletions docs/user/examples/examples.drawio

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions mkdocs-github.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ nav:
- Mass Spring Damper: user/examples/mass-spring-damper/README.md
- Water Tank Fault Injection: user/examples/water_tank_FI/README.md
- Water Tank Model Swap: user/examples/water_tank_swap/README.md
- Desktop Robotti and RabbitMQ: user/examples/drobotti-rmqfmu/README.md
- Codebase: https://github.com/INTO-CPS-Association/DTaaS-examples
- FAQ: FAQ.md
- Developer:
Expand Down
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ nav:
- Mass Spring Damper: user/examples/mass-spring-damper/README.md
- Water Tank Fault Injection: user/examples/water_tank_FI/README.md
- Water Tank Model Swap: user/examples/water_tank_swap/README.md
- Desktop Robotti and RabbitMQ: user/examples/drobotti-rmqfmu/README.md
- Codebase: https://github.com/INTO-CPS-Association/DTaaS-examples
- FAQ: FAQ.md
- Developer:
Expand Down
14 changes: 11 additions & 3 deletions servers/execution/runner/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,19 @@ yarn clean # deletes directories "build", "coverage", and "dist"

## :package: :ship: NPM package

### Github Package Registry

The Github actions workflow of
[lib microservice](../../../.github/workflows/runner.yml) publishes the __runner__
into [public packages](https://github.com/orgs/INTO-CPS-Association/packages).

### Verdaccio - Local Package Registry

Use the instructions in
[publish npm package](../../../docs/developer/npm-packages.md) for help
with publishing **runner npm package**.
with publishing __runner npm package__.

Application of the advice given on that page for **runner** will require
Application of the advice given on that page for __runner__ will require
running the following commands.

### Publish
Expand All @@ -53,7 +61,7 @@ yarn publish #increments version in package.json, publishes to registry and adds
### Unpublish

```bash
npm unpublish --registry http://localhost:4873/ @dtaas/[email protected]
npm unpublish --registry http://localhost:4873/ @into-cps-association/[email protected]
```

## :rocket: Access the service
Expand Down
8 changes: 4 additions & 4 deletions servers/lib/DEVELOPER.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@ yarn clean # deletes directories "build", "coverage", and "dist"
### Github Package Registry

The Github actions workflow of
[lib microservice](../../.github/workflows/lib-ms.yml) publishes the libms
[lib microservice](../../.github/workflows/lib-ms.yml) publishes the __libms__
into [public packages](https://github.com/orgs/INTO-CPS-Association/packages).

### Verdaccio - Local Package Registry

Use the instructions in
[publish npm package](../../docs/developer/npm-packages.md) for help
with publishing **libms npm package** in local computer.
with publishing __libms npm package__ in local computer.

Application of the advice given on that page for **libms** will require
Application of the advice given on that page for __libms__ will require
running the following commands.

### Publish
Expand All @@ -50,7 +50,7 @@ yarn publish #increments version in package.json, publishes to registry and adds
### Unpublish

```bash
npm unpublish --registry http://localhost:4873/ @dtaas/[email protected]
npm unpublish --registry http://localhost:4873/ @into-cps-association/[email protected]
```

## Service Endpoint
Expand Down

0 comments on commit 7f8b6ca

Please sign in to comment.