Method to avoid dynamic singularity for flexible manipulators