I was able to do it in Python code with the Plotly library but i lack the knowledge for the “$ex” veriables and how to fill the data properly from the sensor.
import plotly.graph_objects as go
import random
# Function to generate random positions for a person moving in a room for 5 minutes
def generate_random_positions():
x_positions = [random.uniform(-2000, 2000) for _ in range(5)]
y_positions = [random.uniform(2000, 4000) for _ in range(5)]
return x_positions, y_positions
# Coordinates for the first person
x_data_osoba1, y_data_osoba1 = generate_random_positions()
# Coordinates for the second person
x_data_osoba2, y_data_osoba2 = generate_random_positions()
# Current position of the first person (last point in data for the first person)
aktualni_x_osoba1 = x_data_osoba1[-1]
aktualni_y_osoba1 = y_data_osoba1[-1]
# Current position of the second person (last point in data for the second person)
aktualni_x_osoba2 = x_data_osoba2[-1]
aktualni_y_osoba2 = y_data_osoba2[-1]
# Coordinates for the polygon area
area_x = [0, 6000 * (3**0.5) / 2, 4500, 4000, 3000, 2000, 1000, 0, -1000, -2000, -3000, -4000, -4500, -6000 * (3**0.5) / 2, 0]
area_y = [0, 6000 / 2, (6000**2 - 4500**2)**0.5, (6000**2 - 4000**2)**0.5, (6000**2 - 3000**2)**0.5, (6000**2 - 2000**2)**0.5,
(6000**2 - 1000**2)**0.5, 6000, (6000**2 - 1000**2)**0.5, (6000**2 - 2000**2)**0.5, (6000**2 - 3000**2)**0.5,
(6000**2 - 4000**2)**0.5, (6000**2 - 4500**2)**0.5, 6000 / 2, 0]
# Create a trace for the first person's movement
trace_osoba1 = go.Scatter(x=x_data_osoba1, y=y_data_osoba1, mode='lines+markers', marker=dict(size=10, color='blue'), line=dict(width=2, color='gray'))
# Create a point for the current position of the first person
trace_aktualni_osoba1 = go.Scatter(x=[aktualni_x_osoba1], y=[aktualni_y_osoba1], mode='markers', marker=dict(size=15, color='red'))
# Create a trace for the second person's movement
trace_osoba2 = go.Scatter(x=x_data_osoba2, y=y_data_osoba2, mode='lines+markers', marker=dict(size=10, color='green'), line=dict(width=2, color='gray'))
# Create a point for the current position of the second person
trace_aktualni_osoba2 = go.Scatter(x=[aktualni_x_osoba2], y=[aktualni_y_osoba2], mode='markers', marker=dict(size=15, color='orange'))
# Create a trace for the filled area
trace_area = go.Scatter(x=area_x, y=area_y, fill='toself', fillcolor='rgba(168, 216, 234, 0.15)', line=dict(shape='linear', width=1, dash='dot'))
# Create a layout for the graph
layout = go.Layout(title='Pohyb osob v místnosti za posledních 5 minut', xaxis=dict(title='Osa X'), yaxis=dict(title='Osa Y'))
# Create a figure object combining all traces and layout
fig = go.Figure(data=[trace_osoba1, trace_aktualni_osoba1, trace_osoba2, trace_aktualni_osoba2, trace_area], layout=layout)
# Show the graph
fig.show()
You can run this in “>>>” python console
Looks like this:
@athua Do you think, it could be possible?