Assembly families

Three mechanism families extend the rotating pin: a hinged flap that swings toward a post, a block that slides toward a post, and a lever that pivots next to a stop. Each family builds an Assembly (the contract in src/tolerance_arena/assembly/types.py) from named, bounded parameters and has a closed-form reference distance that does not use the kernel.

  • src/tolerance_arena/assembly/families.py holds the ids, versions, parameters, build, reference_distance and planted.
  • src/tolerance_arena/assembly/references.py holds the closed forms. It imports only math and collections.abc.
  • The tests are tests/assembly/test_assembly_references.py (hand values, no kernel), tests/assembly/test_assembly_families.py (bounds, refusals, planted numbers, this document) and tests/assembly/test_assembly_families_native.py (the kernel against the reference).
  • The evidence of the run that produced these numbers is in docs/assembly-log/families.md.

Frame and placement

Every family is planar. Its solids stand on z = 0 and share one height, so the minimum distance between two solids is the planar distance between their outlines. Lengths are millimetres and angles are degrees. The joint origin is the world origin in every family.

The deviation moves the fixed part by delta along its direction. The moving part gets the joint motion q: a revolute joint turns it counter-clockwise about +Z by q degrees, a prismatic joint slides it by q mm along +X. The joint range is 0 to the limit parameter of the family. The deviation range is minus to plus max_deviation_mm.

Parameters and refusals

A parameter name ends in its unit, _mm or _deg, and every parameter has closed bounds. The code refuses, with a message that names the field, an unknown family id, an unknown parameter, a missing parameter, a value that is not a finite number (booleans and strings included), a value outside its bounds, and a q or delta outside its range. Nothing is clamped or repaired. A refusal happens before any solid exists.

Every family shares two parameters: max_deviation_mm and minimum_mm, the requirement, which is the smallest allowed gap between the two parts.

Functions

  • family_ids() and family(id) list and describe the families.
  • validate_params(id, params) returns a checked copy of the parameters as floats.
  • build(id, params) returns the nominal Assembly.
  • joint_range(id, params) and deviation_range(id, params) return the two ranges.
  • reference_distance(id, params, q, delta) returns the gap at a pose, 0 when the parts touch, overlap or contain one another.
  • planted(id) returns the planted parameters, the requirement, the adverse deviation, the four-point grid over the joint range and the interior pose.

hinged-flap-post

Version 1. Revolute. A flap hinged along one edge swings toward a cylindrical post. The hinge is the z axis through the origin. Before it swings, the flap spans x from 0 to flap_length_mm and y within half flap_thickness_mm of the x axis. The deviation moves the post along x.

ParameterLowHighUnitMeaning
flap_length_mm5100mmFlap extent along x, from the hinge to its tip.
flap_thickness_mm0.520mmFlap extent along y, centred on the hinge line.
flap_width_mm150mmFlap extent along the hinge axis z; every solid of the family has this height.
post_x_mm-100100mmNominal x of the post axis, before the deviation.
post_y_mm-100100mmNominal y of the post axis.
post_radius_mm0.520mmRadius of the cylindrical post.
swing_deg5180degThe joint range is 0 to this angle.
max_deviation_mm0.15mmThe deviation delta ranges from minus this value to plus this value.
minimum_mm0.110mmThe requirement: the smallest allowed gap.

Reference: turn the post centre by minus q about the hinge, which puts the flap back at its start. The gap is the distance from that point to the rectangle, less the post radius. It is 0 when the centre lies inside the rectangle or the post surface overlaps it.

Planted configuration: flap_length_mm 41.5, flap_thickness_mm 2, flap_width_mm 10, post axis at (32, 32), post_radius_mm 2, swing_deg 90, max_deviation_mm 1.2, minimum_mm 1.5. The post axis is 45.25 mm from the hinge at 45 degrees. The adverse deviation is -1.2 mm: it moves the post to (30.8, 32), 44.41 mm from the hinge at 46.1 degrees. The tip corners of the flap sweep a circle of radius 41.51 mm, so the gap between tip and post falls to about 44.41 - 41.51 - 2 = 0.90 mm when the flap points near 46 degrees.

At the adverse deviation the gap is below 1.5 mm from 42.1 to 50.1 degrees and at or above it elsewhere on the 900-step sweep. The four-point grid over the joint range is 0, 30, 60 and 90 degrees. None of them falls in that window.

q (deg)Reference (mm)Kernel (mm)Against the 1.5 mm requirement
029.000029.0000at or above
309.37359.3735at or above
607.80717.8071at or above
9027.800027.8000at or above
450.90630.9063below: violated

The smallest gap over the joint range is 1.743 mm at delta 0 and 0.902 mm at delta -1.2 (900 even steps). The nominal assembly satisfies the requirement and the deviation causes the violation.

sliding-block-post

Version 1. Prismatic. A block slides along x toward a cylindrical post. Before it slides, the block spans x from 0 to block_length_mm and y within half block_width_mm of the x axis. The deviation moves the post along y.

