Tudo: Primeiro commit
This commit is contained in:
commit
06a90928dc
4633 files changed
+6327263
No files matched your search
@@ -0,0 +1,47 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""Checagem de colisão da fiação (rodar com freecadcmd).
|
||||
Amostra o eixo de cada fio a cada 2 mm (ignorando 12 mm nas pontas, que
|
||||
entram em conectores/furos) e acusa pontos que caem dentro de sólidos, com
|
||||
folga igual ao raio do fio."""
|
||||
import os, sys, json, time
|
||||
import FreeCAD as App, Part
|
||||
from FreeCAD import Vector as V
|
||||
ROOT = os.path.expanduser("~/robo_movel")
|
||||
t0 = time.time()
|
||||
doc = App.openDocument(os.path.join(ROOT, "montagem", "RoboMovel_Base.FCStd"))
|
||||
routes = json.load(open(os.path.join(ROOT, "montagem", "rotas_fios.json")))
|
||||
SKIP = ("Fiacao", "Barra_", "M8", "M4", "M3", "Esp_", "Abracadeira", "Prat_")
|
||||
solids = []
|
||||
for o in doc.Objects:
|
||||
if o.TypeId not in ("App::Link", "Part::Feature") or o.Name.startswith(SKIP):
|
||||
continue
|
||||
if any(g.Name.startswith("Fiacao") for g in o.InList):
|
||||
continue
|
||||
sh = Part.getShape(o, "", needSubElement=False, transform=True)
|
||||
for s in sh.Solids:
|
||||
solids.append((o.Name, s, s.BoundBox))
|
||||
print("sólidos:", len(solids), "rotas:", len(routes), "%.1fs" % (time.time() - t0), flush=True)
|
||||
hits = {}
|
||||
for name, pts, d in routes:
|
||||
spl = Part.BSplineCurve()
|
||||
spl.interpolate([V(*p) for p in pts])
|
||||
e = spl.toShape()
|
||||
L = e.Length
|
||||
n = max(2, int(L / 2.0))
|
||||
r = d / 2.0
|
||||
for k in range(n + 1):
|
||||
s = L * k / n
|
||||
if s < 12 or s > L - 12:
|
||||
continue
|
||||
p = e.valueAt(e.getParameterByLength(s))
|
||||
for oname, so, bb in solids:
|
||||
if not bb.isInside(p):
|
||||
continue
|
||||
if so.isInside(p, r * 0.8, True): # eixo dentro do sólido ou a menos de 0,8·r da face
|
||||
key = (name, oname)
|
||||
if key not in hits:
|
||||
hits[key] = [0, p]
|
||||
hits[key][0] += 1
|
||||
for (w, o), (c, p) in sorted(hits.items()):
|
||||
print("COLISÃO %-28s x %-26s pontos=%3d em (%.0f, %.0f, %.0f)" % (w, o, c, p.x, p.y, p.z))
|
||||
print("total", len(hits), "tempo %.0fs" % (time.time() - t0))
|
||||
Reference in new issue
Block a user