Skip to content

Commit 9b71b62

Browse files
committed
collision updates
1 parent 388912c commit 9b71b62

File tree

3 files changed

+43
-28
lines changed

3 files changed

+43
-28
lines changed

examples/Swift.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,20 @@
2222

2323
dt = 0.05
2424

25-
env.record_start('file.webm')
25+
# env.record_start('file.webm')
2626

27-
while not arrived:
27+
# while not arrived:
2828

29-
start = time.time()
30-
v, arrived = rp.p_servo(panda.fkine(), Tep, 1.0)
31-
panda.qd = np.linalg.pinv(panda.jacobe()) @ v
32-
env.step(5)
33-
stop = time.time()
29+
# start = time.time()
30+
# v, arrived = rp.p_servo(panda.fkine(), Tep, 1.0)
31+
# panda.qd = np.linalg.pinv(panda.jacobe()) @ v
32+
# env.step(5)
33+
# stop = time.time()
3434

35-
if stop - start < dt:
36-
time.sleep(dt - (stop - start))
35+
# if stop - start < dt:
36+
# time.sleep(dt - (stop - start))
3737

38-
env.record_stop()
38+
# env.record_stop()
3939

4040
# Uncomment to stop the plot from closing
4141
# env.hold()

roboticstoolbox/robot/ETS.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -221,17 +221,7 @@ def to_dict(self):
221221
# })
222222

223223
for gi in link.collision:
224-
g_fk = link._fk * gi.base
225-
if gi.scale is not None:
226-
scale = gi.scale.tolist()
227-
else:
228-
scale = [1, 1, 1]
229-
li['geometry'].append({
230-
'filename': gi.filename,
231-
'scale': scale,
232-
't': g_fk.t.tolist(),
233-
'q': r2q(g_fk.R).tolist()
234-
})
224+
li['geometry'].append(gi.to_dict(link._fk))
235225

236226
ob['links'].append(li)
237227

@@ -428,7 +418,7 @@ def gravity(self, gravity_new):
428418
def q(self, q_new):
429419
q_new = getvector(q_new, self.n)
430420
self._q = q_new
431-
self.allfkine()
421+
self.fkine_all()
432422

433423
@qd.setter
434424
def qd(self, qd_new):

roboticstoolbox/robot/Shape.py

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
from spatialmath import SE3
77
from spatialmath.base.argcheck import getvector
8+
from spatialmath.base import r2q
89

910
try:
1011
import fcl
@@ -23,7 +24,8 @@ def __init__(
2324
length=0,
2425
scale=[1, 1, 1],
2526
filename=None,
26-
co=None):
27+
co=None,
28+
stype=None):
2729

2830
self.base = base
2931
self.primitive = primitive
@@ -32,6 +34,23 @@ def __init__(
3234
self.length = length
3335
self.filename = filename
3436
self.co = co
37+
self.stype = stype
38+
39+
def to_dict(self, link_fk):
40+
shape_fk = self.base * link_fk
41+
# shape_fk = self.base
42+
43+
shape = {
44+
'stype': self.stype,
45+
'scale': self.scale.tolist(),
46+
'filename': self.filename,
47+
'radius': self.radius,
48+
'length': self.length,
49+
't': self.wT.t.tolist(),
50+
'q': r2q(self.wT.R).tolist()
51+
}
52+
53+
return shape
3554

3655
@property
3756
def wT(self):
@@ -41,7 +60,7 @@ def wT(self):
4160
def wT(self, T):
4261
if not isinstance(T, SE3):
4362
T = SE3(T)
44-
self._wT = self.base * T
63+
self._wT = T * self.base
4564

4665
if _fcl:
4766
tf = fcl.Transform(self._wT.R, self._wT.t)
@@ -67,6 +86,8 @@ def scale(self):
6786
def scale(self, value):
6887
if value is not None:
6988
value = getvector(value, 3)
89+
else:
90+
value = getvector([1, 1, 1], 3)
7091
self._scale = value
7192

7293
@property
@@ -108,7 +129,8 @@ def Box(cls, scale, base=None):
108129
else:
109130
co = None
110131

111-
return cls(True, base=base, scale=scale, co=co)
132+
return cls(
133+
True, base=base, scale=scale, co=co, stype='box')
112134

113135
@classmethod
114136
def Cylinder(cls, radius, length, base=None):
@@ -119,7 +141,9 @@ def Cylinder(cls, radius, length, base=None):
119141
else:
120142
co = None
121143

122-
return cls(True, base=base, radius=radius, length=length, co=co)
144+
return cls(
145+
True, base=base, radius=radius, length=length, co=co,
146+
stype='cylinder')
123147

124148
@classmethod
125149
def Sphere(cls, radius, base=None):
@@ -130,11 +154,12 @@ def Sphere(cls, radius, base=None):
130154
else:
131155
co = None
132156

133-
return cls(True, base=base, radius=radius, co=co)
157+
return cls(True, base=base, radius=radius, co=co, stype='sphere')
134158

135159
@classmethod
136160
def Mesh(cls, filename, base=None, scale=None):
137-
return cls(False, filename=filename, base=base, scale=scale)
161+
return cls(
162+
False, filename=filename, base=base, scale=scale, stype='mesh')
138163

139164

140165
# class Mesh(Shape):

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy