Examples
Five working applications under examples/, from
single-concept demos to a full research application. This page is the
catalog plus a decision tree to help you pick the right one to copy.
Decision tree — which example should I read?#
Are you new to the framework?
├── YES → start with the atomic examples (one concept each).
│ See [Atomic examples](atomic.md) — 5 single-file demos
│ covering Steps 1, 2, 3, 4, and 6/7 of the
│ implementation guide.
│
└── NO → what does your application look like?
Continuous joint-angle control / antagonist muscle pairs?
└── [Elbow flexion](elbow_flexion.md) — PID control of
biceps + triceps with auto-tuner and PyQt5 GUI.
Haptic / tactile feedback (non-functional EMS)?
└── [Haptic navigation](haptic_navigation.md) — directional
cues via `HapticLibrary`.
Need a GUI scaffold without a real strategy?
└── [Generic GUI](generic_gui.md) — reference PyQt5 template
wired to the framework's `SharedRingBuffer`.
Gait-phase-adaptive walking FES?
└── [Walking FES](walking_fes.md) — the
reference application; complete with ML step detector,
per-leg sliders, real-time biomech plots.Catalog#
Atomic examples#
Five single-file demos under examples/atomic/. Each one is ~80
lines, covers exactly one framework concept, and runs as a
standalone script:
| File | Concept |
|---|---|
minimal_closed_loop.py | First strategy |
reading_sensor_data.py | Reading sensors |
semantic_muscle_control.py | Stimulating muscles |
calibration_gate.py | Calibration gate |
lsl_streaming.py | LSL outlets + inlets |
These are the canonical reference for each step in the Implementation Guide.
Elbow flexion#
A complete PID-controlled FES application for elbow flexion. Uses agonist/antagonist muscle pairs (biceps for flexion, triceps for extension), an FFT-based PID auto-tuner, and a PyQt5 GUI with control sliders and real-time plots.
Read it when you need to do continuous joint-angle tracking — the strategy's structure transfers directly to any one-DOF FES application (knee, ankle, wrist).
File: examples/elbow_flexion/
Haptic navigation#
Demonstrates the HapticLibrary extension point. Arrow keys in a
GUI fire haptic cues on different parts of the wearer's body —
belly, back, shoulders. No closed-loop control logic; this is the
canonical example of using EMS as tactile feedback rather than
functional movement.
Read it when you need custom haptic patterns, named playable slots, or any non-functional use of EMS hardware.
File: examples/haptic_navigation/
Generic GUI#
A reference PyQt5 GUI template using the framework's reusable widget
toolkit (fes_framework.gui.app.FesApp,
fes_framework.gui.data_adapter.DataAdapter, plus tab classes for
overview and sensor data). Comes with a no-op DummyStrategy so you
can see the GUI light up without any real control logic.
Read it when you're starting a new GUI-based application from scratch and want a clean template to copy.
File: examples/generic_gui/
Walking FES#
The full reference application — gait-phase-adaptive walking FES for foot drop / post-stroke gait rehabilitation. Five muscle groups per leg (10 total), gait-phase-adaptive timing, ML step detector, comprehensive PyQt5 GUI with three tabs.
This is the template project. Read it last; it pulls together every framework feature.
File: examples/walking_fes/
How to run any example#
From the repo root, with the Teslasuit connected and Control Center running:
python -m examples.<name>.main
# e.g.
python -m examples.elbow_flexion.main
python -m examples.haptic_navigation.main
python -m examples.generic_gui.main
python -m examples.walking_fes.mainAtomic examples run as direct scripts:
python examples/atomic/minimal_closed_loop.pyPress Ctrl-C to stop. The framework's unconditional cleanup ensures EMS is muted and mocap is stopped before the process exits.
Hardware requirements#
All examples target real Teslasuit hardware. There is no mock /
simulator path. If the suit isn't connected, SuitHandler
construction will fail during engine initialisation. See
Installation for the full
hardware setup.
