Skip to content

Commit be11713

Browse files
committed
Interactive README and single host for Wrapper interactive
1 parent 6aa769a commit be11713

File tree

3 files changed

+50
-5
lines changed

3 files changed

+50
-5
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Interactive Simulation
2+
3+
This example showcases a basic "Hello world" interactive simulation.
4+
5+
The simulation relies on `SimulationWrapperInteractive.m` to manage TCP/IP communication with the MATLAB agent, allowing real-time data exchange between the simulation and the client.
6+
7+
## Table of Contents
8+
9+
- [Interactive Simulation](#interactive-simulation)
10+
- [Table of Contents](#table-of-contents)
11+
- [Usage](#usage)
12+
13+
## Usage
14+
15+
Before running the simulation, you need to configure the Matlab agent by setting the simulation folder path in the `config.yaml` file under the simulation section:
16+
17+
```yaml
18+
simulation:
19+
path: <path_to_simulation_folder>
20+
```
21+
22+
This path should point to the directory `interactive-simulation` containing the simulation files
23+
24+
Once configured, you can initiate the simulation using the API as described below.
25+
26+
The simulation can be initiated via the API by submitting a YAML payload, a template of which is available in the file `api/simulation.yaml`
27+
28+
```yaml
29+
simulation:
30+
request_id: abcdef12345 # Unique identifier for this simulation request
31+
client_id: dt # Client identifier for tracking purposes
32+
simulator: matlab # Specifies MATLAB as the simulation engine
33+
type: interactive # Indicates this is an interactive simulation type
34+
file: InteractiveSimulation.m # Main MATLAB file to execute
35+
inputs:
36+
stream_source: "rabbitmq://streaming.inputs.sim123" # RabbitMQ stream for input data
37+
outputs:
38+
predicted:
39+
x_next: float # Next predicted X coordinate value
40+
y_next: float # Next predicted Y coordinate value
41+
misc:
42+
distance_from_origin: float # Calculated distance from origin point
43+
timestamp: float # Simulation timestamp in epoch seconds
44+
```
45+
46+
Use the client `use_matlab_agent_interactive.py` to start the client.

agents/matlab/matlab_agent/resources/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ In the directory
7878
you will find several folders containing practical examples. Each example folder includes a `README.md` with detailed instructions:
7979

8080
- [Streaming Simulation](../docs/examples/streaming-simulation/README.md)
81-
- [Interactive Simulation](../docs/examples/interactive-simulation/InteractiveSimulation.m)
81+
- [Interactive Simulation](../docs/examples/interactive-simulation/README.md)
8282
- [Batch Simulation](../docs/examples/batch-simulation/README.md)
8383
- [Industrial Cooling Fan Anomaly Detection](../docs/examples/industrial-cooling-fan-anomaly-detection/README.md)
8484

agents/matlab/matlab_agent/resources/SimulationWrapperInteractive.m

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@
1010
% Constructor for the SimulationWrapperInteractive class
1111
function obj = SimulationWrapperInteractive()
1212
% Default host and ports (modifiable)
13-
out_host = 'localhost';
13+
host = 'localhost';
1414
out_port = 5678;
15-
in_host = 'localhost';
1615
in_port = 5679;
1716
% Max retries for connecting to the server
1817
max_retries = 5;
@@ -22,8 +21,8 @@
2221
for retry = 1:max_retries
2322
try
2423
% Create a TCP client object to connect to Python server
25-
obj.out_client = tcpclient(out_host, out_port);
26-
obj.in_client = tcpclient(in_host, in_port);
24+
obj.out_client = tcpclient(host, out_port);
25+
obj.in_client = tcpclient(host, in_port);
2726
configureTerminator(obj.out_client, "LF");
2827
configureTerminator(obj.in_client, "LF");
2928
break; % Exit the loop if the connection is successful

0 commit comments

Comments
 (0)