Regarding ikine_sym function

748 views
Skip to first unread message

luizt...@gmail.com

unread,
Oct 3, 2014, 2:43:02 PM10/3/14
to robotics...@googlegroups.com
Hello!

I'm currently trying to use the toolbox to generate the symbolic inverse kinematics of a 6 DOF robot, but when I try to run the newest toolbox it says:

Attempt to execute SCRIPT robot as a function:
E:\Program Files\Matlab\toolbox\rvctools\robot\demos\robot.m

Error in SerialLink/ikine_sym (line 64)
    srobot = sym(robot);

Error in Project_1 (line 25)
RQ = kr162.ikine_sym(T06); 


Is there anything I can do in order to fix it?

Thanks in advance!




PS:Here's the code I'm trying to run, in case it helps:

clc;
clear;

l(1)=Link([0,   0,      0,      0]);
l(2)=Link([0,   0,      0.26,   pi/2]);
l(3)=Link([0,   0,      0.680,  0]);
l(4)=Link([0,   0,      0.035,  -pi/2]);
l(5)=Link([0,   0.670,  0,      -pi/2]);
l(6)=Link([0,   0,      0,      pi/2]);

kr162 = SerialLink(l);
robot = kr162;
% kr162.plot([0 0 0 0 0 0]);

a1 = sym('a1');
a2 = sym('a2');
a3 = sym('a3');
a4 = sym('a4');
a5 = sym('a5');
a6 = sym('a6');

T06 = kr162.fkine([a1 a2 a3 a4 a5 a6])


RQ = kr162.ikine_sym(T06);




Yaokun Lu

unread,
Nov 13, 2014, 9:42:02 AM11/13/14
to robotics...@googlegroups.com
Is anybody could give an example on using  IKINE SYM?   Or it just have not finished yet?I try very hard to use it and I failed.
在 2014年10月4日星期六UTC+8上午2时43分02秒,Luiz Tapparo写道:

Peter Corke

unread,
Nov 16, 2014, 12:34:04 AM11/16/14
to robotics...@googlegroups.com
Grab the latest version off svn.  It's still bleeding edge code...

Peter Corke

unread,
Nov 16, 2014, 12:35:53 AM11/16/14
to robotics...@googlegroups.com
I've added an example to the doco in the latest version in svn.

Here's how it works:

>> mdl_planar2
>> sol = p2.ikine_sym(2)
----- solving for joint 1
lets square and add 1 2
subs sin/cos q1 for S/C
----- solving for joint 2
subs sin/cos q2 for S/C
**final simplification pass

sol = 

    [1x2 sym]    [1x2 sym]

>> s = sol{1}
 
s =
 
[ atan2(- tx^2 - ty^2, -(- tx^4 - 2*tx^2*ty^2 + 4*tx^2 - ty^4 + 4*ty^2)^(1/2)) - atan2(-tx, -ty), - atan2(-tx, -ty) + atan2(- tx^2 - ty^2, (- tx^4 - 2*tx^2*ty^2 + 4*tx^2 - ty^4 + 4*ty^2)^(1/2))]
 
>> q1=s(1)
 
q1 =
 
atan2(- tx^2 - ty^2, -(- tx^4 - 2*tx^2*ty^2 + 4*tx^2 - ty^4 + 4*ty^2)^(1/2)) - atan2(-tx, -ty)
 
>> q2 = s(2)
 
q2 =
 
- atan2(-tx, -ty) + atan2(- tx^2 - ty^2, (- tx^4 - 2*tx^2*ty^2 + 4*tx^2 - ty^4 + 4*ty^2)^(1/2))

muhamma...@gmail.com

unread,
Jun 15, 2015, 2:48:54 AM6/15/15
to robotics...@googlegroups.com
Hi,

I have a simple example that I'm trying to run:
a1 = 1;     %link 1 length
a2 = 1;     %link 2 length
L(1) = Link([ 0 0 a1 0], 'standard');
L(2) = Link([ 0 0 a2 0], 'standard');
twolink = SerialLink(L, 'name', 'two link');
j1 = pi/2;
j2 = pi/2;
T = twolink.fkine([j1 j2]);
q = twolink.ikine_sym(2);


Now, when I look at solution 1, this makes sense.  tx, and ty are values that I can substitute to solve this equation
>> q{1}
ans =

