Skip to main content

riskenv

PyPI - Version PyPI - Python Version License: MIT

riskenv computes the Risk Envelope — a convex hull bounding all collision-risk regions around an agent given a set of moving obstacles. It is designed for real-time motion planning in dynamic environments and works in both 2D and 3D spatial contexts across any application domain (autonomous vessels, ground robots, UAVs, etc.).

The Risk Envelope is defined by three filtering criteria (Indices of Interest I1, I2, I3) derived from closest-point-of-approach (CPA) geometry, and is returned as a set of convex hull vertices ready for use in a downstream planner.

Risk Envelope equation

Risk Envelope diagram


Table of Contents

Installation

pip install riskenv

Requires Python ≥ 3.10.

Usage

Minimal example

import math
from riskenv import create_unsafe_set, Agent, Obstacle

agent = Agent(
    position=(10.0, 10.0),   # (x, y) or (x, y, z) in metres
    heading=0.0,              # yaw angle in radians
    speed=15.0,               # m/s
    yaw_rate=0.2,             # rad/s
    safety_radius=5.0,        # metres
)

obstacles = [
    Obstacle(
        position=(30.0, 20.0),
        heading=math.pi,      # facing along -x axis
        speed=20.0,
        yaw_rate=0.1,
        safety_radius=10.0,
        tag='vessel_a',
    ),
]

# dsf: distance safety factor (metres) — the proximity threshold for I1/I2/I3
# time_of_interest: TCPA horizon in seconds for the I3 filter (default 15 s)
# Returns: list of [x, y] hull vertices, or [] if no risk region exists.
vertices = create_unsafe_set(agent=agent, obstacles=obstacles, dsf=10.0)

Quaternion users

Convert to a heading angle before constructing Agent or Obstacle:

from riskenv import heading_from_quaternion

heading = heading_from_quaternion(qx, qy, qz, qw)

Lower-level API

All internal building blocks are importable directly from the top-level package:

from riskenv import (
    calc_cpa,                              # DCPA / TCPA for a single obstacle
    calculate_obstacle_metrics_for_agent,  # annotate all obstacles with CPA metrics
    predict_position,                      # dead-reckoning position at time dt
    calc_I1, calc_I2, calc_I3,            # individual index-of-interest filters
    unionise_indices_of_interest,          # merge I1 / I2 / I3 without duplicates
    gen_uIoI_convhull,                     # convex hull from a union set
    ObstacleWithMetrics,                   # Obstacle + tcpa/dcpa container
)

CPA metric summary

Case v_rel_norm_sq p_rel == [0, 0] tcpa > 0 DCPA TCPA
1.1 Identical position, same velocity < 1e-6 ✅ – NaN inf
1.2 Zero relative velocity, offset < 1e-6 ❌ – ‖p_rel‖ ‖p_rel‖ / ‖v1‖ (or inf)
2.1 Future CPA ≥ 1e-6 – ✅ ‖p_rel + tcpa · v_rel‖ computed tcpa
2.2 CPA in past or at t=0 ≥ 1e-6 – ❌ NaN NaN

Structure

src/riskenv/
├── objects/              — Agent, Obstacle, ObstacleWithMetrics
├── risk_assessment/      — calc_cpa, heading_from_quaternion, calculate_obstacle_metrics_for_agent
├── indices_of_interest/  — calc_I1, calc_I2, calc_I3, unionise_indices_of_interest
├── collision_geometry/   — gen_uIoI_convhull
├── position_prediction/  — predict_position
└── unsafe_set/           — create_unsafe_set (top-level orchestrator)

References

This package implements the Risk Envelope method for motion planning originally described in:

R. McKee, N. Athanasopoulos, W. Naeem, "Geometric Motion Planning in Dynamic Environments" — (citation pending publication)

License

riskenv is distributed under the terms of the MIT license.

Metadata

Release files for riskenv 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for riskenv 1.0.0
File Size Uploaded
riskenv-1.0.0.tar.gz 8.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for riskenv 1.0.0
File Interpreter ABI Platform
riskenv-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 21.8 kB

Release files / riskenv-1.0.0.tar.gz

Download URL riskenv-1.0.0.tar.gz
Size 8.3 kB
Tags Source
SHA-256 checksum
How to use checksums
9c1cb195a221a18569745482c22e749d400f782047d2dc4fa9abd5745882dce3
BLAKE2b-256 checksum
How to use checksums
100df4725de8d7c3aaa3e873d250b03fdda892aff239285e65d951f09a52e1a1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 9, 2026.

Transparency log

Release files / riskenv-1.0.0-py3-none-any.whl

Download URL riskenv-1.0.0-py3-none-any.whl
Size 13.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5b3f62aa474424595ea1150ba8799fafc1a4e4671baaea6f8d70ce5f44a1e427
BLAKE2b-256 checksum
How to use checksums
d0176cf129859dbcf6a80b4fb0fedaa1c9a519d580face72f71edbb4f41bdfae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 9, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page