Python connector for OTM
Project description
OTM is a platform for simulating vehicular traffic scenarios. It offers multiple models that can be arbitrarily combined in a single simulation. You can use one of the native OTM models (CTM, 2Q, Newell), or you can create a plugin for your own model. You can similarly implement new controllers as plugins.
Learn more here.
Python API
Most users will interact with OTM through its Python API, which can be installed with pip:
pip install pyotm
The pyotm
package contains a single class called OTMWrapper
. Below we see how to use OTMWrapper
to run a step-by-step simulation.
from pyotm.OTMWrapper import OTMWrapper
# in case there is a lingering open gateway
if "otm" in locals():
del otm
# load the configuration file
otm = OTMWrapper("intersection.xml")
# initialize (prepare/rewind the simulation)
otm.initialize(start_time=0.0)
# run step-by-step using the 'advance' method
time = 0.0 # in seconds
advance_time = 10.0
while(time<3600.0 ):
otm.advance(advance_time) # seconds, should be a multiple of sim_dt
print(otm.get_current_time())
time += advance_time;
# deleting the wrapper to shut down the gateway
del otm
Use run
to run an entire simulation.
from pyotm.OTMWrapper import OTMWrapper
import numpy as np
if "otm" in locals():
del otm
otm = OTMWrapper("intersection.xml")
otm.run(start_time=0,duration=2500,output_dt=10)
Y = otm.get_state_trajectory()
print(Y.keys())
del otm
Here get_state_trajectory
has been used to retrieve the state trajectory. This is a dictionary containing various state profiles.
A comprehensive API is available via the otm
attribute of OTMWrapper
. This API provides access to most of the internal state of OTM and should be used with care. The javadoc can be found here.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pyotm-0.0.3.tar.gz
.
File metadata
- Download URL: pyotm-0.0.3.tar.gz
- Upload date:
- Size: 3.8 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4c0cb90797dcbf2346e09e875a026df0dce4965380f93103d29f5f49eb5c34d4 |
|
MD5 | ecd0f4be2327f675fe18828be06bccc9 |
|
BLAKE2b-256 | 26342b62269a28beda9862942aeeec8f66f83611a1d846db198fe59126abac0b |
File details
Details for the file pyotm-0.0.3-py3-none-any.whl
.
File metadata
- Download URL: pyotm-0.0.3-py3-none-any.whl
- Upload date:
- Size: 3.8 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b65b4d796e250bf1adb0ba74f6ddb696e89577136fa0f8829e2e3acf03595634 |
|
MD5 | 3038fe2d807781933d9f0f0b1b327cee |
|
BLAKE2b-256 | a621dbe4e79ee356aa53a91c7c27fad37a9e42efbf93a47bfccef93430dcd585 |