Automatic generation of ship traffic situations from a set of predefined situations
Project description
Traffic Generator
The tool generates a structured set of encounters for verifying automatic collision and grounding avoidance systems. Based on input parameters such as desired situation, relative speed, relative bearing etc, the tool will generate a set of traffic situations. The traffic situations may be written to files and/or inspected using plots.
A paper is written describing the background for the tool and how it works [paper]
For package documentation, see https://dnv-opensource.github.io/ship-traffic-generator/
Installation
To install Ship Traffic Generator, run this command in your terminal:
pip install trafficgen
This is the preferred method to install Traffic Generator, as it will always install the most recent stable release.
You can check your installation by running:
uv run trafficgen --help
Usage
For simplest usage, clone this repo, then run pip install -e .
(you may want to do this in a local environment, such as a venv, see an example with uv
below).
Then run: trafficgen gen-situation
. You can add the option -v
for visualization.
For further explanations, see the documentation pages of the Ship Traffic Generator.
Development Setup
Install UV
This project uses uv
as package manager.
If you haven't already, install uv, preferably using it's "Standalone installer" method:
..on Windows:
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
..on MacOS and Linux:
curl -LsSf https://astral.sh/uv/install.sh | sh
(see docs.astral.sh/uv for all / alternative installation methods.)
Once installed, you can update uv
to its latest version, anytime, by running:
uv self update
Install Python
The traffic generator requires Python 3.11 or later.
If you don't already have a compatible version installed on your machine, you way install Python through uv
:
uv python install
This will install the latest stable version of Python into the uv Python directory, i.e. as a uv-managed version of Python.
Note: you can also do this after you clone the repo, see below.
Alternatively, and if you want a standalone version of Python on your machine, you can install Python either via winget
:
winget install --id Python.Python
or you can download and install Python from the python.org website.
Clone the repository
Clone the traffig generator repository into your local development directory:
git clone https://github.com/dnv-opensource/ship-traffic-generator path/to/your/dir/ship-traffic-generator
Change into the project directory after cloning:
cd ship-traffic-generator
Install dependencies
Run uv sync -U
to create a virtual environment and install all project dependencies into it:
uv sync -U
Note: Using
--no-dev
will omit installing development dependencies.
Note: You can also define the python environment at the same time, by running for example
uv sync -U -p 3.12
to install Python 3.12.
Note:
uv
will create a new virtual environment called.venv
in the project root directory when runninguv sync
the first time. Optionally, you can create your own virtual environment using e.g.uv venv
, before runninguv sync
.
(Optional) Activate the virtual environment
When using uv
, there is in almost all cases no longer a need to manually activate the virtual environment.
uv
will find the .venv
virtual environment in the working directory or any parent directory, and activate it on the fly whenever you run a command via uv
inside your project folder structure:
uv run <command>
However, you still can manually activate the virtual environment if needed.
When developing in an IDE, for instance, this can in some cases be necessary depending on your IDE settings.
To manually activate the virtual environment, run one of the "known" legacy commands:
..on Windows:
.venv\Scripts\activate.bat
Note: If you use the cmd terminal in VS Code, it will show this activated venv as (trafficgen) at the start of every line command. ..on Linux:
source .venv/bin/activate
Install the package
uv pip install -e .
Test the install
pytest .
Documentation
For pre-generated package documentation, see https://dnv-opensource.github.io/ship-traffic-generator/
To generate documentation from the source code, use:
uv run docs/make.bat html
The html documentation will then be available in docs/build/html/index.html
Project details
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 trafficgen-0.8.1.tar.gz
.
File metadata
- Download URL: trafficgen-0.8.1.tar.gz
- Upload date:
- Size: 93.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
939c35a5a096e6c8297e27a9170570dde28393c7fa4b938a2cc8f288ed053de1
|
|
MD5 |
f7b57c5a2e11f57529331278e29c3b77
|
|
BLAKE2b-256 |
0bb5295aa1d355ab9908a3302a2c6f2ffe39ca321b0767ac0f15aadf87291f30
|
Provenance
The following attestation bundles were made for trafficgen-0.8.1.tar.gz
:
Publisher:
publish_release.yml
on dnv-opensource/ship-traffic-generator
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1
-
Predicate type:
https://docs.pypi.org/attestations/publish/v1
-
Subject name:
trafficgen-0.8.1.tar.gz
-
Subject digest:
939c35a5a096e6c8297e27a9170570dde28393c7fa4b938a2cc8f288ed053de1
- Sigstore transparency entry: 211360624
- Sigstore integration time:
-
Permalink:
dnv-opensource/ship-traffic-generator@5ea7fbc55b94f7b2589bc4a1b7aecc4676c16833
-
Branch / Tag:
refs/tags/v0.8.1
- Owner: https://github.com/dnv-opensource
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com
-
Runner Environment:
github-hosted
-
Publication workflow:
publish_release.yml@5ea7fbc55b94f7b2589bc4a1b7aecc4676c16833
-
Trigger Event:
push
-
Statement type:
File details
Details for the file trafficgen-0.8.1-py3-none-any.whl
.
File metadata
- Download URL: trafficgen-0.8.1-py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
eb5d9b8fa3790338d7bc90a6681fcd54aa163ed72eaa361b5e7b9f938ea3e3e1
|
|
MD5 |
408a323fd8c07831edbc4935cf2246b8
|
|
BLAKE2b-256 |
78d6fc2e93f048075f40b03373254b01688a212e470a8150932960acd7d8230c
|
Provenance
The following attestation bundles were made for trafficgen-0.8.1-py3-none-any.whl
:
Publisher:
publish_release.yml
on dnv-opensource/ship-traffic-generator
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1
-
Predicate type:
https://docs.pypi.org/attestations/publish/v1
-
Subject name:
trafficgen-0.8.1-py3-none-any.whl
-
Subject digest:
eb5d9b8fa3790338d7bc90a6681fcd54aa163ed72eaa361b5e7b9f938ea3e3e1
- Sigstore transparency entry: 211360626
- Sigstore integration time:
-
Permalink:
dnv-opensource/ship-traffic-generator@5ea7fbc55b94f7b2589bc4a1b7aecc4676c16833
-
Branch / Tag:
refs/tags/v0.8.1
- Owner: https://github.com/dnv-opensource
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com
-
Runner Environment:
github-hosted
-
Publication workflow:
publish_release.yml@5ea7fbc55b94f7b2589bc4a1b7aecc4676c16833
-
Trigger Event:
push
-
Statement type: