ContentsFoundations to FrontierBezhig

eng-lab/hwe/core/arm.py

All lab code. Download this file.

"""EL01 lab: your first parametric part, and its hand-calculated cross-check.
YOU WRITE THIS FILE (EL01 lab, step 6).

The arm, seen from above (x along the arm, y across it; thickness along z):

    frame end (x = 0)                                   motor centre (x = length)
      +-------------------------------------------+-----------+
      |  o frame     o frame                      |  o     o  |   <- square motor pad,
      |    hole        hole                       |    ( )    |      pad_size on a side,
      +-------------------------------------------+  o     o  |      centred on the motor
                                                  +-----------+

- The bar runs from x = 0 to x = length and is `width` wide, centred on y = 0.
- The pad is a pad_size x pad_size square centred on (length, 0).
- Four motor screw holes sit on a square pattern, motor_hole_spacing apart,
  centred on the motor; one centre hole clears the motor's shaft and clip.
- Two frame bolt holes sit on the centre line at x = frame_hole_inset and
  x = frame_hole_inset + frame_hole_pitch.
- The whole outline is extruded `thickness` upward from z = 0.

Every argument is a length Quantity. build123d works in bare millimetres, so
cross the units boundary exactly once, with hwe.cad.boundary.mm().
"""
from hwe.cad.boundary import mm
from hwe.units import Q_, quantities

LENGTHS = dict(length="[length]", width="[length]", thickness="[length]", pad_size="[length]",
               motor_hole_spacing="[length]", motor_hole_diameter="[length]",
               center_hole_diameter="[length]", frame_hole_diameter="[length]",
               frame_hole_inset="[length]", frame_hole_pitch="[length]")


@quantities(**LENGTHS)
def arm(length, width, thickness, pad_size, motor_hole_spacing, motor_hole_diameter,
        center_hole_diameter, frame_hole_diameter, frame_hole_inset, frame_hole_pitch):
    """Build the arm described above and return it as a build123d Part (millimetres).

    Step 6 of EL01 shows this function in full; type it, don't paste it.
    """
    raise NotImplementedError("Step 6: arm")


@quantities(**LENGTHS, returns="[volume]")
def arm_volume_by_hand(length, width, thickness, pad_size, motor_hole_spacing,
                       motor_hole_diameter, center_hole_diameter, frame_hole_diameter,
                       frame_hole_inset, frame_hole_pitch):
    """The arm's volume from plain geometry, as an independent check on the CAD.

    Top-view area = bar + pad - the part of the pad that overlaps the bar
                    - the area of all seven holes;
    volume = that area x thickness. Return cubic millimetres.
    Some arguments do not affect the volume; say in a comment which, and why.
    The formula assumes a sensible arm: the pad at least as wide as the bar, and
    every hole wholly inside material without touching another hole.
    """
    raise NotImplementedError("Step 6: arm_volume_by_hand")