A 4-degree-of-freedom powered exercise and/or rehabilitation machine has been designed for studies in physical human-machine interaction. The machine, called CSU 4OptimX, is fitted with 4-axis motion and force sensors and a robust impedance control system. A visualization system is used to provide motion reference paths for the human to follow. The control system uses real-time optimization to generate human motion reference paths, machine reference paths and a set of impedance parameters for each axis.