Learning singularity avoidance from constrained motion