Skip to content

IngTIKNA/AutoMaster

Repository files navigation

AutoMaster - OpenDRIVE to Unity Converter

Unity Version OpenDRIVE License

A Unity project that parses OpenDRIVE (.xodr) road network files and generates 3D road geometry using EasyRoads3D for autonomous vehicle simulation and traffic analysis.


📑 Table of Contents


✨ Features

  • OpenDRIVE 1.4+ Parsing: Full support for standard OpenDRIVE XML format
  • Automatic Road Generation: Converts OpenDRIVE geometry to 3D Unity roads
  • Multiple Geometry Types:
    • ✅ Line segments (straight roads)
    • ✅ Arc segments (curved roads with constant curvature)
    • ⏳ Spiral segments (planned)
  • Smart Junction Handling: Automatically distinguishes junctions from regular roads
  • EasyRoads3D Integration: Professional road mesh generation
  • Traffic Object Support: Parses and positions traffic signals from OpenDRIVE data
  • Inspector-Friendly: All settings configurable from Unity Inspector

📋 Requirements

Component Version Notes
Unity 6000.0.60f1+ (LTS) Required
EasyRoads3D v3 Latest Must be purchased separately (Unity Asset Store)
.NET 4.x or later Standard with Unity
Platform Windows/macOS/Linux Cross-platform

Note: EasyRoads3D is a paid third-party plugin and is not included in this repository. You must purchase and import it separately before using this project. See Installation for details.

Recommended System:

  • RAM: 8GB+
  • GPU: DirectX 11/Metal compatible
  • Storage: 2GB+ for project

🚀 Installation

Step 1: Get the Project

Option A: Clone Repository

git clone https://github.com/ingTikna/autoMaster.git
cd autoMaster

Option B: Download ZIP

  1. Download the latest release
  2. Extract to your desired location

Step 2: Install EasyRoads3D (Required)

EasyRoads3D is a paid plugin not included in this repository. You must install it manually:

  1. Purchase EasyRoads3D Pro v3 from the Unity Asset Store
  2. Open the project in Unity (see below)
  3. Go to WindowPackage Manager
  4. Select "My Assets" from the dropdown
  5. Find EasyRoads3D Pro v3 and click "Download" then "Import"
  6. Import all files — this will create the Assets/EasyRoads3D/ folder
  7. Wait for Unity to recompile scripts

Without EasyRoads3D, the project will show compilation errors since the core scripts depend on the EasyRoads3Dv3 namespace.

Step 3: Open in Unity

  1. Open Unity Hub
  2. Click "Add""Add project from disk"
  3. Navigate to the autoMaster/ directory
  4. Click "Select Folder"
  5. Unity will load and compile the project

🎯 Quick Start

1. Open the Project

Launch Unity Hub and open the AutoMaster project (see Installation)

2. Create Scene Setup

Option A: New Scene

1. File → New Scene
2. GameObject → Create Empty (name it "RoadGenerator")
3. Add Component → Scripts → OpenDriveParser
4. Press Play

Option B: Existing Scene

1. Open Assets/Scenes/SampleScene
2. Select existing GameObject or create new one
3. Add Component → OpenDriveParser
4. Press Play

3. Verify Setup

Watch the Console window for:

✅ Type: line, S: 0, X: 123.45, Y: 67.89...
✅ Road network generation complete

The roads will appear in your Scene view automatically!


📖 Usage

Basic Setup

The simplest way to generate roads:

  1. Create GameObject

    Hierarchy → Right-click → Create Empty
    Name: "RoadNetworkGenerator"
    
  2. Add Component

    Inspector → Add Component → OpenDriveParser
    
  3. Configure (Optional)

    Map File Path: Assets/AutoMaster/Data/Maps/Town01.xodr
    
  4. Run

    Press Play button (or Ctrl/Cmd + P)
    

Switching Maps

You can switch between maps directly in the Inspector:

Method 1: Unity Inspector (Recommended)

  1. Select GameObject with OpenDriveParser component
  2. In Inspector, find "Map File Path" field
  3. Change to:
    • Assets/AutoMaster/Data/Maps/Town01.xodr (smaller map)
    • Assets/AutoMaster/Data/Maps/Town02.xodr (larger map)
  4. Press Play to load the new map

Method 2: Script (For Runtime Loading)

