Smart changes of the end-effector orientation for the automatic handling of singular configurations