docs/kitbash.md: Rams and linkages: zones, the strict record, the live knee's readings and costs

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-12-02 20:01:37 +01:00
commit 7dd1de35fe

View file

@ -661,20 +661,31 @@ Transmission angles at `c` and `p` are reported and not gated. Over the R-3 knee
transmission angle of 200,000 sampled four-bars was 21.9 degrees, under the 30 to 40 a textbook asks; a gate there
would have refused every one of them. What a poor angle costs is pin load, and that is the gate.
### Clearance: parts and what a member may touch
### Clearance: parts, and zones about a member's pins
The record names the mechanism's `parts`, each a piece of one body (part -> parent, child, rocker or coupler: the
body whose rest frame it turns with), and `touch`: for each member (`barrel`, `rod`, `rocker`, `coupler`, and a
bell crank's `rocker arm`), the parts it may touch. This is the allowed-collision matrix of motion planning
(MoveIt's ACM): a pair listed there is skipped whole and every other (member, part) pair is checked. A member may
touch what it is pinned to and what is stacked on its pins: the pin, its own eye and clevis, its own plates, the
plates beside it on that pin, the bracket or horn the pin stands in. Nothing is exempt by a name, by a length cut
from a member's end, or by the member's own body: the barrel runs from its back end, the rod to the eye, a bar
from pin to pin. Every body of the kind owns at least one part, or the gate refuses the record.
bell crank's `rocker arm`), zones `(part, pin, radius, depth)`. Every member meets every part. A zone changes what
the member's samples keep from one part, and only within `radius` of the axis of `pin`, measured across the hinge
axis; the pin is one the member rides (the ram `a` and its eye, the rocker its pivot and `p`, the coupler `p` and
`c`, the arm the pivot and `d`). Inside the zone a sample may come as near the part as `-depth`; beyond it the
pair is checked like any other. Nothing is exempt by a name, by a length cut from a member's end, or by the
member's own body: the barrel runs from its back end, the rod to the eye, a bar from pin to pin. Every body of the
kind owns at least one part, or the gate refuses the record.
What it gives up: a pair in `touch` is not checked anywhere, so a coupler let touch the horn that carries `c` may
also pass through that horn's far end unseen. Parts are the grain: cut a body into the piece that carries the pin
and the rest, and let only the first.
A zone's radius is the eye's radius plus a margin: the pin's, collar's or cheek's radius plus what the member
keeps (radius, gap, half the spacing). Its depth says how the member stands to the part there. 0 is beside it: a
plate stacked on the pin, the bracket or horn the pin stands in. The member's axis then stays outside the part, so
a pin whose place along the axis is inside what it claims to stand beside is refused: the gate does not take the
record's x on trust. The pin's radius is for the pin through the member's eye, half the plate's thickness for the
member's own plate, let over its length. Two plates stacked on a pin cross like scissors; the zone that lets one
link by the other's plate reaches as far as the two part, (half width + what a link keeps) / sin of the least
angle they cross at.
What it gives up: inside a zone the gate holds only the member's axis `depth` from the part, not its surface a
gap from it, so a link may graze the plate it scissors with anywhere within the stated radius, and a depth stated
deeper than the eye lets the axis into the part that far. Both are numbers in the record, to be read. The members
are round bars; a plate's flat sides are not modelled, which is why stacked plates need a zone at all.
The oracle is `distance(part, points) -> distances`, `points` in the rest frame of the part's body. Each member is
sampled along its axis at most `spacing` apart (default the barrel's radius) and carried into each body's rest
@ -683,47 +694,53 @@ between samples. A distance is signed: negative inside a part, by any depth. The
`Ram.reach(spacing)`, outside a part only; a point inside reads negative however deep it lies. An oracle that
cannot tell inside from outside raises instead of answering (a nearest-surface query alone reads 0.13 at the
centre of the R-3 thigh's core, and reads clear when capped); nan is refused. `Fit.pairs` holds the least margin
and its angle for every pair checked, `Fit.allowed` every pair skipped.
and its angle for every pair, `Fit.allowed` the pairs a zone lets near a pin.
`search` seats a mechanism from a grid (ram seats; for linkages rocker pivots, child pins, `p` on a polar grid
about R, and `d` about R for a bell crank, the eye standing at `a`'s place along the axis), refuses a grid over
`limit` candidates naming the count, runs every gate but clearance on all of them, then clearance in order of
least arm; a miss returns the tally by gate and the nearest miss. Clearance takes `world(m) -> (parts, touch,
distance)`: a linkage's brackets and links are the candidate's own, so each candidate that reaches the gate is met
with the parts its own pins place. `swept` gives the ram's swept surface in any body's frame, for a recess.
with the parts its own pins place. What `world` returns is read as a record's: anything but the three, a part on
no body of the kind, or a zone that is not a part, a pin the member rides, a radius and a depth is refused.
`swept` gives the ram's swept surface in any body's frame, for a recess.
### The record
`record` and `from_record` carry a mechanism as JSON: `schema` (`brokkr.ram`), `version` (1), `kind`, `hinge`,
`pins`, `offsets`, `ram`, `parts`, `touch`, and `compliance`. It holds what is authored; barrel, closed length and
link lengths are derived by the reader. `compliance` is reserved for a load-path ram's settle (stiffness, damping,
travel); version 1 writes it null and solves none. A record of another schema or version, with a key version 1
does not know (at the top, in `ram` or in `hinge`), or with a compliance block is refused whole: a reader never
reads past what it cannot solve.
`pins`, `offsets`, `ram`, `parts`, `touch` (member -> zones, each `{part, pin, radius, depth}`), and `compliance`.
It holds what is authored; barrel, closed length and link lengths are derived by the reader. `compliance` is
reserved for a load-path ram's settle (stiffness, damping, travel); version 1 writes it null and solves none. A
record of another schema or version (the integer 1: 1.0 and true are not it), with a key version 1 does not know or
without one it does (at the top, in `ram`, `hinge`, `pins` or a zone), with a compliance block, or with a value
that is not its field's (a finite number, the bore over 0, three numbers for a point) is refused whole, as a
`RamError` that names the field: a reader never reads past what it cannot solve. A `Ram` built by hand refuses the
same numbers.
### Readings on the R-3 knee
Bore 0.042, range 0..-125. The kinematic rows are tests/test_ram.py's. The clearance rows are Blender 5.3 readings
on meshes built with the joint library the knee was drawn with (thigh with its front plate, shin with caps and
armour, the bracket that carries R, the horn that carries `c`, twin link plates stacked 5 mm apart at x 0.31..0.345
and 0.35..0.385, pins through the knee's width, a clevis at each ram pin; 4,176 triangles, 12 parts), a signed BVH
oracle (winding number along a ray for the side, nearest face for the depth).
Bore 0.042, range 0..-125. The kinematic rows are tests/test_ram.py's. The clearance rows are
`tests/live/ram_knee.py`'s, Blender 5.3 (`ram_knee.result.json` is the last run): the knee as closed meshes the
test generates (thigh with its front plate, shin with caps and armour, the bracket that carries R, the horn that
carries `c`, twin link plates stacked 5 mm apart at x 0.31..0.345 and 0.35..0.385, pins through the knee's width,
collars at the eye and a base clevis whose foot runs 0.01 into the thigh; 12 parts) and a signed BVH oracle: the
nearest face for the depth, the crossing parity of three rays, by majority, for the side. One ray that grazes an
edge miscounts and signs an isolated sample inside a plate it stands clear of.
| drive | reading |
| --- | --- |
| direct, the joint library's seats, 0..-62 | fits (analytic thigh and shin) |
| direct, 2,000 seat pairs behind the knee | none fits (analytic thigh and shin) |
| four-bar behind the knee | passes every gate before clearance: rocker swing 70.5, L 0.722..1.168, arm 0.096..0.265, pin load 1.61, transmission 16.5. Refused on the meshes: of 23 checked pairs two fail, the barrel and the rod against the shin's body (0.277 and 0.246 inside their clearance at -122.5, 251 steps), a body the ram is not pinned to |
| bell crank in front of the knee | fits on the meshes, the plates on either side: rocker swing 105.7, L 0.659..1.038, arm 0.091..0.215, pin load 1.13, transmission 13.8. 36 pairs checked, 24 let. Over 251 steps the least margin beyond radius, gap and half the spacing is 0.039 (the rod and the rocker's pivot pin at -125), then 0.042 (the coupler and the bracket at 0) and 0.058 (the rocker's arm and the coupler's plates at 0); at spacing 0.01, 0.061. With `touch` empty the same gate refuses 19 pairs, each a member against a pin it rides, its own plates or clevis, a plate stacked on its pin, or the bracket or horn that pin stands in |
| bell-crank search on the meshes | 13,824 candidates, each world built from the candidate's pins: 78 pass the gates before clearance, 21 of them are refused on their own parts, the 22nd fits (arm 0.090, swing 99.9, pin load 0.73) |
| four-bar behind the knee | passes every gate before clearance: rocker swing 70.5, L 0.722..1.168, arm 0.096..0.265, pin load 1.61, transmission 16.5. Refused on the meshes: the barrel and the rod against the shin's body (the barrel 0.122 inside its clearance, 49 steps), a body the ram is not pinned to |
| bell crank in front of the knee | fits on the meshes, the plates on either side: rocker swing 105.7, L 0.659..1.038, arm 0.091..0.215, pin load 1.13, transmission 13.8. 60 pairs, 20 of them with a zone. Over 251 steps, uncapped, the least margin of a pair with no zone is 0.034 (the rocker and the eye's pin at -125), then 0.039 (the rod and the rocker's pivot pin at -125) and 0.042 (the coupler and the bracket at 0). With `touch` empty the same gate refuses 19 pairs, each one a zoned pair; each stated zone takes in the least zone that lets its pair. A zone cut to half its radius refuses its pair |
| the same, a link's x moved | the rocker at x 0.25 (inside the bracket's 0.13..0.35) is refused 0.054 inside the bracket; the coupler at 0.25 (inside the horn's 0.23..0.31) 0.020 inside the horn |
| bell-crank search on the meshes | 13,824 candidates, each world built from the candidate's pins: 78 pass the gates before clearance, 21 of them are refused on their own parts, the 22nd fits (arm 0.090, swing 99.9, pin load 0.73) and holds at 251 steps |
Cost on Starfire, 300 repetitions paired and interleaved with the previous revision, other work holding the cores
at 100 percent: one candidate's gates before clearance at 49 steps took 0.98 ms median on the four-bar (5th to 95th
percentile 0.88 to 3.35) and 0.96 on the bell crank (0.88 to 2.03), the previous revision 1.03 and 1.00 beside
them. A search without a world ran 1.6 to 1.8 ms a candidate over 3,456, so `limit` (20,000) is 30 to 40 s. The
bell crank's clearance against analytic parts added 11 ms; on the meshes its 36 pairs asked 17,248 points and
took 0.12 s capped, in a Python loop of BVH queries; a candidate's world built in 0.045 s, and the 13,824-candidate
mesh search took 29 s (55 s in a busier minute).
Cost on Starfire, Python 3.13, 100 repetitions paired and interleaved: one candidate's gates before clearance at
49 steps took 1.07 ms median on the bell crank; its clearance against the analytic parts (50 pairs, 23,520
points) added 56 ms (5th to 95th percentile 16 to 73, other work on the machine). A search without a world ran 1.6 to 1.8 ms a candidate over 3,456, so `limit`
(20,000) is 30 to 40 s. On the meshes the bell crank's 60 pairs at 49 steps took 0.67 to 0.84 s capped, in a Python loop
of BVH queries with three rays a sample, and the 13,824-candidate search with its 22 worlds 41 to 49 s.
## The actions