Skip to content

Commit 844347c

Browse files
committed
Progress
1 parent 66a04d1 commit 844347c

File tree

4 files changed

+102
-24
lines changed

4 files changed

+102
-24
lines changed

examples/Swift.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
Tep = panda.fkine() * sm.SE3.Tx(-0.2) * sm.SE3.Ty(0.2) * sm.SE3.Tz(0.2)
1818

1919
arrived = False
20-
env.add(panda, show_collision=True)
20+
env.add(panda, show_collision=True, show_robot=False)
2121
time.sleep(1)
2222

2323
dt = 0.05

examples/collision.py

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,41 @@
66
import roboticstoolbox as rp
77
import spatialmath as sm
88
import numpy as np
9+
import fcl
910

10-
r = rp.models.Panda()
11-
r.q = r.qr
11+
# r = rp.models.Panda()
12+
# r.q = r.qr
1213

13-
r.scollision()
14+
# r.scollision()
15+
16+
17+
18+
obj1 = fcl.Box(1, 1, 1)
19+
co1 = fcl.CollisionObject(obj1, fcl.Transform())
20+
obj2 = fcl.Box(1, 1, 1)
21+
co2 = fcl.CollisionObject(obj2, fcl.Transform())
22+
23+
t1 = sm.SE3()
24+
t2 = sm.SE3(10, 2.7, 5.8) * sm.SE3.Rx(1.2) * sm.SE3.Ry(0.2) * sm.SE3.Rz(2.2)
25+
# t2 = sm.SE3(0, 10, 0) * sm.SE3.Rx(1.5)
26+
27+
tf1 = fcl.Transform(t1.R, t1.t)
28+
co1.setTransform(tf1)
29+
tf2 = fcl.Transform(t2.R, t2.t)
30+
co2.setTransform(tf2)
31+
32+
request = fcl.DistanceRequest()
33+
result = fcl.DistanceResult()
34+
ret = fcl.distance(co1, co2, request, result)
35+
print(ret)
36+
print(result.nearest_points)
37+
np1 = result.nearest_points[0]
38+
np2 = result.nearest_points[1]
39+
40+
aTp1 = (t1 * sm.SE3(np1)).t
41+
bTp2 = (t2 * sm.SE3(np2)).t
42+
43+
p1Tp2 = bTp2 - aTp1
44+
45+
d = np.linalg.norm(p1Tp2)
46+
print(d)

roboticstoolbox/models/xacro/franka_description/robots/panda_arm.xacro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@
267267
<collision>
268268
<origin xyz="0 0 0.08" rpy="0 0 0"/>
269269
<geometry>
270-
<sphere radius="${0.04+safety_distance}" />
270+
<sphere radius="${0.025+safety_distance}" />
271271
</geometry>
272272
</collision>
273273
<collision>

roboticstoolbox/robot/ETS.py

Lines changed: 64 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -927,25 +927,70 @@ def jacob0v(self, q=None):
927927

928928
def scollision(self):
929929
i = 0
930-
for l1 in self.ets:
931-
for ob1 in l1.collision:
932-
for l2 in self.ets:
933-
# print(l2.name)
934-
if l1.name != l2.name and \
935-
any([l2.name != li.name for li in l1.parent]) and \
936-
any([l2.name != li.name for li in l1.child]):
937-
for ob2 in l2.collision:
938-
# i += 1
939-
# print(i)
940-
request = fcl.CollisionRequest()
941-
result = fcl.CollisionResult()
942-
ret = fcl.collide(ob1.co, ob2.co, request, result)
943-
if ret:
944-
print(l1.name + ' -> ' + l2.name)
945-
# import code
946-
# code.interact(local=dict(globals(), **locals()))
947-
# print(ob1)
948-
# print(ob2)
930+
931+
l1 = self.ets[1]
932+
ob1 = l1.collision[0]
933+
934+
for l2 in self.ets:
935+
print(l2.name)
936+
if l1.name != l2.name and \
937+
any([l2.name != li.name for li in l1.parent]) and \
938+
any([l2.name != li.name for li in l1.child]):
939+
ob2 = l2.collision[0]
940+
request = fcl.DistanceRequest()
941+
result = fcl.DistanceResult()
942+
ret = fcl.distance(ob1.co, ob2.co, request, result)
943+
print(ret)
944+
# print(result.nearest_points)
945+
np1 = result.nearest_points[0]
946+
np2 = result.nearest_points[1]
947+
948+
aTb = (ob1.wT.inv() * ob2.wT).t
949+
bTa = (ob1.wT.inv() * ob2.wT).inv().t
950+
951+
bTp = -(aTb - np1)
952+
aTp = -(bTa - np2)
953+
954+
955+
956+
# t1 = ob1.wT.t + np1
957+
# t2 = ob2.wT.t + np2
958+
# d = np.linalg.norm(bTp - aTp)
959+
d = np.linalg.norm(np1 - np2)
960+
print(d)
961+
962+
963+
# for l1 in self.ets:
964+
# print(l1.name)
965+
# for ob1 in l1.collision:
966+
967+
# print(ob1.stype)
968+
# print(ob1.wT)
969+
970+
971+
# for l2 in self.ets:
972+
# # print(l2.name)
973+
# if l1.name != l2.name and \
974+
# any([l2.name != li.name for li in l1.parent]) and \
975+
# any([l2.name != li.name for li in l1.child]):
976+
# for ob2 in l2.collision:
977+
# # i += 1
978+
# # print(i)
979+
# request = fcl.CollisionRequest()
980+
# result = fcl.CollisionResult()
981+
# ret = fcl.collide(ob1.co, ob2.co, request, result)
982+
# if ret:
983+
# request = fcl.DistanceRequest()
984+
# result = fcl.DistanceResult()
985+
# ret = fcl.distance(ob1.co, ob2.co, request, result)
986+
# print(l1.name + ' -> ' + l2.name)
987+
# print(ret)
988+
# print(result.nearest_points)
989+
990+
# # import code
991+
# # code.interact(local=dict(globals(), **locals()))
992+
# # print(ob1)
993+
# # print(ob2)
949994
# print(ret)
950995

951996

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