8000 symbolic support · G-SS/robotics-toolbox-python@49a916e · GitHub
[go: up one dir, main page]

Skip to content

Commit 49a916e

Browse files
committed
symbolic support
1 parent e43769e commit 49a916e

File tree

1 file changed

+35
-7
lines changed

1 file changed

+35
-7
lines changed

roboticstoolbox/robot/DHLink.py

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,34 @@
1414
from roboticstoolbox.robot.Link import Link
1515
from functools import wraps
1616

17+
_eps = np.finfo(np.float64).eps
18+
19+
# ---------------------------------------------------------------------------------------#
20+
21+
try: # pragma: no cover
22+
# print('Using SymPy')
23+
import sympy as sym
24+
25+
def _issymbol(x):
26+
return isinstance(x, sym.Expr)
27+
except ImportError:
28+
def _issymbol(x): # pylint: disable=unused-argument
29+
return False
30+
31+
def _cos(theta):
32+
if _issymbol(theta):
33+
return sym.cos(theta)
34+
else:
35+
return np.cos(theta)
36+
37+
def _sin(theta):
38+
if _issymbol(theta):
39+
return sym.sin(theta)
40+
else:
41+
return np.sin(theta)
42+
43+
# ---------------------------------------------------------------------------------------#
44+
1745
class DHLink(Link):
1846
"""
1947
A link superclass for all link types. A Link object holds all information
@@ -439,8 +467,8 @@ def A(self, q):
439467
440468
"""
441469

442-
sa = np.sin(self.alpha)
443-
ca = np.cos(self.alpha)
470+
sa = _sin(self.alpha)
471+
ca = _cos(self.alpha)
444472

445473
if self.flip:
446474
q = -q + self.offset
@@ -449,13 +477,13 @@ def A(self, q):
449477

450478
if self.sigma == 0:
451479
# revolute
452-
st = np.sin(q)
453-
ct = np.cos(q)
480+
st = _sin(q)
481+
ct = _cos(q)
454482
d = self.d
455483
else:
456484
# prismatic
457-
st = np.sin(self.theta)
458-
ct = np.cos(self.theta)
485+
st = _sin(self.theta)
486+
ct = _cos(self.theta)
459487
d = q
460488

461489
if self.mdh == 0:
@@ -475,7 +503,7 @@ def A(self, q):
475503
[0, 0, 0, 1]
476504
])
477505

478-
return SE3(T)
506+
return SE3(T, check=False)
479507

480508
def islimit(self, q):
481509
"""

0 commit comments

Comments
 (0)
0