From d898df6165af916c2ebc282da4f8a2bded07ad03 Mon Sep 17 00:00:00 2001 From: Leni Aniva Date: Sun, 21 Jul 2024 22:34:19 -0700 Subject: [PATCH] feat: Add battery box item --- nhf/touhou/houjuu_nue/electronics.py | 66 ++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/nhf/touhou/houjuu_nue/electronics.py b/nhf/touhou/houjuu_nue/electronics.py index 37c31ac..2cf1c4e 100644 --- a/nhf/touhou/houjuu_nue/electronics.py +++ b/nhf/touhou/houjuu_nue/electronics.py @@ -206,6 +206,70 @@ class MountingBracket(Item): result.copyWorkplane(Cq.Workplane('XY')).tagPlane("conn_mid") return result +@dataclass(frozen=True) +class BatteryBox18650(Item): + """ + A number of 18650 batteries in series + """ + mass: float = 17.4 + 68.80 * 3 + length: float = 75.70 + width_base: float = 61.46 - 18.48 - 20.18 * 2 + battery_dist: float = 20.18 + height: float = 19.66 + # space from bottom to battery begin + thickness: float = 1.66 + battery_diam: float = 18.48 + battery_height: float = 68.80 + n_batteries: int = 3 + + def __post_init__(self): + assert 2 * self.thickness < min(self.length, self.height) + + @property + def name(self) -> str: + return f"BatteryBox 18650*{self.n_batteries}" + + @property + def role(self) -> Role: + return Role.ELECTRONIC + + def generate(self) -> Cq.Workplane: + width = self.width_base + self.battery_dist * (self.n_batteries - 1) + self.battery_diam + return ( + Cq.Workplane('XY') + .box( + length=self.length, + width=width, + height=self.height, + centered=(True, True, False), + ) + .copyWorkplane(Cq.Workplane('XY', origin=(0, 0, self.thickness))) + .box( + length=self.length - self.thickness*2, + width=width - self.thickness*2, + height=self.height - self.thickness, + centered=(True, True, False), + combine='cut', + ) + .copyWorkplane(Cq.Workplane('XY', origin=(-self.battery_height/2, 0, self.thickness + self.battery_diam/2))) + .rarray( + xSpacing=1, + ySpacing=self.battery_dist, + xCount=1, + yCount=self.n_batteries, + center=True, + ) + .cylinder( + radius=self.battery_diam/2, + height=self.battery_height, + direct=(1, 0, 0), + centered=(True, True, False), + combine=True, + ) + ) + + + LINEAR_ACTUATOR_50 = LinearActuator( mass=34.0, @@ -254,6 +318,8 @@ LINEAR_ACTUATOR_BOLT = FlatHeadBolt( ) LINEAR_ACTUATOR_BRACKET = MountingBracket() +BATTERY_BOX = BatteryBox18650() + @dataclass class Flexor: """