Skip to content

TUM-AVS/PedestrianSimulator

Repository files navigation

Linux Python 3.11 Python 3.10 GPLv3 license

Pedestrian Simulator for Social Force Modeling

This repository includes a Pedestrian Simulation Framework built on the CommonRoad scenario format. It simulates pedestrian behavior using a social force model and integrates policy-based movement planning for dynamic and realistic pedestrian predictions.

For a practical application of this pedestrian simulation model, explore our Pedestrian Aware Motion Planner.

Features

  • Social Force Model: Simulates pedestrian interactions and behaviors.
  • Policy-based Planning: Implements movement policies for destination selection.
  • Integration with CommonRoad: Direct compatibility with CommonRoad scenarios.
  • Visualization: Detailed rendering of scenarios and pedestrian trajectories.

🔧 Requirements & Installation

Click to expand

Requirements

The software is developed and tested on recent versions of Linux. We strongly recommend using Ubuntu 22.04 or higher. For the Python installation, we suggest the usage of Virtual Environment with Python 3.11, Python 3.10 or Python 3.9 For the development IDE we suggest PyCharm

1. Clone the repository

git clone <repository-url>
cd <repository-folder>

2. Create and activate a new Virtual Environment

python3.11 -m venv venv
source venv/bin/activate

3. Install all required packages

Installation with Poetry

To install the project and its dependencies, ensure you have Poetry installed. Then, run the following commands:

Install the dependencies and the project:

poetry install

Installation with pip

Alternatively, you can install the project's requirements using pip:

pip install .

🚀 Quick Start

Click to expand
  1. Load a Scenario: Load a CommonRoad scenario that includes pedestrians using the CommonRoadFileReader:

    from commonroad.common.file_reader import CommonRoadFileReader
    
    scenario_path = 'path/to/scenario.xml'
    scenario, planning_problem_set = CommonRoadFileReader(scenario_path).open()
  2. Initialize the Simulator: Instantiate the Pedestrian Simulator with the loaded scenario:

    from pedestrian_simulator import PedestrianSimulator
    
    pedestrian_simulator = PedestrianSimulator(scenario)
  3. Simulate Pedestrian Behavior: Advance the simulation for a specified number of steps:

    for timestep in range(100):
        pedestrian_simulator.step_pedestrians(timestep)

🏃 Example Workflow

Click to expand

The repository includes a Minimal Working Example (MWE) in main.py to demonstrate the pedestrian simulation workflow: You can include the pedestrian simulator in any CommonRoad scenario.

   python3 main.py

📈 Visualization

Click to expand

The framework supports detailed visualization of:

  • Pedestrian trajectories.
  • Interaction forces.
  • Vehicle predictions (if vehicles are present in the scenario).

🛠 Scenario Creation Tool

Click to expand

The create_pedestrian_scenario utility allows you to extend an existing CommonRoad scenario by adding pedestrians, sidewalks, and crosswalks. This tool is highly configurable to adapt to a variety of simulation needs.

Features

  • Add sidewalks and crosswalks to existing scenarios.
  • Add pedestrians to the scenario.
  • Customize parameters such as pedestrian speed, clustering distance, and position deviations.
  • Visualize the generated scenario.

Example Usage

from pedestrian_simulator.tools.create_pedestrian_scenario import create_new_pedestrian_scenario

input_file = "path/to/scenario.xml"
scenario, planning_problem_set = create_new_pedestrian_scenario(
    input_file=input_file,
    pedestrian_speed=1.2,          # Average pedestrian speed
    pedestrians_per_cluster=2.0,  # Number of pedestrians per cluster
    position_deviation=0.2,       # Deviation in positions within a cluster
    cluster_distance=4.0,         # Distance between pedestrian clusters
    seed=42                       # Random seed for reproducibility
)

# Save or visualize the scenario as needed

See also the MWE in create_pedestrian_scenario.py for an example workflow.


📚 Documentation

Click to expand

For detailed explanations of the attributes and methods, refer to the source code. The key method of the simulator is:

  • step_pedestrians(timestep): Advance simulation by one timestep (starting from the given timestep).

📇 Contact Info

Click to expand

Korbinian Moller, Professorship Autonomous Vehicle Systems, School of Engineering and Design, Technical University of Munich, 85748 Garching, Germany

Johannes Betz, Professorship Autonomous Vehicle Systems, School of Engineering and Design, Technical University of Munich, 85748 Garching, Germany


📃 Citation

Click to expand

If you use this Pedestrian Simulator in your research, please cite the related paper:

t.b.d

👥 Code Contributors

Click to expand

Korbinian Moller
Truls Nyberg

Releases

No releases published

Packages

No packages published

Languages