Avoid redundancy "crossroads"

When J6 is aligned with J2,3,4 (or in a similar redundant configuration) and movel(joint_positions) or movec(joint_positions) are used, it can happen that the path choesen by the controller is the less intuitive, i.e. the one which causes a collision of the wrist with the robot itself.

How can I avoid this behavior?

I’d like not to use movej because I need to follow linear movements in the cartesian space.

Alessandro Tondo @qbrobotics

When Wrist 3 and 1 are parallel, the robot is in a singularity situation, hence linear motions are not very practical.
In this specific situation, a Tool Z motion is impossible.

Another singularity would be if the tool flange is directly above or below the Base joint cylinder.

I would suggest avoiding linear moves in this space.
Potentially having a rotational X/Y offset on the TCP could decrease this behavior, or in some situations the Base mounting can be altered.

Thank you Jacob for the reply, but I do not think the problem I described happens in singular configuration.

I believe that it is the exact oppose situtation, where the inverse kinematics produces two possible joint configurations. In such a case I would like the robot to move following the shorter joint path, but it seems not always to be the case.

I notice this behavior when I moved the robot back in a configuration stored earlier from a manual placement (freedrive mode). It can happen for example when J6 is nearly aligned with J2, J3 and J4 because you can reach the same pose in a smaller operative space (i.e. not everywhere) in at least 2 joint configurations.

Numerically, it happens that starting with J4 = 90 deg and moving to a pose where J4 should remain nearly the same, it becomes J4 = 270 deg (or -90 deg) with accordingly changes in J2, J3 and J6.