ParameterLowHighUnitMeaning
block_length_mm1100mmBlock extent along x, the direction it slides.
block_width_mm150mmBlock extent along y, centred on the slide line.
height_mm150mmExtent along z of the block and the post.
post_x_mm-100300mmNominal x of the post axis.
post_y_mm-100100mmNominal y of the post axis, before the deviation.
post_radius_mm0.520mmRadius of the cylindrical post.
travel_mm5300mmThe joint range is 0 to this distance.
max_deviation_mm0.15mmThe deviation delta ranges from minus this value to plus this value.
minimum_mm0.110mmThe requirement: the smallest allowed gap.

Reference: slide the post by minus q along x, which puts the block back at its start. The gap is the distance from that point to the rectangle, less the post radius, and 0 when the centre lies inside or the surface overlaps.

Planted configuration: block_length_mm 12, block_width_mm 8, height_mm 10, post axis at (66, 8.4), post_radius_mm 2, travel_mm 120, max_deviation_mm 1.2, minimum_mm 1.5. The block face at y = 4 and the post surface at y = 6.4 leave 2.4 mm. The adverse deviation is -1.2 mm: it moves the post to y = 7.2 and leaves 1.2 mm. The block passes beside the post while its x span, q to q + 12, contains x = 66, that is for q from 54 to 66 mm. Near the ends of that stretch the corner gives the gap.

At the adverse deviation the gap is below 1.5 mm from 52.6 to 67.4 mm and at or above it elsewhere on the 900-step sweep. The four-point grid is 0, 40, 80 and 120 mm. None of them falls in that window.

q (mm)Reference (mm)Kernel (mm)Against the 1.5 mm requirement
052.094752.0947at or above
4012.361112.3611at or above
8012.361112.3611at or above
12052.094752.0947at or above
601.20001.2000below: violated

The smallest gap over the joint range is 2.400 mm at delta 0 and 1.200 mm at delta -1.2 (900 even steps). The nominal assembly satisfies the requirement and the deviation causes the violation.

lever-stop

Version 1. Revolute. A lever bar pivots about the origin next to a fixed rectangular stop. Before it turns, the lever spans x from -lever_tail_mm to lever_length_mm and y within half lever_width_mm of the x axis. The stop is centred stop_radius_mm from the pivot toward stop_angle_deg. It extends half stop_depth_mm along its normal, which points the same way, and half stop_width_mm across it. The deviation moves the stop along its normal.

ParameterLowHighUnitMeaning
lever_length_mm5150mmLever extent from the pivot to its tip.
lever_tail_mm050mmLever extent from the pivot to its other end.
lever_width_mm0.530mmLever extent across its length, centred on it.
height_mm150mmExtent along z of the lever and the stop.
stop_radius_mm5200mmDistance from the pivot to the stop centre.
stop_depth_mm0.550mmStop extent along its normal.
stop_width_mm0.5100mmStop extent across its normal.
stop_angle_deg-180180degDirection of the stop from the pivot, also the direction of its normal.
swing_deg5180degThe joint range is 0 to this angle.
max_deviation_mm0.15mmThe deviation delta ranges from minus this value to plus this value.
minimum_mm0.110mmThe requirement: the smallest allowed gap.

Reference: both outlines are rectangles with four corners. The gap is the minimum over the 16 pairs of segments, one from each outline. It is 0 when two segments cross, touch or overlap, and when a corner of one rectangle lies inside the other, which covers a rectangle that contains the other without any crossing segment.

Planted configuration: lever_length_mm 40, lever_tail_mm 5, lever_width_mm 4, height_mm 10, stop_radius_mm 45.5, stop_depth_mm 6, stop_width_mm 10, stop_angle_deg 45, swing_deg 90, max_deviation_mm 1.2, minimum_mm 1.5. The inner face of the stop lies 42.5 mm from the pivot. The adverse deviation is -1.2 mm: it moves that face to 41.3 mm. At q = 45 degrees the tip face of the lever, at 40 mm, is parallel to it and 1.3 mm away.

At the adverse deviation the gap is below 1.5 mm from 35.7 to 54.3 degrees and at or above it elsewhere on the 900-step sweep. The four-point grid is 0, 30, 60 and 90 degrees. None of them falls in that window.

q (deg)Reference (mm)Kernel (mm)Against the 1.5 mm requirement
023.668023.6680at or above
304.03804.0380at or above
604.03804.0380at or above
9023.668023.6680at or above
451.30001.3000below: violated

The smallest gap over the joint range is 2.450 mm at delta 0 and 1.250 mm at delta -1.2 (900 even steps). The nominal assembly satisfies the requirement and the deviation causes the violation.

Where the numbers come from

  • The reference column comes from reference_distance and the kernel column from native.measure_distance on solids placed by a local helper in tests/assembly/test_assembly_families_native.py. Both are printed by that test with -s.
  • tests/assembly/test_assembly_families.py and the native test check that every number above matches what the code computes, so a change in the code fails the document check.
  • The kernel and the reference agree within 1e-6 mm on more than 200 poses per family: the grid, the ends of both ranges, poses 0.05 mm from contact, overlapping poses and random poses. The run and its largest differences are in docs/assembly-log/families.md.

Limits

  • The families are planar and the reference models that plane only. A configuration whose solids differ in height is outside the family.
  • The reference distance is a check on the kernel and on the solids a family builds. It does not stand in for a kernel measurement and it never produces a verdict.
  • The planted configurations show one violation hidden from a four-point grid. They are not a claim about the share of designs in a family with that property.