cobot-safety
Geometric human safety enforcement for robotic workspaces.
Zero dependencies. Drop into any Python robotics project and get four-layer collision-free path validation in five lines of code.
pip install cobot-safety
What it does
cobot-safety validates robot pick-and-place plans against human safety
zones after any AI or heuristic planner has run. Four independent
mechanisms — no single failure can produce a dangerous path:
| Mechanism | What it checks |
|---|---|
| Point-in-polygon (ray-casting) | No destination lands inside a human zone |
| Path intersection (2D segment math) | No carry path crosses a human zone, even diagonally |
| Occupancy check | No two objects are placed at the same position |
| Safe-area computation | Candidate positions are always generated outside all zones |
Safety is enforced in Python — the AI cannot override it.
Quick start
from cobot_safety import enforce_safety, make_safety_polygon, ROBOT_BASE_ZONE
# Define where humans are (from your camera or sensor)
human_zone = {
"polygon": make_safety_polygon(
{"x_min": 0.5, "y_min": 0.6, "x_max": 0.9, "y_max": 1.0},
margin=0.05,
)
}
# Your plan (from any planner — Gemini, MoveIt, custom A*)
plan = {
"sequence": [
{"step": 1, "object_id": "bottle",
"from": {"x": 0.2, "y": 0.3}, "to": {"x": 0.8, "y": 0.8}},
{"step": 2, "object_id": "cup",
"from": {"x": 0.3, "y": 0.4}, "to": {"x": 0.1, "y": 0.1}},
],
"clusters": [],
}
zones = [ROBOT_BASE_ZONE, human_zone]
plan, relocated = enforce_safety(plan, zones)
for step in plan["sequence"]:
if step.get("skip"):
print(f"Step {step['step']} skipped — no safe path")
else:
print(f"Step {step['step']} → {step['to']}")
Try it
API
enforce_safety(plan, safety_zones, objects=None)
Main enforcement function. Mutates plan["sequence"] in place.
Parameters:
plan— dict with"sequence"(list of step dicts) and optional"clusters"safety_zones— list of zone dicts, each with a"polygon"keyobjects— optional list of{"id": str, "category": str}for cluster-aware relocation
Returns: (plan, relocated) — the mutated plan and the number of steps relocated.
Steps that could not be made safe have step["skip"] = True.
Geometry primitives
from cobot_safety import (
point_in_polygon, # ray-casting test
in_any_zone, # checks against a list of zones
segments_intersect, # p1-p2 vs p3-p4 (tuple args)
path_crosses_any_zone, # straight-line carry path check
)
Zone construction
from cobot_safety import make_safety_polygon
polygon = make_safety_polygon(
{"x_min": 0.3, "y_min": 0.6, "x_max": 0.7, "y_max": 0.9},
margin=0.05, # outward buffer, default 0.05
)
Safe-area helpers
from cobot_safety import compute_safe_area, generate_grid_positions
sx_min, sx_max, sy_min, sy_max = compute_safe_area(safety_zones)
positions = generate_grid_positions(20, sx_min, sx_max, sy_min, sy_max)
Constants
from cobot_safety import (
ROBOT_BASE_ZONE, # default robot base exclusion zone
DEFAULT_MARGIN, # 0.05 — safety polygon buffer
MIN_SPACING, # 0.11 — grid position spacing
OCCUPANCY_THRESHOLD, # 0.08 — minimum distance between objects
)
Coordinate system
All coordinates are normalized to [0, 1]. (0, 0) is the top-left corner
of the workspace, (1, 1) is the bottom-right.
Tunable constants
Override by importing and reassigning before calling enforce_safety:
import cobot_safety.enforce as se
se.MIN_SPACING = 0.15 # wider grid spacing
se.OCCUPANCY_THRESHOLD = 0.10 # larger personal space per object
Part of SafeArc
cobot-safety is extracted from the
SafeArc hackathon project — a
browser-based AI pipeline for human-safe robotic workspace sorting.
License
Apache 2.0 — see LICENSE.
Metadata
Release files for cobot-safety 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cobot_safety-0.1.0.tar.gz | 20.1 kB | Without provenance | Details for cobot_safety-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cobot_safety-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for cobot_safety-0.1.0-py3-none-any.whl |
Total release size: 36.9 kB
Release files / cobot_safety-0.1.0.tar.gz
| Download URL | cobot_safety-0.1.0.tar.gz |
|---|---|
| Size | 20.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
09d363a779d43134eed83de9dc26515efdab230b8455165ebde6eed8d8079d23
|
|
BLAKE2b-256 checksum How to use checksums |
9bb2a43684242d24a71069a4827bdae3e2027b03cdcde7eb5657c5a324977ce5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / cobot_safety-0.1.0-py3-none-any.whl
| Download URL | cobot_safety-0.1.0-py3-none-any.whl |
|---|---|
| Size | 16.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
42579a54d86675ae43e5e496a0338da15ec889a9621979dea4cfc966db2f11c3
|
|
BLAKE2b-256 checksum How to use checksums |
2a40dcd1176e3175f7776f6ce5155add8b9b36a1c513f5c1b8a41d54a2135c10
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Security for cobot-safety 0.1.0
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.