Skip to content

Commit 0fd5098

Browse files
author
Ross Hatton
committed
Improved handling of symbolic variables in kinematics and N_link_chain code
1 parent faa3a0b commit 0fd5098

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

ProgramFiles/Geometry/NLinkChain/N_link_chain.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@
151151
% the array symbolic, because matlab tries to cast items being inserted
152152
% into an array into the array class, rather than converting the array to
153153
% accomodate the class of the items being inserted
154-
if isa(jointangles,'sym')
154+
if or( isa(jointangles,'sym'), isa(linklengths,'sym') )
155155
chain_m = sym(chain_m);
156156
end
157157

@@ -185,7 +185,7 @@
185185
% the array symbolic, because matlab tries to cast items being inserted
186186
% into an array into the array class, rather than converting the array to
187187
% accomodate the class of the items being inserted
188-
if isa(jointangles,'sym')
188+
if or( isa(jointangles,'sym'), isa(linklengths,'sym') )
189189
jointchain_m = sym(jointchain_m);
190190
end
191191

@@ -225,7 +225,7 @@
225225
% the array symbolic, because matlab tries to cast items being inserted
226226
% into an array into the array class, rather than converting the array to
227227
% accomodate the class of the items being inserted
228-
if isa(jointangles,'sym')
228+
if or( isa(jointangles,'sym'),isa(linklengths,'sym') )
229229
J_pattern = sym(J_pattern);
230230
end
231231

ProgramFiles/Physics/Nonholonomic/Nonholonomic_connection_discrete.m

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,17 @@
9797

9898
% Prevent Matlab from playing tricks with imaginary numbers on symbolic
9999
% inputs and from complaining about assumptions on constants
100-
if isa(jointangles,'sym')
100+
if or( isa(jointangles,'sym'), isa(geometry.linklengths,'sym') )
101101
omega = sym(omega);
102-
assume(symvar(jointangles),'real')
102+
symjointangles = symvar(jointangles);
103+
if ~isempty(symjointangles)
104+
assume(symjointangles,'real')
105+
end
106+
symlinklengths = symvar(geometry.linklengths);
107+
if ~isempty(symlinklengths)
108+
assume(symlinklengths,'real')
109+
end
110+
103111
warning('off','symbolic:sym:sym:AssumptionsOnConstantsIgnored')
104112
end
105113

ProgramFiles/Utilities/kinematics/Adjinv.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,8 @@
88

99
Adjoint_inverse_action = TgLginv(g)*TeRg(g);
1010

11+
if isa(Adjoint_inverse_action,'sym')
12+
Adjoint_inverse_action = simplify(Adjoint_inverse_action,'steps',50);
13+
end
14+
1115
end

0 commit comments

Comments
 (0)