using AutoMaster.Core;

public class MapSwitcher : MonoBehaviour
{
    public OpenDriveParser parser;

    public void LoadTown02()
    {
        parser.mapFilePath = "Assets/AutoMaster/Data/Maps/Town02.xodr";
        // Reload logic here
    }
}

Using Custom Maps

Step 1: Prepare Your Map

Ensure your OpenDRIVE file:

  • Uses .xodr extension
  • Follows OpenDRIVE 1.4+ standard
  • Contains valid <road> and <geometry> elements

Step 2: Import to Unity

# Copy to project
cp your_map.xodr autoMaster/Assets/AutoMaster/Data/Maps/

# Or drag-and-drop into Unity's Project window

Step 3: Configure Path

In Unity Inspector:

OpenDriveParser Component
└─ Map File Path: Assets/AutoMaster/Data/Maps/your_map.xodr

Step 4: Test

Press Play and check Console for any errors.

Configuring Road Properties

Changing Road Width

In Inspector (if exposed):

OpenDriveParser Component
└─ Road Width: 12.0

In Code:

Edit OpenDriveParser.cs (lines 33, 52):

// Junction roads
roadType_jnc.roadWidth = 15.0f;  // Change from 12.0f

// Ordinary roads
roadType.roadWidth = 15.0f;      // Change from 12.0f

Changing Materials

  1. Navigate to Assets/AutoMaster/Resources/Materials/Roads/
  2. Select material (e.g., twoLaneRoadMat.mat)
  3. In Inspector, modify:
    • Shader properties
    • Textures
    • Colors
  4. Changes apply immediately in Play mode

📁 Project Structure

autoMaster/                                  # Unity project root
├── Assets/
│   ├── AutoMaster/                          # Main project assets
│   │   ├── Scripts/                         # C# source code
│   │   │   ├── Core/
│   │   │   │   └── OpenDriveParser.cs       # Main parser controller
│   │   │   ├── Data/
│   │   │   │   ├── ParsedRoadSegment.cs    # Road data model
│   │   │   │   └── TrafficObject.cs        # Traffic object data
│   │   │   ├── Geometry/
│   │   │   │   ├── PathBase.cs             # Abstract base class
│   │   │   │   ├── LinePath.cs             # Straight roads
│   │   │   │   └── ArcPath.cs              # Curved roads
│   │   │   └── Utilities/
│   │   │       ├── PathType.cs             # Geometry type enum
│   │   │       └── XmlFileLoader.cs        # XML parsing helper
│   │   ├── Data/
│   │   │   ├── Maps/                       # OpenDRIVE map files
│   │   │   │   ├── Town01.xodr            # Sample map 1 (498 KB)
│   │   │   │   └── Town02.xodr            # Sample map 2 (1.1 MB)
│   │   │   └── Scenarios/
│   │   │       └── scenario01.mat          # Scenario config
│   │   └── Resources/                      # Unity Resources folder
│   │       ├── Materials/
│   │       │   └── Roads/                  # Road materials
│   │       │       ├── twoLaneRoadMat.mat
│   │       │       ├── noBoundaries.mat
│   │       │       ├── lanelessRoadMat.mat
│   │       │       ├── lanelessRoadLeft.mat
│   │       │       └── lanelessRoadRight.mat
│   │       └── Textures/
│   │           └── Roads/                  # Road textures
│   │               ├── twoLaneRoad.jpg
│   │               ├── lanelessRoad.jpg
│   │               ├── lanelessRoadLeft.jpg
│   │               ├── lanelessRoadRight.jpg
│   │               └── lanelessRoadNoBDR.jpg
│   ├── EasyRoads3D/                        # Third-party plugin (NOT included — install from Asset Store)
│   ├── Scenes/                             # Unity scenes
│   └── Settings/                           # Project settings
├── Packages/                               # Package dependencies
│   └── manifest.json
├── ProjectSettings/                        # Unity configuration
├── Library/                                # Unity cache (auto-generated)
├── Temp/                                   # Temporary files (auto-generated)
├── Logs/                                   # Unity logs (auto-generated)
├── .gitignore                              # Git ignore rules
└── README.md                               # This file

🏗️ Architecture

System Overview

