Code Monkey home page Code Monkey logo

pycarmodel_calibration's Introduction

badge badge badge

Pycarmodel_calibration

This carmodel calibration tool was developed for my student thesis. The purpose is to calibrate the Extended Intelligent Driver Model (EIDM) from dron data. The private dataset contains drone footage of vehicles driving off at an intersection, similiar to this video. The calibration tool would first find a selection of vehicles in pairs, each one containing a leader and a follower. Using SUMO to simulate the EIDM behavior, an optimization algorithm finds the best set of parameters from the dataset's trajectory. The leader's trajectory is the input and the follower's trajectory is simulated. The basis if calibration is the deviation between the follower's simulated trajectory to the real follower's trajectory.

CLI usage

Use carmodel-calibration --help for help. The help updates the information displayed for different actions, e.g. carmodel-calibration --action=calibration --help will have different options.

usage: carmodel-calibration Data-Directory Output-Directory differential_evolution [-h] [--num-workers NUM_WORKERS] [--population-size POPULATION_SIZE] [--max-iter MAX_ITER] [--models MODELS]
                                                                     [--param-keys PARAM_KEYS] [--force-selection] [--no-report]

optional arguments:
  -h, --help            show this help message and exit
  --population-size POPULATION_SIZE
                        Size of the populationdoes not apply to direct.
  --max-iter MAX_ITER   Number of max iterations.
  --models MODELS       Models to train as comma separated list e.g. `eidm`.
  --param-keys PARAM_KEYS
                        comma separated list of parameters e.g. `speedFactor,minGap,...`
  --force-selection     If the flag is passed, then the selection is forced to be recalculateld.
  --no-report           Will not create reports in the output directory.

Here's an example usage using differential evolution as calibration algorithm.

carmodel-calibration --action=calibrate "path/to/input/data" "path/to/output-data/directory" differential_evolution --population-size=200 --max-iter=100 --param-keys="speedFactor,minGap,accel,decel,startupDelay,tau,delta,tpreview,tPersDrive,tPersEstimate,treaction,ccoolness,jerkmax,epsilonacc,taccmax,Mflatness,Mbegin"

Installation

Prerequisites

  1. Follow the SUMO installation instructions: https://sumo.dlr.de/docs/Installing/index.html and remember the installation directory or copy it to clipboard. You may look here for a specific version.
  2. Open a command-prompt, and verify that sumo and netgenerate are in the PATH variable:
    sumo --version
    netgenerate
    
  3. If both commands show their info, then youre done. If not, add /path/to/sumo/bin to your PATH environment variable, this is platform specific.

Installation by building from source

  1. Ensure that python --version returns 3.8.*. If not, install anaconda and create a python 3.8.* environment or install python directly without anaconda (not recommended).
    $ python --version
    Python 3.8.16
    
  2.  pip install setuptools
     git clone https://github.com/stepeos/pycarmodel_calibration.git
     cd pycarmodel_calibration
     python3 -m pip install --upgrade build
     python3 -m build
     pip install ./dist/carmodel_calibration-0.1-py3-none-any.whl
    
  3. successful, if carmodel-calibration --help shows the help

Example Usage:

For educational purposes, InD dataset can be acquired for free from levelxdata.com/ind-dataset/. This dataset does not contain any intersection with traffic lights, however with the right configuration file, some calibration targets can still be found.

  1. Download the dataset to /my/dataset/path/inD-dataset-v1.0/
  2. create a results directory mkdir -p /my/dataset/path/inD-dataset-v1.0/results
  3. download the sample config wget -O /my/dataset/path/inD-dataset-v1.0/data/data_config.json https://github.com/stepeos/pycarmodel_calibration/main/ind_config.json
  4. start the calibration process carmodel-calibration --action=calibrate /my/dataset/path/inD-dataset-v1.0/data/ /my/dataset/path/inD-dataset-v1.0/results/ differential_evolution --population-size=200 --max-iter=100 --param-keys=speedFactor,minGap,accel,decel,startupDelay,tau,delta,tpreview,tPersDrive,tPersEstimate,treaction,ccoolness,jerkmax,epsilonacc,taccmax,Mflatness,Mbegin (if the path contains spaces, one can use quotes like "/my-path/with whitespaces/inD-dataset-v1.0")

pycarmodel_calibration's People

Contributors

stepeos avatar domsall avatar

Stargazers

 avatar

Watchers

 avatar

pycarmodel_calibration's Issues

Usage of traffic_light_time

traffic_light_time has a default value of 60.
The config-file of the tl intersection has a traffic_light_time value of -1.
The config-file of the non-tl intersection has a traffic_light_time value of 1.

The code used to always include the following function:

for leader in car_at_redlight(data_frame, lane_data, lanes):
free_leaders += " " + str(leader)
entries.append(("", leader))

Now, this is only called, when traffic_light_time exists in the config file (used to not exist). And with the traffic_light_time value of the tl-intersection being -1, this function would not be called here, too.

tlt = self._data_set.get_file_specific_options(rec).get(
"traffic_light_time") or 0
if tlt > 0:

Is this the correct behavior? My current code always calls this function.

Extending the framework for FCD data

Right now, a single drive off is extracted for calibration.
It would be beneficial if longer trajectories with multiple drive offs could be used for calibration.

Floating Car Data (FCD) or stationary camera systems can measure/extract such long trajectories.

Queued followers not correctly identified

When I change the dataset or timing, the some queued vehicles may get disregarded. This issue probably stems from the calculation of the traffic light's cycle time.

GDE3 from pymoode runs into error in compiled Code part.

When using pymoode with GDE3 (and pcd ranking) and a small population size, the Code runs into an error in metrics.py. It happens somewhere in the compiled Code (pymoode.cython.mnn and pymoode.cython.pruning_cd). When we use the Python Code (pymoode.misc.mnn and pymoode.misc.pruning_cd) everything works fine.

It seems that the algorithm runs out of space (solutions/population) to manage the results.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.