2024-06-28 20:07:37 -07:00
|
|
|
"""
|
|
|
|
This file describes the shapes of the wing shells. The joints are defined in
|
|
|
|
`__init__.py`.
|
|
|
|
"""
|
2024-06-24 16:13:15 -07:00
|
|
|
import math
|
2024-07-11 16:02:54 -07:00
|
|
|
from enum import Enum
|
2024-07-15 22:57:38 -07:00
|
|
|
from dataclasses import dataclass, field
|
|
|
|
from typing import Mapping, Tuple, Optional
|
2024-07-22 13:26:37 -07:00
|
|
|
|
2024-06-24 16:13:15 -07:00
|
|
|
import cadquery as Cq
|
2024-07-04 12:03:38 -07:00
|
|
|
from nhf import Material, Role
|
2024-07-16 15:42:39 -07:00
|
|
|
from nhf.build import Model, TargetKind, target, assembly, submodel
|
2024-07-15 22:57:38 -07:00
|
|
|
from nhf.parts.box import box_with_centre_holes, MountingBox, Hole
|
2024-07-04 00:42:14 -07:00
|
|
|
from nhf.parts.joints import HirthJoint
|
2024-07-17 19:28:56 -07:00
|
|
|
from nhf.parts.planar import extrude_with_markers
|
2024-07-21 21:49:28 -07:00
|
|
|
from nhf.touhou.houjuu_nue.joints import RootJoint, ShoulderJoint, ElbowJoint, DiskJoint
|
2024-07-24 00:22:38 -07:00
|
|
|
from nhf.touhou.houjuu_nue.electronics import (
|
|
|
|
LINEAR_ACTUATOR_10,
|
|
|
|
LINEAR_ACTUATOR_21,
|
|
|
|
LINEAR_ACTUATOR_50,
|
2024-08-01 22:38:45 -07:00
|
|
|
ElectronicBoard,
|
2024-08-03 23:31:36 -07:00
|
|
|
LightStrip,
|
2024-08-01 22:38:45 -07:00
|
|
|
ELECTRONIC_MOUNT_HEXNUT,
|
2024-07-24 00:22:38 -07:00
|
|
|
)
|
2024-07-06 16:41:13 -07:00
|
|
|
import nhf.utils
|
2024-06-24 16:13:15 -07:00
|
|
|
|
2024-07-24 21:49:54 -07:00
|
|
|
ELBOW_PARAMS = dict(
|
|
|
|
hole_diam=4.0,
|
|
|
|
actuator=LINEAR_ACTUATOR_50,
|
|
|
|
parent_arm_width=15,
|
|
|
|
)
|
2024-07-25 13:05:12 -07:00
|
|
|
WRIST_DISK_PARAMS = dict(
|
|
|
|
movement_angle=30,
|
|
|
|
radius_disk=13.0,
|
|
|
|
radius_housing=15.0,
|
|
|
|
)
|
2024-07-24 21:49:54 -07:00
|
|
|
WRIST_PARAMS = dict(
|
|
|
|
)
|
|
|
|
|
2024-07-16 14:25:17 -07:00
|
|
|
@dataclass(kw_only=True)
|
2024-07-15 22:57:38 -07:00
|
|
|
class WingProfile(Model):
|
2024-07-09 19:57:54 -07:00
|
|
|
|
2024-07-15 22:57:38 -07:00
|
|
|
name: str = "wing"
|
2024-07-07 21:01:40 -07:00
|
|
|
|
2024-07-16 21:20:45 -07:00
|
|
|
base_width: float = 80.0
|
2024-07-19 16:13:33 -07:00
|
|
|
root_joint: RootJoint = field(default_factory=lambda: RootJoint())
|
2024-07-14 00:47:44 -07:00
|
|
|
|
|
|
|
panel_thickness: float = 25.4 / 16
|
2024-07-29 01:06:27 -07:00
|
|
|
# s0 is armoured
|
|
|
|
panel_thickness_s0: float = 25.4 / 8
|
2024-07-19 22:29:57 -07:00
|
|
|
# 1/4" acrylic for the spacer. Anything thinner would threathen structural
|
|
|
|
# strength
|
|
|
|
spacer_thickness: float = 25.4 / 4
|
2024-07-25 22:40:44 -07:00
|
|
|
rod_width: float = 10.0
|
2024-07-14 17:56:02 -07:00
|
|
|
|
2024-08-03 23:31:36 -07:00
|
|
|
light_strip: LightStrip = LightStrip()
|
|
|
|
|
2024-07-16 15:42:39 -07:00
|
|
|
shoulder_joint: ShoulderJoint = field(default_factory=lambda: ShoulderJoint(
|
|
|
|
))
|
2024-07-17 21:37:08 -07:00
|
|
|
shoulder_angle_bias: float = 0.0
|
2024-07-17 00:30:41 -07:00
|
|
|
shoulder_width: float = 36.0
|
2024-07-19 14:06:13 -07:00
|
|
|
shoulder_tip_x: float = -260.0
|
|
|
|
shoulder_tip_y: float = 165.0
|
2024-07-22 15:20:09 -07:00
|
|
|
shoulder_tip_bezier_x: float = 100.0
|
|
|
|
shoulder_tip_bezier_y: float = -50.0
|
|
|
|
shoulder_base_bezier_x: float = -30.0
|
|
|
|
shoulder_base_bezier_y: float = 30.0
|
2024-07-09 19:57:54 -07:00
|
|
|
|
2024-07-29 10:49:03 -07:00
|
|
|
s0_hole_width: float = 40.0
|
|
|
|
s0_hole_height: float = 10.0
|
2024-07-21 23:34:02 -07:00
|
|
|
s0_top_hole: bool = False
|
|
|
|
s0_bot_hole: bool = True
|
|
|
|
|
|
|
|
electronic_board: ElectronicBoard = field(default_factory=lambda: ElectronicBoard())
|
|
|
|
|
2024-07-15 22:57:38 -07:00
|
|
|
s1_thickness: float = 25.0
|
2024-07-09 21:13:16 -07:00
|
|
|
|
2024-07-24 21:49:54 -07:00
|
|
|
elbow_joint: ElbowJoint
|
2024-07-17 10:22:59 -07:00
|
|
|
# Distance between the two spacers on the elbow, halved
|
|
|
|
elbow_h2: float = 5.0
|
2024-07-09 21:13:16 -07:00
|
|
|
|
2024-07-24 21:49:54 -07:00
|
|
|
wrist_joint: ElbowJoint
|
2024-07-17 10:22:59 -07:00
|
|
|
# Distance between the two spacers on the elbow, halved
|
|
|
|
wrist_h2: float = 5.0
|
2024-07-09 21:13:16 -07:00
|
|
|
|
2024-07-16 11:55:38 -07:00
|
|
|
mat_panel: Material = Material.ACRYLIC_TRANSLUSCENT
|
|
|
|
mat_bracket: Material = Material.ACRYLIC_TRANSPARENT
|
|
|
|
mat_hs_joint: Material = Material.PLASTIC_PLA
|
|
|
|
role_panel: Role = Role.STRUCTURE
|
2024-07-15 22:57:38 -07:00
|
|
|
|
2024-07-16 17:18:28 -07:00
|
|
|
# Subclass must populate
|
2024-07-17 21:17:50 -07:00
|
|
|
elbow_bot_loc: Cq.Location
|
2024-07-16 17:18:28 -07:00
|
|
|
elbow_height: float
|
2024-07-17 21:17:50 -07:00
|
|
|
wrist_bot_loc: Cq.Location
|
2024-07-16 17:18:28 -07:00
|
|
|
wrist_height: float
|
2024-07-24 21:49:54 -07:00
|
|
|
elbow_rotate: float
|
2024-07-20 22:55:43 -07:00
|
|
|
wrist_rotate: float = -30.0
|
2024-07-21 22:13:56 -07:00
|
|
|
# Position of the elbow axle with 0 being bottom and 1 being top (flipped on the left side)
|
2024-07-24 18:03:43 -07:00
|
|
|
elbow_axle_pos: float
|
|
|
|
wrist_axle_pos: float
|
|
|
|
elbow_joint_overlap_median: float
|
|
|
|
wrist_joint_overlap_median: float
|
2024-07-16 17:18:28 -07:00
|
|
|
|
2024-07-18 21:07:08 -07:00
|
|
|
# False for the right side, True for the left side
|
2024-07-19 23:49:38 -07:00
|
|
|
flip: bool
|
2024-07-16 17:18:28 -07:00
|
|
|
|
2024-07-09 21:13:16 -07:00
|
|
|
def __post_init__(self):
|
2024-07-15 22:57:38 -07:00
|
|
|
super().__init__(name=self.name)
|
2024-07-09 21:13:16 -07:00
|
|
|
|
2024-07-22 15:02:26 -07:00
|
|
|
assert self.electronic_board.length == self.shoulder_height
|
|
|
|
|
2024-07-17 21:17:50 -07:00
|
|
|
self.elbow_top_loc = self.elbow_bot_loc * Cq.Location.from2d(0, self.elbow_height)
|
|
|
|
self.wrist_top_loc = self.wrist_bot_loc * Cq.Location.from2d(0, self.wrist_height)
|
2024-07-24 22:24:23 -07:00
|
|
|
self.elbow_axle_loc = self.elbow_bot_loc * \
|
|
|
|
Cq.Location.from2d(0, self.elbow_height * self.elbow_axle_pos)
|
|
|
|
self.wrist_axle_loc = self.wrist_bot_loc * \
|
|
|
|
Cq.Location.from2d(0, self.wrist_height * self.wrist_axle_pos)
|
2024-07-11 16:02:54 -07:00
|
|
|
|
2024-07-19 14:06:13 -07:00
|
|
|
assert self.elbow_joint.total_thickness < min(self.s1_thickness, self.s2_thickness)
|
|
|
|
assert self.wrist_joint.total_thickness < min(self.s2_thickness, self.s3_thickness)
|
|
|
|
|
2024-07-17 21:37:08 -07:00
|
|
|
self.shoulder_joint.angle_neutral = -self.shoulder_angle_neutral - self.shoulder_angle_bias
|
2024-07-23 16:49:25 -07:00
|
|
|
self.shoulder_axle_loc = Cq.Location.from2d(self.shoulder_tip_x, self.shoulder_tip_y - self.shoulder_width / 2, 0)
|
2024-07-19 16:37:47 -07:00
|
|
|
self.shoulder_joint.child_guard_width = self.s1_thickness + self.panel_thickness * 2
|
2024-07-22 15:02:26 -07:00
|
|
|
|
2024-07-19 15:06:57 -07:00
|
|
|
assert self.spacer_thickness == self.root_joint.child_mount_thickness
|
|
|
|
|
2024-07-21 22:13:56 -07:00
|
|
|
@property
|
|
|
|
def s2_thickness(self) -> float:
|
|
|
|
"""
|
|
|
|
s2 needs to duck under s1, so its thinner
|
|
|
|
"""
|
|
|
|
return self.s1_thickness - 2 * self.panel_thickness
|
|
|
|
@property
|
|
|
|
def s3_thickness(self) -> float:
|
|
|
|
"""
|
|
|
|
s3 does not need to duck under s2
|
|
|
|
"""
|
2024-07-22 09:49:16 -07:00
|
|
|
extra = 2 * self.panel_thickness if self.flip else 0
|
|
|
|
return self.s1_thickness - 2 * self.panel_thickness - extra
|
2024-07-21 22:13:56 -07:00
|
|
|
|
2024-07-25 09:47:41 -07:00
|
|
|
@submodel(name="root-joint")
|
|
|
|
def submodel_root_joint(self) -> Model:
|
|
|
|
return self.root_joint
|
2024-07-16 22:26:06 -07:00
|
|
|
@submodel(name="shoulder-joint")
|
|
|
|
def submodel_shoulder_joint(self) -> Model:
|
|
|
|
return self.shoulder_joint
|
|
|
|
@submodel(name="elbow-joint")
|
|
|
|
def submodel_elbow_joint(self) -> Model:
|
|
|
|
return self.elbow_joint
|
|
|
|
@submodel(name="wrist-joint")
|
|
|
|
def submodel_wrist_joint(self) -> Model:
|
|
|
|
return self.wrist_joint
|
|
|
|
|
2024-07-15 22:57:38 -07:00
|
|
|
@property
|
|
|
|
def root_height(self) -> float:
|
|
|
|
return self.shoulder_joint.height
|
|
|
|
|
2024-07-16 17:18:28 -07:00
|
|
|
@property
|
|
|
|
def shoulder_height(self) -> float:
|
|
|
|
return self.shoulder_joint.height
|
|
|
|
|
2024-07-17 00:30:41 -07:00
|
|
|
def outer_profile_s0(self) -> Cq.Sketch:
|
|
|
|
"""
|
2024-07-22 15:20:09 -07:00
|
|
|
The outer boundary of s0 top/bottom slots
|
2024-07-17 00:30:41 -07:00
|
|
|
"""
|
2024-07-15 22:57:38 -07:00
|
|
|
tip_x = self.shoulder_tip_x
|
|
|
|
tip_y = self.shoulder_tip_y
|
2024-07-17 00:30:41 -07:00
|
|
|
return (
|
2024-07-15 22:57:38 -07:00
|
|
|
Cq.Sketch()
|
|
|
|
.spline([
|
|
|
|
(0, 0),
|
|
|
|
(-30.0, 80.0),
|
|
|
|
(tip_x, tip_y)
|
|
|
|
])
|
2024-07-17 00:30:41 -07:00
|
|
|
#.segment(
|
|
|
|
# (tip_x, tip_y),
|
|
|
|
# (tip_x - 10, tip_y),
|
|
|
|
#)
|
|
|
|
)
|
2024-07-22 15:20:09 -07:00
|
|
|
def inner_profile_s0(self) -> Cq.Edge:
|
|
|
|
"""
|
|
|
|
The inner boundary of s0
|
|
|
|
"""
|
|
|
|
tip_x = self.shoulder_tip_x
|
|
|
|
tip_y = self.shoulder_tip_y
|
|
|
|
dx2 = self.shoulder_tip_bezier_x
|
|
|
|
dy2 = self.shoulder_tip_bezier_y
|
|
|
|
dx1 = self.shoulder_base_bezier_x
|
|
|
|
dy1 = self.shoulder_base_bezier_y
|
|
|
|
sw = self.shoulder_width
|
|
|
|
return Cq.Edge.makeBezier(
|
|
|
|
[
|
|
|
|
Cq.Vector(*p)
|
|
|
|
for p in [
|
|
|
|
(tip_x, tip_y - sw),
|
|
|
|
(tip_x + dx2, tip_y - sw + dy2),
|
|
|
|
(-self.base_width + dx1, dy1),
|
|
|
|
(-self.base_width, 0),
|
|
|
|
]
|
|
|
|
]
|
|
|
|
)
|
2024-07-17 00:30:41 -07:00
|
|
|
|
2024-07-17 01:06:52 -07:00
|
|
|
@property
|
|
|
|
def shoulder_angle_neutral(self) -> float:
|
|
|
|
"""
|
|
|
|
Returns the neutral angle of the shoulder
|
|
|
|
"""
|
2024-07-22 15:20:09 -07:00
|
|
|
result = math.degrees(math.atan2(-self.shoulder_tip_bezier_y, self.shoulder_tip_bezier_x))
|
2024-07-17 01:06:52 -07:00
|
|
|
assert result >= 0
|
2024-07-23 16:49:25 -07:00
|
|
|
return result / 2
|
2024-07-17 01:06:52 -07:00
|
|
|
|
2024-07-17 00:30:41 -07:00
|
|
|
@target(name="profile-s0", kind=TargetKind.DXF)
|
2024-07-21 23:34:02 -07:00
|
|
|
def profile_s0(self, top: bool = True) -> Cq.Sketch:
|
2024-07-17 00:30:41 -07:00
|
|
|
tip_x = self.shoulder_tip_x
|
|
|
|
tip_y = self.shoulder_tip_y
|
2024-07-22 15:20:09 -07:00
|
|
|
dx2 = self.shoulder_tip_bezier_x
|
|
|
|
dy2 = self.shoulder_tip_bezier_y
|
|
|
|
dx1 = self.shoulder_base_bezier_x
|
|
|
|
dy1 = self.shoulder_base_bezier_y
|
2024-07-17 00:30:41 -07:00
|
|
|
sw = self.shoulder_width
|
|
|
|
sketch = (
|
|
|
|
self.outer_profile_s0()
|
|
|
|
.segment((-self.base_width, 0), (0, 0))
|
2024-07-15 22:57:38 -07:00
|
|
|
.segment(
|
|
|
|
(tip_x, tip_y),
|
2024-07-17 00:30:41 -07:00
|
|
|
(tip_x, tip_y - sw),
|
2024-07-15 22:57:38 -07:00
|
|
|
)
|
2024-07-22 15:20:09 -07:00
|
|
|
.bezier([
|
2024-07-17 00:30:41 -07:00
|
|
|
(tip_x, tip_y - sw),
|
2024-07-22 15:20:09 -07:00
|
|
|
(tip_x + dx2, tip_y - sw + dy2),
|
|
|
|
(-self.base_width + dx1, dy1),
|
2024-07-16 21:20:45 -07:00
|
|
|
(-self.base_width, 0),
|
2024-07-22 15:20:09 -07:00
|
|
|
])
|
2024-07-15 22:57:38 -07:00
|
|
|
.assemble()
|
2024-07-19 14:06:13 -07:00
|
|
|
.push([self.shoulder_axle_loc.to2d_pos()])
|
|
|
|
.circle(self.shoulder_joint.radius, mode='a')
|
|
|
|
.circle(self.shoulder_joint.bolt.diam_head / 2, mode='s')
|
2024-07-15 22:57:38 -07:00
|
|
|
)
|
2024-07-21 23:34:02 -07:00
|
|
|
top = top == self.flip
|
|
|
|
if (self.s0_top_hole and top) or (self.s0_bot_hole and not top):
|
2024-07-29 10:49:03 -07:00
|
|
|
assert self.base_width > self.s0_hole_width
|
|
|
|
x = (self.base_width - self.s0_hole_width) / 2
|
2024-07-21 23:34:02 -07:00
|
|
|
sketch = (
|
|
|
|
sketch
|
|
|
|
.reset()
|
2024-07-29 10:49:03 -07:00
|
|
|
.polygon([
|
|
|
|
(-x, 0),
|
|
|
|
(-x, self.s0_hole_height),
|
|
|
|
(-self.base_width + x, self.s0_hole_height),
|
|
|
|
(-self.base_width + x, 0),
|
|
|
|
], mode='s')
|
2024-07-21 23:34:02 -07:00
|
|
|
)
|
2024-07-15 22:57:38 -07:00
|
|
|
return sketch
|
|
|
|
|
2024-07-16 21:20:45 -07:00
|
|
|
def outer_shell_s0(self) -> Cq.Workplane:
|
2024-07-29 01:06:27 -07:00
|
|
|
t = self.panel_thickness_s0
|
2024-07-17 00:30:41 -07:00
|
|
|
profile = Cq.Wire.assembleEdges(self.outer_profile_s0().edges().vals())
|
2024-07-16 21:20:45 -07:00
|
|
|
result = (
|
|
|
|
Cq.Workplane('XZ')
|
|
|
|
.rect(t, self.root_height + t*2, centered=(False, False))
|
2024-07-17 00:30:41 -07:00
|
|
|
.sweep(profile)
|
2024-07-16 21:20:45 -07:00
|
|
|
)
|
|
|
|
plane = result.copyWorkplane(Cq.Workplane('XZ'))
|
|
|
|
plane.moveTo(0, 0).tagPlane("bot")
|
|
|
|
plane.moveTo(0, self.root_height + t*2).tagPlane("top")
|
|
|
|
return result
|
2024-07-22 15:20:09 -07:00
|
|
|
def inner_shell_s0(self) -> Cq.Workplane:
|
2024-07-29 01:06:27 -07:00
|
|
|
t = self.panel_thickness_s0
|
2024-07-22 15:20:09 -07:00
|
|
|
#profile = Cq.Wire.assembleEdges(self.inner_profile_s0())
|
|
|
|
result = (
|
|
|
|
Cq.Workplane('XZ')
|
|
|
|
.rect(t, self.root_height + t*2, centered=(False, False))
|
|
|
|
.sweep(self.inner_profile_s0())
|
|
|
|
)
|
|
|
|
plane = result.copyWorkplane(Cq.Workplane('XZ'))
|
|
|
|
plane.moveTo(t, 0).tagPlane("bot")
|
|
|
|
plane.moveTo(t, self.root_height + t*2).tagPlane("top")
|
|
|
|
return result
|
2024-07-16 21:20:45 -07:00
|
|
|
|
2024-07-16 15:42:39 -07:00
|
|
|
@submodel(name="spacer-s0-shoulder")
|
2024-07-23 16:49:25 -07:00
|
|
|
def spacer_s0_shoulder(self, left: bool=True) -> MountingBox:
|
2024-07-15 22:57:38 -07:00
|
|
|
"""
|
2024-07-19 16:13:33 -07:00
|
|
|
Shoulder side serves double purpose for mounting shoulder joint and
|
|
|
|
structural support
|
2024-07-15 22:57:38 -07:00
|
|
|
"""
|
2024-07-23 16:49:25 -07:00
|
|
|
sign = 1 if left else -1
|
2024-07-15 22:57:38 -07:00
|
|
|
holes = [
|
|
|
|
hole
|
2024-07-17 00:30:41 -07:00
|
|
|
for i, (x, y) in enumerate(self.shoulder_joint.parent_conn_hole_pos)
|
2024-07-15 22:57:38 -07:00
|
|
|
for hole in [
|
2024-07-23 16:49:25 -07:00
|
|
|
Hole(x=x, y=sign * y, tag=f"conn_top{i}"),
|
|
|
|
Hole(x=-x, y=sign * y, tag=f"conn_bot{i}"),
|
2024-07-15 22:57:38 -07:00
|
|
|
]
|
|
|
|
]
|
|
|
|
return MountingBox(
|
|
|
|
length=self.shoulder_joint.height,
|
2024-07-17 00:30:41 -07:00
|
|
|
width=self.shoulder_joint.parent_lip_width,
|
2024-07-15 22:57:38 -07:00
|
|
|
thickness=self.spacer_thickness,
|
|
|
|
holes=holes,
|
|
|
|
hole_diam=self.shoulder_joint.parent_conn_hole_diam,
|
|
|
|
centred=(True, True),
|
2024-07-16 17:18:28 -07:00
|
|
|
flip_y=self.flip,
|
2024-07-23 16:49:25 -07:00
|
|
|
centre_bot_top_tags=True,
|
2024-07-15 22:57:38 -07:00
|
|
|
)
|
2024-07-25 22:40:44 -07:00
|
|
|
@submodel(name="spacer-s0-base")
|
2024-07-15 22:57:38 -07:00
|
|
|
def spacer_s0_base(self) -> MountingBox:
|
|
|
|
"""
|
2024-07-19 16:13:33 -07:00
|
|
|
Base side connects to H-S joint
|
2024-07-15 22:57:38 -07:00
|
|
|
"""
|
2024-07-19 15:06:57 -07:00
|
|
|
assert self.root_joint.child_width < self.base_width
|
|
|
|
assert self.root_joint.child_corner_dx * 2 < self.base_width
|
|
|
|
assert self.root_joint.child_corner_dz * 2 < self.root_height
|
|
|
|
dy = self.root_joint.child_corner_dx
|
|
|
|
dx = self.root_joint.child_corner_dz
|
2024-07-15 22:57:38 -07:00
|
|
|
holes = [
|
2024-07-16 21:20:45 -07:00
|
|
|
Hole(x=-dx, y=-dy),
|
|
|
|
Hole(x=dx, y=-dy),
|
|
|
|
Hole(x=dx, y=dy),
|
|
|
|
Hole(x=-dx, y=dy),
|
2024-07-25 09:47:41 -07:00
|
|
|
Hole(x=0, y=0, diam=self.root_joint.axis_diam, tag="axle"),
|
2024-07-15 22:57:38 -07:00
|
|
|
]
|
|
|
|
return MountingBox(
|
|
|
|
length=self.root_height,
|
2024-07-19 15:06:57 -07:00
|
|
|
width=self.root_joint.child_width,
|
2024-07-15 22:57:38 -07:00
|
|
|
thickness=self.spacer_thickness,
|
|
|
|
holes=holes,
|
2024-07-19 15:06:57 -07:00
|
|
|
hole_diam=self.root_joint.corner_hole_diam,
|
2024-07-15 22:57:38 -07:00
|
|
|
centred=(True, True),
|
2024-07-16 17:18:28 -07:00
|
|
|
flip_y=self.flip,
|
2024-07-15 22:57:38 -07:00
|
|
|
)
|
2024-07-21 23:34:02 -07:00
|
|
|
@submodel(name="spacer-s0-electronic")
|
2024-07-22 15:02:26 -07:00
|
|
|
def spacer_s0_electronic_mount(self) -> MountingBox:
|
2024-08-01 22:38:45 -07:00
|
|
|
"""
|
|
|
|
This one has circular holes for the screws
|
|
|
|
"""
|
2024-07-19 16:13:33 -07:00
|
|
|
return MountingBox(
|
2024-07-22 15:02:26 -07:00
|
|
|
holes=self.electronic_board.mount_holes,
|
|
|
|
hole_diam=self.electronic_board.mount_hole_diam,
|
2024-07-19 16:13:33 -07:00
|
|
|
length=self.root_height,
|
2024-07-22 15:02:26 -07:00
|
|
|
width=self.electronic_board.width,
|
2024-07-21 23:34:02 -07:00
|
|
|
centred=(True, True),
|
2024-07-19 16:13:33 -07:00
|
|
|
thickness=self.spacer_thickness,
|
2024-07-25 13:19:56 -07:00
|
|
|
flip_y=False,#self.flip,
|
2024-07-22 15:02:26 -07:00
|
|
|
generate_reverse_tags=True,
|
2024-07-19 16:13:33 -07:00
|
|
|
)
|
2024-08-01 22:38:45 -07:00
|
|
|
@submodel(name="spacer-s0-electronic2")
|
|
|
|
def spacer_s0_electronic_mount2(self) -> MountingBox:
|
|
|
|
"""
|
|
|
|
This one has hexagonal holes
|
|
|
|
"""
|
|
|
|
face = ELECTRONIC_MOUNT_HEXNUT.cutting_face()
|
|
|
|
holes = [
|
|
|
|
Hole(x=h.x, y=h.y, face=face, tag=h.tag)
|
|
|
|
for h in self.electronic_board.mount_holes
|
|
|
|
]
|
2024-08-02 00:28:12 -07:00
|
|
|
def post(sketch: Cq.Sketch) -> Cq.Sketch:
|
|
|
|
return (
|
|
|
|
sketch
|
|
|
|
.push([(0,0)])
|
|
|
|
.rect(70, 130, mode='s')
|
|
|
|
)
|
2024-08-01 22:38:45 -07:00
|
|
|
return MountingBox(
|
|
|
|
holes=holes,
|
|
|
|
hole_diam=self.electronic_board.mount_hole_diam,
|
|
|
|
length=self.root_height,
|
|
|
|
width=self.electronic_board.width,
|
|
|
|
centred=(True, True),
|
|
|
|
thickness=self.spacer_thickness,
|
|
|
|
flip_y=False,#self.flip,
|
|
|
|
generate_reverse_tags=True,
|
2024-08-02 00:28:12 -07:00
|
|
|
profile_callback=post,
|
2024-08-01 22:38:45 -07:00
|
|
|
)
|
2024-07-24 12:45:38 -07:00
|
|
|
@submodel(name="spacer-s0-shoulder-act")
|
|
|
|
def spacer_s0_shoulder_act(self) -> MountingBox:
|
|
|
|
return MountingBox(
|
2024-08-03 23:31:36 -07:00
|
|
|
holes=[Hole(x=0)],
|
2024-07-24 12:45:38 -07:00
|
|
|
hole_diam=self.shoulder_joint.actuator.back_hole_diam,
|
|
|
|
length=self.root_height,
|
|
|
|
width=10.0,
|
|
|
|
centred=(True, True),
|
|
|
|
thickness=self.spacer_thickness,
|
|
|
|
flip_y=self.flip,
|
|
|
|
generate_reverse_tags=True,
|
|
|
|
)
|
2024-07-15 22:57:38 -07:00
|
|
|
|
|
|
|
def surface_s0(self, top: bool = False) -> Cq.Workplane:
|
2024-07-19 16:13:33 -07:00
|
|
|
base_dx = -(self.base_width - self.root_joint.child_width) / 2 - 10
|
2024-07-24 16:17:07 -07:00
|
|
|
base_dy = self.root_joint.base_to_surface_thickness
|
2024-07-21 23:34:02 -07:00
|
|
|
#mid_spacer_loc = (
|
|
|
|
# Cq.Location.from2d(0, -self.shoulder_width/2) *
|
|
|
|
# self.shoulder_axle_loc *
|
|
|
|
# Cq.Location.rot2d(self.shoulder_joint.angle_neutral)
|
|
|
|
#)
|
2024-07-23 16:49:25 -07:00
|
|
|
axle_rotate = Cq.Location.rot2d(-self.shoulder_angle_neutral)
|
2024-07-15 22:57:38 -07:00
|
|
|
tags = [
|
2024-07-23 16:49:25 -07:00
|
|
|
("shoulder_left",
|
|
|
|
self.shoulder_axle_loc * axle_rotate * self.shoulder_joint.parent_lip_loc(left=True)),
|
|
|
|
("shoulder_right",
|
|
|
|
self.shoulder_axle_loc * axle_rotate * self.shoulder_joint.parent_lip_loc(left=False)),
|
2024-07-24 12:45:38 -07:00
|
|
|
("shoulder_act",
|
2024-08-01 00:26:25 -07:00
|
|
|
self.shoulder_axle_loc * axle_rotate * Cq.Location.from2d(100, -20)),
|
2024-07-17 19:28:56 -07:00
|
|
|
("base", Cq.Location.from2d(base_dx, base_dy, 90)),
|
2024-08-01 00:26:25 -07:00
|
|
|
("electronic_mount", Cq.Location.from2d(-35, 65, 60)),
|
2024-07-15 22:57:38 -07:00
|
|
|
]
|
2024-07-17 19:28:56 -07:00
|
|
|
result = extrude_with_markers(
|
2024-07-21 23:34:02 -07:00
|
|
|
self.profile_s0(top=top),
|
2024-07-29 01:06:27 -07:00
|
|
|
self.panel_thickness_s0,
|
2024-07-15 22:57:38 -07:00
|
|
|
tags,
|
|
|
|
reverse=not top,
|
|
|
|
)
|
2024-07-16 21:20:45 -07:00
|
|
|
h = self.panel_thickness if top else 0
|
|
|
|
result.copyWorkplane(Cq.Workplane('XZ')).moveTo(0, h).tagPlane("corner")
|
2024-07-22 15:20:09 -07:00
|
|
|
result.copyWorkplane(Cq.Workplane('XZ')).moveTo(-self.base_width, h).tagPlane("corner_left")
|
2024-07-16 21:20:45 -07:00
|
|
|
return result
|
2024-07-15 22:57:38 -07:00
|
|
|
|
2024-07-16 15:42:39 -07:00
|
|
|
@assembly()
|
2024-07-23 22:40:49 -07:00
|
|
|
def assembly_s0(
|
|
|
|
self,
|
|
|
|
ignore_electronics: bool=False) -> Cq.Assembly:
|
2024-07-15 22:57:38 -07:00
|
|
|
result = (
|
|
|
|
Cq.Assembly()
|
2024-07-16 11:55:38 -07:00
|
|
|
.addS(self.surface_s0(top=True), name="bot",
|
|
|
|
material=self.mat_panel, role=self.role_panel)
|
|
|
|
.addS(self.surface_s0(top=False), name="top",
|
2024-07-17 00:30:41 -07:00
|
|
|
material=self.mat_panel, role=self.role_panel,
|
|
|
|
loc=Cq.Location((0, 0, self.root_height + self.panel_thickness)))
|
|
|
|
.constrain("bot", "Fixed")
|
|
|
|
.constrain("top", "Fixed")
|
2024-07-22 15:20:09 -07:00
|
|
|
.constrain("bot@faces@>Z", "top@faces@<Z", "Point",
|
|
|
|
param=self.shoulder_height)
|
2024-07-16 21:20:45 -07:00
|
|
|
.addS(self.outer_shell_s0(), name="outer_shell",
|
|
|
|
material=self.mat_panel, role=self.role_panel)
|
|
|
|
.constrain("bot?corner", "outer_shell?bot", "Plane", param=0)
|
|
|
|
.constrain("top?corner", "outer_shell?top", "Plane", param=0)
|
2024-07-22 15:20:09 -07:00
|
|
|
#.addS(self.inner_shell_s0(), name="inner_shell",
|
|
|
|
# material=self.mat_panel, role=self.role_panel)
|
|
|
|
#.constrain("bot?corner_left", "inner_shell?bot", "Point")
|
|
|
|
#.constrain("top?corner_left", "inner_shell?top", "Point")
|
2024-07-15 22:57:38 -07:00
|
|
|
)
|
|
|
|
for o, tag in [
|
2024-07-23 16:49:25 -07:00
|
|
|
(self.spacer_s0_shoulder(left=True).generate(), "shoulder_left"),
|
|
|
|
(self.spacer_s0_shoulder(left=False).generate(), "shoulder_right"),
|
2024-07-24 12:45:38 -07:00
|
|
|
(self.spacer_s0_shoulder_act().generate(), "shoulder_act"),
|
2024-07-19 16:13:33 -07:00
|
|
|
(self.spacer_s0_base().generate(), "base"),
|
2024-07-22 15:02:26 -07:00
|
|
|
(self.spacer_s0_electronic_mount().generate(), "electronic_mount"),
|
2024-07-15 22:57:38 -07:00
|
|
|
]:
|
2024-07-16 17:18:28 -07:00
|
|
|
top_tag, bot_tag = "top", "bot"
|
2024-07-25 13:19:56 -07:00
|
|
|
if self.flip and tag.startswith("shoulder"):
|
2024-07-16 17:18:28 -07:00
|
|
|
top_tag, bot_tag = bot_tag, top_tag
|
2024-07-15 22:57:38 -07:00
|
|
|
(
|
|
|
|
result
|
2024-07-16 11:55:38 -07:00
|
|
|
.addS(o, name=tag,
|
|
|
|
role=Role.STRUCTURE | Role.CONNECTION,
|
|
|
|
material=self.mat_bracket)
|
2024-07-16 17:18:28 -07:00
|
|
|
.constrain(f"{tag}?{bot_tag}", f"bot?{tag}", "Plane")
|
|
|
|
.constrain(f"{tag}?{top_tag}", f"top?{tag}", "Plane")
|
2024-07-15 22:57:38 -07:00
|
|
|
.constrain(f"{tag}?dir", f"top?{tag}_dir", "Axis")
|
|
|
|
)
|
2024-08-01 22:38:45 -07:00
|
|
|
result.addS(
|
|
|
|
self.spacer_s0_electronic_mount2().generate(),
|
|
|
|
name="electronic_mount2",
|
|
|
|
role=Role.STRUCTURE | Role.CONNECTION,
|
|
|
|
material=self.mat_bracket)
|
|
|
|
for hole in self.electronic_board.mount_holes:
|
|
|
|
result.constrain(
|
|
|
|
f"electronic_mount?{hole.tag}",
|
|
|
|
f"electronic_mount2?{hole.tag}_rev",
|
|
|
|
"Plane")
|
2024-07-23 22:40:49 -07:00
|
|
|
if not ignore_electronics:
|
2024-07-22 15:02:26 -07:00
|
|
|
result.add(self.electronic_board.assembly(), name="electronic_board")
|
|
|
|
for hole in self.electronic_board.mount_holes:
|
|
|
|
assert hole.tag
|
2024-08-02 00:24:25 -07:00
|
|
|
result.constrain(
|
|
|
|
f"electronic_mount2?{hole.tag}",
|
|
|
|
f'electronic_board/{hole.tag}_spacer?top',
|
|
|
|
"Plane",
|
|
|
|
param=0
|
2024-07-22 15:02:26 -07:00
|
|
|
)
|
2024-07-15 22:57:38 -07:00
|
|
|
return result.solve()
|
|
|
|
|
|
|
|
|
|
|
|
### s1, s2, s3 ###
|
2024-07-16 17:18:28 -07:00
|
|
|
def profile(self) -> Cq.Sketch:
|
|
|
|
"""
|
2024-07-19 22:29:57 -07:00
|
|
|
Generates profile from shoulder and above. Subclass should implement
|
2024-07-16 17:18:28 -07:00
|
|
|
"""
|
2024-07-23 22:12:46 -07:00
|
|
|
@target(name="profile-s2-bridge", kind=TargetKind.DXF)
|
|
|
|
def profile_s2_bridge(self) -> Optional[Cq.Sketch]:
|
|
|
|
return None
|
2024-07-19 23:49:38 -07:00
|
|
|
@target(name="profile-s3-extra", kind=TargetKind.DXF)
|
|
|
|
def profile_s3_extra(self) -> Optional[Cq.Sketch]:
|
|
|
|
"""
|
|
|
|
Extra element to be glued on s3. Not needed for left side
|
|
|
|
"""
|
|
|
|
return None
|
2024-07-15 22:57:38 -07:00
|
|
|
|
2024-07-19 23:49:38 -07:00
|
|
|
def _wrist_joint_retract_cut_polygon(self, loc: Cq.Location) -> Optional[Cq.Sketch]:
|
2024-07-19 22:29:57 -07:00
|
|
|
"""
|
|
|
|
Creates a cutting polygon for removing the contraction part of a joint
|
|
|
|
"""
|
2024-07-19 23:49:38 -07:00
|
|
|
if not self.flip:
|
|
|
|
"""
|
|
|
|
No cutting needed on RHS
|
|
|
|
"""
|
|
|
|
return None
|
2024-07-19 22:29:57 -07:00
|
|
|
theta = math.radians(self.wrist_joint.motion_span)
|
|
|
|
dx = self.wrist_height * math.tan(theta)
|
|
|
|
dy = self.wrist_height
|
|
|
|
sign = -1 if self.flip else 1
|
|
|
|
points = [
|
|
|
|
(0, 0),
|
|
|
|
(0, -sign * dy),
|
|
|
|
(-dx, -sign * dy),
|
|
|
|
]
|
|
|
|
return (
|
|
|
|
Cq.Sketch()
|
|
|
|
.polygon([
|
|
|
|
(loc * Cq.Location.from2d(*p)).to2d_pos()
|
|
|
|
for p in points
|
|
|
|
])
|
|
|
|
)
|
|
|
|
|
2024-07-23 22:12:46 -07:00
|
|
|
def _joint_extension_cut_polygon(
|
2024-07-21 22:13:56 -07:00
|
|
|
self,
|
|
|
|
loc_bot: Cq.Location,
|
|
|
|
loc_top: Cq.Location,
|
2024-07-23 22:12:46 -07:00
|
|
|
height: float,
|
2024-07-21 22:13:56 -07:00
|
|
|
angle_span: float,
|
2024-07-23 22:12:46 -07:00
|
|
|
axle_pos: float,
|
|
|
|
bot: bool = True,
|
|
|
|
child: bool = False,
|
|
|
|
overestimate: float = 1.2,
|
|
|
|
median: float = 0.5,
|
2024-07-21 22:13:56 -07:00
|
|
|
) -> Cq.Sketch:
|
|
|
|
"""
|
2024-07-23 22:12:46 -07:00
|
|
|
A cut polygon to accomodate for joint extensions
|
2024-07-21 22:13:56 -07:00
|
|
|
"""
|
2024-07-23 22:12:46 -07:00
|
|
|
loc_ext = loc_bot if bot else loc_top
|
2024-07-21 22:13:56 -07:00
|
|
|
loc_tip = loc_top if bot else loc_bot
|
2024-07-23 22:12:46 -07:00
|
|
|
theta = math.radians(angle_span * (median if child else 1 - median))
|
2024-07-25 10:41:58 -07:00
|
|
|
if self.flip:
|
|
|
|
axle_pos = 1 - axle_pos
|
2024-07-23 22:12:46 -07:00
|
|
|
y_sign = -1 if bot else 1
|
|
|
|
sign = -1 if child else 1
|
|
|
|
dh = axle_pos * height * (overestimate - 1)
|
|
|
|
loc_left = loc_ext * Cq.Location.from2d(0, y_sign * dh)
|
|
|
|
loc_right = loc_left * Cq.Location.from2d(sign * height * overestimate * axle_pos * math.tan(theta), 0)
|
2024-07-21 22:13:56 -07:00
|
|
|
|
|
|
|
return (
|
|
|
|
Cq.Sketch()
|
|
|
|
.segment(
|
|
|
|
loc_tip.to2d_pos(),
|
2024-07-23 22:12:46 -07:00
|
|
|
loc_left.to2d_pos(),
|
2024-07-21 22:13:56 -07:00
|
|
|
)
|
2024-07-23 22:12:46 -07:00
|
|
|
.segment(
|
|
|
|
loc_left.to2d_pos(),
|
|
|
|
loc_right.to2d_pos(),
|
2024-07-21 22:13:56 -07:00
|
|
|
)
|
|
|
|
.segment(
|
2024-07-23 22:12:46 -07:00
|
|
|
loc_right.to2d_pos(),
|
2024-07-21 22:13:56 -07:00
|
|
|
loc_tip.to2d_pos(),
|
|
|
|
)
|
|
|
|
.assemble()
|
|
|
|
)
|
|
|
|
|
2024-07-19 22:29:57 -07:00
|
|
|
|
2024-07-15 22:57:38 -07:00
|
|
|
def _assembly_insert_spacer(
|
|
|
|
self,
|
|
|
|
a: Cq.Assembly,
|
|
|
|
spacer: Cq.Workplane,
|
|
|
|
point_tag: str,
|
|
|
|
front_tag: str = "front",
|
|
|
|
back_tag: str = "back",
|
|
|
|
flipped: bool = False,
|
2024-07-17 10:22:59 -07:00
|
|
|
rotate: bool = False,
|
2024-07-15 22:57:38 -07:00
|
|
|
):
|
|
|
|
"""
|
|
|
|
For a child joint facing up, front panel should be on the right, back
|
|
|
|
panel on the left
|
|
|
|
"""
|
|
|
|
site_front, site_back = "right", "left"
|
|
|
|
if flipped:
|
|
|
|
site_front, site_back = site_back, site_front
|
2024-07-17 10:22:59 -07:00
|
|
|
angle = 180 if rotate else 0
|
2024-07-15 22:57:38 -07:00
|
|
|
(
|
|
|
|
a
|
2024-07-16 11:55:38 -07:00
|
|
|
.addS(
|
|
|
|
spacer,
|
|
|
|
name=point_tag,
|
|
|
|
material=self.mat_bracket,
|
|
|
|
role=self.role_panel)
|
2024-07-15 22:57:38 -07:00
|
|
|
.constrain(f"{front_tag}?{point_tag}",
|
|
|
|
f"{point_tag}?{site_front}", "Plane")
|
|
|
|
.constrain(f"{back_tag}?{point_tag}",
|
|
|
|
f"{point_tag}?{site_back}", "Plane")
|
|
|
|
.constrain(f"{point_tag}?dir", f"{front_tag}?{point_tag}_dir",
|
|
|
|
"Axis", param=angle)
|
|
|
|
)
|
|
|
|
|
2024-07-11 16:02:54 -07:00
|
|
|
def _mask_elbow(self) -> list[Tuple[float, float]]:
|
|
|
|
"""
|
|
|
|
Polygon shape to mask out parts above the elbow
|
|
|
|
"""
|
|
|
|
def _mask_wrist(self) -> list[Tuple[float, float]]:
|
2024-07-17 01:19:17 -07:00
|
|
|
"""
|
|
|
|
Polygon shape to mask wrist
|
|
|
|
"""
|
2024-07-11 16:02:54 -07:00
|
|
|
|
2024-07-24 16:17:07 -07:00
|
|
|
def _spacer_from_disk_joint(
|
|
|
|
self,
|
|
|
|
joint: ElbowJoint,
|
|
|
|
segment_thickness: float,
|
2024-07-24 21:49:54 -07:00
|
|
|
child: bool=False,
|
2024-07-24 16:17:07 -07:00
|
|
|
) -> MountingBox:
|
2024-07-24 21:49:54 -07:00
|
|
|
sign = 1 if child else -1
|
2024-07-24 16:17:07 -07:00
|
|
|
holes = [
|
2024-07-24 21:49:54 -07:00
|
|
|
Hole(sign * x, tag=tag)
|
2024-07-24 16:17:07 -07:00
|
|
|
for x, tag in joint.hole_loc_tags()
|
|
|
|
]
|
2024-08-03 23:31:36 -07:00
|
|
|
tongue_thickness = joint.disk_joint.tongue_thickness
|
|
|
|
carve_width = joint.lip_side_depression_width
|
|
|
|
assert carve_width >= self.light_strip.width
|
|
|
|
carve_height = (segment_thickness - tongue_thickness) / 2
|
|
|
|
assert carve_height >= self.light_strip.height
|
2024-07-25 12:57:33 -07:00
|
|
|
def carve_sides(profile):
|
2024-08-03 23:31:36 -07:00
|
|
|
dy = (segment_thickness + tongue_thickness) / 4
|
2024-07-25 12:57:33 -07:00
|
|
|
return (
|
|
|
|
profile
|
|
|
|
.push([(0,-dy), (0,dy)])
|
2024-08-03 23:31:36 -07:00
|
|
|
.rect(carve_width, carve_height, mode='s')
|
2024-07-25 12:57:33 -07:00
|
|
|
)
|
2024-07-24 21:49:54 -07:00
|
|
|
# FIXME: Carve out the sides so light can pass through
|
2024-07-24 16:17:07 -07:00
|
|
|
mbox = MountingBox(
|
|
|
|
length=joint.lip_length,
|
|
|
|
width=segment_thickness,
|
|
|
|
thickness=self.spacer_thickness,
|
|
|
|
holes=holes,
|
|
|
|
hole_diam=joint.hole_diam,
|
|
|
|
centred=(True, True),
|
|
|
|
centre_left_right_tags=True,
|
2024-07-25 12:57:33 -07:00
|
|
|
profile_callback=carve_sides,
|
2024-07-24 16:17:07 -07:00
|
|
|
)
|
|
|
|
return mbox
|
2024-07-11 16:02:54 -07:00
|
|
|
|
2024-07-16 15:42:39 -07:00
|
|
|
@target(name="profile-s1", kind=TargetKind.DXF)
|
2024-07-11 16:02:54 -07:00
|
|
|
def profile_s1(self) -> Cq.Sketch:
|
2024-07-23 22:12:46 -07:00
|
|
|
cut_poly = self._joint_extension_cut_polygon(
|
|
|
|
loc_bot=self.elbow_bot_loc,
|
|
|
|
loc_top=self.elbow_top_loc,
|
|
|
|
height=self.elbow_height,
|
|
|
|
angle_span=self.elbow_joint.motion_span,
|
|
|
|
axle_pos=self.elbow_axle_pos,
|
|
|
|
bot=not self.elbow_joint.flip,
|
|
|
|
median=self.elbow_joint_overlap_median,
|
|
|
|
child=False,
|
|
|
|
).reset().polygon(self._mask_elbow(), mode='a')
|
2024-07-11 16:02:54 -07:00
|
|
|
profile = (
|
|
|
|
self.profile()
|
|
|
|
.reset()
|
2024-07-23 22:12:46 -07:00
|
|
|
.push([self.elbow_axle_loc.to2d_pos()])
|
|
|
|
.each(lambda _: cut_poly, mode='i')
|
|
|
|
#.polygon(self._mask_elbow(), mode='i')
|
2024-07-11 16:02:54 -07:00
|
|
|
)
|
|
|
|
return profile
|
2024-07-17 13:09:46 -07:00
|
|
|
def surface_s1(self, front: bool = True) -> Cq.Workplane:
|
2024-07-24 16:17:07 -07:00
|
|
|
rot_elbow = Cq.Location.rot2d(self.elbow_rotate)
|
|
|
|
loc_elbow = rot_elbow * self.elbow_joint.parent_arm_loc()
|
|
|
|
tags = [
|
2024-07-24 12:45:38 -07:00
|
|
|
("shoulder",
|
|
|
|
Cq.Location((0, self.shoulder_height / 2, 0)) *
|
|
|
|
self.shoulder_joint.child_lip_loc()),
|
2024-07-24 16:17:07 -07:00
|
|
|
("elbow", self.elbow_axle_loc * loc_elbow),
|
2024-07-23 19:13:06 -07:00
|
|
|
("elbow_act", self.elbow_axle_loc * rot_elbow *
|
|
|
|
self.elbow_joint.actuator_mount_loc()),
|
2024-07-11 16:02:54 -07:00
|
|
|
]
|
|
|
|
profile = self.profile_s1()
|
2024-07-17 19:28:56 -07:00
|
|
|
return extrude_with_markers(
|
2024-07-17 12:11:08 -07:00
|
|
|
profile, self.panel_thickness, tags, reverse=front)
|
2024-07-25 22:40:44 -07:00
|
|
|
@submodel(name="spacer-s1-rod")
|
|
|
|
def spacer_s1_rod(self) -> MountingBox:
|
|
|
|
return MountingBox(
|
|
|
|
length=self.s1_thickness,
|
|
|
|
width=self.rod_width,
|
|
|
|
thickness=self.panel_thickness,
|
|
|
|
)
|
2024-07-16 15:42:39 -07:00
|
|
|
@submodel(name="spacer-s1-shoulder")
|
2024-07-15 22:57:38 -07:00
|
|
|
def spacer_s1_shoulder(self) -> MountingBox:
|
2024-07-24 15:15:58 -07:00
|
|
|
sign = 1#-1 if self.flip else 1
|
2024-07-15 22:57:38 -07:00
|
|
|
holes = [
|
2024-07-24 12:45:38 -07:00
|
|
|
Hole(x=sign * x)
|
2024-07-15 22:57:38 -07:00
|
|
|
for x in self.shoulder_joint.child_conn_hole_pos
|
|
|
|
]
|
|
|
|
return MountingBox(
|
2024-07-24 12:45:38 -07:00
|
|
|
length=self.shoulder_joint.child_lip_height,
|
2024-07-15 22:57:38 -07:00
|
|
|
width=self.s1_thickness,
|
|
|
|
thickness=self.spacer_thickness,
|
|
|
|
holes=holes,
|
2024-07-24 12:45:38 -07:00
|
|
|
centred=(True, True),
|
2024-07-15 22:57:38 -07:00
|
|
|
hole_diam=self.shoulder_joint.child_conn_hole_diam,
|
2024-07-24 12:45:38 -07:00
|
|
|
centre_left_right_tags=True,
|
|
|
|
centre_bot_top_tags=True,
|
2024-07-15 22:57:38 -07:00
|
|
|
)
|
2024-07-16 15:42:39 -07:00
|
|
|
@submodel(name="spacer-s1-elbow")
|
2024-07-15 22:57:38 -07:00
|
|
|
def spacer_s1_elbow(self) -> MountingBox:
|
2024-07-24 16:17:07 -07:00
|
|
|
return self._spacer_from_disk_joint(
|
2024-07-17 10:22:59 -07:00
|
|
|
joint=self.elbow_joint,
|
|
|
|
segment_thickness=self.s1_thickness,
|
2024-07-15 22:57:38 -07:00
|
|
|
)
|
2024-07-23 19:13:06 -07:00
|
|
|
@submodel(name="spacer-s1-elbow-act")
|
|
|
|
def spacer_s1_elbow_act(self) -> MountingBox:
|
|
|
|
return MountingBox(
|
|
|
|
length=self.s1_thickness,
|
|
|
|
width=self.s1_thickness,
|
|
|
|
thickness=self.spacer_thickness,
|
|
|
|
holes=[Hole(x=0,y=0)],
|
|
|
|
centred=(True, True),
|
|
|
|
hole_diam=self.elbow_joint.hole_diam,
|
|
|
|
centre_left_right_tags=True,
|
|
|
|
)
|
2024-07-16 15:42:39 -07:00
|
|
|
@assembly()
|
2024-07-15 22:57:38 -07:00
|
|
|
def assembly_s1(self) -> Cq.Assembly:
|
|
|
|
result = (
|
|
|
|
Cq.Assembly()
|
2024-07-16 11:55:38 -07:00
|
|
|
.addS(self.surface_s1(front=True), name="front",
|
|
|
|
material=self.mat_panel, role=self.role_panel)
|
2024-07-15 22:57:38 -07:00
|
|
|
.constrain("front", "Fixed")
|
2024-07-16 11:55:38 -07:00
|
|
|
.addS(self.surface_s1(front=False), name="back",
|
|
|
|
material=self.mat_panel, role=self.role_panel)
|
2024-07-15 22:57:38 -07:00
|
|
|
.constrain("front@faces@>Z", "back@faces@<Z", "Point",
|
|
|
|
param=self.s1_thickness)
|
|
|
|
)
|
2024-07-23 19:13:06 -07:00
|
|
|
for o, t in [
|
2024-07-24 12:45:38 -07:00
|
|
|
(self.spacer_s1_shoulder(), "shoulder"),
|
2024-07-24 16:17:07 -07:00
|
|
|
(self.spacer_s1_elbow(), "elbow"),
|
2024-07-23 19:13:06 -07:00
|
|
|
(self.spacer_s1_elbow_act(), "elbow_act"),
|
|
|
|
]:
|
2024-07-15 22:57:38 -07:00
|
|
|
self._assembly_insert_spacer(
|
|
|
|
result,
|
2024-07-23 19:13:06 -07:00
|
|
|
o.generate(),
|
2024-07-15 22:57:38 -07:00
|
|
|
point_tag=t,
|
2024-07-24 16:17:07 -07:00
|
|
|
flipped=True,
|
2024-07-15 22:57:38 -07:00
|
|
|
)
|
|
|
|
return result.solve()
|
2024-07-11 16:02:54 -07:00
|
|
|
|
2024-07-16 15:42:39 -07:00
|
|
|
@target(name="profile-s2", kind=TargetKind.DXF)
|
2024-07-11 16:02:54 -07:00
|
|
|
def profile_s2(self) -> Cq.Sketch:
|
2024-07-23 22:12:46 -07:00
|
|
|
# Calculates `(profile - (E - JE)) * (W + JW)`
|
|
|
|
cut_elbow = (
|
|
|
|
Cq.Sketch()
|
|
|
|
.polygon(self._mask_elbow())
|
|
|
|
.reset()
|
|
|
|
.boolean(self._joint_extension_cut_polygon(
|
|
|
|
loc_bot=self.elbow_bot_loc,
|
|
|
|
loc_top=self.elbow_top_loc,
|
|
|
|
height=self.elbow_height,
|
|
|
|
angle_span=self.elbow_joint.motion_span,
|
|
|
|
axle_pos=self.elbow_axle_pos,
|
|
|
|
bot=not self.elbow_joint.flip,
|
|
|
|
median=self.elbow_joint_overlap_median,
|
|
|
|
child=True,
|
|
|
|
), mode='s')
|
|
|
|
)
|
|
|
|
cut_wrist = (
|
|
|
|
Cq.Sketch()
|
|
|
|
.polygon(self._mask_wrist())
|
|
|
|
)
|
|
|
|
if self.flip:
|
|
|
|
poly = self._joint_extension_cut_polygon(
|
|
|
|
loc_bot=self.wrist_bot_loc,
|
|
|
|
loc_top=self.wrist_top_loc,
|
|
|
|
height=self.wrist_height,
|
|
|
|
angle_span=self.wrist_joint.motion_span,
|
|
|
|
axle_pos=self.wrist_axle_pos,
|
|
|
|
bot=not self.wrist_joint.flip,
|
|
|
|
median=self.wrist_joint_overlap_median,
|
|
|
|
child=False,
|
|
|
|
)
|
|
|
|
cut_wrist = (
|
|
|
|
cut_wrist
|
|
|
|
.reset()
|
|
|
|
.boolean(poly, mode='a')
|
|
|
|
)
|
2024-07-11 16:02:54 -07:00
|
|
|
profile = (
|
|
|
|
self.profile()
|
|
|
|
.reset()
|
2024-07-23 22:12:46 -07:00
|
|
|
.boolean(cut_elbow, mode='s')
|
|
|
|
.boolean(cut_wrist, mode='i')
|
2024-07-11 16:02:54 -07:00
|
|
|
)
|
|
|
|
return profile
|
2024-07-17 13:09:46 -07:00
|
|
|
def surface_s2(self, front: bool = True) -> Cq.Workplane:
|
2024-07-25 10:41:58 -07:00
|
|
|
rot_elbow = Cq.Location.rot2d(self.elbow_rotate)
|
|
|
|
loc_elbow = rot_elbow * self.elbow_joint.child_arm_loc()
|
2024-07-23 19:13:06 -07:00
|
|
|
rot_wrist = Cq.Location.rot2d(self.wrist_rotate)
|
|
|
|
loc_wrist = rot_wrist * self.wrist_joint.parent_arm_loc()
|
2024-07-24 16:17:07 -07:00
|
|
|
tags = [
|
|
|
|
("elbow", self.elbow_axle_loc * loc_elbow),
|
2024-07-25 10:41:58 -07:00
|
|
|
("elbow_act", self.elbow_axle_loc * rot_elbow *
|
|
|
|
self.elbow_joint.actuator_mount_loc(child=True)),
|
2024-07-24 16:17:07 -07:00
|
|
|
("wrist", self.wrist_axle_loc * loc_wrist),
|
|
|
|
("wrist_act", self.wrist_axle_loc * rot_wrist *
|
|
|
|
self.wrist_joint.actuator_mount_loc()),
|
|
|
|
|
|
|
|
# for mounting the bridge only
|
2024-07-18 21:07:08 -07:00
|
|
|
("wrist_bot", self.wrist_axle_loc * loc_wrist *
|
2024-07-18 14:03:01 -07:00
|
|
|
Cq.Location.from2d(0, -self.wrist_h2)),
|
2024-07-18 21:07:08 -07:00
|
|
|
("wrist_top", self.wrist_axle_loc * loc_wrist *
|
2024-07-18 14:03:01 -07:00
|
|
|
Cq.Location.from2d(0, self.wrist_h2)),
|
2024-07-12 11:04:28 -07:00
|
|
|
]
|
|
|
|
profile = self.profile_s2()
|
2024-07-17 19:28:56 -07:00
|
|
|
return extrude_with_markers(profile, self.panel_thickness, tags, reverse=front)
|
2024-07-23 22:12:46 -07:00
|
|
|
def surface_s2_bridge(self, front: bool = True) -> Optional[Cq.Workplane]:
|
2024-07-20 22:55:43 -07:00
|
|
|
profile = self.profile_s2_bridge()
|
2024-07-23 22:12:46 -07:00
|
|
|
if profile is None:
|
|
|
|
return None
|
2024-07-20 22:55:43 -07:00
|
|
|
loc_wrist = Cq.Location.rot2d(self.wrist_rotate) * self.wrist_joint.parent_arm_loc()
|
|
|
|
tags = [
|
|
|
|
("wrist_bot", self.wrist_axle_loc * loc_wrist *
|
|
|
|
Cq.Location.from2d(0, -self.wrist_h2)),
|
|
|
|
("wrist_top", self.wrist_axle_loc * loc_wrist *
|
|
|
|
Cq.Location.from2d(0, self.wrist_h2)),
|
|
|
|
]
|
|
|
|
return extrude_with_markers(
|
|
|
|
profile, self.panel_thickness, tags, reverse=not front)
|
2024-07-25 22:40:44 -07:00
|
|
|
@submodel(name="spacer-s2-rod")
|
|
|
|
def spacer_s2_rod(self) -> MountingBox:
|
|
|
|
return MountingBox(
|
|
|
|
length=self.s2_thickness,
|
|
|
|
width=self.rod_width,
|
|
|
|
thickness=self.panel_thickness,
|
|
|
|
)
|
2024-07-16 15:42:39 -07:00
|
|
|
@submodel(name="spacer-s2-elbow")
|
2024-07-15 22:57:38 -07:00
|
|
|
def spacer_s2_elbow(self) -> MountingBox:
|
2024-07-24 16:17:07 -07:00
|
|
|
return self._spacer_from_disk_joint(
|
2024-07-17 10:22:59 -07:00
|
|
|
joint=self.elbow_joint,
|
|
|
|
segment_thickness=self.s2_thickness,
|
2024-07-24 21:49:54 -07:00
|
|
|
child=True,
|
2024-07-15 22:57:38 -07:00
|
|
|
)
|
2024-07-25 12:31:25 -07:00
|
|
|
@submodel(name="spacer-s2-elbow-act")
|
2024-07-25 10:41:58 -07:00
|
|
|
def spacer_s2_elbow_act(self) -> MountingBox:
|
|
|
|
return MountingBox(
|
|
|
|
length=self.s2_thickness,
|
|
|
|
width=self.s2_thickness,
|
|
|
|
thickness=self.spacer_thickness,
|
|
|
|
holes=[Hole(x=0,y=0)],
|
|
|
|
centred=(True, True),
|
|
|
|
hole_diam=self.elbow_joint.hole_diam,
|
|
|
|
centre_left_right_tags=True,
|
|
|
|
)
|
2024-07-16 15:42:39 -07:00
|
|
|
@submodel(name="spacer-s2-wrist")
|
2024-07-15 22:57:38 -07:00
|
|
|
def spacer_s2_wrist(self) -> MountingBox:
|
2024-07-24 16:17:07 -07:00
|
|
|
return self._spacer_from_disk_joint(
|
2024-07-17 10:22:59 -07:00
|
|
|
joint=self.wrist_joint,
|
|
|
|
segment_thickness=self.s2_thickness,
|
2024-07-15 22:57:38 -07:00
|
|
|
)
|
2024-07-23 19:13:06 -07:00
|
|
|
@submodel(name="spacer-s2-wrist-act")
|
|
|
|
def spacer_s2_wrist_act(self) -> MountingBox:
|
|
|
|
return MountingBox(
|
|
|
|
length=self.s2_thickness,
|
|
|
|
width=self.s2_thickness,
|
|
|
|
thickness=self.spacer_thickness,
|
|
|
|
holes=[Hole(x=0,y=0)],
|
|
|
|
centred=(True, True),
|
|
|
|
hole_diam=self.wrist_joint.hole_diam,
|
|
|
|
centre_left_right_tags=True,
|
|
|
|
)
|
2024-07-16 15:42:39 -07:00
|
|
|
@assembly()
|
2024-07-15 22:57:38 -07:00
|
|
|
def assembly_s2(self) -> Cq.Assembly:
|
|
|
|
result = (
|
|
|
|
Cq.Assembly()
|
2024-07-16 11:55:38 -07:00
|
|
|
.addS(self.surface_s2(front=True), name="front",
|
|
|
|
material=self.mat_panel, role=self.role_panel)
|
2024-07-15 22:57:38 -07:00
|
|
|
.constrain("front", "Fixed")
|
2024-07-16 11:55:38 -07:00
|
|
|
.addS(self.surface_s2(front=False), name="back",
|
|
|
|
material=self.mat_panel, role=self.role_panel)
|
2024-07-15 22:57:38 -07:00
|
|
|
.constrain("front@faces@>Z", "back@faces@<Z", "Point",
|
|
|
|
param=self.s1_thickness)
|
|
|
|
)
|
2024-07-23 22:12:46 -07:00
|
|
|
bridge_front = self.surface_s2_bridge(front=True)
|
|
|
|
bridge_back = self.surface_s2_bridge(front=False)
|
|
|
|
if bridge_front:
|
|
|
|
(
|
|
|
|
result
|
|
|
|
.addS(bridge_front, name="bridge_front",
|
|
|
|
material=self.mat_panel, role=self.role_panel)
|
|
|
|
.constrain("front?wrist_bot", "bridge_front?wrist_bot", "Plane")
|
|
|
|
.constrain("front?wrist_top", "bridge_front?wrist_top", "Plane")
|
|
|
|
)
|
|
|
|
if bridge_back:
|
|
|
|
(
|
|
|
|
result
|
|
|
|
.addS(bridge_back, name="bridge_back",
|
|
|
|
material=self.mat_panel, role=self.role_panel)
|
|
|
|
.constrain("back?wrist_bot", "bridge_back?wrist_bot", "Plane")
|
|
|
|
.constrain("back?wrist_top", "bridge_back?wrist_top", "Plane")
|
|
|
|
)
|
2024-07-23 19:13:06 -07:00
|
|
|
for o, t in [
|
2024-07-24 16:17:07 -07:00
|
|
|
(self.spacer_s2_elbow(), "elbow"),
|
2024-07-25 10:41:58 -07:00
|
|
|
(self.spacer_s2_elbow_act(), "elbow_act"),
|
2024-07-24 16:17:07 -07:00
|
|
|
(self.spacer_s2_wrist(), "wrist"),
|
2024-07-23 19:13:06 -07:00
|
|
|
(self.spacer_s2_wrist_act(), "wrist_act"),
|
|
|
|
]:
|
2024-07-15 22:57:38 -07:00
|
|
|
is_parent = t.startswith("elbow")
|
|
|
|
self._assembly_insert_spacer(
|
|
|
|
result,
|
|
|
|
o.generate(),
|
|
|
|
point_tag=t,
|
2024-07-24 21:49:54 -07:00
|
|
|
flipped=True,#is_parent,
|
2024-07-15 22:57:38 -07:00
|
|
|
)
|
|
|
|
return result.solve()
|
2024-07-12 11:04:28 -07:00
|
|
|
|
2024-07-16 15:42:39 -07:00
|
|
|
@target(name="profile-s3", kind=TargetKind.DXF)
|
2024-07-11 16:02:54 -07:00
|
|
|
def profile_s3(self) -> Cq.Sketch:
|
2024-07-23 22:12:46 -07:00
|
|
|
cut_wrist = (
|
|
|
|
Cq.Sketch()
|
|
|
|
.polygon(self._mask_wrist())
|
|
|
|
)
|
|
|
|
if self.flip:
|
|
|
|
poly = self._joint_extension_cut_polygon(
|
|
|
|
loc_bot=self.wrist_bot_loc,
|
|
|
|
loc_top=self.wrist_top_loc,
|
|
|
|
height=self.wrist_height,
|
|
|
|
angle_span=self.wrist_joint.motion_span,
|
|
|
|
axle_pos=self.wrist_axle_pos,
|
|
|
|
bot=not self.wrist_joint.flip,
|
|
|
|
median=self.wrist_joint_overlap_median,
|
|
|
|
child=True,
|
|
|
|
)
|
|
|
|
cut_wrist = (
|
|
|
|
cut_wrist
|
|
|
|
.boolean(poly, mode='s')
|
|
|
|
)
|
2024-07-11 16:02:54 -07:00
|
|
|
profile = (
|
|
|
|
self.profile()
|
2024-07-23 22:12:46 -07:00
|
|
|
.boolean(cut_wrist, mode='s')
|
2024-07-11 16:02:54 -07:00
|
|
|
)
|
|
|
|
return profile
|
2024-07-12 11:04:28 -07:00
|
|
|
def surface_s3(self,
|
|
|
|
front: bool = True) -> Cq.Workplane:
|
2024-07-25 12:31:25 -07:00
|
|
|
rot_wrist = Cq.Location.rot2d(self.wrist_rotate)
|
|
|
|
loc_wrist = rot_wrist * self.wrist_joint.child_arm_loc()
|
2024-07-12 11:04:28 -07:00
|
|
|
tags = [
|
2024-07-24 16:17:07 -07:00
|
|
|
("wrist", self.wrist_axle_loc * loc_wrist),
|
2024-07-25 12:31:25 -07:00
|
|
|
("wrist_act", self.wrist_axle_loc * rot_wrist *
|
|
|
|
self.wrist_joint.actuator_mount_loc(child=True)),
|
2024-07-18 21:07:08 -07:00
|
|
|
("wrist_bot", self.wrist_axle_loc * loc_wrist *
|
2024-07-18 14:03:01 -07:00
|
|
|
Cq.Location.from2d(0, self.wrist_h2)),
|
2024-07-18 21:07:08 -07:00
|
|
|
("wrist_top", self.wrist_axle_loc * loc_wrist *
|
2024-07-18 14:03:01 -07:00
|
|
|
Cq.Location.from2d(0, -self.wrist_h2)),
|
2024-07-12 11:04:28 -07:00
|
|
|
]
|
|
|
|
profile = self.profile_s3()
|
2024-07-17 19:28:56 -07:00
|
|
|
return extrude_with_markers(profile, self.panel_thickness, tags, reverse=front)
|
2024-07-19 23:49:38 -07:00
|
|
|
def surface_s3_extra(self,
|
|
|
|
front: bool = True) -> Optional[Cq.Workplane]:
|
|
|
|
profile = self.profile_s3_extra()
|
|
|
|
if profile is None:
|
|
|
|
return None
|
2024-07-23 19:13:06 -07:00
|
|
|
loc_wrist = Cq.Location.rot2d(self.wrist_rotate) * self.wrist_joint.child_arm_loc()
|
2024-07-19 23:49:38 -07:00
|
|
|
tags = [
|
|
|
|
("wrist_bot", self.wrist_axle_loc * loc_wrist *
|
|
|
|
Cq.Location.from2d(0, self.wrist_h2)),
|
|
|
|
("wrist_top", self.wrist_axle_loc * loc_wrist *
|
|
|
|
Cq.Location.from2d(0, -self.wrist_h2)),
|
|
|
|
]
|
|
|
|
return extrude_with_markers(profile, self.panel_thickness, tags, reverse=not front)
|
2024-07-25 22:40:44 -07:00
|
|
|
@submodel(name="spacer-s3-rod")
|
|
|
|
def spacer_s3_rod(self) -> MountingBox:
|
|
|
|
return MountingBox(
|
|
|
|
length=self.s3_thickness,
|
|
|
|
width=self.rod_width,
|
|
|
|
thickness=self.panel_thickness,
|
|
|
|
)
|
2024-07-16 15:42:39 -07:00
|
|
|
@submodel(name="spacer-s3-wrist")
|
2024-07-15 22:57:38 -07:00
|
|
|
def spacer_s3_wrist(self) -> MountingBox:
|
2024-07-24 16:17:07 -07:00
|
|
|
return self._spacer_from_disk_joint(
|
2024-07-17 10:22:59 -07:00
|
|
|
joint=self.wrist_joint,
|
|
|
|
segment_thickness=self.s3_thickness,
|
2024-07-24 21:49:54 -07:00
|
|
|
child=True,
|
2024-07-15 22:57:38 -07:00
|
|
|
)
|
2024-07-25 12:31:25 -07:00
|
|
|
@submodel(name="spacer-s3-wrist-act")
|
|
|
|
def spacer_s3_wrist_act(self) -> MountingBox:
|
|
|
|
return MountingBox(
|
|
|
|
length=self.s3_thickness,
|
|
|
|
width=self.s3_thickness,
|
|
|
|
thickness=self.spacer_thickness,
|
|
|
|
holes=[Hole(x=0,y=0)],
|
|
|
|
centred=(True, True),
|
|
|
|
hole_diam=self.wrist_joint.hole_diam,
|
|
|
|
centre_left_right_tags=True,
|
|
|
|
)
|
2024-07-16 15:42:39 -07:00
|
|
|
@assembly()
|
2024-07-15 22:57:38 -07:00
|
|
|
def assembly_s3(self) -> Cq.Assembly:
|
|
|
|
result = (
|
|
|
|
Cq.Assembly()
|
2024-07-16 11:55:38 -07:00
|
|
|
.addS(self.surface_s3(front=True), name="front",
|
|
|
|
material=self.mat_panel, role=self.role_panel)
|
2024-07-15 22:57:38 -07:00
|
|
|
.constrain("front", "Fixed")
|
2024-07-16 11:55:38 -07:00
|
|
|
.addS(self.surface_s3(front=False), name="back",
|
|
|
|
material=self.mat_panel, role=self.role_panel)
|
2024-07-15 22:57:38 -07:00
|
|
|
.constrain("front@faces@>Z", "back@faces@<Z", "Point",
|
|
|
|
param=self.s1_thickness)
|
|
|
|
)
|
2024-07-19 23:49:38 -07:00
|
|
|
if not self.flip:
|
|
|
|
(
|
|
|
|
result
|
|
|
|
.addS(self.surface_s3_extra(front=True), name="extra_front",
|
|
|
|
material=self.mat_panel, role=self.role_panel)
|
|
|
|
.constrain("front?wrist_bot", "extra_front?wrist_bot", "Plane")
|
|
|
|
.constrain("front?wrist_top", "extra_front?wrist_top", "Plane")
|
|
|
|
.addS(self.surface_s3_extra(front=False), name="extra_back",
|
|
|
|
material=self.mat_panel, role=self.role_panel)
|
|
|
|
.constrain("back?wrist_bot", "extra_back?wrist_bot", "Plane")
|
|
|
|
.constrain("back?wrist_top", "extra_back?wrist_top", "Plane")
|
|
|
|
)
|
2024-07-25 12:31:25 -07:00
|
|
|
self._assembly_insert_spacer(
|
|
|
|
result,
|
|
|
|
self.spacer_s3_wrist_act().generate(),
|
|
|
|
point_tag="wrist_act",
|
|
|
|
flipped=True,
|
|
|
|
)
|
2024-07-24 16:17:07 -07:00
|
|
|
self._assembly_insert_spacer(
|
|
|
|
result,
|
|
|
|
self.spacer_s3_wrist().generate(),
|
|
|
|
point_tag="wrist",
|
|
|
|
flipped=True,
|
|
|
|
)
|
2024-07-15 22:57:38 -07:00
|
|
|
return result.solve()
|
2024-07-11 16:02:54 -07:00
|
|
|
|
2024-07-16 15:42:39 -07:00
|
|
|
@assembly()
|
2024-07-24 16:17:07 -07:00
|
|
|
def assembly(
|
|
|
|
self,
|
|
|
|
parts: Optional[list[str]] = None,
|
|
|
|
shoulder_deflection: float = 0.0,
|
|
|
|
elbow_wrist_deflection: float = 0.0,
|
|
|
|
root_offset: int = 5,
|
|
|
|
fastener_pos: float = 0.0,
|
|
|
|
ignore_fasteners: bool = False,
|
|
|
|
ignore_electronics: bool = False,
|
|
|
|
ignore_actuators: bool = False,
|
|
|
|
) -> Cq.Assembly():
|
2024-07-24 21:49:54 -07:00
|
|
|
assert 0 <= elbow_wrist_deflection <= 1
|
|
|
|
assert 0 <= shoulder_deflection <= 1
|
|
|
|
assert 0 <= fastener_pos <= 1
|
2024-07-15 22:57:38 -07:00
|
|
|
if parts is None:
|
2024-07-21 18:45:13 -07:00
|
|
|
parts = [
|
|
|
|
"root",
|
|
|
|
"s0",
|
|
|
|
"shoulder",
|
|
|
|
"s1",
|
|
|
|
"elbow",
|
|
|
|
"s2",
|
|
|
|
"wrist",
|
|
|
|
"s3",
|
|
|
|
]
|
2024-07-24 21:49:54 -07:00
|
|
|
result = Cq.Assembly()
|
2024-07-16 23:32:23 -07:00
|
|
|
tag_top, tag_bot = "top", "bot"
|
|
|
|
if self.flip:
|
|
|
|
tag_top, tag_bot = tag_bot, tag_top
|
|
|
|
|
2024-07-15 22:57:38 -07:00
|
|
|
if "s0" in parts:
|
2024-07-23 22:40:49 -07:00
|
|
|
result.add(self.assembly_s0(
|
|
|
|
ignore_electronics=ignore_electronics
|
|
|
|
), name="s0")
|
2024-07-19 15:06:57 -07:00
|
|
|
if "root" in parts:
|
|
|
|
result.addS(self.root_joint.assembly(
|
|
|
|
offset=root_offset,
|
|
|
|
fastener_pos=fastener_pos,
|
2024-07-23 22:40:49 -07:00
|
|
|
ignore_fasteners=ignore_fasteners,
|
2024-07-19 15:06:57 -07:00
|
|
|
), name="root")
|
|
|
|
result.constrain("root/parent", "Fixed")
|
|
|
|
if "s0" in parts and "root" in parts:
|
|
|
|
(
|
|
|
|
result
|
2024-07-24 16:21:46 -07:00
|
|
|
.constrain("s0/base?conn0", "root/child?conn0", "Point")
|
|
|
|
.constrain("s0/base?conn1", "root/child?conn1", "Point")
|
|
|
|
.constrain("s0/base?conn2", "root/child?conn2", "Point")
|
|
|
|
#.constrain("s0/base?conn3", "root/child?conn3", "Point")
|
2024-07-19 15:06:57 -07:00
|
|
|
)
|
2024-07-15 22:57:38 -07:00
|
|
|
if "shoulder" in parts:
|
2024-07-19 18:59:58 -07:00
|
|
|
angle = shoulder_deflection * self.shoulder_joint.angle_max_deflection
|
2024-07-19 15:06:57 -07:00
|
|
|
result.add(self.shoulder_joint.assembly(
|
|
|
|
fastener_pos=fastener_pos,
|
2024-07-23 22:40:49 -07:00
|
|
|
deflection=angle,
|
|
|
|
ignore_fasteners=ignore_fasteners), name="shoulder")
|
2024-07-15 22:57:38 -07:00
|
|
|
if "s0" in parts and "shoulder" in parts:
|
2024-07-23 16:49:25 -07:00
|
|
|
for i in range(len(self.shoulder_joint.parent_conn_hole_pos)):
|
|
|
|
(
|
|
|
|
result
|
|
|
|
.constrain(f"s0/shoulder_left?conn_top{i}", f"shoulder/parent_{tag_top}/lip_left?conn{i}", "Plane")
|
|
|
|
.constrain(f"s0/shoulder_left?conn_bot{i}", f"shoulder/parent_{tag_bot}/lip_left?conn{i}", "Plane")
|
|
|
|
.constrain(f"s0/shoulder_right?conn_top{i}", f"shoulder/parent_{tag_top}/lip_right?conn{i}", "Plane")
|
|
|
|
.constrain(f"s0/shoulder_right?conn_bot{i}", f"shoulder/parent_{tag_bot}/lip_right?conn{i}", "Plane")
|
|
|
|
)
|
2024-07-15 22:57:38 -07:00
|
|
|
if "s1" in parts:
|
|
|
|
result.add(self.assembly_s1(), name="s1")
|
|
|
|
if "s1" in parts and "shoulder" in parts:
|
2024-07-24 12:45:38 -07:00
|
|
|
for i in range(len(self.shoulder_joint.child_conn_hole_pos)):
|
|
|
|
result.constrain(f"s1/shoulder?conn{i}", f"shoulder/child/lip?conn{i}", "Plane")
|
2024-07-15 22:57:38 -07:00
|
|
|
if "elbow" in parts:
|
2024-07-19 22:29:57 -07:00
|
|
|
angle = self.elbow_joint.motion_span * elbow_wrist_deflection
|
2024-07-23 22:40:49 -07:00
|
|
|
result.add(self.elbow_joint.assembly(
|
|
|
|
angle=angle,
|
|
|
|
ignore_actuators=ignore_actuators), name="elbow")
|
2024-07-15 22:57:38 -07:00
|
|
|
if "s1" in parts and "elbow" in parts:
|
2024-07-24 16:17:07 -07:00
|
|
|
for _, tag in self.elbow_joint.hole_loc_tags():
|
|
|
|
result.constrain(
|
|
|
|
f"s1/elbow?{tag}",
|
|
|
|
f"elbow/parent_upper/lip?{tag}", "Plane")
|
2024-07-24 21:49:54 -07:00
|
|
|
#if not ignore_actuators:
|
|
|
|
# result.constrain(
|
|
|
|
# "elbow/bracket_back?conn_side",
|
|
|
|
# "s1/elbow_act?conn0",
|
|
|
|
# "Plane")
|
2024-07-15 22:57:38 -07:00
|
|
|
if "s2" in parts:
|
|
|
|
result.add(self.assembly_s2(), name="s2")
|
|
|
|
if "s2" in parts and "elbow" in parts:
|
2024-07-24 16:17:07 -07:00
|
|
|
for _, tag in self.elbow_joint.hole_loc_tags():
|
|
|
|
result.constrain(
|
|
|
|
f"s2/elbow?{tag}",
|
|
|
|
f"elbow/child/lip?{tag}", "Plane")
|
2024-07-15 22:57:38 -07:00
|
|
|
if "wrist" in parts:
|
2024-07-19 22:29:57 -07:00
|
|
|
angle = self.wrist_joint.motion_span * elbow_wrist_deflection
|
2024-07-23 22:40:49 -07:00
|
|
|
result.add(self.wrist_joint.assembly(
|
|
|
|
angle=angle,
|
|
|
|
ignore_actuators=ignore_actuators), name="wrist")
|
2024-07-15 22:57:38 -07:00
|
|
|
if "s2" in parts and "wrist" in parts:
|
2024-07-24 16:17:07 -07:00
|
|
|
for _, tag in self.wrist_joint.hole_loc_tags():
|
|
|
|
result.constrain(
|
|
|
|
f"s2/wrist?{tag}",
|
|
|
|
f"wrist/parent_upper/lip?{tag}", "Plane")
|
2024-07-15 22:57:38 -07:00
|
|
|
if "s3" in parts:
|
|
|
|
result.add(self.assembly_s3(), name="s3")
|
|
|
|
if "s3" in parts and "wrist" in parts:
|
2024-07-24 16:17:07 -07:00
|
|
|
for _, tag in self.wrist_joint.hole_loc_tags():
|
|
|
|
result.constrain(
|
|
|
|
f"s3/wrist?{tag}",
|
|
|
|
f"wrist/child/lip?{tag}", "Plane")
|
2024-07-24 21:49:54 -07:00
|
|
|
#if not ignore_actuators:
|
|
|
|
# result.constrain(
|
|
|
|
# "wrist/bracket_back?conn_side",
|
|
|
|
# "s2/wrist_act?conn0",
|
|
|
|
# "Plane")
|
2024-07-16 12:03:51 -07:00
|
|
|
if len(parts) > 1:
|
|
|
|
result.solve()
|
2024-07-09 19:57:54 -07:00
|
|
|
|
2024-07-16 12:03:51 -07:00
|
|
|
return result
|
2024-07-16 17:18:28 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@dataclass(kw_only=True)
|
|
|
|
class WingR(WingProfile):
|
|
|
|
"""
|
|
|
|
Right side wings
|
|
|
|
"""
|
|
|
|
|
2024-07-18 11:08:34 -07:00
|
|
|
elbow_bot_loc: Cq.Location = Cq.Location.from2d(290.0, 30.0, 27.0)
|
2024-07-16 17:18:28 -07:00
|
|
|
elbow_height: float = 111.0
|
2024-07-24 21:49:54 -07:00
|
|
|
elbow_rotate: float = 10.0
|
|
|
|
elbow_joint: ElbowJoint = field(default_factory=lambda: ElbowJoint(
|
2024-07-25 10:41:58 -07:00
|
|
|
disk_joint=DiskJoint(
|
|
|
|
movement_angle=55,
|
2024-07-25 13:05:12 -07:00
|
|
|
spring_angle_at_0=75,
|
2024-07-25 10:41:58 -07:00
|
|
|
),
|
2024-07-24 21:49:54 -07:00
|
|
|
flexor_offset_angle=15,
|
|
|
|
flexor_mount_angle_child=-75,
|
|
|
|
flexor_child_arm_radius=None,
|
|
|
|
angle_neutral=10.0,
|
|
|
|
flip=False,
|
|
|
|
**ELBOW_PARAMS
|
|
|
|
))
|
2024-07-16 17:18:28 -07:00
|
|
|
|
2024-07-18 11:08:34 -07:00
|
|
|
wrist_bot_loc: Cq.Location = Cq.Location.from2d(403.0, 289.0, 45.0)
|
2024-07-16 17:18:28 -07:00
|
|
|
wrist_height: float = 60.0
|
2024-07-24 21:49:54 -07:00
|
|
|
wrist_joint: ElbowJoint = field(default_factory=lambda: ElbowJoint(
|
2024-07-25 13:05:12 -07:00
|
|
|
disk_joint=DiskJoint(
|
|
|
|
spring_angle_at_0=120,
|
|
|
|
**WRIST_DISK_PARAMS,
|
|
|
|
),
|
2024-07-24 21:49:54 -07:00
|
|
|
flip=True,
|
2024-07-25 12:31:25 -07:00
|
|
|
angle_neutral=-20.0,
|
|
|
|
child_arm_radius=23.0,
|
|
|
|
parent_arm_radius=30.0,
|
2024-07-29 01:06:27 -07:00
|
|
|
flexor_line_length=50.0,
|
|
|
|
flexor_line_slack=3.0,
|
|
|
|
flexor_offset_angle=45.0,
|
|
|
|
flexor_child_arm_radius=None,
|
2024-07-25 12:31:25 -07:00
|
|
|
flexor_mount_angle_parent=20,
|
|
|
|
flexor_mount_angle_child=-40,
|
|
|
|
hole_pos=[10, 20],
|
|
|
|
lip_length=50,
|
2024-07-29 01:06:27 -07:00
|
|
|
actuator=LINEAR_ACTUATOR_10,
|
2024-07-25 12:31:25 -07:00
|
|
|
#flexor_pos_smaller=False,
|
2024-07-24 21:49:54 -07:00
|
|
|
**WRIST_PARAMS
|
|
|
|
))
|
2024-07-16 17:18:28 -07:00
|
|
|
|
|
|
|
# Extends from the wrist to the tip of the arrow
|
|
|
|
arrow_height: float = 300
|
2024-07-17 21:17:50 -07:00
|
|
|
arrow_angle: float = -8
|
2024-07-16 17:18:28 -07:00
|
|
|
|
2024-07-19 23:49:38 -07:00
|
|
|
# Underapproximate the wrist tangent angle to leave no gaps on the blade
|
|
|
|
blade_wrist_approx_tangent_angle: float = 40.0
|
|
|
|
# Some overlap needed to glue the two sides
|
|
|
|
blade_overlap_angle: float = -1
|
|
|
|
blade_hole_angle: float = 3
|
|
|
|
blade_hole_diam: float = 12.0
|
|
|
|
blade_hole_heights: list[float] = field(default_factory=lambda: [230, 260])
|
|
|
|
blade_angle: float = 7
|
|
|
|
|
2024-07-16 17:18:28 -07:00
|
|
|
# Relative (in wrist coordinate) centre of the ring
|
2024-07-17 21:17:50 -07:00
|
|
|
ring_rel_loc: Cq.Location = Cq.Location.from2d(45.0, 25.0)
|
|
|
|
ring_radius_inner: float = 22.0
|
2024-07-16 17:18:28 -07:00
|
|
|
|
2024-07-19 23:49:38 -07:00
|
|
|
flip: bool = False
|
2024-07-24 18:03:43 -07:00
|
|
|
elbow_axle_pos: float = 0.4
|
|
|
|
wrist_axle_pos: float = 0.0
|
|
|
|
elbow_joint_overlap_median: float = 0.35
|
|
|
|
wrist_joint_overlap_median: float = 0.5
|
2024-07-19 23:49:38 -07:00
|
|
|
|
2024-07-16 17:18:28 -07:00
|
|
|
def __post_init__(self):
|
|
|
|
super().__post_init__()
|
2024-07-17 21:17:50 -07:00
|
|
|
assert self.arrow_angle < 0, "Arrow angle cannot be positive"
|
|
|
|
self.arrow_bot_loc = self.wrist_bot_loc \
|
|
|
|
* Cq.Location.from2d(0, -self.arrow_height)
|
|
|
|
self.arrow_other_loc = self.arrow_bot_loc \
|
|
|
|
* Cq.Location.rot2d(self.arrow_angle) \
|
|
|
|
* Cq.Location.from2d(0, self.arrow_height + self.wrist_height)
|
|
|
|
self.ring_loc = self.wrist_top_loc * self.ring_rel_loc
|
2024-07-16 17:18:28 -07:00
|
|
|
assert self.ring_radius > self.ring_radius_inner
|
|
|
|
|
2024-07-19 23:49:38 -07:00
|
|
|
assert 0 > self.blade_overlap_angle > self.arrow_angle
|
|
|
|
assert 0 < self.blade_hole_angle < self.blade_angle
|
|
|
|
assert self.blade_wrist_approx_tangent_angle <= self.wrist_bot_loc.to2d_rot()
|
|
|
|
|
2024-07-16 17:18:28 -07:00
|
|
|
@property
|
|
|
|
def ring_radius(self) -> float:
|
2024-07-17 21:17:50 -07:00
|
|
|
(dx, dy), _ = self.ring_rel_loc.to2d()
|
2024-07-16 17:18:28 -07:00
|
|
|
return (dx * dx + dy * dy) ** 0.5
|
|
|
|
|
|
|
|
def profile(self) -> Cq.Sketch:
|
|
|
|
"""
|
|
|
|
Net profile of the wing starting from the wing root with no divisions
|
|
|
|
"""
|
|
|
|
result = (
|
|
|
|
Cq.Sketch()
|
|
|
|
.segment(
|
|
|
|
(0, 0),
|
|
|
|
(0, self.shoulder_joint.height),
|
|
|
|
tag="shoulder")
|
|
|
|
.spline([
|
|
|
|
(0, self.shoulder_joint.height),
|
2024-07-17 21:17:50 -07:00
|
|
|
self.elbow_top_loc.to2d_pos(),
|
|
|
|
self.wrist_top_loc.to2d_pos(),
|
2024-07-16 17:18:28 -07:00
|
|
|
],
|
|
|
|
tag="s1_top")
|
|
|
|
#.segment(
|
|
|
|
# (self.wrist_x, self.wrist_y),
|
|
|
|
# (wrist_top_x, wrist_top_y),
|
|
|
|
# tag="wrist")
|
|
|
|
.spline([
|
|
|
|
(0, 0),
|
2024-07-17 21:17:50 -07:00
|
|
|
self.elbow_bot_loc.to2d_pos(),
|
|
|
|
self.wrist_bot_loc.to2d_pos(),
|
2024-07-16 17:18:28 -07:00
|
|
|
],
|
|
|
|
tag="s1_bot")
|
|
|
|
)
|
|
|
|
result = (
|
|
|
|
result
|
|
|
|
.segment(
|
2024-07-17 21:17:50 -07:00
|
|
|
self.wrist_bot_loc.to2d_pos(),
|
|
|
|
self.arrow_bot_loc.to2d_pos(),
|
2024-07-16 17:18:28 -07:00
|
|
|
)
|
|
|
|
.segment(
|
2024-07-17 21:17:50 -07:00
|
|
|
self.arrow_bot_loc.to2d_pos(),
|
|
|
|
self.arrow_other_loc.to2d_pos(),
|
2024-07-16 17:18:28 -07:00
|
|
|
)
|
|
|
|
.segment(
|
2024-07-17 21:17:50 -07:00
|
|
|
self.arrow_other_loc.to2d_pos(),
|
|
|
|
self.wrist_top_loc.to2d_pos(),
|
2024-07-16 17:18:28 -07:00
|
|
|
)
|
|
|
|
)
|
|
|
|
# Carve out the ring
|
|
|
|
result = result.assemble()
|
|
|
|
result = (
|
|
|
|
result
|
2024-07-17 21:17:50 -07:00
|
|
|
.push([self.ring_loc.to2d_pos()])
|
2024-07-16 17:18:28 -07:00
|
|
|
.circle(self.ring_radius, mode='a')
|
|
|
|
.circle(self.ring_radius_inner, mode='s')
|
|
|
|
.clean()
|
|
|
|
)
|
|
|
|
return result
|
|
|
|
|
2024-07-23 22:12:46 -07:00
|
|
|
def _child_joint_extension_profile(
|
|
|
|
self,
|
|
|
|
axle_loc: Cq.Location,
|
|
|
|
radius: float,
|
|
|
|
angle_span: float,
|
|
|
|
bot: bool = False) -> Cq.Sketch:
|
|
|
|
"""
|
|
|
|
Creates a sector profile which accomodates extension
|
|
|
|
"""
|
|
|
|
# leave some margin for gluing
|
|
|
|
margin = 5
|
|
|
|
sign = -1 if bot else 1
|
|
|
|
axle_loc = axle_loc * Cq.Location.rot2d(-90 if bot else 90)
|
|
|
|
loc_h = Cq.Location.from2d(radius, 0)
|
|
|
|
loc_offset = axle_loc * Cq.Location.from2d(0, margin)
|
|
|
|
start = axle_loc * loc_h
|
|
|
|
mid = axle_loc * Cq.Location.rot2d(-sign * angle_span/2) * loc_h
|
|
|
|
end = axle_loc * Cq.Location.rot2d(-sign * angle_span) * loc_h
|
|
|
|
return (
|
|
|
|
Cq.Sketch()
|
|
|
|
.segment(
|
|
|
|
loc_offset.to2d_pos(),
|
|
|
|
start.to2d_pos(),
|
|
|
|
)
|
|
|
|
.arc(
|
|
|
|
start.to2d_pos(),
|
|
|
|
mid.to2d_pos(),
|
|
|
|
end.to2d_pos(),
|
|
|
|
)
|
|
|
|
.segment(
|
|
|
|
end.to2d_pos(),
|
|
|
|
axle_loc.to2d_pos(),
|
|
|
|
)
|
|
|
|
.segment(
|
|
|
|
axle_loc.to2d_pos(),
|
|
|
|
loc_offset.to2d_pos(),
|
|
|
|
)
|
|
|
|
.assemble()
|
|
|
|
)
|
|
|
|
|
|
|
|
@target(name="profile-s2-bridge", kind=TargetKind.DXF)
|
|
|
|
def profile_s2_bridge(self) -> Cq.Sketch:
|
|
|
|
"""
|
|
|
|
This extension profile is required to accomodate the awkward shaped
|
|
|
|
joint next to the scythe
|
|
|
|
"""
|
|
|
|
profile = self._child_joint_extension_profile(
|
|
|
|
axle_loc=self.wrist_axle_loc,
|
|
|
|
radius=self.wrist_height,
|
|
|
|
angle_span=self.wrist_joint.motion_span,
|
2024-07-24 21:49:54 -07:00
|
|
|
bot=False,
|
2024-07-23 22:12:46 -07:00
|
|
|
)
|
|
|
|
return profile
|
|
|
|
|
2024-07-19 23:49:38 -07:00
|
|
|
def profile_s3_extra(self) -> Cq.Sketch:
|
|
|
|
"""
|
|
|
|
Implements the blade part on Nue's wing
|
|
|
|
"""
|
|
|
|
left_bot_loc = self.arrow_bot_loc * Cq.Location.rot2d(-1)
|
|
|
|
hole_bot_loc = self.arrow_bot_loc * Cq.Location.rot2d(self.blade_hole_angle)
|
|
|
|
right_bot_loc = self.arrow_bot_loc * Cq.Location.rot2d(self.blade_angle)
|
2024-07-23 22:12:46 -07:00
|
|
|
h_loc = Cq.Location.from2d(0, self.arrow_height)
|
2024-07-19 23:49:38 -07:00
|
|
|
|
|
|
|
# Law of sines, uses the triangle of (wrist_bot_loc, arrow_bot_loc, ?)
|
|
|
|
theta_wp = math.radians(90 - self.blade_wrist_approx_tangent_angle)
|
|
|
|
theta_b = math.radians(self.blade_angle)
|
|
|
|
h_blade = math.sin(theta_wp) / math.sin(math.pi - theta_b - theta_wp) * self.arrow_height
|
|
|
|
h_blade_loc = Cq.Location.from2d(0, h_blade)
|
|
|
|
return (
|
|
|
|
Cq.Sketch()
|
|
|
|
.segment(
|
|
|
|
self.arrow_bot_loc.to2d_pos(),
|
|
|
|
(left_bot_loc * h_loc).to2d_pos(),
|
|
|
|
)
|
|
|
|
.segment(
|
|
|
|
(self.arrow_bot_loc * h_loc).to2d_pos(),
|
|
|
|
)
|
|
|
|
.segment(
|
|
|
|
(right_bot_loc * h_blade_loc).to2d_pos(),
|
|
|
|
)
|
|
|
|
.close()
|
|
|
|
.assemble()
|
|
|
|
.reset()
|
|
|
|
.push([
|
|
|
|
(hole_bot_loc * Cq.Location.from2d(0, h)).to2d_pos()
|
|
|
|
for h in self.blade_hole_heights
|
|
|
|
])
|
|
|
|
.circle(self.blade_hole_diam / 2, mode='s')
|
|
|
|
)
|
|
|
|
|
2024-07-17 01:19:17 -07:00
|
|
|
def _mask_elbow(self) -> list[Tuple[float, float]]:
|
|
|
|
l = 200
|
2024-07-17 21:17:50 -07:00
|
|
|
elbow_x, _ = self.elbow_bot_loc.to2d_pos()
|
|
|
|
elbow_top_x, _ = self.elbow_top_loc.to2d_pos()
|
2024-07-17 01:19:17 -07:00
|
|
|
return [
|
|
|
|
(0, -l),
|
2024-07-17 21:17:50 -07:00
|
|
|
(elbow_x, -l),
|
|
|
|
self.elbow_bot_loc.to2d_pos(),
|
|
|
|
self.elbow_top_loc.to2d_pos(),
|
|
|
|
(elbow_top_x, l),
|
2024-07-17 01:19:17 -07:00
|
|
|
(0, l)
|
|
|
|
]
|
|
|
|
|
|
|
|
def _mask_wrist(self) -> list[Tuple[float, float]]:
|
|
|
|
l = 200
|
2024-07-17 21:17:50 -07:00
|
|
|
wrist_x, _ = self.wrist_bot_loc.to2d_pos()
|
|
|
|
_, wrist_top_y = self.wrist_top_loc.to2d_pos()
|
2024-07-17 01:19:17 -07:00
|
|
|
return [
|
|
|
|
(0, -l),
|
2024-07-17 21:17:50 -07:00
|
|
|
(wrist_x, -l),
|
|
|
|
self.wrist_bot_loc.to2d_pos(),
|
|
|
|
self.wrist_top_loc.to2d_pos(),
|
2024-07-17 01:19:17 -07:00
|
|
|
#(self.wrist_top_x, self.wrist_top_y),
|
2024-07-17 21:17:50 -07:00
|
|
|
(0, wrist_top_y),
|
2024-07-17 01:19:17 -07:00
|
|
|
]
|
|
|
|
|
|
|
|
|
2024-07-16 17:18:28 -07:00
|
|
|
@dataclass(kw_only=True)
|
|
|
|
class WingL(WingProfile):
|
|
|
|
|
2024-07-25 10:41:58 -07:00
|
|
|
elbow_bot_loc: Cq.Location = Cq.Location.from2d(260.0, 105.0, 0.0)
|
|
|
|
elbow_height: float = 95.0
|
2024-07-24 21:49:54 -07:00
|
|
|
elbow_rotate: float = 15.0
|
|
|
|
elbow_joint: ElbowJoint = field(default_factory=lambda: ElbowJoint(
|
2024-07-25 10:41:58 -07:00
|
|
|
disk_joint=DiskJoint(
|
2024-07-25 13:05:12 -07:00
|
|
|
spring_angle_at_0=100,
|
2024-07-25 10:41:58 -07:00
|
|
|
movement_angle=50,
|
|
|
|
),
|
2024-07-25 12:38:05 -07:00
|
|
|
angle_neutral=30.0,
|
2024-07-25 10:41:58 -07:00
|
|
|
flexor_mount_angle_child=220,
|
|
|
|
flexor_mount_angle_parent=0,
|
|
|
|
flexor_line_length=50.0,
|
|
|
|
flexor_line_slack=10.0,
|
2024-07-25 00:09:16 -07:00
|
|
|
#flexor_line_length=0.0,
|
|
|
|
#flexor_line_slack=0.0,
|
2024-07-25 10:41:58 -07:00
|
|
|
flexor_offset_angle=0,
|
|
|
|
flexor_child_angle_fix=85,
|
|
|
|
flexor_parent_angle_fix=None,
|
|
|
|
flexor_child_arm_radius=50.0,
|
|
|
|
parent_arm_radius=50.0,
|
|
|
|
child_arm_radius=50.0,
|
2024-07-24 22:24:23 -07:00
|
|
|
flexor_pos_smaller=False,
|
2024-07-24 21:49:54 -07:00
|
|
|
flip=True,
|
|
|
|
**ELBOW_PARAMS
|
|
|
|
))
|
2024-07-25 10:41:58 -07:00
|
|
|
elbow_axle_pos: float = 0.53
|
|
|
|
elbow_joint_overlap_median: float = 0.5
|
2024-07-16 17:18:28 -07:00
|
|
|
|
2024-07-24 22:24:23 -07:00
|
|
|
wrist_angle: float = 0.0
|
2024-07-19 18:59:58 -07:00
|
|
|
wrist_bot_loc: Cq.Location = Cq.Location.from2d(460.0, -10.0, -45.0)
|
2024-07-16 17:18:28 -07:00
|
|
|
wrist_height: float = 43.0
|
2024-07-24 21:49:54 -07:00
|
|
|
wrist_joint: ElbowJoint = field(default_factory=lambda: ElbowJoint(
|
2024-07-25 13:05:12 -07:00
|
|
|
disk_joint=DiskJoint(
|
|
|
|
**WRIST_DISK_PARAMS,
|
|
|
|
),
|
2024-07-24 21:49:54 -07:00
|
|
|
flip=False,
|
2024-07-25 12:31:25 -07:00
|
|
|
hole_pos=[10],
|
|
|
|
lip_length=30,
|
|
|
|
child_arm_radius=23.0,
|
|
|
|
parent_arm_radius=30.0,
|
2024-07-25 12:35:36 -07:00
|
|
|
flexor_offset_angle=0.0,
|
2024-07-25 12:31:25 -07:00
|
|
|
flexor_child_arm_radius=None,
|
2024-07-25 12:35:36 -07:00
|
|
|
flexor_line_length=50.0,
|
|
|
|
flexor_line_slack=1.0,
|
|
|
|
actuator=LINEAR_ACTUATOR_10,
|
2024-07-24 21:49:54 -07:00
|
|
|
**WRIST_PARAMS
|
|
|
|
))
|
2024-07-16 17:18:28 -07:00
|
|
|
|
2024-07-18 11:08:34 -07:00
|
|
|
shoulder_bezier_ext: float = 120.0
|
|
|
|
shoulder_bezier_drop: float = 15.0
|
|
|
|
elbow_bezier_ext: float = 80.0
|
2024-07-16 17:18:28 -07:00
|
|
|
wrist_bezier_ext: float = 30.0
|
|
|
|
|
|
|
|
arrow_length: float = 135.0
|
|
|
|
arrow_height: float = 120.0
|
|
|
|
|
|
|
|
flip: bool = True
|
2024-07-22 09:49:16 -07:00
|
|
|
wrist_axle_pos: float = 0.5
|
2024-07-23 22:12:46 -07:00
|
|
|
wrist_joint_overlap_median: float = 0.5
|
|
|
|
|
2024-07-24 21:49:54 -07:00
|
|
|
|
2024-07-16 17:18:28 -07:00
|
|
|
def __post_init__(self):
|
|
|
|
assert self.wrist_height <= self.shoulder_joint.height
|
2024-07-17 21:17:50 -07:00
|
|
|
self.wrist_bot_loc = self.wrist_bot_loc.with_angle_2d(self.wrist_angle)
|
2024-07-24 21:49:54 -07:00
|
|
|
|
2024-07-25 12:42:35 -07:00
|
|
|
self.wrist_joint.angle_neutral = self.wrist_bot_loc.to2d_rot() * 0.7 + 30.0
|
2024-07-18 21:07:08 -07:00
|
|
|
self.wrist_rotate = -self.wrist_joint.angle_neutral
|
2024-07-24 12:45:38 -07:00
|
|
|
self.shoulder_joint.flip = True
|
2024-07-17 21:17:50 -07:00
|
|
|
|
|
|
|
super().__post_init__()
|
2024-07-16 17:18:28 -07:00
|
|
|
|
|
|
|
def arrow_to_abs(self, x, y) -> Tuple[float, float]:
|
2024-07-17 21:17:50 -07:00
|
|
|
rel = Cq.Location.from2d(x * self.arrow_length, y * self.arrow_height / 2 + self.wrist_height / 2)
|
|
|
|
return (self.wrist_bot_loc * rel).to2d_pos()
|
2024-07-16 17:18:28 -07:00
|
|
|
|
|
|
|
def profile(self) -> Cq.Sketch:
|
|
|
|
result = (
|
|
|
|
Cq.Sketch()
|
|
|
|
.segment(
|
|
|
|
(0,0),
|
|
|
|
(0, self.shoulder_height)
|
|
|
|
)
|
|
|
|
.bezier([
|
|
|
|
(0, 0),
|
2024-07-18 11:08:34 -07:00
|
|
|
(self.shoulder_bezier_ext, -self.shoulder_bezier_drop),
|
2024-07-17 21:17:50 -07:00
|
|
|
(self.elbow_bot_loc * Cq.Location.from2d(-self.elbow_bezier_ext, 0)).to2d_pos(),
|
|
|
|
self.elbow_bot_loc.to2d_pos(),
|
2024-07-16 17:18:28 -07:00
|
|
|
])
|
|
|
|
.bezier([
|
|
|
|
(0, self.shoulder_joint.height),
|
|
|
|
(self.shoulder_bezier_ext, self.shoulder_joint.height),
|
2024-07-17 21:17:50 -07:00
|
|
|
(self.elbow_top_loc * Cq.Location.from2d(-self.elbow_bezier_ext, 0)).to2d_pos(),
|
|
|
|
self.elbow_top_loc.to2d_pos(),
|
2024-07-16 17:18:28 -07:00
|
|
|
])
|
|
|
|
.bezier([
|
2024-07-17 21:17:50 -07:00
|
|
|
self.elbow_bot_loc.to2d_pos(),
|
|
|
|
(self.elbow_bot_loc * Cq.Location.from2d(self.elbow_bezier_ext, 0)).to2d_pos(),
|
|
|
|
(self.wrist_bot_loc * Cq.Location.from2d(-self.wrist_bezier_ext, 0)).to2d_pos(),
|
|
|
|
self.wrist_bot_loc.to2d_pos(),
|
2024-07-16 17:18:28 -07:00
|
|
|
])
|
|
|
|
.bezier([
|
2024-07-17 21:17:50 -07:00
|
|
|
self.elbow_top_loc.to2d_pos(),
|
|
|
|
(self.elbow_top_loc * Cq.Location.from2d(self.elbow_bezier_ext, 0)).to2d_pos(),
|
|
|
|
(self.wrist_top_loc * Cq.Location.from2d(-self.wrist_bezier_ext, 0)).to2d_pos(),
|
|
|
|
self.wrist_top_loc.to2d_pos(),
|
2024-07-16 17:18:28 -07:00
|
|
|
])
|
|
|
|
)
|
|
|
|
# arrow base positions
|
|
|
|
base_u, base_v = 0.3, 0.3
|
|
|
|
result = (
|
|
|
|
result
|
|
|
|
.bezier([
|
2024-07-17 21:17:50 -07:00
|
|
|
self.wrist_top_loc.to2d_pos(),
|
|
|
|
(self.wrist_top_loc * Cq.Location.from2d(self.wrist_bezier_ext, 0)).to2d_pos(),
|
2024-07-16 17:18:28 -07:00
|
|
|
self.arrow_to_abs(base_u, base_v),
|
|
|
|
])
|
|
|
|
.bezier([
|
2024-07-17 21:17:50 -07:00
|
|
|
self.wrist_bot_loc.to2d_pos(),
|
|
|
|
(self.wrist_bot_loc * Cq.Location.from2d(self.wrist_bezier_ext, 0)).to2d_pos(),
|
2024-07-16 17:18:28 -07:00
|
|
|
self.arrow_to_abs(base_u, -base_v),
|
|
|
|
])
|
|
|
|
)
|
|
|
|
# Create the arrow
|
|
|
|
arrow_beziers = [
|
|
|
|
[
|
|
|
|
(0, 1),
|
|
|
|
(0.3, 1),
|
|
|
|
(0.8, .2),
|
|
|
|
(1, 0),
|
|
|
|
],
|
|
|
|
[
|
|
|
|
(0, 1),
|
|
|
|
(0.1, 0.8),
|
|
|
|
(base_u, base_v),
|
|
|
|
]
|
|
|
|
]
|
|
|
|
arrow_beziers = [
|
|
|
|
l2
|
|
|
|
for l in arrow_beziers
|
|
|
|
for l2 in [l, [(x, -y) for x,y in l]]
|
|
|
|
]
|
|
|
|
for line in arrow_beziers:
|
|
|
|
result = result.bezier([self.arrow_to_abs(x, y) for x,y in line])
|
|
|
|
return result.assemble()
|
2024-07-17 01:19:17 -07:00
|
|
|
|
|
|
|
def _mask_elbow(self) -> list[Tuple[float, float]]:
|
|
|
|
l = 200
|
2024-07-17 21:17:50 -07:00
|
|
|
elbow_bot_x, _ = self.elbow_bot_loc.to2d_pos()
|
|
|
|
elbow_top_x, _ = self.elbow_top_loc.to2d_pos()
|
2024-07-17 01:19:17 -07:00
|
|
|
return [
|
|
|
|
(0, -l),
|
2024-07-17 21:17:50 -07:00
|
|
|
(elbow_bot_x, -l),
|
|
|
|
self.elbow_bot_loc.to2d_pos(),
|
|
|
|
self.elbow_top_loc.to2d_pos(),
|
|
|
|
(elbow_top_x, l),
|
2024-07-17 01:19:17 -07:00
|
|
|
(0, l)
|
|
|
|
]
|
|
|
|
|
|
|
|
def _mask_wrist(self) -> list[Tuple[float, float]]:
|
|
|
|
l = 200
|
2024-07-17 21:17:50 -07:00
|
|
|
elbow_bot_x, _ = self.elbow_bot_loc.to2d_pos()
|
2024-07-21 00:17:43 -07:00
|
|
|
elbow_top_x, elbow_top_y = self.elbow_top_loc.to2d_pos()
|
2024-07-17 21:17:50 -07:00
|
|
|
_, wrist_bot_y = self.wrist_bot_loc.to2d_pos()
|
2024-07-21 00:17:43 -07:00
|
|
|
wrist_top_x, wrist_top_y = self.wrist_top_loc.to2d_pos()
|
2024-07-17 01:19:17 -07:00
|
|
|
return [
|
|
|
|
(0, -l),
|
2024-07-17 21:17:50 -07:00
|
|
|
(elbow_bot_x, wrist_bot_y),
|
|
|
|
self.wrist_bot_loc.to2d_pos(),
|
|
|
|
self.wrist_top_loc.to2d_pos(),
|
2024-07-21 00:17:43 -07:00
|
|
|
(wrist_top_x, wrist_top_y + l),
|
|
|
|
(elbow_top_x, elbow_top_y + l),
|
2024-07-17 01:19:17 -07:00
|
|
|
(0, l),
|
|
|
|
]
|