Skip to content

Commit

Permalink
SerialLink.double and Link.double
Browse files Browse the repository at this point in the history
Link.double converts link parameters to numeric (double) type

dl = l.double is a Link object in which all the parameters are
numeric ('double') type.

Useful when you are using Pi=sym('pi') to avoid round off errors
(e.g in sin(Pi/2)), but later you want to pass the link object to
a method (e.g. ikine) which only supports real numbers.

Will give an error if a symbolic variable is not convertable to
double number.

See also SerialLink.double

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

SerialLink.double converts SerialLink object parameters to numeric (double) type

dr = r.double is a SerialLink object in which all the parameters are
numeric ('double') type.

Useful when you are using Pi=sym('pi') to avoid round off errors
e.g in sin(Pi/2)), but later you want to pass the SerialLink object to
a method (e.g. ikine) which only supports real numbers.

Will give an error if a symbolic variable is not convertable to
double number.

See also Link.double

Author: Amin Yahyaabadi (aminyahyaabadi74@gmail.com)
  • Loading branch information
aminya committed Jul 8, 2019
1 parent 9cfdfd8 commit 7e212c1
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 1 deletion.
24 changes: 23 additions & 1 deletion @SerialLink/SerialLink.m
Original file line number Diff line number Diff line change
Expand Up @@ -901,7 +901,29 @@ function dyn(r, j)
sr.links(i) = r.links(i).sym;
end
end


function dr = double(r)
% SerialLink.double converts SerialLink object parameters to numeric (double) type
%
% dr = r.double is a SerialLink object in which all the parameters are
% numeric ('double') type.
%
% Useful when you are using Pi=sym('pi') to avoid round off errors
% e.g in sin(Pi/2)), but later you want to pass the SerialLink object to
% a method (e.g. ikine) which only supports real numbers.
%
% Will give an error if a symbolic variable is not convertable to
% double number.
%
% See also Link.double
%
% Author: Amin Yahyaabadi (aminyahyaabadi74@gmail.com)

dr = SerialLink(r);
for i=1:r.n
dr.links(i) = r.links(i).double;
end
end

function p = isprismatic(robot)
%SerialLink.isprismatic identify prismatic joints
Expand Down
42 changes: 42 additions & 0 deletions Link.m
Original file line number Diff line number Diff line change
Expand Up @@ -991,6 +991,48 @@ function dyn(links)
l.B = sym(l.B);
l.Tc = sym(l.Tc);
end

function l = double(l)
%Link.double converts link parameters to numeric (double) type
%
% dl = l.double is a Link object in which all the parameters are
% numeric ('double') type.
%
% Useful when you are using Pi=sym('pi') to avoid round off errors
% (e.g in sin(Pi/2)), but later you want to pass the link object to
% a method (e.g. ikine) which only supports real numbers.
%
% Will give an error if a symbolic variable is not convertable to
% double number.
%
% See also SerialLink.double
%
% Author: Amin Yahyaabadi (aminyahyaabadi74@gmail.com)

if l.issym % we can disable the check, we should compare the speed.

if ~isempty(l.theta) % && isa(l.d,'sym') % we can check for sym class individually, speed should be compared.
l.d=double(l.d);
end

if ~isempty(l.theta)
l.theta=double(l.theta);
end

l.alpha=double(l.alpha);
l.a=double(l.a);
l.offset=double(l.offset);

l.offset=double(l.I);
l.offset=double(l.r);
l.offset=double(l.m);

l.Jm = double(l.Jm);
l.G = double(l.G);
l.B = double(l.B);
l.Tc = double(l.Tc);
end
end


end % methods
Expand Down

0 comments on commit 7e212c1

Please sign in to comment.