@@ -79,7 +79,6 @@ def __init__(
79
79
self ._hasgeometry = False
80
80
self ._hascollision = False
81
81
82
-
83
82
for link in links :
84
83
if not isinstance (link , Link ):
85
84
raise TypeError ('links should all be Link subclass' )
@@ -309,7 +308,7 @@ def hasgeometry(self):
309
308
>>> import roboticstoolbox as rtb
310
309
>>> robot = rtb.models.DH.Puma560()
311
310
>>> robot.hasgeometry
312
-
311
+
313
312
:seealso: :func:`hascollision`
314
313
"""
315
314
return self ._hasgeometry
@@ -336,7 +335,6 @@ def hascollision(self):
336
335
"""
337
336
return self ._hascollision
338
337
339
-
340
338
@property
341
339
def qrandom (self ):
342
340
"""
@@ -535,7 +533,7 @@ def todegrees(self, q):
535
533
536
534
for j , revolute in enumerate (self .revolutejoints ):
537
535
if revolute :
538
- q [:,j ] *= 180.0 / np .pi
536
+ q [:, j ] *= 180.0 / np .pi
539
537
if q .shape [0 ] == 1 :
540
538
return q [0 ]
541
539
else :
@@ -570,7 +568,7 @@ def toradians(self, q):
570
568
571
569
for j , revolute in enumerate (self .revolutejoints ):
572
570
if revolute :
573
- q [:,j ] *= np .pi / 180.0
571
+ q [:, j ] *= np .pi / 180.0
574
572
if q .shape [0 ] == 1 :
575
573
return q [0 ]
576
574
else :
@@ -983,7 +981,7 @@ def base(self):
983
981
else :
984
982
self ._base = SE3 ()
985
983
986
- # return a copy, otherwise somebody with
984
+ # return a copy, otherwise somebody with
987
985
# reference to the base can change it
988
986
return self ._base .copy ()
989
987
@@ -1055,7 +1053,7 @@ def qlim(self):
1055
1053
1056
1054
Limits are extracted from the link objects. If joints limits are
1057
1055
not set for:
1058
-
1056
+
1059
1057
- a revolute joint [-𝜋. 𝜋] is returned
1060
1058
- a prismatic joint an exception is raised
1061
1059
@@ -1641,8 +1639,8 @@ def plot_vellipse(
1641
1639
1642
1640
def teach (
1643
1641
self , q = None , block = True , order = 'xyz' , limits = None ,
1644
- jointaxes = True , jointlabels = False ,
1645
- vellipse = False , fellipse = False , eeframe = True , shadow = True ,
1642
+ jointaxes = True , jointlabels = False ,
1643
+ vellipse = False , fellipse = False , eeframe = True , shadow = True ,
1646
1644
name = True , backend = None ):
1647
1645
"""
1648
1646
Graphical teach pendant
@@ -1705,7 +1703,7 @@ def teach(
1705
1703
env .launch ('Teach ' + self .name , limits = limits )
1706
1704
env .add (
1707
1705
self , readonly = True ,
1708
- jointaxes = jointaxes , jointlabels = jointlabels , eeframe = eeframe ,
1706
+ jointaxes = jointaxes , jointlabels = jointlabels , eeframe = eeframe ,
1709
1707
shadow = shadow , name = name )
1710
1708
1711
1709
env ._add_teach_panel (self , q )
@@ -1718,7 +1716,6 @@ def teach(
1718
1716
fell = self .fellipse (centre = 'ee' )
1719
1717
env .add (fell )
1720
1718
1721
-
1722
1719
# Keep the plot open
1723
1720
if block : # pragma: no cover
1724
1721
env .hold ()
@@ -1727,7 +1724,7 @@ def teach(
1727
1724
1728
1725
# --------------------------------------------------------------------- #
1729
1726
1730
- def closest_point (self , shape , inf_dist = 1.0 ):
1727
+ def closest_point (self , q , shape , inf_dist = 1.0 , skip = False ):
1731
1728
'''
1732
1729
closest_point(shape, inf_dist) returns the minimum euclidean
1733
1730
distance between this robot and shape, provided it is less than
@@ -1739,14 +1736,20 @@ def closest_point(self, shape, inf_dist=1.0):
1739
1736
:param inf_dist: The minimum distance within which to consider
1740
1737
the shape
1741
1738
:type inf_dist: float
1739
+ :param skip: Skip setting all shape transforms based on q, use this
1740
+ option if using this method in conjuction with Swift to save time
1741
+ :type skip: boolean
1742
1742
:returns: d, p1, p2 where d is the distance between the shapes,
1743
1743
p1 and p2 are the points in the world frame on the respective
1744
- shapes
1745
- :rtype: float, SE3, SE3
1744
+ shapes. The points returned are homogeneous with [x, y, z, 1].
1745
+ :rtype: float, ndarray(1x4), ndarray(1x4)
1746
1746
'''
1747
1747
1748
+ if not skip :
1749
+ self ._set_link_fk (q )
1750
+
1748
1751
d = 10000
1749
- p1 = None ,
1752
+ p1 = None
1750
1753
p2 = None
1751
1754
1752
1755
for link in self .links :
@@ -1762,15 +1765,21 @@ def closest_point(self, shape, inf_dist=1.0):
1762
1765
1763
1766
return d , p1 , p2
1764
1767
1765
- def collided (self , shape ):
1768
+ def collided (self , q , shape , skip = False ):
1766
1769
'''
1767
1770
collided(shape) checks if this robot and shape have collided
1768
1771
:param shape: The shape to compare distance to
1769
1772
:type shape: Shape
1773
+ :param skip: Skip setting all shape transforms based on q, use this
1774
+ option if using this method in conjuction with Swift to save time
1775
+ :type skip: boolean
1770
1776
:returns: True if shapes have collided
1771
1777
:rtype: bool
1772
1778
'''
1773
1779
1780
+ if not skip :
1781
+ self ._set_link_fk (q )
1782
+
1774
1783
for link in self .links :
1775
1784
if link .collided (shape ):
1776
1785
return True
0 commit comments