Author: Yixiang Lin, Tiancheng (Gavin) Yang
Affiliation: The University of Melbourne
License: MIT
This repository provides a complete experimental stack for the M2 haptic robot:
- M2 controller (C++): real‑time state machine, perturbation scheduling, preload detection, and CSV logging.
- Unity front‑end: operator UI, countdowns, per‑trial control, and session metadata.
Both components communicate over a simple TCP interface to coordinate trials and persist reproducible data for analysis.
M2Machine/: robot runtime and state machine with phasesCalibState→StandbyState→ProbMoveStateProbMoveStatephases:TO_A→WAIT_START→TRIAL
Unity-Ui/: Unity app that drives sessions, countdowns, and parameter updates
- Deterministic LEFT/UP perturbation scheduling per 10‑trial block
- Preload detection in
WAIT_START(last 200 ms, default threshold 3 N on +X) - Adjustable preload parameters from UI (
S_PLT,S_PLW) - Two scoring modes (V1 count successes, V2 effort‑distance)
- Robust CSV logging (per‑state and per‑trial)
- Explicit STRT‑gated trials for automation and reproducibility
- Launch the M2 controller binary.
- Ensure Unity connects (UI shows link status).
- Begin a prob‑move session: send
BGIN. - Set parameters between trials (in
WAIT_START):S_SID <int>: session/subject ID (64‑bit integer)S_MD <1|2>: scoring mode (1 = V1 count, 2 = V2 effort)S_TS <n>: V1 target successesS_MT <n>: maximum trialsS_PLT <N>: preload threshold in Newtons (default 3.0)S_PLW <s>: preload window in seconds (default 0.200)
- Unity performs a 3‑2‑1 countdown and sends
STRTto start a trial. - Review CSVs in
logs/after runs.
Notes
- Parameter commands are accepted only between trials (
WAIT_START). - STRT is debounced; send only once per trial start.
Commands (UI → M2):
BGIN— enter ProbMove state (start a block)STRT— start a trial (consumed inWAIT_STARTwhen at A)HALT— end ProbMove and return to StandbyRSTA— reset toTO_A(re‑center/hold at A)S_SID <int>— set session/subject IDS_MD <1|2>— set scoring modeS_TS <int>— set target successes (V1)S_MT <int>— set max trialsS_PLT <float>— set preload threshold (N)S_PLW <float>— set preload window (s)
Events/Reports (M2 → UI):
OK/BUSY/ERR ARG— command resultsTRIAL_BEGIN ... preload=0|1 ...— trial start summary with preload tagTREN— trial end summary (time, duration, reached, distance, effort, score, mode, indices)SESS— session summary (mode, V1 success/trials, V2 score/trials)
BGIN→ M2 transitions toTO_A, thenWAIT_START(hold at A).- UI updates parameters (only in
WAIT_START). - UI countdown (3‑2‑1) → send
STRT. - M2 checks last 200 ms preload window (X‑force ≥ threshold), logs tag, enters
TRIAL. - Trial runs with internal LEFT/UP perturbation; on end → back to
WAIT_START. - Repeat until stop condition (target successes/max trials) or
HALT.
Logs are written to logs/ and are session‑scoped when applicable.
M2Machine.csv— global runtime (time, position, velocity, force)M2ProbMove_<session>.csv— per‑tick trial info (pos, vel, internal/user forces, effort, meta)Standby_<session>.csv— sparse samples while idlingPreloadWindow_<session>.csv— raw rows within the last preload window before STRTTrialTags_<session>.csv— per‑trial preload tag and window summary
Tip: Session IDs are included in logs; anonymize before sharing.
- Logs can contain subject/session identifiers and sensor traces.
- Anonymize/redact IDs and comply with local ethics/data policies before external sharing.