feat: Add deflection parameter to assembly

This commit is contained in:
Leni Aniva 2024-07-18 14:41:29 -07:00
parent 052575017a
commit 0ed1a1a5a4
Signed by: aniva
GPG Key ID: 4D9B1C8D10EA4C50
2 changed files with 16 additions and 11 deletions

View File

@ -117,19 +117,21 @@ class Parameters(Model):
return self.wing_l3 return self.wing_l3
@assembly() @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 Assembly of harness with all the wings
""" """
result = ( result = (
Cq.Assembly() Cq.Assembly()
.add(self.harness.assembly(), name="harness", loc=Cq.Location((0, 0, 0))) .add(self.harness.assembly(), name="harness", loc=Cq.Location((0, 0, 0)))
.add(self.wing_r1.assembly(parts), name="wing_r1") .add(self.wing_r1.assembly(parts, **kwargs), name="wing_r1")
.add(self.wing_r2.assembly(parts), name="wing_r2") .add(self.wing_r2.assembly(parts, **kwargs), name="wing_r2")
.add(self.wing_r3.assembly(parts), name="wing_r3") .add(self.wing_r3.assembly(parts, **kwargs), name="wing_r3")
.add(self.wing_l1.assembly(parts), name="wing_l1") .add(self.wing_l1.assembly(parts, **kwargs), name="wing_l1")
.add(self.wing_l2.assembly(parts), name="wing_l2") .add(self.wing_l2.assembly(parts, **kwargs), name="wing_l2")
.add(self.wing_l3.assembly(parts), name="wing_l3") .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)]: for tag, offset in [("r1", 9), ("r2", 7), ("r3", 6), ("l1", 7), ("l2", 8), ("l3", 9)]:
self.harness.hs_hirth_joint.add_constraints( self.harness.hs_hirth_joint.add_constraints(

View File

@ -622,7 +622,8 @@ class WingProfile(Model):
@assembly() @assembly()
def assembly(self, def assembly(self,
parts: Optional[list[str]] = None, parts: Optional[list[str]] = None,
angle_elbow_wrist: float = 0.0, shoulder_deflection: float = 0.0,
elbow_wrist_deflection: float = 0.0,
) -> Cq.Assembly(): ) -> Cq.Assembly():
if parts is None: if parts is None:
parts = ["s0", "shoulder", "s1", "elbow", "s2", "wrist", "s3"] parts = ["s0", "shoulder", "s1", "elbow", "s2", "wrist", "s3"]
@ -636,7 +637,7 @@ class WingProfile(Model):
if "s0" in parts: if "s0" in parts:
result.add(self.assembly_s0(), name="s0") result.add(self.assembly_s0(), name="s0")
if "shoulder" in parts: 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: if "s0" in parts and "shoulder" in parts:
( (
result result
@ -656,7 +657,8 @@ class WingProfile(Model):
.constrain("s1/shoulder_bot?conn1", f"shoulder/child/lip_{tag_bot}?conn1", "Plane") .constrain("s1/shoulder_bot?conn1", f"shoulder/child/lip_{tag_bot}?conn1", "Plane")
) )
if "elbow" in parts: 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: if "s1" in parts and "elbow" in parts:
( (
result result
@ -676,7 +678,8 @@ class WingProfile(Model):
.constrain("s2/elbow_bot?conn1", "elbow/child/lip?conn_bot1", "Plane") .constrain("s2/elbow_bot?conn1", "elbow/child/lip?conn_bot1", "Plane")
) )
if "wrist" in parts: 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: if "s2" in parts and "wrist" in parts:
# Mounted backwards to bend in other direction # Mounted backwards to bend in other direction
( (