I refer to topic
where this question was asked already, but not completely answered:
In short, it is the sum of squared error. But it is a bit more complicated than that.
I made some tests with an UR10e in a simulation and got that result:
=== Compare results for QNear1 and QNear2 ===
Result1 for QNear1: [ -108.729756° /-167.715858° /53.28137° /23.502614° /87.616465° /-63.232788° ]
Result2 for QNear2: [ 43.902276° /-87.599227° /83.131068° /-83.608423° /91.688389° /144.144138° ]
Pose for Result1: [ -399.8mm /-621.7mm /949.8mm /-2.1° /-2° /98° ]
Pose for Result2: [ -399.8mm /-621.7mm /949.8mm /-2.1° /-2° /98° ]
Distance btw. poses: [ -0mm /-0mm /-0mm /-0° /-0° /0° ]
===both joint lists (Result1 and Result2) are valid results!===
Distance btw. Result1 and QNear1: [ 0° /-57.715858° /-3.41863° /68.502614° /-2.383535° /0° ]
Distance btw. Result2 and QNear1: [ 0° /22.400773° /26.431068° /-38.608423° /1.688389° /0° ]
Shoulder: Result2 is 35.315085° closer
Ellbow: Result1 is 23.012438° closer
Wrist1: Result2 is 29.894191° closer
Wrist2: Result2 is 0.695146° closer
If Result2 is closer to QNear1, why was it not returned to get_inverse_kin( TargetPos, QNear1)?
from that script (I omit some functions):
def QNearTestShort():
local TargetPose = p[ -0.3998, -0.6217, 0.9498, d2r(-2.1), d2r(-2.0), d2r(98) ]
local QNear1 = [ d2r(0), d2r(-110), d2r(56.7), d2r(-45), d2r(90), d2r(0) ]
local QNear2 = [ d2r(45), d2r(-110), d2r(56.7), d2r(-45), d2r(90), d2r(0) ]
local Result1 = get_inverse_kin( TargetPose, QNear1 )
local Result2 = get_inverse_kin( TargetPose, QNear2 )
local Pose1 = get_forward_kin( Result1 )
local Pose2 = get_forward_kin( Result2 )
Debug( "=== Compare results for QNear1 and QNear2 === " )
Debug( "Result1 for QNear1: " + to_joints_str( Result1 ) )
Debug( "Result2 for QNear2: " + to_joints_str( Result2 ) )
Debug( "Pose for Result1: " + to_pose_str( Pose1 ) )
Debug( "Pose for Result2: " + to_pose_str( Pose2 ) )
Debug( "Distance btw. poses: " + to_pose_str( SubtractPose(Pose1,Pose2) ) )
Debug( "===both joint lists (Result1 and Result2) are valid results!===" )
local Distance1 = SubtractJoint(Result1,QNear1)
local Distance2 = SubtractJoint(Result2,QNear1)
# mask the first and last coordinate away (I was told, if QNear[i]==0 this coordinate will not be used)
Distance1[0] = 0
Distance2[0] = 0
Distance1[5] = 0
Distance2[5] = 0
# check, if Result1 or Result2 is "nearer" to QNear1:
Debug( "Distance btw. Result1 and QNear1: " + to_joints_str( Distance1 ) )
Debug( "Distance btw. Result2 and QNear1: " + to_joints_str( Distance2 ) )
Judge( "Shoulder: ", Distance1[1], Distance2[1] )
Judge( "Ellbow: ", Distance1[2], Distance2[2] )
Judge( "Wrist1: ", Distance1[3], Distance2[3] )
Judge( "Wrist2: ", Distance1[4], Distance2[4] )
Debug( "If Result2 is closer to QNear1, why was it not returned to get_inverse_kin( TargetPos, QNear1)?" )
end
QNearTestShort()
halt
After all it seems to me, that QNear in get_inverse_kin is only usable in special cases, but not in the general case.
Can you give me some more explanation about that? Especially how to use it in a general case reliably?
-Ludwig