IK errors

Hi,

if ForearmLength == ArmLength all works
but if not i got some error (the biger the difference the bigger the error).
(for some software to control servo device using ssc32 or others serial controler)

In the picture the arm should touch the mouse at all times(using IK to get angle and then FK to get the points and draw the arm.)

Im using this ik code

[code]
public void SetXYZ(double XVal, double YVal, double ZVal, double WristTableVal)
{
//Inverse Kinematic Tcp to axis.

		double ShoulderLength = RLArm.BaseRadius;
		double ShoulderHeight = RLArm.TableHeight + RLArm.BaseHeight;
		
		double FingersLength = Math.Sqrt(Math.Pow(XVal, 2) + Math.Pow(ZVal, 2));
		
		double WristHeight = YVal - Math.Sin(Radians(WristTableVal)) * RLArm.HandLength;
		double WristLength = FingersLength - Math.Cos(Radians(WristTableVal)) * RLArm.HandLength;
		
		double SEWOpening = Math.Sqrt(Math.Pow(WristHeight - ShoulderHeight, 2) + Math.Pow(WristLength - ShoulderLength, 2));
		double SEWOpeningPercent = SEWOpening / (RLArm.ForearmLength + RLArm.ArmLength);
		
		double BasePosition = Degrees(Math.Atan2(ZVal, XVal));
		double ElbowPosition = Degrees(Math.Acos((Math.Pow(RLArm.ForearmLength, 2) + Math.Pow(RLArm.ArmLength, 2) - Math.Pow(SEWOpening, 2)) / (2 * RLArm.ForearmLength * RLArm.ArmLength))) - RLArm.ShoulderNeutralAngle;
		double ShoulderPosition = RLArm.ShoulderNeutralAngle - Degrees(Math.Atan2(WristLength - ShoulderLength, WristHeight - ShoulderHeight) +
		                                                               Math.Acos((Math.Pow(RLArm.ForearmLength, 2) - Math.Pow(RLArm.ArmLength, 2) + Math.Pow(SEWOpening, 2)) / (2 * RLArm.ForearmLength * SEWOpening))) - ElbowPosition;
		double WristPosition = WristTableVal - (ShoulderPosition + ElbowPosition + RLArm.ShoulderNeutralAngle + RLArm.ElbowNeutralAngle + RLArm.WristNeutralAngle);
		
		
		Console.WriteLine("IK Base: {0}, Elbow: {1}, Shoulder:{2}, Wrist: {3}, X: {4}, Y:{5}, Z:{6}, WristTable: {7}",
		                  BasePosition, ElbowPosition,
		                  ShoulderPosition, WristPosition,
		                  XVal, YVal, ZVal, WristTableVal);
		
		//TODO log out of range to console
		if(SEWOpeningPercent > 1)
			return;
		
		try {
			//Use local so to not trigger update too many times.
			this.ax_Base.Position = BasePosition;
			this.ax_Elbow.Position = ElbowPosition;
			this.ax_Shoulder.Position = ShoulderPosition;
			this.ax_Wrist.Position = WristPosition;
		} catch (ArgumentOutOfRangeException) {
			//TODO log out of range to console
			Console.WriteLine("IK Out of range");
		}
	}[/code]

Also it seams that lynxmotion.com/images/html/proj073.htm is also affected by this.

Change “arm Length” or “Forearm Length” then the 2 graph will show different result.

I can’t understand why this is happening ???

I have no earthly idea why you are seeing that problem nor how to fix it for you. But we have been using these formulas in our programs without issue. Our arms do not have the same length for the two segments.

This is the problem, for the IK code to work they need to be equal, but in the current situation they are not and for this the current IK code doesn’t work. Also it is the same for the example from this website, when loaded in excel the defaults values are the same but as soon as you change one of them the forward and reverse kinematic show different result. Right now we use a basic Lynxmotion arm to test our setup. But in the future it will be upgraded to serial servo with 0.6 degrees precision and we cant have any error sneaking in with the IK calculation as the 0.6 degrees will be limit in our allowed tolerance.

Still looking for a solution to this problem.

I used the document from Mike Keesling to derive the IK formulas for my programs and I don’t have this segment length problem that you seem to be having here. With these formulas the segments DO NOT have to be equal at all and it will still function correctly.

Try looking here: lynxmotion.com/images/html/proj057.htm

Thanks. That did solve my problem. Even if i would have liked to understand why it didn’t work.