The leg is a torque-driven two-link planar manipulator (thigh + shank, hinged at hip and knee) — the same rigid-body model used to design real gait-training exoskeletons like the Lokomat. Its equations of motion follow standard robot dynamics:
M(q) q̈ + C(q,q̇) q̇ + G(q) = τ
M11 = m1·lc1² + m2·(l1² + lc2² + 2·l1·lc2·cos θ2) + I1 + I2
M12 = m2·(lc2² + l1·lc2·cos θ2) + I2 , M22 = m2·lc2² + I2
G1 = (m1·lc1 + m2·l1)·g·sinθ1 + m2·lc2·g·sin(θ1+θ2)
G2 = m2·lc2·g·sin(θ1+θ2)
A reference "ghost" trajectory θ_ref(t) approximates the hip/knee flexion pattern of one gait cycle (a sinusoidal hip swing plus the double-hump knee-flexion seen in stance and swing). The robot applies an assist-as-needed PD torque toward that target, scaled by the assistance slider; the simulated patient contributes their own residual torque scaled by (1 − impairment):
τ = [assist·Kp + (1−impair)·Kp_pt]·(θref−θ) + [assist·Kd + (1−impair)·Kd_pt]·(θ̇ref−θ̇)
- Assistance level — robot guidance-force gain; higher values pull the leg tighter onto the reference path (0% = leg swings freely under its own dynamics).
- Patient impairment — how much voluntary torque the simulated patient contributes; low impairment plus low assistance can still track well, high impairment needs the robot's help.
- Cadence — walking speed, sets the reference trajectory's frequency (steps/min).
- Body-weight support — a harness unloads a fraction of body weight (real BWSTT — body-weight-support treadmill training), scaling effective gravity g_eff = g·(1 − BWS) and reducing the torque needed to hold the leg up.
RMS tracking error is the root-mean-square angular deviation of the actual leg from the reference over the last gait cycle — the number a real Lokomat-style controller (and its therapist) watches to titrate how much guidance a patient still needs.