-
Notifications
You must be signed in to change notification settings - Fork 11
/
assemble_addons.py
64 lines (49 loc) · 1.63 KB
/
assemble_addons.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
from zencad.libs.screw import screw
from zencad.libs.kinematic import kinematic_frame
import zencad.libs.screw
import pyservoce
def attach_speed_model(baseunit):
def func(unit):
unit.global_frame_speed_reference = screw()
unit.global_frame_speed = screw()
unit.global_frame_acceleration_reference = screw()
unit.global_frame_acceleration = screw()
for u in unit.childs:
func(u)
func(baseunit)
def update_speed_model(baseunit):
def func(unit, prev):
if isinstance(unit.parent, kinematic_frame):
unit.global_frame_speed = unit.parent.global_spdscr
#print(unit.parent.global_spdscr)
if prev:
reference = prev.global_frame_speed_reference
radius = (prev.global_pose.inverse() * unit.global_pose).translation()
arm = prev.global_pose(radius)
else:
reference = screw()
arm = pyservoce.vector3()
unit.global_frame_speed_reference = (
reference.kinematic_carry(arm) + unit.global_frame_speed
)
for u in unit.childs:
func(u, unit)
func(baseunit, None)
def accfunc(unit, prev):
if isinstance(unit.parent, kinematic_frame):
unit.global_frame_acceleration = unit.parent.global_accscr
if prev:
reference = prev.global_frame_acceleration_reference
spdref = prev.global_frame_speed_reference
radius = (prev.global_pose.inverse() * unit.global_pose).translation()
arm = prev.global_pose(radius)
else:
reference = screw()
spdref = screw()
arm = pyservoce.vector3()
unit.global_frame_acceleration_reference = (
zencad.libs.screw.second_kinematic_carry(reference, spdref, arm) + unit.global_frame_acceleration
)
for u in unit.childs:
accfunc(u, unit)
accfunc(baseunit, None)