┌─────────────────────────────────────────────────────┐
│                  Unity Scene                        │
│  ┌───────────────────────────────────────────────┐  │
│  │          OpenDriveParser (MonoBehaviour)      │  │
│  │  ┌─────────────────────────────────────────┐  │  │
│  │  │  1. Load .xodr file via XmlFileLoader  │  │  │
│  │  │  2. Parse road geometry & junctions     │  │  │
│  │  │  3. Create LinePath/ArcPath objects     │  │  │
│  │  │  4. Generate ERRoadNetwork              │  │  │
│  │  │  5. Apply materials & build mesh        │  │  │
│  │  └─────────────────────────────────────────┘  │  │
│  └───────────────────────────────────────────────┘  │
└─────────────────────────────────────────────────────┘
          ↓                  ↓                  ↓
   [EasyRoads3D]      [Unity Rendering]   [3D Roads]

Core Components

1. OpenDriveParser (Scripts/Core/OpenDriveParser.cs)

  • Role: Main controller, orchestrates entire process
  • Responsibilities:
    • Loads OpenDRIVE XML file
    • Configures road types and materials
    • Creates road geometry via EasyRoads3D
    • Manages traffic object placement

2. XmlFileLoader (Scripts/Utilities/XmlFileLoader.cs)

  • Role: XML parsing helper
  • Methods:
    • getRoadList() - Returns all <road> elements
    • getGeoList() - Returns all <geometry> elements
    • getSignalsList() - Returns traffic signal data
    • getPlanViewList() - Returns plan view nodes

3. Data Models (Scripts/Data/)

  • ParsedRoadSegment: Stores road geometry data
    • Type (line/arc/spiral)
    • Position (X, Y)
    • Heading (Hdg)
    • Length, Curvature
    • Junction ID
  • TrafficObject: Stores traffic signal data
    • Position (xPos, yPos, sPos, tPos)
    • Path reference
    • Placement flags

4. Geometry Classes (Scripts/Geometry/)

  • PathBase: Abstract base class for all paths
  • LinePath: Implements straight road segments
    • Calculates start/end points
    • Generates marker array for EasyRoads3D
  • ArcPath: Implements curved road segments
    • Computes arc radius and central angle
    • Interpolates points along curve
    • Handles clockwise/counterclockwise curves

Data Flow

OpenDRIVE XML File
       ↓
XmlFileLoader.Load()
       ↓
Parse <road> & <geometry> elements
       ↓
Create ParsedRoadSegment objects
       ↓
Determine if Junction or Ordinary road
       ↓
Create LinePath or ArcPath objects
       ↓
Generate Vector3[] markers
       ↓
ERRoadNetwork.CreateRoad()
       ↓
EasyRoads3D mesh generation
       ↓
3D Road in Unity Scene

🗺️ OpenDRIVE Maps

Included Maps

Map Size Lines Roads Junctions Source
Town01.xodr 498 KB 7,778 50+ 10+ RoadRunner 2019
Town02.xodr 1.1 MB 13,234 100+ 20+ RoadRunner 2019

Map Details

Town01.xodr

  • Description: Small urban environment
  • Features: Basic intersections, straight roads, simple curves
  • Use Case: Testing, development, quick iterations
  • Parse Time: ~0.5 seconds

Town02.xodr

  • Description: Larger complex urban network
  • Features: Multiple junctions, complex geometry, roundabouts
  • Use Case: Performance testing, realistic scenarios
  • Parse Time: ~1.2 seconds

OpenDRIVE Format Support

Supported Elements:

<OpenDRIVE>
  <road junction="-1|id">           ✅ Supported
    <planView>                      ✅ Supported
      <geometry s="" x="" y="" hdg="" length="">
        <line/>                     ✅ Supported
        <arc curvature=""/>         ✅ Supported
        <spiral/>                   ⏳ Planned
      </geometry>
    </planView>
    <signals>                       ✅ Parsed (not visualized)
      <signal s="" t="" name=""/>
    </signals>
  </road>
</OpenDRIVE>

📚 API Reference

OpenDriveParser

namespace AutoMaster.Core
{
    public class OpenDriveParser : MonoBehaviour
    {
        // Public Fields (Inspector-configurable)
        public string mapFilePath;        // Path to .xodr file
        public ERRoadNetwork roadNetwork; // EasyRoads3D network

        // Methods
        void Start();                     // Auto-runs on scene start
        List<ParsedRoadSegment> ParseOpenDrive(string filePath);
    }
}

