Automatic Physical Law Discovery for Embedded Control Systems.
Discovers interpretable control equations from sensor data using Symbolic Regression, then deploys them as C code on microcontrollers — no neural network required at runtime.
EdgeSense takes raw sensor data and produces a human-readable equation that describes the physical law governing the system. The output is a single C function, ready for STM32 / Arduino / ESP32.
Input: sensor CSV (error, gyro_y, thrust)
Output: C function deployable in under 1 KB flash
From pool_record.csv (real USV motion data), symbolic regression discovered:
thrust_cmd = ((error × −1.019) + gyro_y + 1.337) × 0.271
This is a PD controller — discovered automatically from data, without being told what form the equation should take.
Hall of fame (all candidates, ordered by complexity):
| Complexity | Loss | Equation |
|---|---|---|
| 1 | 0.496 | −0.201 |
| 3 | 0.199 | x1 × 0.274 |
| 5 | 0.159 | (x1 − 0.728) × 0.274 |
| 7 | 0.044 | (x1 + x0 × −0.579) × 0.272 |
| 9 | 0.00069 | (x0 × −1.019 + x1 + 1.337) × 0.271 |
| 11 | 0.00052 | x0 × −0.266 + (x2 + x1 + 0.722) × 0.273 |
Complexity 9 is the recommended deployment equation — lowest loss with minimal operations, no risk of NaN, directly compilable.
Sensor CSV
↓
EdgeSense (Symbolic Regression + NN ensemble)
↓
hall_of_fame.csv ← human-readable candidates
↓
real_physics_model.c ← selected equation as C function
↓
MicroSafe-RL ← runtime safety filter
↓
Actuator
/* GENERATED BY EDGESENSE NANO v2.0 */
float real_physics_model_inference(float x0, float x1, float x2) {
// x0 = error, x1 = gyro_y, x2 = thrust
float azuro_out = (x0 * (-1.0192606f) + x1 + 1.3368257f) * 0.2706757f;
float synergy_force = -0.015f * azuro_out;
return azuro_out + synergy_force;
}Zero heap allocation. No neural network at runtime. Runs in under 1 µs on STM32F401.
from src.edgesense_core import EdgeSenseAnomalyFull
model = EdgeSenseAnomalyFull(input_dim=3)
model.train_model(X, y, epochs=50) # NN + SGD + DecisionTree ensemble
predictions = model.predict(X_new)
model.export_onnx(input_dim=3) # optional ONNX exportSymbolic regression runs via scripts/train_on_real_data.py and outputs
outputs/hall_of_fame.csv with all candidate equations ranked by complexity and loss.
├── src/
│ ├── edgesense_core.py # NN + ensemble training
│ ├── symbolic_reg.py # symbolic regression engine
│ ├── symbolic_from_nn.py # NN → symbolic distillation
│ ├── energy_estimator.py # power / energy accounting
│ ├── anomaly_detector.py # drift and anomaly detection
│ └── onnx_export.py # ONNX export
├── firmware/
│ ├── src/inference.c # C inference engine
│ └── include/model.h
├── MainDemo/
│ ├── MainDemo.ino # Arduino/STM32 full demo
│ ├── MicroSafeRL.h # safety layer (submodule)
│ └── real_symbolic_model.c # generated equation
├── data/
│ └── pool_record.csv # USV pool test data
└── outputs/
└── */hall_of_fame.csv # discovered equations per run
EdgeSense output feeds directly into MicroSafe-RL:
#include "MicroSafeRL_CBF_Grav.h"
MicroSafeRL_CBF_Grav safety;
void loop() {
float cmd = real_physics_model_inference(error, gyro_y, thrust);
float safe_cmd = safety.apply(cmd, sensor);
motor.set(safe_cmd);
}MicroSafe-RL repository: github.com/Kretski/MicroSafe-RL
- Autonomous surface vessels (USV)
- Drone attitude control
- Industrial process control
- Any system where the control law is unknown but sensor data is available
- Zenodo: [doi link]
- arXiv: cs.SY / cs.RO — pending
- Data: pool_record.csv (simulated USV motion — real hardware validation planned, BSHC Varna)
Copyright © 2025 Dimitar Kretski. All rights reserved.
Non-commercial use (research, education, personal projects): Free to use with attribution.
Commercial use: Requires separate license. Contact: kretski1@gmail.com github.com/Kretski
This repository is not MIT-licensed.