From 0ed1a1a5a40f22ce3bf1ad603e3ac0b517c2d7c9 Mon Sep 17 00:00:00 2001 From: Leni Aniva Date: Thu, 18 Jul 2024 14:41:29 -0700 Subject: [PATCH] feat: Add deflection parameter to assembly --- nhf/touhou/houjuu_nue/__init__.py | 16 +++++++++------- nhf/touhou/houjuu_nue/wing.py | 11 +++++++---- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/nhf/touhou/houjuu_nue/__init__.py b/nhf/touhou/houjuu_nue/__init__.py index aa327fb..f2e779b 100644 --- a/nhf/touhou/houjuu_nue/__init__.py +++ b/nhf/touhou/houjuu_nue/__init__.py @@ -117,19 +117,21 @@ class Parameters(Model): return self.wing_l3 @assembly() - def wings_harness_assembly(self, parts: Optional[list[str]] = None) -> Cq.Assembly: + def wings_harness_assembly(self, + parts: Optional[list[str]] = None, + **kwargs) -> Cq.Assembly: """ Assembly of harness with all the wings """ result = ( Cq.Assembly() .add(self.harness.assembly(), name="harness", loc=Cq.Location((0, 0, 0))) - .add(self.wing_r1.assembly(parts), name="wing_r1") - .add(self.wing_r2.assembly(parts), name="wing_r2") - .add(self.wing_r3.assembly(parts), name="wing_r3") - .add(self.wing_l1.assembly(parts), name="wing_l1") - .add(self.wing_l2.assembly(parts), name="wing_l2") - .add(self.wing_l3.assembly(parts), name="wing_l3") + .add(self.wing_r1.assembly(parts, **kwargs), name="wing_r1") + .add(self.wing_r2.assembly(parts, **kwargs), name="wing_r2") + .add(self.wing_r3.assembly(parts, **kwargs), name="wing_r3") + .add(self.wing_l1.assembly(parts, **kwargs), name="wing_l1") + .add(self.wing_l2.assembly(parts, **kwargs), name="wing_l2") + .add(self.wing_l3.assembly(parts, **kwargs), name="wing_l3") ) for tag, offset in [("r1", 9), ("r2", 7), ("r3", 6), ("l1", 7), ("l2", 8), ("l3", 9)]: self.harness.hs_hirth_joint.add_constraints( diff --git a/nhf/touhou/houjuu_nue/wing.py b/nhf/touhou/houjuu_nue/wing.py index a1d5d37..2c70b57 100644 --- a/nhf/touhou/houjuu_nue/wing.py +++ b/nhf/touhou/houjuu_nue/wing.py @@ -622,7 +622,8 @@ class WingProfile(Model): @assembly() def assembly(self, parts: Optional[list[str]] = None, - angle_elbow_wrist: float = 0.0, + shoulder_deflection: float = 0.0, + elbow_wrist_deflection: float = 0.0, ) -> Cq.Assembly(): if parts is None: parts = ["s0", "shoulder", "s1", "elbow", "s2", "wrist", "s3"] @@ -636,7 +637,7 @@ class WingProfile(Model): if "s0" in parts: result.add(self.assembly_s0(), name="s0") if "shoulder" in parts: - result.add(self.shoulder_joint.assembly(), name="shoulder") + result.add(self.shoulder_joint.assembly(deflection=shoulder_deflection * 80), name="shoulder") if "s0" in parts and "shoulder" in parts: ( result @@ -656,7 +657,8 @@ class WingProfile(Model): .constrain("s1/shoulder_bot?conn1", f"shoulder/child/lip_{tag_bot}?conn1", "Plane") ) if "elbow" in parts: - result.add(self.elbow_joint.assembly(angle=angle_elbow_wrist), name="elbow") + angle = self.elbow_joint.disk_joint.movement_angle * elbow_wrist_deflection + result.add(self.elbow_joint.assembly(angle=angle), name="elbow") if "s1" in parts and "elbow" in parts: ( result @@ -676,7 +678,8 @@ class WingProfile(Model): .constrain("s2/elbow_bot?conn1", "elbow/child/lip?conn_bot1", "Plane") ) if "wrist" in parts: - result.add(self.wrist_joint.assembly(angle=angle_elbow_wrist), name="wrist") + angle = self.wrist_joint.disk_joint.movement_angle * elbow_wrist_deflection + result.add(self.wrist_joint.assembly(angle=elbow_wrist_deflection), name="wrist") if "s2" in parts and "wrist" in parts: # Mounted backwards to bend in other direction (