problems using ikine..

3,586 views
Skip to first unread message

Tehseen Akhtar

unread,
Mar 13, 2013, 4:01:38 AM3/13/13
to robotics...@googlegroups.com
Hi peter..
i just started using the robotics toolbox and found it very interesting and also very helping in my teaching..
i was trying to go through some examples in order to get a smooth start with the forward and inverse kinematics of simple manipulation..
..
but i am having some problems with the ikine command..
in the first example given below i receive the following error message:

%%%Error Message%%%
??? Index exceeds matrix dimensions.

Error in ==> SerialLink.ikine at 137
    J0 = J0(m, m);

Error in ==> Fkine at 39
QF = ThreeLink.ikine(TL, Q0, [1 1 0 0 0 1]);
%%%%%%%%%%%%% 

%%%%Start of code%%%%%
%%% First we clean the workspace
clc;
clear;
%%% QUESTION 1:
a1 = sym('a1');
l1 = sym('l1');
a2 = sym('a2');
l2 = sym('l2');
a3 = sym('a3');
l3 = sym('l3');
T01 = trotz(a1)*transl(l1, 0, 0);
T12 = trotz(a2)*transl(l2, 0, 0);
T23 = trotz(a3)*transl(l3, 0, 0);
%%% QUESTION 2:
T03 = T01*T12*T23;
%%% Alternatively, we could also solve the forward kinematics for
%%% this robot using its D-H parameters. Then, ssuming a_i=1
L(1) = Link([0 0 1 0]);
L(2) = Link([0 0 1 0]);
L(3) = Link([0 0 1 0]);
ThreeLink = SerialLink(L);
ThreeLink.name = 'Planar3R';
%%% To verify that we have correctly built the robot, we can plot it
ThreeLink.plot([pi/4 pi/4 pi/4]);
%%% Now, the forward kinematics can be solved using the
%%% fkine function. For example:
ThreeLink.fkine([pi/4 pi/4 pi/4]);
%%% QUESTION 3:
%%%
%%% The problem consist in solving the inverse kinematics of this
%%% robot for the following configuration:
TL = [-1 0 0 0 ; 0 -1 0 1; 0 0 1 0; 0 0 0 1];
%%% One possibility consists in using the numerical method
%%% implemented by ikine. The problem is to give a good guess so that
%%% the algorithm converges to a valid solution. After some trial and
%%% error a good starting point is theta_1=0, theta_2=pi, and
%%% theta_3=pi
Q0 = [0 -pi/2 pi/2];
QF = ThreeLink.ikine(TL, Q0, [1 1 0 0 0 1]);
ThreeLink.plot(QF);

%%%%End%%%

Peter Corke

unread,
Mar 14, 2013, 1:02:13 AM3/14/13
to robotics...@googlegroups.com
This is a recently introduced bug, change that line to

 J0 = J0(m, :);

Tehseen Akhtar

unread,
Mar 14, 2013, 2:32:03 AM3/14/13
to robotics...@googlegroups.com
Thank you very much sir..
The problem is solved..

Regards


--
You received this message because you are subscribed to the Google Groups "Robotics & Machine Vision Toolboxes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotics-tool-...@googlegroups.com.
To post to this group, send an email to robotics...@googlegroups.com.
Visit this group at http://groups.google.com/group/robotics-tool-box?hl=en-GB.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
As'salam o Alikum Wa Rehmatullah e Wabarakatuhu..!!





Warm Regards:
Tehseen Akhtar

Tehseen Akhtar

unread,
Mar 14, 2013, 3:40:13 AM3/14/13
to robotics...@googlegroups.com
Hi Sir..
I have solved few problems problems but in all  these problems the Homogeneous Transformation matrix is given and we have to find the link angles using ikine.
But in my case i only have x,y,z coordinates of the point where i want my robot to move.
My question is that how can i make the transformation matrix from the x,y and z coordinates.
I am trying to calculate the inverse kinematics of problem no 6 in the attached file.
suppose if i have the x,y,z coordinates of the final point how can i make the transformation matrix for ikine.
because the transformation matrices used in ikine in other examples are with numeric values but i have the general transformaton matrix with cos and sin angles????

Thanks in advance.. :)

PROBLEMS.pdf

Tehseen Akhtar

unread,
Mar 14, 2013, 3:41:22 AM3/14/13
to robotics...@googlegroups.com
sorry its  **joint angles at the end of first sentence.
Message has been deleted

Felipe

unread,
Mar 15, 2013, 10:40:38 AM3/15/13
to robotics...@googlegroups.com
Hello, Tehseen.
Maybe you can try to fix the rotation part of the matrix and build it using your x,y,z coordinates. For example, if you don't want any rotation, you can build your transformation matrix with an identity rotation submatrix:
T = [1 0 0 x;0 1 0 y;0 0 1 z;0 0 0 1]
Try and tell us if this works. :-)

