Skip to main content

Overview

The Urban Mobility MARL (Multi-Agent Reinforcement Learning) WebSocket API provides real-time control and interaction with dynamic urban mobility simulations. This system enables you to create, modify, and observe complex multi-agent scenarios involving pedestrians, vehicles, and environmental stimuli in real-time.

Key Features

  • Real-time Agent Control: Dynamically add, remove, and modify agents during simulation
  • Multi-Agent Types: Support for pedestrians, vehicles, and public transport
  • Environmental Stimuli: Add emergency scenarios like evacuations or disasters
  • Pathfinding: Intelligent routing using real-world road networks
  • Geospatial Integration: Uses actual geographic data and elevation models
  • Scalable: Handle thousands of agents simultaneously

Connection

Connect to the WebSocket endpoint to start interacting with the MARL system:
The WebSocket server runs on port 8001 by default. For production environments, use the secure WebSocket protocol (wss://) when available.

Agent Types

The system supports multiple agent types, each with unique behaviors:

Simulation Flow

1. Connection & Initialization

2. Receive Agent Data

3. Dynamic Interaction

Agent Properties

Each agent contains comprehensive data for realistic simulation:

Basic Properties

  • ID: Unique identifier (sim_agent_123)
  • Position: Geographic coordinates [latitude, longitude]
  • Velocity: Movement vector [dLat, dLng]
  • Type: Agent type (0=pedestrian, 1=vehicle)
  • Goal: Target destination coordinates

Behavioral Properties

  • Path: Array of waypoint coordinates for vehicles
  • Fleeing Status: Whether agent is responding to emergency stimulus
  • State: Current behavioral state (walking, driving, waiting, etc.)

Visual Properties

  • Model References: 3D model URLs and animation data
  • Attributes: Customizable properties for appearance and behavior

Geospatial Features

Real-World Data Integration

  • OpenStreetMap: Road networks and building footprints
  • Elevation Models: Terrain height data for realistic positioning
  • Geographic Bounds: Configurable simulation areas

Coordinate Systems

  • Input/Output: Geographic coordinates (WGS84)
  • Internal Processing: Projected coordinates for performance
  • 3D Positioning: Includes elevation data for vertical accuracy

Performance Considerations

Scalability

  • Agent Limits: Up to 1,000 agents per simulation (configurable)
  • Update Frequency: Real-time updates with minimal latency
  • Memory Management: Efficient spatial indexing and culling

Network Optimization

  • Message Batching: Multiple updates combined when possible
  • Compression: JSON payload optimization
  • Connection Management: Automatic reconnection and heartbeat

Use Cases

Emergency Response Planning

Simulate evacuation scenarios with dynamic obstacles and changing conditions:

Traffic Flow Analysis

Study traffic patterns and congestion with realistic vehicle behavior:

Urban Planning

Test infrastructure changes and their impact on mobility:

Crowd Dynamics

Study pedestrian flow in public spaces and events:

Integration Examples

Three.js Visualization

Unity Integration

Error Handling

Connection Issues

Message Validation

Next Steps