O --- O
libPEDSIM Documentation
O --- O

PEDSIM is a microscopic pedestrian crowd simulation library. It is suitable for use in crowd simulations (e.g. indoor evacuation simulation, large scale outdoor simulations), where one is interested in output like pedestrian density or evacuation time. Also, the quality of the individual agent's trajectory is high enough for creating massive pedestrian crowd animations (e.g. for motion pictures or architectural visualization). Since libpedsim is easy to use and extend, it is a good starting point for science projects. See the examples page for example pictures, short movies, and for screenshots.

The PEDSIM library allows you to use pedestrian dynamics in your own software. Based on pure C++ without additional packages, it runs virtually on every operating system. PEDSIM has been developed and tested on Linux. Also supported, but slightly less tested, is Visual Studio on Windows. In the ecosystem directory you find additional parts that use or extend the PEDSIM library. They are meant to give a quick overview of the capabilities, and are starting points for your own experiments. Most of them are built using the Qt Framework, which you'll need to download separately.

The pedestrians are visible on the user interface in real-time. Using the file or network-based output, both batch and real-time processing is possible.

To create video sequences the output of PEDSIM is usually fed into a rendering engine, where realistically looking humans are created. These humans walk based on the trajectories generated by PEDSIM.

General Usage Notes

See the Code Example further down, and have a look at the full source code, available on the download page.

Detailed Class Documentation

There is a complete documentation of the classes in the library. It is automatically generated out of the source code. You can access this documentation online here. This same documentation is delivered as PDF file with the library for offline use.

Code Example

This example shows the very basic usage of the library. No fancy graphics, of course, only text output to the console. This is example01.cpp in the examples folder.

Please note:
Additional steps around the example code might be required in order to compile it. If you are using Windows and, for example, Microsoft Visual Studio, you can create a new console application using the wizard. Create a file called example01.cpp and copy-paste the code into it. In the project's Properties, under Linker/Input, add libpedsim.lib in front of the Additional Dependencies list. Click run. Also see Using PEDSIM on Windows.

On a typical linux system, if you are in the libpedsim folder, use this to compile, link and run:

g++ examples/example01.cpp -o example -lpedsim -L. -I. -std=c++11

It will create 100 agents, which are placed somewhat randomly distributed around -50/0. They should walk between -100/0 and 100/0. An obstacle (wall) is placed from 0/-50 to 0/50. The agents must walk around that obstacle. That's it, as simple as that: the agents will walk with that little code.

If you want to display some graphics, write a file, or send data over the network, you will get the agent's positions with a->getPosition(). Of course, you can inherit your own classes from Tagent, Tobctacle etc, if you want to have more control. See the Demo App Source for an example.

// pedsim - A microscopic pedestrian simulation system.
// Copyright (c) by Christian Gloor
#include <iostream>
#include <cstdlib>
#include <chrono>
#include <thread>
#include "ped_includes.h"
#include "ped_outputwriter.h"
using namespace std;
int main(int argc, char *argv[]) {
// create an output writer which will send output to a file
ow->setScenarioName("Example 01");
cout << "PedSim Example using libpedsim version " << Ped::LIBPEDSIM_VERSION << endl;
// Setup
Ped::Tscene *pedscene = new Ped::Tscene(-200, -200, 400, 400);
Ped::Twaypoint *w1 = new Ped::Twaypoint(-100, 0, 24);
Ped::Twaypoint *w2 = new Ped::Twaypoint(+100, 0, 12);
Ped::Tobstacle *o = new Ped::Tobstacle(0, -50, 0, +50);
for (int i = 0; i<10; i++) {
a->setPosition(-50 + rand()/(RAND_MAX/80)-40, 0 + rand()/(RAND_MAX/20) -10, 0);
// Move all agents for 700 steps (and write their position through the outputwriter)
for (int i=0; i<700; ++i) {
// Cleanup
for (Ped::Tagent* agent : pedscene->getAllAgents()) delete agent;
delete pedscene;
delete w1;
delete w2;
delete o;
delete ow;
O --- O

⁠(c) Christian Gloor [ c|h|g|l|o|o|r|@|s|i|l|m|a|r|i|l|.|o|r|g| ]