Usage:

// Access from another script
OpenDriveParser parser = GetComponent<OpenDriveParser>();
parser.mapFilePath = "Assets/AutoMaster/Data/Maps/Town02.xodr";

XmlFileLoader

namespace AutoMaster.Utilities
{
    public class XmlFileLoader
    {
        public XmlFileLoader(string filePath);
        public XmlNodeList getRoadList();
        public XmlNodeList getGeoList();
        public XmlNodeList getSignalsList();
        public XmlNodeList getPlanViewList();
    }
}

LinePath

namespace AutoMaster.Geometry
{
    public class LinePath : PathBase
    {
        public LinePath(
            int road_index,
            float x_Start,
            float y_Start,
            float z,
            float length,
            float hdg
        );

        public Vector3[] markers;  // Road waypoints
    }
}

ArcPath

namespace AutoMaster.Geometry
{
    public class ArcPath : PathBase
    {
        public ArcPath(
            int road_index,
            float x_Start,
            float y_Start,
            float z,
            float length,
            float hdg,
            float curvature
        );

        public Vector3[] markers;  // Road waypoints
    }
}

🎨 Customization

Materials

Available Materials

Located in Assets/AutoMaster/Resources/Materials/Roads/:

Material Usage Features
twoLaneRoadMat Ordinary roads Two-lane markings, yellow center line
noBoundaries Junctions No lane markings, plain surface
lanelessRoadMat Alternative No markings, gray surface
lanelessRoadLeft Directional Left-side marking variant
lanelessRoadRight Directional Right-side marking variant

Customizing Materials

Edit Existing:

  1. Navigate to Resources/Materials/Roads/
  2. Double-click material
  3. Modify shader properties in Inspector
  4. Adjust albedo texture, smoothness, metallic, etc.

Create New:

// In OpenDriveParser.cs
Material customMaterial = Resources.Load("Materials/Roads/MyCustomMat") as Material;
roadType.roadMaterial = customMaterial;

Textures

Located in Assets/AutoMaster/Resources/Textures/Roads/:

  • twoLaneRoad.jpg (158 KB) - Two-lane texture
  • lanelessRoad.jpg (79 KB) - Plain road texture
  • Additional variants for different road types

To use custom textures:

  1. Import image to Textures/Roads/
  2. Create new Material
  3. Assign texture to material
  4. Update OpenDriveParser.cs to load your material

Road Width

Global Change:

Edit OpenDriveParser.cs:

// Line 33 (Junction roads)
roadType_jnc.roadWidth = 15.0f;  // Default: 12.0f

// Line 52 (Ordinary roads)
roadType.roadWidth = 15.0f;      // Default: 12.0f

Per-Road Change (Advanced):

// Create different road types
ERRoadType narrowRoadType = new ERRoadType();
narrowRoadType.roadWidth = 8.0f;

ERRoadType wideRoadType = new ERRoadType();
wideRoadType.roadWidth = 16.0f;

// Use conditionally based on road attributes

🔧 Troubleshooting

Common Issues

1. Materials Not Loading

Error Message:

Material 'twoLaneRoadMat' not found in Resources/Materials/Roads!

Solutions:

  • ✅ Verify material exists: Assets/AutoMaster/Resources/Materials/Roads/twoLaneRoadMat.mat
  • ✅ Check spelling in OpenDriveParser.cs
  • ✅ Ensure folder is named exactly "Resources" (case-sensitive)
  • ✅ Reimport material: Right-click → Reimport

2. OpenDRIVE File Not Found

Error Message:

FileNotFoundException: Could not find file "Assets/..."

Solutions:

  • ✅ Verify file path uses forward slashes: / not \
  • ✅ Check file is in Assets/AutoMaster/Data/Maps/
  • ✅ Ensure extension is .xodr
  • ✅ Use absolute path from Assets: Assets/AutoMaster/Data/Maps/Town01.xodr

3. Roads Not Generating

Symptoms:

  • Scene runs but no roads appear
  • No errors in Console

Solutions:

  • ✅ Check Console for warnings
  • ✅ Verify roadNetwork is not null (Inspector)
  • ✅ Ensure OpenDRIVE file has <geometry> elements
  • ✅ Adjust camera position (roads may be far from origin)
  • ✅ Check Scene view, not just Game view

