TeslasuitDocumentation
Frameworks

Examples

Six working applications under examples/, from single-concept demos to complete applications with a GUI. This page is the catalog plus a decision tree to help you pick the right one to copy.

All examples are in the public repository: github.com/teslasuit/RapidKit/tree/main/examples. Each example folder has its own README with run instructions.


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 cues triggered from the keyboard?
       └── [Haptic navigation](haptic_navigation.md): discrete
           directional cues via `HapticLibrary`.

       Haptic cues driven by direction and distance?
       └── [Haptic proximity radar](haptic_proximity_radar.md):
           a draggable target selects the body zone (direction)
           and the intensity (distance).

       Balance biofeedback from body posture?
       └── [Vestibular training](vestibular_training.md): haptic
           cues on the side of the lean when postural sway leaves
           a stability boundary.

       Need a GUI scaffold without a real strategy?
       └── [Generic GUI](generic_gui.md) — reference PyQt5 template
           wired to the framework's `SharedRingBuffer`.

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:

FileConcept
minimal_closed_loop.pyFirst strategy
reading_sensor_data.pyReading sensors
semantic_muscle_control.pyStimulating muscles
calibration_gate.pyCalibration gate
lsl_streaming.pyLSL outlets + inlets

These are the canonical reference for each step in the Implementation Guide.

Folder: examples/atomic/

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).

Folder: 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.

Folder: examples/haptic_navigation/

Haptic proximity radar#

The continuous analogue of haptic navigation. A draggable target sits on a radar disc around the wearer: its direction selects which body zone fires (neighbouring zones blend on the diagonals) and its distance sets the intensity.

Read it when your cue needs to encode a continuous direction and magnitude rather than discrete on/off events.

Folder: examples/haptic_proximity_radar/

Vestibular training#

A balance rehabilitation concept using haptic biofeedback. Motion capture tracks postural sway in real time; when the trunk leaves a configurable stability boundary, the suit cues the side of the lean. This is a concept, not a clinically validated protocol.

Read it when you need sensor-driven haptic output (no EMS) from motion capture data.

Folder: examples/vestibular_training/

Generic GUI#

A reference PyQt5 GUI template using the framework's reusable widget toolkit (teslasuit_rapidkit.gui.app.FesApp, teslasuit_rapidkit.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.

Folder: examples/generic_gui/


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.haptic_proximity_radar.main
python -m examples.vestibular_training.main
python -m examples.generic_gui.main

The GUI examples need the optional GUI dependencies (pip install -e ".[gui]").

Atomic examples run as direct scripts:

python examples/atomic/minimal_closed_loop.py

Press Ctrl-C to stop. The framework's unconditional cleanup ensures EMS is muted and mocap is stopped before the process exits.


Hardware requirements#

ExampleHardware
AtomicTeslasuit connected and powered on
Elbow flexionTeslasuit 4.x or XR5, seated subject
Haptic navigationTeslasuit 4.x or XR5, on the same WiFi network as the host
Haptic proximity radarTeslasuit 4R
Vestibular trainingTeslasuit 4.x or XR5
Generic GUITeslasuit optional (plots stay empty without one)

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.