Felipe

unread,
Mar 16, 2013, 10:33:04 AM3/16/13
to robotics...@googlegroups.com
Hello, Tehseen.
I just saw the file and read problem #6, and I realized that the suggestion I gave is not going. 
Sorry!

Peter Corke

unread,
Mar 16, 2013, 8:29:23 PM3/16/13
to robotics...@googlegroups.com
This is not a group for discussing homework or tutorials problems, go talk to your professor.

Tehseen Akhtar

unread,
Mar 17, 2013, 5:41:10 AM3/17/13
to robotics...@googlegroups.com
Hi Peter..
Well i am not a student i am Lecturer in an engineering college in Pakistan..
you can see my profile here:
..
This is the official website of the college where i teach..
and the pdf file that i attached was a random file that i downloaded from the internet just to get a grip on the robotics tool box..
i am also consulting the robot.pdf manual that you uploaded on the internet..
..
i have studied robotics in my bachelors and masters and i love robotics and when i got your robotics tool box i saw that complex problems could be solved very easily but in order to do that one should know how to use the robotics tool box correctly so that is why i started solving random example with my few students..
And the question that i asked about the transformation matrix has nothing to do with any assignment..
and i thought that who else can help us then the one who actually wrote this tool box.. :)

Regerds: 

Tehseen Akhtar

unread,
Mar 17, 2013, 5:45:19 AM3/17/13
to robotics...@googlegroups.com
Hi Felipe..
Well i already tried your suggestion and it didn't work.
but thanks anyways for the help..

Regards

Peter Corke

unread,
Apr 15, 2013, 5:48:07 PM4/15/13
to robotics...@googlegroups.com, annum...@gmail.com
Telling me you get an error is not helpful.  There is help info with the block and examples in the book, specifically what more do you need?

I can't stress this enough, inverse kinematics is one of the least straightforward aspect of arm robotics, you can't just use it, you really need to understand what's going on.

peter

On Tuesday, 16 April 2013 06:57:22 UTC+10, annum...@gmail.com wrote:


Hi peter..
i have been using the robotics toolbox for some time now..n i m having some problems in using the simulink blocks..especially the ikine block...so could u plz tell me what are the inputs that need to be given to the block...i m getting an error again and again...also plz tell me what is the meaning of the interpreted matlab function in the block.

edris farah

unread,
Apr 15, 2013, 9:24:38 PM4/15/13
to robotics...@googlegroups.com
in (SerialLink.ikine) change
J0 = J0(m, m);
to:
J0 = J0(m, :);
save
and run again


--

Piotr Waksmundzki

unread,
Jan 16, 2014, 12:34:48 PM1/16/14
to robotics...@googlegroups.com
I've similar problem with RRRR robot:

   l=Link([0,3.5,0,-pi/2,0])
   l(2)=Link([0,0,3,0,0])
   l(3)=Link([0,0,2.5,0,0])
   l(4)=Link([0,0,0.65,0,0])



I've changed

J0 = J0(m, m);
to:
J0 = J0(m, :);

