Generative AI–Driven Autonomous Vehicle Simulation for Unknown Unsafe Events Discovery
TeraSim is an open-source platform for automated autonomous-vehicle (AV) simulation using generative AI. Its primary objective is to efficiently uncover real-world unknown unsafe events by automatically creating diverse and statistically realistic traffic environments.
The framework has evolved from its initial focus on planning-and-control testing to a complete simulation workflow, which now includes:
- High-fidelity HD map generation for large-scale, accurate simulation environments
- Generative traffic environment creation for naturalistic and adversarial scenario testing
- Generative sensor simulation for camera and LiDAR perception validation
This expanded scope enables a unified pipeline from map generation to perception and planning validation.
- [09/29/2025]: TeraSim-World source codes are available. See TeraSim_World.md to get started.
TeraSim-World automatically synthesizes geographically grounded, safety-critical data for End-to-End autonomous driving anywhere in the world.
✨ Key Capabilities:
- 🗺️ Global Coverage: Generate realistic driving scenarios for any location worldwide
- 🎯 Safety-Critical Data: Automatically create safety-critical events for E2E AV safety testing
- 🔄 NVIDIA Cosmos-Drive Compatible: Direct integration with video generation model training platforms
🚀 Source code is now available! See TeraSim_World.md for getting started guide.
- Tools for building city-scale, high-resolution digital twins suitable for AV testing.
- Automated conversion of real-world survey data into simulation-ready HD maps.
- Provides accurate lane geometry and traffic-control metadata for downstream simulations.
- Automated scenario generation based on large-scale naturalistic driving data.
- Adversarial scenario synthesis to reveal rare or high-risk interactions (e.g., aggressive cut-ins, unexpected pedestrian crossings).
- Integration with SUMO and third-party simulators such as CARLA and Autoware.
terasim-cosmosintegrates TeraSim-World with generative AI–based camera and LiDAR simulation.- Enables perception validation and sensor pipeline testing under diverse conditions.
- Ongoing work: support for fully custom sensor models and configurable realism levels is under active development.
TeraSim uses a modular monorepo design. Each package can be used independently or combined into a complete simulation pipeline.
TeraSim/
├── packages/
│ ├── terasim/ # Core simulation engine
│ ├── terasim-envgen/ # HD map and environment generation
│ ├── terasim-nde-nade/ # Naturalistic & adversarial environment algorithms
│ ├── terasim-cosmos/ # TeraSim-World integration & generative AI sensor simulation
│ ├── terasim-sensor/ # Baseline sensor utilities
│ ├── terasim-datazoo/ # Data processing utilities for real driving datasets
│ ├── terasim-service/ # RESTful API for external simulators
│ └── terasim-vis/ # Visualization and analysis tools
├── examples/ # Example configurations and scenarios
├── docs/ # Documentation and figures
└── tests/ # Test suites
git clone https://github.com/mcity/TeraSim.git
cd TeraSim
conda create -n terasim python=3.10 -y
conda activate terasim
./setup_environment.shThis script installs all required Python packages and dependencies, including SUMO.
Requirements
- Python 3.10–3.12
- SUMO 1.23.1 (installed by the setup script)
- Redis for service components
- gcc/g++ compilers (for Cython extensions)
See TeraSim_World.md for Quick Start Example.
Additional examples are available in the examples/ directory.
Contributions are welcome. Please read the CONTRIBUTING.md guidelines and join the GitHub discussions for feedback or proposals.
Explore our other research on autonomous driving testing!
-
NDE – Learning naturalistic driving environment with statistical realism Paper | Code
-
NADE – Intelligent driving intelligence test with naturalistic and adversarial environment Paper | Code
-
D2RL – Dense deep reinforcement learning for AV safety validation Paper | Code
- TeraSim Core and other packages: Apache 2.0 License
- Visualization Tools: MIT License
This project includes modified code from SumoNetVis licensed under the MIT License.

