I'm doing inverse kinematics for 4 dof robot using robotics toolbox matlab. The code is given below:
preach = [0.326 0.223 0.342]; % reach point of end-effector
% create links using D-H parameters
% Link('d', 0.15005, 'a', 0.0203, 'alpha', -pi/2)
L(1) = Link([0 0 0.15 pi/2 0], 'standard');
L(2) = Link([0 0 0.15 0 0], 'standard');
L(3) = Link([0 0 0.15 0 0], 'standard');
L(4) = Link([0 0 0.15 0 0], 'standard');
% set limits for joints
L(1).qlim=[deg2rad(-160) deg2rad(160)];
L(2).qlim=[deg2rad(-45) deg2rad(45)];
L(3).qlim=[deg2rad(-60) deg2rad(60)];
L(4).qlim=[deg2rad(-50) deg2rad(50)];
%build the robot model
rob = SerialLink(L, 'name','rob');
qready = [0 0 0 0]; % initial position of robot
plot(rob,qready,'noname');
T1= transl(preach); % convert of reach point of 4x4 homogenous matrix
[qreach,err] = rob.ikcon(T1, qready); % find inverse kinematics with error
Matlab shows results like this(using robotics toolbox ):
>> [qreach,err] = rob.ikcon(T1, qready)
qreach =
2.7925 0.7854 1.0472 0.8727
err =
9.6055
I'm not taking preach = [0.326 0.223 0.342]; randomly. Infact, first I do forward kinemtics to get these points. code is below:
% to find forward kinemtics
qreadyrr = [0.6 0.45 0.63 0.22]; % setting the four angles randomly within range to get preach
T0 = fkine(rob, qreadyrr);
then, I got T0 as
>> T0
T0 =
0.2208 -0.7953 0.5646 0.3267
0.1510 -0.5441 -0.8253 0.2235
0.9636 0.2675 0.0000 0.3421
0 0 0 1.0000
Also, when I put this T0 in place of T1 in inverse kinematics code as given above, the values I got is very accurate with negligible error.
>> [qreach,err] = rob.ikcon(T0, qready)
qreach =
0.6002 0.4502 0.6296 0.2204
err =
4.6153e-07
The point is, in my case, I have only px, py and pz values for transformation matrix but with this, inverse kinematics is not solving it correctly. I want to do inverse kinematics px, py and pz values. how can I do it correctly.
Thanks.