# Robots in LinuxCNC-Singularities

29 Aug 2019 08:58 #143538 by m.bofi
Hey everyone, first a big thanks to the community which has given amazing help to me in order to complete my thesis and a challenging robot configuration in LinuxCNC.

As i was considering my configuration for a Mitsubishi RM501 robotic arm in LinuxCNC some questions arised. Firstly considering how to set elbow up- elbow down configuration and which to choose. The answer came easy by detecting current position and choosing the one closest to it.

The problem I found more challenging is how to deal with singularities. Most commertial controllers detect the jacobian becoming singular (by checking that the determinant getting very small, or the joint speed increment becoming very big and so joint speed rising too fast) and either use psuedo jacobian or just set the joints' speed directly to a certain value(80% of the max joint speed for exampe). In LinuxCNC however what happens?

Jacobian determinant is very taxing to compute every time. So I thought finding singular point in advance. It was a pain but it brought results. So now I know the singularities beforehand and in kinematics file i can check if i'm close to one or not. So my question is this. Can I set the joint speed in a certain value from the kinematics problem for as long as robot is near the singularity? Or do you have in mind another solution?

29 Aug 2019 09:23 #143541
If i remember correctly ( this was 4 years ago ), singularity is the event when a programmed move can be made by moving more than 1 joint, meaning the same move can be achieved by moving say joint 2 or joint 5 so it can not decide which one of them to use.
You should double check that.

29 Aug 2019 09:49 #143543 by m.bofi
What you said is one aspect of it but has many implications that make difficult to control the robot. So, say that i have a pose that my robot looks to the left and i want it to move to a symmetrical pose looking to the right. That would make the robot pass through a singularity area which a vertical cylinder in the central axis of the robot.

I checked the pumakins.c and there are appropriate flags PUMA_SINGULAR to check that the puma is at a singular state. But where is this flag fed to and how LinuxCNC uses it? Thats my main concern because i want to replicate its effect for my own application.

29 Aug 2019 22:10 - 29 Aug 2019 22:10 #143606 by andypugh
As far as I can see PUMA_SINGULAR is added to the *iflags bit array, but is never used to modify the behaviour:

github.com/LinuxCNC/linuxcnc/blob/master...tics/pumakins.c#L132
Last edit: 29 Aug 2019 22:10 by andypugh.

02 Sep 2019 09:50 #143890 by m.bofi
Sorry for late answer, i just returned home and thanks for the reply.This is what i noticed too. Maybe the *iflag array is used somehow? I'm buffled.

02 Sep 2019 11:09 #143892 by andypugh
iflags and fflags are mentioned only in passing in the kinematics docs:
linuxcnc.org/docs/2.8/html/motion/kinematics.html

The flags are just a long int. I think that they exist only as a way to pass info between the functions, there are comments in the code, but the meaning of each bit position is not defined, leading me to believe that the meaning of the flags is not standardised, and so can't be being used outside of a specific kins module.
github.com/LinuxCNC/linuxcnc/blob/master...ics/kinematics.h#L51
The flags are declared in control.c, but it does nothing with the returned values:
github.com/LinuxCNC/linuxcnc/blob/49b095...emc/motion/control.c
Nor does command.c

05 Oct 2019 21:52 #147224 by Roiki
From what I've seen, linuxcnc has no easy way to handle pose selection or singularities. You'd need to develop it yourself. I've come to the conclusion that it's easier to use proper software for code generation and let linuxcnc handle just the motion control on the joint level. That way it shouldnt run into any singularities and you get better control of what you're actually doing.
I'm finding there's really no good solutions for this robots unfortunately.

06 Oct 2019 16:29 #147258 by andypugh
If there is a known-good strategy for a particular robot then there is no reason that it could not be built in to the kinematics module.
Arguably the kinematics module is the _only_ place in LinuxCNC that singularity avoidance can be coded in, as that it the only bit of code with all the required information about the specific robot.