Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
8a0e05a
Fixed bug #68, target ships within one situation now have different i…
tomarnepedersen Sep 22, 2025
94cfbd3
While working on #68, some warnings was issued. Fix it.
tomarnepedersen Sep 22, 2025
eae08a1
#68, updated changelog
tomarnepedersen Sep 22, 2025
1d281e5
add documentation on output files (new page), add links to maritime s…
StephanieKemna Sep 23, 2025
ee3f83d
Merge pull request #72 from dnv-opensource/71-add-example-output-to-d…
StephanieKemna Sep 23, 2025
2da99f8
#68 Fixing comment from reviewer. Updated generated files.
tomarnepedersen Sep 24, 2025
7692fd6
Merge branch 'dev' into 68-ts-id-numbers-are-same-in-output-situation…
tomarnepedersen Sep 24, 2025
63b31c2
Merge pull request #69 from dnv-opensource/68-ts-id-numbers-are-same-…
tomarnepedersen Sep 24, 2025
d257dab
Updated before release
tomarnepedersen Sep 24, 2025
af6f7f8
Update docs/source/output_files.rst
StephanieKemna Oct 3, 2025
d543e0f
Update docs/source/output_files.rst
StephanieKemna Oct 3, 2025
2e27f85
clarify that an output folder needs to be specified in order for file…
StephanieKemna Oct 3, 2025
5c0745b
reference source MSS
StephanieKemna Oct 3, 2025
955815d
markdownlint; add newlines, add example PR test procedure
StephanieKemna Oct 3, 2025
615a733
Merge branch 'dev' of github.com:dnv-opensource/ship-traffic-generato…
StephanieKemna Oct 3, 2025
1f11358
fix ruff complaint that I caused, and edit printout because you could…
StephanieKemna Oct 3, 2025
05f9a1d
Updated doc file and changelog
tomarnepedersen Oct 3, 2025
47d609a
updates after running ruff and pyright
tomarnepedersen Oct 3, 2025
86a0158
Updated text
tomarnepedersen Oct 3, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,15 @@ The changelog format is based on [Keep a Changelog](https://keepachangelog.com/e

## [Unreleased]

## [0.8.2] - 2025-10-03
* [bug] fixed bug that all target ships had id = 10.
* [bug] fixed duplicate -v parameter warning.
* If own ship ID is not given in own_ship.json file, then ID is set to 1. Target ship IDs will follow from own ship ID.
* Better documentation of output files, added links to maritime schema, and improved navigation between related sections.
* Updated documentaion of target ships in input_files.rst

## [0.8.1] - 2025-05-12
* Changed first assert in test_basic_cli() from 0 to 2.
* Changed first assert in test_basic_cli() from 0 to 2.

## [0.8.0] - 2025-05-09

Expand Down
6 changes: 3 additions & 3 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ authors:
email: Minos.Hemrich@dnv.com
affiliation: DNV
testers:
- given-names: Grunde
family-names: Løvoll
- given-names: Melih
family-names: Akdag
affiliation: DNV
- given-names: Stephanie
family-names: Kemna
Expand All @@ -36,4 +36,4 @@ keywords:
- Systematic assessment
license: MIT
url: 'https://github.com/dnv-opensource/ship-traffic-generator'
version: 0.7.2
version: 0.8.2
50 changes: 50 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# 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.
Expand All @@ -10,12 +11,15 @@ For package documentation, see [https://dnv-opensource.github.io/ship-traffic-ge
## Installation

To install Ship Traffic Generator, run this command in your terminal:

```sh
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:

```sh
uv run trafficgen --help
```
Expand All @@ -35,52 +39,68 @@ For further explanations, see the [documentation pages](https://dnv-opensource.g
This project uses `uv` as package manager.
If you haven't already, install [uv](https://docs.astral.sh/uv), preferably using it's ["Standalone installer"](https://docs.astral.sh/uv/getting-started/installation/#__tabbed_1_2) method: <br>
..on Windows:

```sh
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
```

..on MacOS and Linux:

```sh
curl -LsSf https://astral.sh/uv/install.sh | sh
```

(see [docs.astral.sh/uv](https://docs.astral.sh/uv/getting-started/installation/) for all / alternative installation methods.)

Once installed, you can update `uv` to its latest version, anytime, by running:

```sh
uv self update
```

### Install Python

The traffic generator requires Python 3.11 or later. <br>

If you don't already have a compatible version installed on your machine, you way install Python through `uv`:

```sh
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`:

```sh
winget install --id Python.Python
```

or you can download and install Python from the [python.org](https://www.python.org/downloads/) website.

### Clone the repository

Clone the traffig generator repository into your local development directory:

```sh
git clone https://github.com/dnv-opensource/ship-traffic-generator path/to/your/dir/ship-traffic-generator
```

Change into the project directory after cloning:

```sh
cd ship-traffic-generator
```

### Install dependencies

Run `uv sync -U` to create a virtual environment and install all project dependencies into it:

```sh
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.
Expand All @@ -90,8 +110,10 @@ uv sync -U
> `uv 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. <br>
`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:

```sh
uv run <command>
```
Expand All @@ -100,11 +122,15 @@ 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: <br>
..on Windows:

```sh
.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:

```sh
source .venv/bin/activate
```
Expand All @@ -126,7 +152,31 @@ pytest .
For pre-generated package documentation, see [https://dnv-opensource.github.io/ship-traffic-generator/](https://dnv-opensource.github.io/ship-traffic-generator/)

To generate documentation from the source code, use:

```sh
uv run docs/make.bat html
```

The html documentation will then be available in `docs/build/html/index.html`

### Testing PRs

1. Check out the PR branch

1. Update dependencies, re-install latest package, and run tests (ensure all pass):

```sh
.venv\Scripts\activate.bat
uv self update
uv sync -U
uv pip install -e .
pytest .
```

1. Run any additional tests you want / care about / related to PR topic, e.g.:

```sh
trafficgen gen-situation -o test_output
```

and make edits to config or change this command to test new functionalities.
20 changes: 10 additions & 10 deletions data/baseline_situations_generated/traffic_situation_01.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.6.0",
"version": "0.8.2",
"title": "HO",
"description": "A head on situation with one target ship.",
"ownShip": {
Expand Down Expand Up @@ -28,7 +28,7 @@
}
],
"static": {
"id": 0,
"id": 1,
"mmsi": 257847600,
"name": "BASTO VI",
"dimensions": {
Expand Down Expand Up @@ -70,16 +70,16 @@
}
],
"static": {
"id": 10,
"id": 2,
"name": "target_ship_1",
"dimensions": {
"length": 122.0,
"width": 20.0,
"height": 8.0,
"a": 61.0,
"b": 61.0,
"c": 10.0,
"d": 10.0
"length": 178.0,
"width": 30.0,
"height": 30.0,
"a": 89.0,
"b": 89.0,
"c": 15.0,
"d": 15.0
},
"shipType": "Passenger"
}
Expand Down
6 changes: 3 additions & 3 deletions data/baseline_situations_generated/traffic_situation_02.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.6.0",
"version": "0.8.2",
"title": "CR-GW",
"description": "A crossing situation with one target ship. Own ship is give-way.",
"ownShip": {
Expand Down Expand Up @@ -28,7 +28,7 @@
}
],
"static": {
"id": 0,
"id": 1,
"mmsi": 257847600,
"name": "BASTO VI",
"dimensions": {
Expand Down Expand Up @@ -70,7 +70,7 @@
}
],
"static": {
"id": 10,
"id": 2,
"name": "target_ship_1",
"dimensions": {
"length": 122.0,
Expand Down
6 changes: 3 additions & 3 deletions data/baseline_situations_generated/traffic_situation_03.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.6.0",
"version": "0.8.2",
"title": "CR-SO",
"description": "A crossing situation with one target ship. Own ship is stand-on.",
"ownShip": {
Expand Down Expand Up @@ -28,7 +28,7 @@
}
],
"static": {
"id": 0,
"id": 1,
"mmsi": 257847600,
"name": "BASTO VI",
"dimensions": {
Expand Down Expand Up @@ -70,7 +70,7 @@
}
],
"static": {
"id": 10,
"id": 2,
"name": "target_ship_1",
"dimensions": {
"length": 50.0,
Expand Down
20 changes: 10 additions & 10 deletions data/baseline_situations_generated/traffic_situation_04.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.6.0",
"version": "0.8.2",
"title": "OT-GW",
"description": "A overting situation with one target ship. Own ship is give-way.",
"ownShip": {
Expand Down Expand Up @@ -28,7 +28,7 @@
}
],
"static": {
"id": 0,
"id": 1,
"mmsi": 257847600,
"name": "BASTO VI",
"dimensions": {
Expand Down Expand Up @@ -70,16 +70,16 @@
}
],
"static": {
"id": 10,
"id": 2,
"name": "target_ship_1",
"dimensions": {
"length": 178.0,
"width": 30.0,
"height": 30.0,
"a": 89.0,
"b": 89.0,
"c": 15.0,
"d": 15.0
"length": 122.0,
"width": 20.0,
"height": 8.0,
"a": 61.0,
"b": 61.0,
"c": 10.0,
"d": 10.0
},
"shipType": "Passenger"
}
Expand Down
38 changes: 19 additions & 19 deletions data/baseline_situations_generated/traffic_situation_05.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.6.0",
"version": "0.8.2",
"title": "OT-SO",
"description": "A overtaking situation with one target ship. Own ship is stand-on.",
"ownShip": {
Expand Down Expand Up @@ -28,7 +28,7 @@
}
],
"static": {
"id": 0,
"id": 1,
"mmsi": 257847600,
"name": "BASTO VI",
"dimensions": {
Expand All @@ -47,41 +47,41 @@
{
"initial": {
"position": {
"lon": 10.47731353,
"lat": 58.73759413
"lon": 10.47473875,
"lat": 58.73258475
},
"sog": 15.0,
"cog": 5.04,
"heading": 5.04,
"sog": 15.9,
"cog": 5.67,
"heading": 5.67,
"navStatus": "Under way using engine"
},
"waypoints": [
{
"position": {
"lon": 10.47731353,
"lat": 58.73759413
"lon": 10.47473875,
"lat": 58.73258475
}
},
{
"position": {
"lon": 10.4983629,
"lat": 58.86153921
"lon": 10.49994834,
"lat": 58.86444213
}
}
],
"static": {
"id": 10,
"id": 2,
"name": "target_ship_1",
"dimensions": {
"length": 50.0,
"width": 10.0,
"length": 122.0,
"width": 20.0,
"height": 8.0,
"a": 25.0,
"b": 25.0,
"c": 5.0,
"d": 5.0
"a": 61.0,
"b": 61.0,
"c": 10.0,
"d": 10.0
},
"shipType": "Cargo"
"shipType": "Passenger"
}
}
]
Expand Down
Loading
Loading