fix: Collision of wing geometry

This commit is contained in:
Leni Aniva 2024-07-24 00:22:38 -07:00
parent a010baa099
commit 45213adda7
Signed by: aniva
GPG Key ID: 4D9B1C8D10EA4C50
3 changed files with 30 additions and 17 deletions

View File

@ -41,7 +41,8 @@ import nhf.touhou.houjuu_nue.harness as MH
from nhf.parts.item import Item
import nhf.utils
WING_DEFLECT = 10.0
WING_DEFLECT_ODD = 0.0
WING_DEFLECT_EVEN = 25.0
@dataclass
class Parameters(Model):
"""
@ -52,23 +53,26 @@ class Parameters(Model):
wing_r1: MW.WingR = field(default_factory=lambda: MW.WingR(
name="r1",
shoulder_angle_bias = WING_DEFLECT,
shoulder_angle_bias = WING_DEFLECT_ODD,
s0_top_hole=False,
s0_bot_hole=True,
arrow_height=350.0
))
wing_r2: MW.WingR = field(default_factory=lambda: MW.WingR(
name="r2",
shoulder_angle_bias = WING_DEFLECT_EVEN,
s0_top_hole=True,
s0_bot_hole=True,
))
wing_r3: MW.WingR = field(default_factory=lambda: MW.WingR(
name="r3",
shoulder_angle_bias = WING_DEFLECT,
shoulder_angle_bias = WING_DEFLECT_ODD,
s0_top_hole=True,
s0_bot_hole=False,
))
wing_l1: MW.WingL = field(default_factory=lambda: MW.WingL(
name="l1",
shoulder_angle_bias = WING_DEFLECT_EVEN,
wrist_angle=-60.0,
s0_top_hole=False,
s0_bot_hole=True,
@ -76,12 +80,13 @@ class Parameters(Model):
wing_l2: MW.WingL = field(default_factory=lambda: MW.WingL(
name="l2",
wrist_angle=-30.0,
shoulder_angle_bias = WING_DEFLECT,
shoulder_angle_bias = WING_DEFLECT_ODD,
s0_top_hole=True,
s0_bot_hole=True,
))
wing_l3: MW.WingL = field(default_factory=lambda: MW.WingL(
name="l3",
shoulder_angle_bias = WING_DEFLECT_EVEN,
wrist_angle=-0.0,
s0_top_hole=True,
s0_bot_hole=False,

View File

@ -303,7 +303,7 @@ class ShoulderJoint(Model):
directrix_id: int = 0
angle_neutral: float = -15.0
angle_max_deflection: float = 90.0
angle_max_deflection: float = 65.0
def __post_init__(self):
assert self.parent_lip_length * 2 < self.height
@ -1022,8 +1022,8 @@ class ElbowJoint(Model):
# Moves the hole to be some distance apart from 0
mount_r, mount_loc_angle, mount_parent_r = self.flexor.open_pos()
loc_span = Cq.Location.from2d(mount_r if child else mount_parent_r, 0)
r = (-mount_loc_angle - self.angle_neutral if child else 0) + 180 + self.flexor_offset_angle
loc_rot = Cq.Location.rot2d(r)
alpha = (-mount_loc_angle if child else 0) + 180 - self.flexor_offset_angle
loc_rot = Cq.Location.rot2d(alpha)
loc = loc_rot * loc_span * loc_mount_orient * loc_mount
return loc.flip_y() if self.flip and not child and not unflip else loc
@ -1062,14 +1062,17 @@ class ElbowJoint(Model):
Cq.Location((-lip_dz, 0, 0), (1, 0, 0), 90) *
Cq.Location((0, 0, 0), (0, 1, 0), 90)
)
loc_rot_neutral = Cq.Location.rot2d(self.angle_neutral)
loc_disk = flip_x * flip_z * Cq.Location((-self.child_arm_radius, 0, 0))
loc_cut_rel = Cq.Location((0, self.disk_joint.spring.radius_inner, -self.disk_joint.disk_bot_thickness))
disk_cut = self.disk_joint._disk_cut().located(
loc_lip.inverse * loc_cut_rel * loc_disk)
result = (
Cq.Assembly()
.add(self.disk_joint.disk(), name="disk", loc=Cq.Location((0, 0, -dz), (0,0,1), angle))
.add(self.lip().cut(disk_cut), name="lip", loc=loc_disk.inverse * loc_lip)
.add(self.disk_joint.disk(), name="disk",
loc=loc_rot_neutral * Cq.Location((0, 0, -dz), (0,0,1), angle))
.add(self.lip().cut(disk_cut), name="lip",
loc=loc_rot_neutral * loc_disk.inverse * loc_lip)
)
# Orientes the hole surface so it faces +X
loc_thickness = Cq.Location((-self.lip_thickness, 0, 0), (0, 1, 0), 90)
@ -1136,12 +1139,12 @@ class ElbowJoint(Model):
result.add(
self.actuator_mount(),
name="act",
loc=self.actuator_mount_loc(child=False) * loc_thickness)
loc=self.actuator_mount_loc(child=False, unflip=True) * loc_thickness)
else:
result.add(
Cq.Edge.makeLine((-1,0,0), (1,0,0)),
name="act",
loc=self.actuator_mount_loc(child=False))
loc=self.actuator_mount_loc(child=False, unflip=True))
return result
@assembly()

View File

@ -14,7 +14,12 @@ from nhf.parts.box import box_with_centre_holes, MountingBox, Hole
from nhf.parts.joints import HirthJoint
from nhf.parts.planar import extrude_with_markers
from nhf.touhou.houjuu_nue.joints import RootJoint, ShoulderJoint, ElbowJoint, DiskJoint
from nhf.touhou.houjuu_nue.electronics import LINEAR_ACTUATOR_21, LINEAR_ACTUATOR_50, ElectronicBoard
from nhf.touhou.houjuu_nue.electronics import (
LINEAR_ACTUATOR_10,
LINEAR_ACTUATOR_21,
LINEAR_ACTUATOR_50,
ElectronicBoard
)
import nhf.utils
@dataclass(kw_only=True)
@ -55,9 +60,9 @@ class WingProfile(Model):
movement_angle=55,
),
hole_diam=4.0,
angle_neutral=30.0,
angle_neutral=10.0,
actuator=LINEAR_ACTUATOR_50,
flexor_offset_angle=0,
flexor_offset_angle=30,
flip=False,
))
# Distance between the two spacers on the elbow, halved
@ -74,9 +79,9 @@ class WingProfile(Model):
child_arm_radius=23.0,
parent_arm_radius=30.0,
hole_diam=4.0,
angle_neutral=-30.0,
actuator=LINEAR_ACTUATOR_21,
flexor_offset_angle=0,
angle_neutral=0.0,
actuator=LINEAR_ACTUATOR_10,
flexor_offset_angle=30.0,
flip=True,
))
# Distance between the two spacers on the elbow, halved