And wrote a mask matrix m=[1 1 1 1 0 0] (is that correct? i'm new with all this stuff).

But I still got an error:

%%%%%%%%%%%%%%%%%%%%%%%%%%

Error using SerialLink/ikine (line 124)
For a manipulator with fewer than 6DOF a mask matrix argument must be specified

Error in mojrob_inv (line 51)
qi = mojrob2.ikine(T, 'pinv');

chri...@gmail.com

unread,
May 27, 2018, 4:36:04 PM5/27/18
to Robotics & Machine Vision Toolboxes
Hi Peter,

I am using MATLAB R2017a and the robotic toolbox to solve the inverse kinematics of a robot consisting of 5 joints using the following piece of code:


L(1) = Link([0 d1 a1 Alpha1]);
L(2) = Link([0 d2 a2 Alpha2]);
L(3) = Link([0 d3 a3 Alpha3]);
L(4) = Link([0 d4 a4 Alpha4]);
L(5) = Link([0 d5 a5 Alpha5]);

Robot = SerialLink(L);
Robot.name = 'Robotic Arm';

Trans_mat = [ 1 0 0 PosIn_X; 0 1 0 PosIn_Y; 0 0 1 PosIn_Z; 0 0 0 1]

J = Robot.ikine(Trans_mat, [0 0 0 0 0], [1 1 1 1 1 0])*180/pi

When running the program the following error keeps coming up:

Error using SerialLink/ikine (line 164)
Number of robot DOF must be >= the same number of 1s in the mask matrix

Error in GUI_3>btn_Inverse_Callback (line 326)
J = Robot.ikine(Trans_mat, [0 0 0 0 0], [1 1 1 1 1 0])*180/pi

Kind Regards

Peter Corke

unread,
Jun 17, 2018, 8:11:07 AM6/17/18
to Robotics & Machine Vision Toolboxes
Chris, can you send a complete runnable example, this code has lots of undefined magic numbers.

peter 

firdauz...@gmail.com

unread,
Dec 1, 2018, 4:40:46 PM12/1/18
to Robotics & Machine Vision Toolboxes
>> startup_rvc
Robotics, Vision & Control: (c) Peter Corke 1992-2011 http://www.petercorke.com
- Robotics Toolbox for Matlab (release 9.4)
>> L1=216; L2=260; L3=152; L4=145.5;
>> 
>> L(1)=Link([0 L1 0 0]);
>> L(2)=Link([0 L2 0 pi/2]);
>> L(3)=Link([pi/2 L3 0 0]);
>> L(4)=Link([pi/2 L4 0 0]);
>> 
>> KukaKR3=SerialLink (L);
>> 
>> KukaKR3
 
KukaKR3 = 
 
robot (4 axis, RRRR, stdDH)                          
+---+-----------+-----------+-----------+-----------+
| j |     theta |         d |         a |     alpha |
+---+-----------+-----------+-----------+-----------+
|  1|         q1|        216|          0|          0|
|  2|         q2|        260|          0|      1.571|
|  3|         q3|        152|          0|          0|
|  4|         q4|      145.5|          0|          0|
+---+-----------+-----------+-----------+-----------+
                                                     
grav =    0  base = 1  0  0  0   tool =  1  0  0  0  
          0         0  1  0  0           0  1  0  0  
       9.81         0  0  1  0           0  0  1  0  
                    0  0  0  1           0  0  0  1  
 
>> KukaKR3.plot ([0 0 0 0])
Warning: The DrawMode property will be removed in a future release. Use the SortMethod property
instead. 
> In SerialLink/plot>create_new_robot (line 340)
  In SerialLink/plot (line 184) 
Warning: The EraseMode property is no longer supported and will error in a future release. 
> In SerialLink/plot>create_new_robot (line 367)
  In SerialLink/plot (line 184) 
>> KukaKR3.plot ([0 0 pi/2 0])
Warning: The DrawMode property will be removed in a future release. Use the SortMethod property
instead. 
> In SerialLink/plot>create_new_robot (line 340)
  In SerialLink/plot (line 184) 
Warning: The EraseMode property is no longer supported and will error in a future release. 
> In SerialLink/plot>create_new_robot (line 367)
  In SerialLink/plot (line 184) 
>> KukaKR3.plot ([0 pi/2 0 0])
>> KukaKR3.plot ([0 pi/3 0 0])
Warning: The DrawMode property will be removed in a future release. Use the SortMethod property
instead. 
> In SerialLink/plot>create_new_robot (line 340)
  In SerialLink/plot (line 184) 
Warning: The EraseMode property is no longer supported and will error in a future release. 
> In SerialLink/plot>create_new_robot (line 367)
  In SerialLink/plot (line 184) 
>> KukaKR3.plot ([0 pi/4 0 0])
>> KukaKR3.plot ([0 0 0 pi/2])
>> KukaKR3.plot ([0 pi/3 0 pi/2])
>> KukaKR3.plot ([0 0 0 0])
Warning: The DrawMode property will be removed in a future release. Use the SortMethod property
instead. 
> In SerialLink/plot>create_new_robot (line 340)
  In SerialLink/plot (line 184) 
Warning: The EraseMode property is no longer supported and will error in a future release. 
> In SerialLink/plot>create_new_robot (line 367)
  In SerialLink/plot (line 184) 
>> KukaKR3.fkine ([0 0 0 0])

ans =

    1.0000         0         0         0
         0    0.0000   -1.0000 -297.5000
         0    1.0000    0.0000  476.0000
         0         0         0    1.0000

>> %inverse kinematics
>> 
>> T= [1 0 0 0;
       0 0 -1 -297.5;
       0 1 0 476;
       0 0 0 1];
>> KukaKR3.ikine(T)

I try run for inverse kinematic. but there got 'Error using SerialLink/ikine (line 114)
For a manipulator with fewer than 6DOF a mask matrix argument must be specified'

Peter Corke

unread,
Dec 1, 2018, 4:51:49 PM12/1/18
to Robotics & Machine Vision Toolboxes
It looks like you are using a very old version of the toolbox and a fairly recent version of MATLAB, which is why you are getting so many warnings.

Read the documentation for ikine() to understand what a mask matrix is.  Perhaps also have a look at the FAQ, linked off the this Google groups page, or read a textbook about robot kinematics to understand why IK is tricky for an under actuated robot (your robot only has 4 joints, not 6).

peter
Reply all
Reply to author
Forward
0 new messages