Trajectory tracking for permanent magnet synchronous motors