Off position robot model - Inverse Kinematics

I had to make a Unity3D robot model(ABB IRB 1600-6R/6DOF), that given a desired end effector transformation matrix, it would calculate and rotate the robot joints to the appropriate angles(Inverse Kinematics Computation). I found some code in Robotics Toolbox for MATLAB that, lets say that you trust me, actually calculates the needed angles(its the general "offset" case in ikine6s.m) - but for a different zero angle position than my chosen one, which is corrected using the appropriate offsets.

So, I have set my 3D robot model in Unity3D correctly, angles are correct, I give the same parameters in Robotics Toolbox in MATLAB and the results are the same, I plot the robot stance in MATLAB to see it-it's on position-, I then run the code in Unity3D and the robot model seems to move to the stance I saw in MATLAB but it is off position- the end effector is away from its desired position.

Am I missing something?

The scaling is correct. I have subtracted a translation (equal to the distance of the bottom of the model's base contact to the floor, to the start of the next link- as MATLAB doesnt calculate it) from the Y component of the desired position of the end effector(in its homogenous transformation matrix I use as the rotation part, the identity matrix, so we do not care about that part). Here are some pictures showing my case(say Px, Py, Pz is my desired EE position):

MATLAB-This is the plot of the results of the MATLAB ikine6s with input Px, Py, Pz in the corresponding translation part of the desired homogenous transform matrix: Unity3D-This is what I get for the same input and angles in Unity3D-the EE is off position(should be half inside white sphere): • Well i guess its those axes... – hey Sep 6 '16 at 17:53
• What changes do I need? – hey Sep 6 '16 at 17:54

Is is hard to make out from the perspectives that you have included, but is seems that the matlap screenshot has a rotation of approx 45 degrees around the global z axis. Taking a look at the grid in the unitz screenshot it seems that the robot has also a 45 degree angle with the global vertical axes (y axis).

I would suggest the following:

• Check if the units match. Matlab uses radians while unity in most cases uses degrees for rotation

• Check succession of children and parent game object in unity. Make sure that the root coordinate system is the one you think it is and that each linkage is the child of the previous one.

• make sure that the coordinate systems where each linkage meets the next one un Unity corresponds to the Matlab one. This might be tricky, due to different coordinate systems. In Unity each game object has its own coordinate system. There are no rules on how these are oriented and they might be left or right handed. The coordinate system in Matlab is left handed and it is oriented according to the DH convention. Make sure that the coordinate system at the joints in Unity are the same as in Matlab or the joint angles are correctly transformed.

• make sure that both system use the same handed coordinate systems, adjust if not

• lookup which Denavit Hartenberg convention is used in Matlab (proximal, distal, modified, classic) and follow that in Unity

If everything else fails (or you just do not want to bother with coordinate systems) and it is not important to squeeze out every bit of performance in Unity, you can use the built-in Inverse Kinematics in Unity.

UPDATE: build-in un Unity seems to only support humanoid models. Look in the assets tore for a free on which supports serial structures.

Troubleshooting: Take the a MAtlab forward model. Get the position and orientation of each joint coordinate system in the global frame. Draw these in Unity in a global frame. See which is the first one which is not located at its corresponding joint. Fix then go forward until the last one is in place (at the EE).

• -isn't proximal/modifies and distal/classic reffering to the same convention? That's what I thought I don't know or stumbled across any other. -i had already double-checked dots 1,2 and 5 but explain dot 3 as I dont get what you exactly mean. As it goes for dot 4 I noticed, some time after I uploaded the question, that Unity uses a different coordinate system than MATLAB, so I changed the input in Unity (lets say MATLAB's is Px,Py,Pz) to Px,Pz,Py but I think I may leave out a minus sign, is it correct as it is? Or should it be Px,Pz,-Py ot sth else I miss. I have tried both. – hey Sep 8 '16 at 2:07
• The EE is still off position, but I think the first suggestion is closer to the actual desired EE position. Is there something else I should change? -I searched many of the scripts available in the Asset Store, but couldn't make out how to use them, so I decided to write my own. -And lastly, this is a very nice answer, it may help the most with the same question so I'll accept it, but try to help me a bit more to solve mine. – hey Sep 8 '16 at 2:14
• I think you need the minus in the CS transformation but I am not completly sure. as for point 3 see the update of the post. I also added a troubleshooting method which may help – 50k4 Sep 9 '16 at 20:40
• To my knowledge, there are are 3 DH paramter sets form the 4 above just 2 are the same not 2-2. I might be wrong, chck out this paper: proceedings.asmedigitalcollection.asme.org/… – 50k4 Sep 9 '16 at 20:49
• I updated the answer explaining point 3 better and with an added troubleshooting method. – 50k4 Sep 9 '16 at 20:50