A GRU model that improves the performance of adaptive oscillators in stop-go and go-stop situations.
Project description
ao_compensation_model
A GRU-based compensation model that improves the performance of adaptive oscillators (AOs) during stop-go and go-stop gait transitions. The model learns the phase error between the AO output and the ground-truth gait phase, and applies a real-time correction on edge devices via TFLite.
Pipeline
| Step | Command | Description |
|---|---|---|
| 1 | prep |
Bandpass-filters raw IMU hip angles, extracts ground-truth gait phase, and computes delta-phi training targets. |
| 2 | train |
Trains a GRU network on sliding windows of AO features and exports an optimized TFLite model. |
| 3 | validate |
Runs frame-by-frame TFLite inference on test data and visualises AO phase vs. enhanced phase vs. ground truth. |
| 4 | txt2csv |
Converts raw sensor text files (tab / comma / semicolon delimited) in a folder to semicolon-delimited CSVs. |
Install
From PyPI:
pip install ao-compensation-model
From source:
git clone https://github.com/lhharry/ao_compensation_model.git
cd ao_compensation_model
uv sync
Usage
CLI
All commands follow the pattern:
uv run python -m ao_compensation_model <command> [options]
Data Preparation
# Prepare ground-truth targets from all raw CSVs
uv run python -m ao_compensation_model prep
# Prepare a single file
uv run python -m ao_compensation_model prep --file 20260304_17_13_22_stopgo.csv
# Prepare with a custom stationary threshold (default: 0.083)
uv run python -m ao_compensation_model prep --file recording.csv --threshold 0.1
Training
uv run python -m ao_compensation_model train
Validation
# Validate all test files
uv run python -m ao_compensation_model validate
# Validate a specific test file
uv run python -m ao_compensation_model validate --file 20260304_14_26_34_4km_stopgo.csv
File Conversion
# Opens a folder picker GUI
uv run python -m ao_compensation_model txt2csv
# Convert a specific folder
uv run python -m ao_compensation_model txt2csv --file /path/to/folder
CLI Flags
| Flag | Applies to | Description |
|---|---|---|
--file |
prep, validate, txt2csv |
prep: single CSV to process. validate: single test CSV. txt2csv: folder path. |
--threshold |
prep |
Amplitude threshold for stationary detection (default: 0.083). |
--log-level |
all | Log level (TRACE, DEBUG, INFO, SUCCESS, WARNING, ERROR, CRITICAL). |
--stderr-level |
all | Stderr log level. |
As a Library
from ao_compensation_model.training import build_gru_model, compute_sample_weights
from ao_compensation_model.utils import bandpass_filter, extract_true_phase
from ao_compensation_model.validation import validate
Development
- Install uv from Astral.
git clone git@github.com:lhharry/ao_compensation_model.gitmake init— create virtual environment and install dependenciesmake format— format code and run type checksmake test— run the test suite with coveragemake clean— delete temporary files and directories
Publishing
Pushing a version tag triggers automatic publishing to PyPI via GitHub Actions (Trusted Publishing):
# Update version in pyproject.toml, then:
git tag v0.1.1
git push origin --tags
Structure
├── src
│ └── ao_compensation_model
│ ├── __init__.py
│ ├── __main__.py
│ ├── app.py
│ ├── definitions.py
│ ├── gt_dataprep.py
│ ├── training.py
│ ├── txt2csv.py
│ ├── utils.py
│ ├── validation.py
│ ├── dataset/
│ └── model/
├── tests
│ ├── __init__.py
│ ├── conftest.py
│ ├── app_test.py
│ ├── gt_dataprep_test.py
│ ├── training_test.py
│ └── utils_test.py
├── .github/workflows/
├── CONTRIBUTING.md
├── Dockerfile
├── LICENSE
├── Makefile
├── README.md
└── pyproject.toml
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
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
File details
Details for the file ao_compensation_model-0.1.3.tar.gz.
File metadata
- Download URL: ao_compensation_model-0.1.3.tar.gz
- Upload date:
- Size: 15.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bdf7b19bebaf0f31a600847fbbbf9c94aa0d23c68eb4ddd473b0aacaf376889a
|
|
| MD5 |
e664ed53cbe448b66bfe1449324ac6d9
|
|
| BLAKE2b-256 |
afcf5a1878065e6e124b724cc55fdff912bb8b6b1ce6847a92035ba01040f2cf
|
Provenance
The following attestation bundles were made for ao_compensation_model-0.1.3.tar.gz:
Publisher:
pypi-publish.yml on lhharry/ao_compensation_model
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ao_compensation_model-0.1.3.tar.gz -
Subject digest:
bdf7b19bebaf0f31a600847fbbbf9c94aa0d23c68eb4ddd473b0aacaf376889a - Sigstore transparency entry: 1049695125
- Sigstore integration time:
-
Permalink:
lhharry/ao_compensation_model@ebeca97682743c8dcbf74540ad983da650b01e04 -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/lhharry
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@ebeca97682743c8dcbf74540ad983da650b01e04 -
Trigger Event:
push
-
Statement type:
File details
Details for the file ao_compensation_model-0.1.3-py3-none-any.whl.
File metadata
- Download URL: ao_compensation_model-0.1.3-py3-none-any.whl
- Upload date:
- Size: 18.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f9c2798fbb4ff435f1cfb4787334c76cf663a5b1234870994ef47bb0f1dbb50f
|
|
| MD5 |
036431bc7db7da2a20e0e5eaa0698309
|
|
| BLAKE2b-256 |
d40e43f8bfd5974621cfb583c8f389e02719adfd2c0ade481d6fc6a880492feb
|
Provenance
The following attestation bundles were made for ao_compensation_model-0.1.3-py3-none-any.whl:
Publisher:
pypi-publish.yml on lhharry/ao_compensation_model
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ao_compensation_model-0.1.3-py3-none-any.whl -
Subject digest:
f9c2798fbb4ff435f1cfb4787334c76cf663a5b1234870994ef47bb0f1dbb50f - Sigstore transparency entry: 1049695128
- Sigstore integration time:
-
Permalink:
lhharry/ao_compensation_model@ebeca97682743c8dcbf74540ad983da650b01e04 -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/lhharry
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@ebeca97682743c8dcbf74540ad983da650b01e04 -
Trigger Event:
push
-
Statement type: