In this paper, robust constraint-following control (RCFC) with the optimal design is developed to handle the trajectory tracking control issues for permanent magnet linear motors, which control performance is deteriorated mainly by friction, ripple force, and external disturbance. Specifically, fuzzy description for the main nonlinearity of the PMLM system and its fuzzy dynamic model is formulated. Then, the tracking specification is modeled as a performance constraint, the RCFC algorithm following the Udwadia-Kalaba theory is designed to comply with this constraint, and possess strong robustness to uncertainties simultaneously. The resulting controller is demonstrated to be uniform bounded and uniform ultimate bounded with Lyapunov analysis. Furthermore, the optimal design issue via a fuzzy approach is investigated to achieve the optimal tradeoff between control effort and system performance. Finally, the rapid control prototype platform CSPACE is employed to implement the real-time control while avoiding the time-consuming repetitive programming and debugging. Simulation and experiment results illustrate the actual effectiveness of the proposed algorithm.