[ atan2(- tx^2 - ty^2, -(- tx^4 - 2*tx^2*ty^2 + 4*tx^2 - ty^4 + 4*ty^2)^(1/2)) - atan2(-tx, -ty), - atan2(-tx, -ty) + atan2(- tx^2 - ty^2, (- tx^4 - 2*tx^2*ty^2 + 4*tx^2 - ty^4 + 4*ty^2)^(1/2))]

 
On the other hand, solution two has some extra variables S1, C1, which I don't know how to interpret. 
>> q{2}
ans =
[ - atan2(C1*tx + S1*ty - 1, C1*ty - S1*tx) + atan2(1, -(tx^2 - 2*C1*tx + ty^2 - 2*S1*ty)^(1/2)), - atan2(C1*tx + S1*ty - 1, C1*ty - S1*tx) + atan2(1, (tx^2 - 2*C1*tx + ty^2 - 2*S1*ty)^(1/2))]

 
Glancing at the code for the function I see that these might be intermediate variables.  Is this a bug or am I misinterpreting something?

Thanks in advance for the help!

MC

Peter Corke

unread,
Jun 20, 2015, 9:15:24 PM6/20/15
to robotics...@googlegroups.com, muhamma...@gmail.com, muhamma...@gmail.com
Sorry, this is a fairly common shorthand used when writing kinematic equations:

S1 = sin(q1)
C1 = cos(q1)

So you solve first for q1, then q2 depends on the result of q1.

peter

giov...@gmail.com

unread,
Aug 21, 2017, 9:48:06 AM8/21/17
to Robotics & Machine Vision Toolboxes
Hi Peter,

I am trying to use "ikine_sym" but running into the following error:

Error using  *  (line 286)
invalid operand types to * operator

Error in SerialLink/ikine_sym>pieper (line 262)
    T = inv(robot.base) * T * inv(robot.tool);

Error in SerialLink/ikine_sym (line 106)
        [left,right] = pieper(srobot, j, 'left');

I have tried it in my code (3RP3R manipulator) and the example you posted, but in neither of the cases it works. I also downloaded the last version of "ikine_sym" on github, but nothing. Is there something I might be missing? Thank you very much.

BW

Giovanni

Peter Corke

unread,
Nov 11, 2017, 8:15:07 PM11/11/17
to Robotics & Machine Vision Toolboxes
Quick workaround, lines 269-271 should be:

    T = inv(robot.base.T) * T * inv(robot.tool.T);

    

    q = robot.gencoords();



it will throw a bunch of warnings but work.


Peter

umair2...@gmail.com

unread,
Jul 22, 2018, 8:17:10 AM7/22/18
to Robotics & Machine Vision Toolboxes
mdl_planar2
sol = p2.ikine_sym(2)
Warning: FINDSYM will be removed in a future release. Use SYMVAR instead. 
> In sym/findsym (line 32)
  In Link/set.Tc (line 516)
  In Link/sym (line 864)
  In SerialLink/sym (line 753)
  In SerialLink/ikine_sym (line 78) 
Warning: FINDSYM will be removed in a future release. Use SYMVAR instead. 
> In sym/findsym (line 32)
  In Link/set.Tc (line 518)
  In Link/sym (line 864)
  In SerialLink/sym (line 753)
  In SerialLink/ikine_sym (line 78) 
Warning: FINDSYM will be removed in a future release. Use SYMVAR instead. 
> In sym/findsym (line 32)
  In Link/set.Tc (line 516)
  In Link/sym (line 864)
  In SerialLink/sym (line 753)
  In SerialLink/ikine_sym (line 78) 
Warning: FINDSYM will be removed in a future release. Use SYMVAR instead. 
> In sym/findsym (line 32)
  In Link/set.Tc (line 518)
  In Link/sym (line 864)
  In SerialLink/sym (line 753)
  In SerialLink/ikine_sym (line 78) 
----- solving for joint 1
lets square and add 1 2
subs sin/cos q1 for S/C
Error using sym>convertChar (line 1448)
Character vectors and strings in the first argument can only specify a variable or number. To evaluate character vectors and
strings representing symbolic expressions, use 'str2sym'.

Error in sym>tomupad (line 1214)
        S = convertChar(x);

Error in sym (line 211)
                S.s = tomupad(x);

Error in SerialLink/ikine_sym>mvar (line 370)
        v = sym( sprintf(fmt, varargin{:}) );

Error in SerialLink/ikine_sym (line 177)
        trigsubOld = [trigsubOld mvar('sin(q%d)', j) mvar('cos(q%d)', j)];

i am getting this error every time i use ikine_sym please help

Peter Corke

unread,
Jul 22, 2018, 8:36:35 AM7/22/18
to Robotics & Machine Vision Toolboxes
I can only think you are using an old version of MATLAB, SymMath toolbox and RTB.  findsym is not used by the current version of RTB.  Using latest tools the solution is:

>> mdl_planar2
>> sol = p2.ikine_sym(2)
----- solving for joint 1
lets square and add 1 2
subs sin/cos q1 for S/C
----- solving for joint 2
subs sin/cos q2 for S/C
**final simplification pass
sol =
  1×2 cell array
    {1×2 sym}    {1×2 sym}
Reply all
Reply to author
Forward
0 new messages