← All projects

ReDance · Project lab Human-Centered Neuroengineering: Neurorehabilitation · TUM · Summer 2026 · team of 5

A dance game that helps a stroke patient move

A seated, music-driven rehabilitation game designed around one patient.

A 74-year-old stroke patient with one-sided weakness loves music and dancing but is afraid of falling. Her balance assessment (Berg Balance Scale) showed deficits in trunk flexion, trunk rotation and hip flexion. The exercises had to be safe while seated, motivating without being exhausting, and in simple German.

A lab session of the game on screen.
A lab session: live avatar (left), current step, score and movement bars (centre), instruction video (right).

My contribution

Data path and game logic, in a team of five.

I turned raw IMU data into live movement detection and built the game around it.

Sensor analysis

IMU data logger with live plots, and the analysis that decided which sensor measures which movement.

Live detection

Live movement detection, including turn sensing from the integrated gyro on the upper back, the part that needed the most iterations.

Game and logging

The MuJoCo live mode, calibration breaks with real recalibration, no-punishment game logic, session logging, music and video sync, and the German simple-language UI.

Robustness

On the PC side: handling empty frames from cable or multiplexer outages and waiting for the serial port.

Diagram: four IMUs on an ESP32 stream over USB to a Python app that calibrates, senses turns, classifies five movements, runs the 39-step game, logs each session and drives a MuJoCo avatar and instruction videos.
The game’s data path. Highlighted: what I built — live movement detection, turn sensing, the game logic and the session logger. Firmware: Eraraya Morenzo Muten; avatar model and directional calibration: Maysa Ouaja.

How it works

Four sensors, one calibration, transparent rules.

Every decision the game makes can be explained to a therapist.

Sense

Four ICM-20948 IMUs (lower back, upper back, both thighs) on an ESP32 stream to a Python app over USB serial.

Calibrate

Works for any sensor mounting: a median gravity baseline per sensor and the patient’s own movement directions.

Classify

A transparent rule-based classifier for 5 movements plus neutral, so therapists can explain every decision.

Play and log

A 39-step routine with instruction videos, spoken German rewards, music, a score and a live MuJoCo avatar. Every session is logged for physiotherapist review.

Results, with context

Playable live, with clear next fixes.

All results come from a small evaluation; the notes say what each number covers.

≈ 30 Hz

median live sampling

33 ms between samples. The limit is the 115,200-baud text-based serial link, not the sensors.

637 / 637

detected samples labelled correctly

10 labelled seated recordings from one team member, in-sample. Right turns were never detected offline.

67.5

System Usability Scale

Perceived usability from 0 to 100; 68 is the usual average.

The workload questionnaire showed no time pressure but high effort and frustration, which pointed to straps and recalibration as the next fix.

Four line charts of IMU angles over samples: lumbar tilt rises to about 60 degrees for a forward lean, left and right thigh tilt rise to about 30 and 40 degrees for leg lifts, and the upper-back gyro yaw rate swings positive and negative for turns.
Recorded traces from the physio replay view. Each movement shows on its own sensor: lumbar tilt for leaning, thigh tilt for each leg lift, and the upper-back gyro’s yaw rate for turning, which tilt alone cannot see.

Reflection

Turn detection is still the weakest part.

The game works live, but the evaluation is still small.

Known limits

One subject, in-sample evaluation and no end-to-end latency measurement.

Next steps

More subjects, a magnetometer-based heading estimate and a replay view for physiotherapists.

TeamSimon Appoltshauser, Emily Joyce, Eraraya Morenzo Muten, Maysa Ouaja and Yujie Yang.

Full case study

Project lab Human-Centered Neuroengineering: Neurorehabilitation · TUM · Summer 2026 · team of 5

Turning four IMUs into a game a stroke patient can trust

Designed around one patient: seated, motivating, and explainable to her therapist.

MuJoCo avatar seated on a chair, seen from the side and from the front, with blue blocks marking the sensors on the back and thighs.
The MuJoCo avatar that mirrors the patient live, from the side (a) and the front (b). The blue blocks mark where the IMUs sit. Avatar model: Maysa Ouaja.

Why

Our patient is 74, has one-sided weakness after a stroke, loves music and dancing, and is afraid of falling. Her Berg Balance Scale assessment showed deficits in trunk flexion, trunk rotation and hip flexion, so those three movement families became the core of the routine. Everything had to work seated, in simple German, and without making her feel she had failed.

Calibration that works however the sensors are strapped on

  • Neutral: at least 2 s and 20 frames of sitting still, then a component-wise median of each sensor’s gravity vector, robust to spikes and small movements.
  • Directional: five opening steps (lean forward, lift each leg, turn each way) record the patient’s own movement direction for every sensor.
  • Automatic: the neutral calibration repeats in each of the 16 breaks of a round.
  • Per patient: the therapist sets a threshold for each movement, with left and right kept separate so the weaker side can get an easier target.

The hardest part: detecting a trunk turn

Turning took more iterations than anything else in the project. I built the integrated-angle turn and moved it to the upper-back sensor; the steps:

  • An accelerometer cannot see a rotation about gravity, so turns had to come from the gyroscope, which is relative and noisy.
  • A rate spikes and disappears while the patient still holds the turn, so I integrated rate into angle; drift is held in check by a 3.5 °/s deadband, a ±45° clamp and the recalibration in every break.
  • The lumbar spine barely rotates, while the thoracic spine provides about 65–70 % of rotation, so I moved turn sensing to the upper-back IMU.
  • Lifting a leg causes a yaw spike that reads as a turn, so a turn only counts while every tilt feature is low.
  • Camera mirror view, avatar convention and sensor sign each flipped left and right; we fixed one anatomical convention everywhere (positive turn = right).

A game without punishment

The first version reset progress after a wrong move, which was frustrating. The final routine has 39 steps and 34 scored repetitions (up to 960 points a round), counts a repetition only when the patient moves into a pose and back out again so holding cannot count twice, never takes points away, offers a skip button, and speaks simple German with instruction videos and spoken rewards.

Why 30 Hz and not more

The median live sampling is about 30 Hz (33 ms between samples). The limit is the link, not the sensors: one ASCII frame is about 230 bytes, which takes about 20 ms at 115,200 baud before the I²C reads and a short delay are added. A binary protocol or a higher baud rate is the fix.

Results, with context

  • 637 of 637 detected movement samples were labelled correctly on 10 seated recordings, but these come from one team member and are in-sample, and right turns were never detected offline.
  • System Usability Scale 67.5, just below the usual average of 68.
  • The workload questionnaire showed no time pressure but high effort and frustration, which we traced to straps, harness and recalibration rather than to the game itself.
  • End-to-end latency was not measured; from the parameters, a repetition counts about 150–200 ms after the movement.
Team repository ↗