4. Compilation Errors

Error Message:

error CS0246: The type or namespace name 'X' could not be found

Solutions:

  • ✅ Reimport all scripts: Assets → Reimport All
  • ✅ Check all namespace using statements
  • ✅ Restart Unity Editor
  • ✅ Delete Library folder and reopen project

5. EasyRoads3D Errors

Error Message:

The type or namespace name 'EasyRoads3Dv3' could not be found

Solutions:

  • EasyRoads3D is not included in this repository — you must purchase and import it separately from the Unity Asset Store
  • ✅ Verify EasyRoads3D folder exists at Assets/EasyRoads3D/ after importing
  • ✅ If already imported, check that the folder is not empty
  • ✅ Reimport via Window → Package Manager → My Assets → EasyRoads3D → Import
  • ✅ Contact EasyRoads3D support if the plugin has issues after import

⚡ Performance

Benchmarks

Tested on: Intel i7-9700K, 16GB RAM, GTX 1080

Map File Size Parse Time Roads Generated FPS (Editor)
Town01 498 KB 0.5s 50+ 60+
Town02 1.1 MB 1.2s 100+ 45+

Optimization Tips

For Large Maps (>50MB)

  1. Streaming Loading

    // Load map in chunks
    IEnumerator LoadMapAsync(string path) {
        // Parse section by section
        // Yield between sections
    }
  2. LOD System

    • Generate high-detail roads near camera
    • Use low-poly meshes for distant roads
    • Implement culling for off-screen roads
  3. Async XML Parsing

    async Task<List<ParsedRoadSegment>> ParseOpenDriveAsync(string path) {
        // Use async XML reading
        await Task.Run(() => ParseXML());
    }
  4. Object Pooling

    • Reuse road segment objects
    • Pool EasyRoads3D components

🤝 Contributing

We welcome contributions! Here's how to get started:

Development Setup

  1. Fork the repository

    git clone https://github.com/ingTikna/autoMaster.git
  2. Create a feature branch

    git checkout -b feature/your-feature-name
  3. Make your changes

    • Follow C# coding conventions
    • Add XML comments to public methods
    • Update README if needed
  4. Test thoroughly

    • Test with both sample maps
    • Verify no Console errors
    • Check performance impact
  5. Commit and push

    git commit -m "Add: Brief description of feature"
    git push origin feature/your-feature-name
  6. Create Pull Request

    • Describe changes clearly
    • Reference any related issues
    • Include screenshots if applicable

Coding Standards

// Good: PascalCase for classes and methods
public class RoadGenerator
{
    public void ParseRoadNetwork() { }
}

// Good: camelCase for private fields
private float roadWidth = 12.0f;

// Good: XML comments for public APIs
/// <summary>
/// Parses an OpenDRIVE file and generates roads.
/// </summary>
/// <param name="filePath">Path to .xodr file</param>
/// <returns>List of parsed road segments</returns>
public List<ParsedRoadSegment> ParseOpenDrive(string filePath)

📄 License

This project is provided as-is for educational and research purposes.

Third-Party Licenses

Component License Usage
EasyRoads3D v3 Commercial (not included — purchase separately) Road mesh generation
OpenDRIVE Format Open Standard (ASAM) Map file format
Unity Engine Unity EULA Game engine
RoadRunner Commercial Map creation tool

Note: EasyRoads3D is a commercial plugin and is not distributed with this repository. You must purchase it separately from the Unity Asset Store.


🙏 Credits

Development

  • Project: AutoMaster
  • Purpose: OpenDRIVE to Unity conversion for autonomous vehicle simulation
  • Year: 2026

Third-Party Tools

Standards & Formats

  • OpenDRIVE: Road network standard by ASAM e.V.
  • RoadRunner: Map generation tool by MathWorks

Community

Special thanks to:

  • Unity community for tutorials and support
  • EasyRoads3D community for documentation
  • ASAM for maintaining the OpenDRIVE standard
  • All contributors and testers

📞 Contact & Support

Get Help

Resources

Stay Updated

  • ⭐ Star this repository
  • 👀 Watch for updates
  • 🐛 Report bugs
  • 💡 Suggest features

Version 1.0.0 | Unity 6000.0.60f1 (LTS) | Last Updated: February 2026

⬆ Back to Top

About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors