From a0ae8c91eb8ac86bbca075a4fae00d47c482cd62 Mon Sep 17 00:00:00 2001 From: Leni Aniva Date: Sat, 13 Jul 2024 16:19:17 -0700 Subject: [PATCH] feat: Remove fixed rotation constraints There is currently a bug when it comes to solving deeply nested assemblies. We need to come up with a solution. --- nhf/touhou/houjuu_nue/joints.py | 29 ++++++++++++++--------------- nhf/touhou/houjuu_nue/wing.py | 8 ++++---- nhf/utils.py | 2 +- 3 files changed, 19 insertions(+), 20 deletions(-) diff --git a/nhf/touhou/houjuu_nue/joints.py b/nhf/touhou/houjuu_nue/joints.py index a2f85a3..dfd5207 100644 --- a/nhf/touhou/houjuu_nue/joints.py +++ b/nhf/touhou/houjuu_nue/joints.py @@ -458,7 +458,7 @@ class DiskJoint(Model): ) ) result.faces("Z").hole(self.radius_axle * 2) # tube which holds the spring interior @@ -491,11 +491,11 @@ class DiskJoint(Model): disk: str, angle: float, ) -> Cq.Assembly: - ( + return ( assembly .constrain(f"{disk}?mate_bot", f"{housing_lower}?mate", "Plane") .constrain(f"{disk}?mate_top", f"{housing_upper}?mate", "Plane") - .constrain(f"{housing_lower}?dirX", f"{housing_upper}?dir", "Axis") + .constrain(f"{housing_lower}?dirX", f"{housing_upper}?dir", "Axis", param=0) .constrain(f"{housing_lower}?dirX", f"{disk}?dir", "Axis", param=angle) .constrain(f"{housing_lower}?dirY", f"{disk}?dir", "Axis", param=angle - 90) ) @@ -513,9 +513,9 @@ class DiskJoint(Model): .add(self.disk(), name="disk", color=Role.CHILD.color) .add(self.housing_lower(), name="housing_lower", color=Role.PARENT.color) .add(self.housing_upper(), name="housing_upper", color=Role.CASING.color) - .constrain("housing_lower", "Fixed") + #.constrain("housing_lower", "Fixed") ) - self.add_constraints( + result = self.add_constraints( result, housing_lower="housing_lower", housing_upper="housing_upper", @@ -574,10 +574,10 @@ class ElbowJoint: self.child_beam.beam() .add(self.disk_joint.disk(), name="disk", loc=flip * Cq.Location((-self.child_arm_radius, 0, -dz), (0, 0, 1), angle)) - .constrain("disk", "Fixed") - .constrain("top", "Fixed") - .constrain("bot", "Fixed") - .solve() + #.constrain("disk", "Fixed") + #.constrain("top", "Fixed") + #.constrain("bot", "Fixed") + #.solve() ) return result @@ -607,22 +607,21 @@ class ElbowJoint: loc=axial_offset * Cq.Location((0, 0, housing_dz))) .add(connector, name="connector", loc=axial_offset) - .constrain("housing", "Fixed") - .constrain("connector", "Fixed") - .solve() + #.constrain("housing", "Fixed") + #.constrain("connector", "Fixed") + #.solve() ) return result def assembly(self, angle: float = 0) -> Cq.Assembly: - da = self.disk_joint.tongue_span / 2 + 180 result = ( Cq.Assembly() .add(self.child_joint(), name="child", color=Role.CHILD.color) .add(self.parent_joint_lower(), name="parent_lower", color=Role.CASING.color) .add(self.parent_joint_upper(), name="parent_upper", color=Role.PARENT.color) - #.constrain("parent_lower", "Fixed") + #.constrain("child/disk?mate_bot", "Fixed") ) - self.disk_joint.add_constraints( + result = self.disk_joint.add_constraints( result, housing_lower="parent_lower", housing_upper="parent_upper/housing", diff --git a/nhf/touhou/houjuu_nue/wing.py b/nhf/touhou/houjuu_nue/wing.py index b3bc434..da83b90 100644 --- a/nhf/touhou/houjuu_nue/wing.py +++ b/nhf/touhou/houjuu_nue/wing.py @@ -364,8 +364,8 @@ class WingProfile: abscissa = 200 return [ (0, -abscissa), - (self.wrist_x - self.wrist_s * abscissa, - self.wrist_y - self.wrist_c * abscissa), + (self.wrist_x, -abscissa), + (self.wrist_x, self.wrist_y), (self.wrist_top_x, self.wrist_top_y), (0, abscissa), ] @@ -410,9 +410,9 @@ class WingProfile: profile = ( self.profile() .reset() - .polygon(self._mask_wrist(), mode='i') - .reset() .polygon(self._mask_elbow(), mode='s') + .reset() + .polygon(self._mask_wrist(), mode='i') ) return profile def surface_s2(self, diff --git a/nhf/utils.py b/nhf/utils.py index a834022..b1b92d8 100644 --- a/nhf/utils.py +++ b/nhf/utils.py @@ -48,7 +48,7 @@ def tagPlane(self, tag: str, else: v = Cq.Vector(direction) edge = Cq.Edge.makeLine(v * (-1), v) - self.eachpoint(edge.moved, useLocalCoordinates=True).tag(tag) + return self.eachpoint(edge.located, useLocalCoordinates=True).tag(tag) Cq.Workplane.tagPlane = tagPlane