Skip to main content

An embedded domain-specific language for spatial sensor fusion and AI

Project description

Spaxiom-DSL

                ███████╗██████╗  █████╗ ██╗  ██╗██╗ ██████╗ ███╗   ███╗
                ██╔════╝██╔══██╗██╔══██╗╚██╗██╔╝██║██╔═══██╗████╗ ████║
                ███████╗██████╔╝███████║ ╚███╔╝ ██║██║   ██║██╔████╔██║
                ╚════██║██╔═══╝ ██╔══██║ ██╔██╗ ██║██║   ██║██║╚██╔╝██║
                ███████║██║     ██║  ██║██╔╝ ██╗██║╚██████╔╝██║ ╚═╝ ██║
                ╚══════╝╚═╝     ╚═╝  ╚═╝╚═╝  ╚═╝╚═╝ ╚═════╝ ╚═╝     ╚═╝
    

PyPI version Spaxiom CI Project Status: Beta

An embedded domain-specific language for spatial sensor fusion, temporal reasoning, and real-time event detection.

     ╔═══════════╗                   ╔═══════════╗
     ║ SENSORS   ║                   ║ DETECTION ║
     ║ ●━━━━━━━━━║═══════════════════║━━━━━━━━━● ║
     ║ ●━━━━━━━━━║═══════════════════║━━━━━━━━━● ║
     ╚═══════════╝                   ╚═══════════╝
           │                               ▲
           ▼                               │
     ╔═══════════╗     ╔═══════════╗     ╔═══════════╗
     ║           ║     ║           ║     ║           ║
     ║  SPATIAL  ║════>║ TEMPORAL  ║════>║   EVENTS  ║
     ║           ║     ║           ║     ║           ║
     ╚═══════════╝     ╚═══════════╝     ╚═══════════╝
    

What is Spaxiom?

Spaxiom is a powerful Domain-Specific Language (DSL) designed for building intelligent systems that work with:

  • Spatial Data: Zones, sensors, and physical spaces
  • Temporal Logic: Time-based conditions and historical analysis
  • Event Processing: Triggering actions based on complex conditions
  • Entity Management: Tracking and querying objects in your system
  • Physical Units: Working with measurements in a type-safe manner

With Spaxiom, you can easily define complex conditions that span across space and time, and connect them to real-world events.

Key Features

  • 🏠 Spatial Zones: Define and work with 2D spatial regions
  • Sensors: Interface with various sensor types and data streams
  • ⏱️ Temporal Logic: Create conditions that must be true for specific durations
  • 🔄 Event Callbacks: Register event handlers triggered by complex conditions
  • 👥 Entity Tracking: Maintain collections of entities with flexible attributes
  • 📏 Physical Units: Work with measurements and conversions seamlessly
  • 🧩 Logical Operators: Combine conditions using intuitive &, |, and ~ operators
  • 📄 YAML Configuration: Define sensors and system setup through YAML files

Installation

pip install spaxiom

Quick Examples

Spatial & Temporal Logic

from spaxiom import Sensor, Zone, Condition, on, within

# Define a zone and sensor
office_zone = Zone(0, 0, 10, 10)
motion_sensor = Sensor("motion1", "motion", (5, 5, 0))

# Create condition based on sensor data
motion_detected = Condition(lambda: motion_sensor.read() > 0.5)

# Make it temporal - must be true for 5 seconds
sustained_motion = within(5.0, motion_detected)

# Register an event handler
@on(sustained_motion)
def alert_sustained_motion():
    print("Motion has been detected for 5 seconds!")

Entity Management

from spaxiom import EntitySet, Entity, exists, on, Condition

# Create a collection of entities
persons = EntitySet("Persons")

# Add entities with attributes
persons.add(Entity(attrs={"type": "person", "confidence": 0.9}))

# Create condition based on entity existence
person_detected = exists(persons, lambda p: p.attrs.get("confidence", 0) > 0.8)

# Register an event handler
@on(person_detected)
def alert_person():
    print("Person detected with high confidence!")

Physical Units

from spaxiom import Quantity

# Create measurements with units
distance = Quantity(10, "m")
time = Quantity(2, "s")

# Automatic unit conversion
speed = distance / time  # 5 m/s

# Convert to different units
speed_kph = speed.to("km/hour")  # 18 km/h

YAML Configuration

from spaxiom import load_sensors_from_yaml, on, Condition, within

# Load sensors from YAML configuration file
sensors = load_sensors_from_yaml("sensors_config.yaml")

# Access sensors by name from the registry
from spaxiom import SensorRegistry
registry = SensorRegistry()
motion_sensor = registry.get("motion_sensor1")

# Create condition based on sensor from config
motion_detected = Condition(lambda: motion_sensor.read() > 0.5)

# Register event handler
@on(motion_detected)
def alert_motion():
    print("Motion detected!")

Example YAML configuration:

sensors:
  - name: motion_sensor1
    type: gpio_digital
    pin: 17
    location: [0, 0, 0]
    pull_up: true
    
  - name: temperature_sensor1
    type: random
    location: [1, 2, 0]
    hz: 5.0

Documentation

Online Documentation

The full documentation is available online at: https://joescanlin.github.io/spaxiom-dsl/

Local Documentation

For local development, you can build and view the documentation using MkDocs:

# Install MkDocs and required extensions
pip install mkdocs-material pymdown-extensions

# Serve the documentation locally
mkdocs serve

# Build the documentation
mkdocs build

The documentation source files are located in the docs/ directory. Some key sections:

Documentation Updates

The documentation is automatically deployed to GitHub Pages when changes are pushed to the main branch. Changes to files in the docs/ directory or to mkdocs.yml will trigger a new build and deployment.

License

MIT

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

spaxiom-0.1.0.tar.gz (64.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

spaxiom-0.1.0-py3-none-any.whl (83.7 kB view details)

Uploaded Python 3

File details

Details for the file spaxiom-0.1.0.tar.gz.

File metadata

  • Download URL: spaxiom-0.1.0.tar.gz
  • Upload date:
  • Size: 64.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for spaxiom-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f291d6a3fb3307502e2bbc4c75671ea123830422c751735df15f10c339531253
MD5 a9fe500786a21b616968888feb3d442d
BLAKE2b-256 27a6eb66aea3a0ceb6da093931ee38ff6f35665c38192a68b449e1158f07de11

See more details on using hashes here.

File details

Details for the file spaxiom-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: spaxiom-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 83.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for spaxiom-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f12359067b5077e8eb507e9245c6675c655f994b312992e45df6bddcd9050eca
MD5 6872167c04ee27a964abbaa9d29a478e
BLAKE2b-256 ec47c95b50969f0533a1aca869d6bef10f0e651e15d939fc231f7119ce0fe35f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page