EDON CAV Engine Python SDK
Project description
EDON Python SDK
Product-ready Python SDK for the EDON CAV Engine.
Installation
# Basic installation (REST only)
pip install -e sdk/python
# With gRPC support
pip install -e "sdk/python[grpc]"
# Future: Install from PyPI
pip install edon[grpc]
Quick Start
from edon import EdonClient, TransportType
# REST transport (default, uses EDON_BASE_URL env var)
client = EdonClient()
# Or explicitly
client = EdonClient(
base_url="http://127.0.0.1:8001",
transport=TransportType.REST
)
# Create sensor window (240 samples per signal)
window = {
"EDA": [0.1] * 240, # Electrodermal activity
"TEMP": [36.5] * 240, # Temperature
"BVP": [0.5] * 240, # Blood volume pulse
"ACC_x": [0.0] * 240, # Accelerometer X
"ACC_y": [0.0] * 240, # Accelerometer Y
"ACC_z": [1.0] * 240, # Accelerometer Z
"temp_c": 22.0, # Environmental temperature (°C)
"humidity": 50.0, # Humidity (%)
"aqi": 35, # Air Quality Index
"local_hour": 14, # Local hour [0-23]
}
# Compute CAV
result = client.cav(window)
print(f"State: {result['state']}")
print(f"CAV: {result['cav_smooth']}")
print(f"P-Stress: {result['parts']['p_stress']:.3f}")
# Classify state (convenience method)
state = client.classify(window)
print(f"State: {state}")
Robot Integration Example
from edon import EdonClient
import time
client = EdonClient()
while True:
# Collect sensor data (4 seconds = 240 samples)
window = build_window_from_robot_sensors()
# Get EDON state
result = client.cav(window)
state = result['state']
p_stress = result['parts']['p_stress']
# Map to control scales
if state == "restorative":
speed, torque, safety = 0.7, 0.7, 0.95
elif state == "balanced":
speed, torque, safety = 1.0, 1.0, 0.85
elif state == "focus":
speed, torque, safety = 1.2, 1.1, 0.8
elif state == "overload":
speed, torque, safety = 0.4, 0.4, 1.0
# Apply to robot controllers
apply_scales_to_controllers(speed, torque, safety)
time.sleep(4.0) # Wait for next window
gRPC Transport
from edon import EdonClient, TransportType
# gRPC transport
client = EdonClient(
transport=TransportType.GRPC,
grpc_host="localhost",
grpc_port=50051
)
result = client.cav(window)
# Control scales included in gRPC response
if 'controls' in result:
print(f"Speed: {result['controls']['speed']:.2f}")
print(f"Torque: {result['controls']['torque']:.2f}")
print(f"Safety: {result['controls']['safety']:.2f}")
# Streaming (server push)
for update in client.stream(window):
print(f"State: {update['state']}, CAV: {update['cav_smooth']}")
# Process update...
client.close() # Close gRPC channel
API Reference
EdonClient
Methods:
cav(window)- Compute CAV from sensor windowcav_batch(windows)- Batch CAV computation (REST only, 1-5 windows)classify(window)- Classify state (convenience method)stream(window)- Stream CAV updates (gRPC only)health()- Check service healthclose()- Close connections (gRPC only)
Parameters:
base_url- REST API base URL (default: fromEDON_BASE_URLenv var)api_key- API token (default: fromEDON_API_TOKENenv var)transport-TransportType.RESTorTransportType.GRPCgrpc_host- gRPC server host (default: "localhost")grpc_port- gRPC server port (default: 50051)
Environment Variables
EDON_BASE_URL- Base URL for REST API (default: http://127.0.0.1:8000)EDON_API_TOKEN- API token for authentication (optional)
Examples
See examples/python/ and clients/robot_example.py for complete examples.
API Contract
See docs/OEM_API_CONTRACT.md for exact request/response schemas and versioning policy.
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
edon-2.0.0.tar.gz
(18.8 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
edon-2.0.0-py3-none-any.whl
(20.0 kB
view details)
File details
Details for the file edon-2.0.0.tar.gz.
File metadata
- Download URL: edon-2.0.0.tar.gz
- Upload date:
- Size: 18.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0864fa2b7cc5e8204f62e51edb37153f499a77decfae98fdb8b5feb65e75da82
|
|
| MD5 |
c4726837084e8411556ee23e788b9137
|
|
| BLAKE2b-256 |
3ebbe2da71cd7de0a6bbb457d47a3e66bb3a781a03b6cc3ca1062d5989bbee9a
|
File details
Details for the file edon-2.0.0-py3-none-any.whl.
File metadata
- Download URL: edon-2.0.0-py3-none-any.whl
- Upload date:
- Size: 20.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9acf65ca1e77a1f379aa28f35bd8235cea36bc86b195052005f9931413c718b3
|
|
| MD5 |
af9fc1ba65161a9b88c49624cec18d9d
|
|
| BLAKE2b-256 |
f30b503e13cb17819a824c52ac346684090a1313d333d3d39e9811f11ae922b8
|