Skip to content

Digital Twin/ Data Visualization


Download Latest Version

Example demonstrating pulling real time data from an online source

  • Real time data can update the bar chart and the color change on the road

  • Can use either right mouse button or grip button on a controller to use a highlighter tool to view sample power consumption information on the house model

  • Press spacebar to start and stop recording

  • Press "/" to save a screenshot or use built in video recording

  • User data is saved in the data folder

  • Afterwards can review data with the Session Replay

  • Works with Multi-User as well

This application leverages SightLab, Vizard, and custom modules to provide a real-time and replayable visualization platform. The core functionalities include data fetching, visualization management, energy tracking, and SightLab interaction.

Installation and Setup

  1. Requires installing requests python library

Execution Flow

Initialization

  1. Launch Data_Visualizer_Main.py.
  2. Select the operating mode: SINGLE, SERVER, or CLIENT.
  3. Press either the right hand mouse or trigger button to bring up the highlighter to select a house that will show appliance data

Real-Time Visualization

  • Energy data fetched via EnergyManager updates appliance usage and emissions.
  • VisualizationManager renders updates (e.g., changing street color based on emissions).

Replay Mode

  1. Use Data_Visualizer_Replay.py to review session data.
  2. Visualize gaze paths, fixation points, and heat maps.
  3. Adjust replay settings (e.g., dwell time, visibility toggles).

Key Features

  • Dynamic Data Integration: Real-time API-driven updates to visualize energy usage.
  • 360 and 3D Media: Fully compatible with SightLab's environment management.
  • Multi-User Collaboration: SERVER/CLIENT modes for shared VR experiences.
  • Custom Visualizations: Bar graphs and street lines to represent data trends.
  • Replay and Analysis: Session replay for heat map and gaze data analysis.

Data Modification Guide

This guide explains how to modify the Data Visualizer example to use different data sources for the bar graph, 3D text display, and colored street line visualizations.

Quick Start - Minimal Changes

Understanding JSON Keys: The strings like "temperature_celsius" are keys from the API's JSON response.

Example API response from current API:

{
  "appliances_usage_kWh": 15.3,
  "battery_storage_percent": 75,
  "co2_emissions_kg": 12.5,
  "temperature_celsius": 22.4,
  "solar_power_kW": 8.2
}

To use a different API:

  1. Find available keys - Visit your API URL in a browser to see the JSON response

  2. Change the API_URL in Data_Visualizer_Main.py:

# Change from:
API_URL = "https://help.worldviz.com/.netlify/functions/energy-stats"
# To:
API_URL = "https://api.example.com/your-data-endpoint"
  1. Use the correct JSON keys - If your API returns {"temp": 25, "power": 100}, use:
data.get("temp", 20)      # Not "temperature_celsius"
data.get("power", 0)      # Not "appliances_usage_kWh"

Change Bar Graph to Show Temperature Instead of Battery

In energy_manager.py, add to __init__():

self.last_known_temperature = None

In energy_manager.py, add to fetch_energy_data():

self.last_known_temperature = data.get("temperature_celsius", 20)  # "temperature_celsius" is the JSON key

In energy_manager.py, add new method:

def get_temperature(self):
    return self.last_known_temperature or 20

In Data_Visualizer_Main.py, change line ~90:

# Change from:
data_fetcher=energy_manager.get_battery_storage,
# To:
data_fetcher=energy_manager.get_temperature,

In Data_Visualizer_Main.py, change line ~91:

# Change from:
graph_name="Battery",
# To:
graph_name="Temperature",

The bar graph now shows temperature data.


Change 3D Text to Show Solar Power Instead of Appliance Usage

In energy_manager.py, in fetch_energy_data() method, change:

# Change from:
usage_value = data.get("appliances_usage_kWh", "N/A")
# To:
usage_value = data.get("solar_power_kW", "N/A")

In Data_Visualizer_Main.py, in update_appliance_text(), change:

# Change from:
appliance_text.message(f"Appliance Usage: {usage_value:.1f} kWh")
# To:
appliance_text.message(f"Solar Power: {usage_value:.1f} kW")

The 3D text now shows solar power.


Change Street Line to Show Temperature Trend Instead of Emissions

In energy_manager.py, add to __init__():

self.last_known_temperature = None

In energy_manager.py, in fetch_energy_data(), add:

self.last_known_temperature = data.get("temperature_celsius", 20)

In Data_Visualizer_Main.py, in update_street_color(), change:

# Change from:
energy_manager.last_known_emissions,
# To:
energy_manager.last_known_temperature,

The street line color now changes based on temperature trends.

Additional Resources

Refer to the SightLab-specific documentation for extending functionality:

  • Setting Up 3D Models and 360 Media: Details on environments and ROI tagging.
  • Code Examples: Found in SightLab Adding Instructions, Rating, Gaze Based Interactions.
  • Proximity Sensors: Use vizproximity for sensor-based interactions.
  • Multi User Sessions: Use SightLab's multi user functionality to run remote or local multi-user sessions.