Skip to content

ssm-lab/CAS782_Project_MB_RG

 
 

Repository files navigation

CAS782 Project: CARLA Scene Graph + VIATRA

Final project repository for CAS782 (Digital Twins), focused on a CARLA-driven scene graph pipeline with incremental graph query matching and model transformation using VIATRA.


Quick Start

Step 1: Read Prerequisites

Before starting, review all system requirements:

PREREQUISITES.md (5-10 minutes to read)

  • System requirements (Windows 10/11, disk space, GPU)
  • Required software (Git, Python 3.8+, Visual C++ Build Tools)
  • One-time setup checklist
  • Troubleshooting

Step 2: Run One Setup Script

Once prerequisites are met, run the automated setup:

.\SETUP.ps1

Note: This will download CARLA 0.9.16 (~8GB) and may take 10-30 minutes depending on your internet connection.

Step 3: Follow Printed Instructions

The script will output detailed next steps, including:

  • How to activate the virtual environment
  • How to start the CARLA server
  • How to run demos
  • How to start the live scene graph stream

Documentation Guide

Once setup is complete, explore these guides:

Document Purpose When to Read
QUICKSTART.md First-time usage workflows After SETUP.ps1 completes

Repository Structure

Setup & Documentation:

  • PREREQUISITES.md — System requirements & one-time setup
  • SETUP.ps1 — Automated environment setup (run once after clone)
  • QUICKSTART.md — First-time usage guide

Source Code:

  • src/carla_scenegraph_export.py — Export CARLA state as XMI scene graphs
  • src/scenegraph_stream_bridge.py — Continuous stream producer (XMI + JSONL)
  • src/scenario_ego_follow.py — Demo: ego vehicle follows lead vehicle (with follow camera)

Metamodel & Queries:

  • SceneGraphModel/model/SceneGraph.ecore — EMF metamodel (Vehicle, Pedestrian, Node, Edge)
  • SceneGraphQueries/src/queries/scenegraph.vql — VIATRA query patterns (fastVehicle, connected, etc.)

Scale Simulation & Utilities:

  • scripts/bootstrap_windows.ps1 — Legacy prerequisite checker
  • scripts/run_scenegraph_stream.ps1 — Start scene graph stream
  • scripts/open_live_view.ps1 — Open live graph visualization

Data & Outputs:

  • data/stream/latest_snapshot.xmi — Most recent snapshot (auto-synced)
  • data/stream/events.jsonl — Incremental change events (JSONL format)
  • data/stream/live_view.html — Auto-refresh browser visualization

System Architecture

Data Flow:

CARLA Simulator → Scene Graph Export → latest_snapshot.xmi + JSONL Events
                ↓
            VIATRA Query Engine
                ↓
              Query Results

Components:

  • Scene Source: CARLA 0.9.16 simulation (vehicles, pedestrians, environment)
  • Extraction: Python bridge collects positions, speeds, relationships
  • Format: EMF XMI (W3C standard) + JSONL event stream (incremental updates)
  • Querying: VIATRA incremental pattern matching on live XMI models
  • Metamodel: Single unified SceneGraph.ecore (Vehicle, Pedestrian, Node, Edge, Scene)

💾 Stream Output Format

All outputs are written to data/stream/ directory:

File Format Purpose
latest_snapshot.xmi XMI Current world state (load into VIATRA)
events.jsonl JSONL Incremental changes per tick (node/edge deltas)
current_state.json JSON Same as latest_snapshot.xmi but in JSON
live_view.html HTML Auto-refresh browser visualization

Example XMI Snapshot:

<scenegraph:Scene xmlns:scenegraph="http://cas782/scenegraph" name="CARLA_Stream">
  <nodes xsi:type="scenegraph:Vehicle" id="26" x="-64.6" y="24.5" z="-0.01" speed="0.0" />
  <nodes xsi:type="scenegraph:Vehicle" id="32" x="120.3" y="28.6" z="0.13" speed="0.004" />
</scenegraph:Scene>

Example JSONL Event:

{"timestamp": "2026-03-09T02:33:12.935688+00:00", "tick": 1, "snapshot": "data/stream/latest_snapshot.xmi", "node_changes": {"added": [{"node_type": "Vehicle", "external_id": "26", "x": -64.6446, "y": 24.471, "z": -0.0075, "speed": 0.0}], "removed": [], "updated": []}}

References & Links

Project Documentation:

External Resources:


For Setup Issues:

  • See PREREQUISITES.md troubleshooting section
  • Check Windows firewall (CARLA uses ports 2000-2001)

For Usage Questions:


License

See LICENSE file.


About

Fork of Ryan Gowland's and Marko Buha's project from CAS 782 (2026W)

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 94.9%
  • Java 2.2%
  • Shell 1.6%
  • PowerShell 1.2%
  • HTML 0.1%