brokkr_kitbash: follow refuses a loop whose ends depend on more than one driver; joints pages unlimited with its rows

follow names the driver and every other input between a loop's two ends: a
follower of another driver, or a joint with travel that follows nothing. A
joint both ends hang from, and one held by limits of one value, are not inputs.
The torque link fixture holds its lug by limits [90, 90]: one row with travel
that nothing drives, nothing unlimited.

joints builds its rows in core.joint_rows; unlimited lists the ids of the rows
a report carries and is counted with them, so a report is never over a receipt
and always carries a row.

Live kitbash_follows: 76 checks; both halves of the loop-ends rule, the two
second-driver refusals, the free lug, a hinge above both ends, and a tree of
264 unlimited joints with 62-character names.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-12-03 13:04:04 +01:00
commit 56730c0c87
4 changed files with 199 additions and 50 deletions

View file

@ -70,7 +70,9 @@ a pointer to the driver. A follower's kit_roll or kit_slide is then derived: by
for the closing part of a loop and its parent, by solving the two so the closure holds (core.close_loop, over the
kit's socket frames at stored params: no pin is stored). pose() derives every follower of a driver in the driver's
own action (driven) and write_connections writes them with it, all or none; roll, aim, reach and slide on a follower
are refused. A follower has one driver and a driver is never a follower. No Blender driver or constraint is made.
are refused. A follower has one driver and a driver is never a follower; follow refuses a loop whose two ends
depend on any joint that is not its driver, a follower of its driver or held by limits of one value, so one driver's
pose is all a loop's value is a function of. No Blender driver or constraint is made.
"""
bl_info = {"name": "Brokkr Kitbash", "author": "GameCult", "version": (0, 1, 0), "blender": (5, 3, 0),
"category": "Object", "description": "Parametric machine parts from kits, with socket frames; agent-callable through Brokkr."}
@ -822,13 +824,15 @@ def bounded(report: dict, advice: str) -> dict:
return report
def fitted(report: dict, key: str, rows: list) -> list:
def fitted(report: dict, key: str, rows: list, beside=None) -> list:
"""The rows of one list of a report that fit what a receipt carries beside the rest of the report, in order; those
left off the end are counted in report[key + 'Omitted']. The one rule that trims a report's rows to a receipt:
the scene keeps what the rows would have said."""
the scene keeps what the rows would have said. `beside(row)` is what a caller adds to the report for a row it
keeps (joints: its id in `unlimited`), counted with the row."""
kept, size = [], len(json.dumps(report, separators=(",", ":"))) + 2 * len(key) + 24
for row in rows:
size += len(json.dumps(row, separators=(",", ":"))) + 1
extra = None if beside is None else beside(row)
size += sum(len(json.dumps(value, separators=(",", ":"))) + 1 for value in (row, extra) if value is not None)
if size > REPORT_LIMIT:
report[key + "Omitted"] = len(rows) - len(kept)
break
@ -1205,38 +1209,36 @@ class BROKKR_KITBASH_OT_joints(PolishOperator):
@kit_work
def work(self, context):
root, kits, rows, rigid_count = mesh_object(self.object_name), {}, [], 0
root, kits, entries = mesh_object(self.object_name), {}, []
built_part(root, kits)
frame = np.linalg.inv(np.array(root.matrix_world, dtype=np.float64))
todo = [(root, None)]
while todo: # depth first, children by name: a joint's parent joint is the nearest DOF connection above it, and rigid connections fold into it
child, above = todo.pop()
todo = [root]
while todo: # depth first, children by name: the order core.joint_rows reads a joint's parent joint in
child = todo.pop()
if child != root or link(child) is not None and child.parent is not None and PART in child.parent: # the root's own joint comes first, parent null
part, built = built_part(child, kits)
stated = link(child)
parent_socket, _ = mated(child.parent, *built_part(child.parent, kits), child, part, built, stated)
kind = dof(child.parent, parent_socket)
if kind is None:
rigid_count += child != root
else:
record, value = joint_record(child), stated[2] if kind == "revolute" else stated[3]
at = frame @ np.array(child.parent.matrix_world, dtype=np.float64) @ parent_socket["matrix"]
limits, follows = record["limits"] and [round(v, 6) for v in record["limits"]], record["follows"]
rows.append({"id": child.name, "parent": above, "part": part["name"], "socket": f"{child.parent.name}:{stated[1]}", "kind": kind,
"axis": [round(float(v), 6) for v in at[:3, 2]], "origin": [round(float(v), 6) for v in at[:3, 3]], "value": round(value, 6),
"limits": limits, "min": limits and round(record["limits"][0] - value, 6), "max": limits and round(record["limits"][1] - value, 6),
"mechanism": record["mechanism"], "compliance": record["compliance"],
"driven": follows and {"by": follows["driver"] and follows["driver"].name, "kind": follows["kind"], "k": follows["k"], "offset": follows["offset"]}})
above = child.name
todo += [(below, above) for below in sorted(attached(child), key=lambda o: o.name, reverse=True)]
if kind is not None or child != root:
record = joint_record(child)
follows = record["follows"]
entries.append((child.name, child.parent.name, part["name"], parent_socket, np.array(child.parent.matrix_world, dtype=np.float64), kind,
stated[2] if kind == "revolute" else stated[3], record,
follows and {"by": follows["driver"] and follows["driver"].name, "kind": follows["kind"], "k": follows["k"], "offset": follows["offset"]}))
todo += sorted(attached(child), key=lambda o: o.name, reverse=True)
rows, rigid_count = core.joint_rows(np.array(root.matrix_world, dtype=np.float64), entries)
ids = [row["id"] for row in rows]
report = {"schema": "brokkr.joints", "version": 2, "root": root.name, "frame": "the root object's: Blender axes (+Z up), metres", "rigid": rigid_count,
"unlimited": [row["id"] for row in rows if row["limits"] is None and row["driven"] is None], "next": "x" * 63}
"unlimited": [], "next": max(ids, key=lambda name: len(json.dumps(name)), default=None)}
if self.after:
ids = [row["id"] for row in rows]
if self.after not in ids:
raise Refused(f"after {self.after!r} is not the id of a joint under {root.name!r}: it is the `next` of the report before, or empty.")
rows = rows[ids.index(self.after) + 1:]
report["joints"] = fitted(report, "joints", rows)
def unlimited(row):
return row["id"] if row["limits"] is None and row["driven"] is None else None
report["joints"] = fitted(report, "joints", rows, unlimited) # a row and its id in `unlimited` are kept or left together: the list pages with the rows
report["unlimited"] = [row["id"] for row in report["joints"] if unlimited(row) is not None]
report["next"] = report["joints"][-1]["id"] if "jointsOmitted" in report and report["joints"] else None
return report
@ -1317,6 +1319,25 @@ class BROKKR_KITBASH_OT_follow(PolishOperator):
if moves(ends[0]) == moves(ends[1]):
raise Refused(f"the loop's two ends, {ends[0].name!r} (the base) and {ends[1].name!r} (closed on), {'both move' if moves(ends[0]) else 'neither moves'} with "
f"{driver.name!r}: exactly one of them is the driver, follows it, or hangs from one that does; nothing changed.")
chains = [[], []] # each end and what it hangs from, up to the root
for found, o in zip(chains, ends):
while o is not None:
found.append(o)
o = o.parent
others = {} # {a part whose pose moves one end against the other, and is not the driver: why}, from the joints under the ends' nearest common part
for o in (o for found in chains for o in found if not (o in chains[0] and o in chains[1])):
its, limits = joint_record(o)["follows"], joint_record(o)["limits"]
if connection_kind(o)[0] is None or o == driver or its is not None and its["driver"] in (None, driver):
continue
if its is not None:
others.setdefault(its["driver"], f"{o.name!r} follows it")
elif limits is None or limits[0] < limits[1]: # limits of one value hold a joint still: a pin with no travel
others.setdefault(o, "it follows nothing and its joint has travel, so it is posed by hand")
if others:
raise Refused(f"the loop's two ends, {ends[0].name!r} (the base) and {ends[1].name!r} (closed on), depend on more than one driver: {driver.name!r} and "
f"{', '.join(f'{o.name!r} ({why})' for o, why in sorted(others.items(), key=lambda item: item[0].name))}. A follower takes its value from "
"one driver, and a pose of another would open the loop: let every joint between the two ends be the driver, follow it, or be held by "
"limits of one value; nothing changed.")
follows = {"driver": driver, "kind": given["kind"], "k": float(given["k"]) if ratio else None, "offset": float(given["offset"]) if ratio else None}
entries, moved = driven(driver, driver_sockets, driver_stated, driver_stated[2], driver_stated[3], None, {o: follows for o in pair})
write_connections(entries)

View file

@ -360,7 +360,7 @@
},
{
"name": "brokkr_kitbash.joints",
"doc": "The joints of the tree of kit parts attached under a root part, as {schema: brokkr.joints, version: 2, root, frame, rigid, unlimited, next, joints}. A row per revolute or prismatic connection, depth first with children by name, so a joint's parent row comes before it; a root that itself states a revolute or prismatic connection has its own row first, parent null: id (the child object), parent (the id of the nearest joint above, or null: rigid connections fold into it and are counted in rigid), part, socket ('Object:socket', the parent socket), kind, axis and origin (that socket's z and origin in the root object's frame: Blender axes, +Z up, metres), value (the roll in degrees or the slide in metres now), limits ([lo, hi] or null), min and max (the limits less the value: the travel either way from this pose), mechanism, compliance and driven (null, or {by: the driver's id, kind: ratio | loop, k, offset}: the value is derived from the driver's, so a rig makes a driven bone and not a DOF). kind is revolute or prismatic: Aetheria's ShipJoint calls them rotate and slide, one to one. unlimited lists the ids of the rows that are not driven and state no limits, in the whole tree: an exporter that needs limits refuses by this one field. Axis, origin and order are derived at each report from the kits and the parent tree; nothing stores them. Rows a receipt cannot carry are counted in jointsOmitted, and next is then the id of the last row carried (else null): call again with after set to it for the rows that follow. after refuses an id that is no row's. Refuses a connection that cannot be read. Evaluates no modifier.",
"doc": "The joints of the tree of kit parts attached under a root part, as {schema: brokkr.joints, version: 2, root, frame, rigid, unlimited, next, joints}. A row per revolute or prismatic connection, depth first with children by name, so a joint's parent row comes before it; a root that itself states a revolute or prismatic connection has its own row first, parent null: id (the child object), parent (the id of the nearest joint above, or null: rigid connections fold into it and are counted in rigid), part, socket ('Object:socket', the parent socket), kind, axis and origin (that socket's z and origin in the root object's frame: Blender axes, +Z up, metres), value (the roll in degrees or the slide in metres now), limits ([lo, hi] or null), min and max (the limits less the value: the travel either way from this pose), mechanism, compliance and driven (null, or {by: the driver's id, kind: ratio | loop, k, offset}: the value is derived from the driver's, so a rig makes a driven bone and not a DOF). kind is revolute or prismatic: Aetheria's ShipJoint calls them rotate and slide, one to one. unlimited lists the ids of the rows this report carries that are not driven and state no limits: an exporter that needs limits refuses by this one field of each report. Axis, origin and order are derived at each report from the kits and the parent tree; nothing stores them. Rows a receipt cannot carry are counted in jointsOmitted, and next is then the id of the last row carried (else null): call again with after set to it for the rows that follow and their unlimited ids; a report is never over a receipt and always carries a row. after refuses an id that is no row's. Refuses a connection that cannot be read. Evaluates no modifier.",
"changesScene": false,
"editModeSafe": true,
"result": "brokkr_mesh_polish_result",
@ -384,7 +384,7 @@
},
{
"name": "brokkr_kitbash.follow",
"doc": "State that an attached kit part's joint follows another's: its roll or slide is then derived from the driver's whenever the driver is posed, and roll, aim, reach and slide on it are refused. record is JSON. {\"driver\": name, \"kind\": \"ratio\", \"k\": number, \"offset\": number}: the value is k x the driver's value + offset (a kneecap at k 0.5, a pinion at minus ring over pinion, a crosshead's slide in metres per degree of a roll); the driver states limits, so its value is one number. {\"driver\": name, \"kind\": \"loop\"}: object_name is a part that states a closure that holds; its joint and its parent's are the two unknowns solved so the closure keeps holding (a rocker and coupler closing on a crank; a ram's barrel and rod closing on the part it pushes; a torque link's two arms), and both follow the driver. Exactly one end of the loop, the parent's parent or the part closed on, moves with the driver: it is the driver, follows it, or hangs from one that does. The loop is planar: its pins are parallel. null clears the statement, and a loop partner's with it. The follower moves at once and the report's followers lists every follower of the driver as {part, value}. Refuses, with nothing changed: a rigid connection; a driver that is the follower, below it, or itself a follower; a follower that already follows or that drives another; a ratio whose driver states no limits; a value outside the follower's own limits; a loop with no closure that holds, with both ends or neither moving with the driver, that is not planar, or at a dead centre (its two joints in line). Nothing stores a pin or a linkage: a loop is solved from the kits' socket frames each time, and no Blender driver or constraint is made.",
"doc": "State that an attached kit part's joint follows another's: its roll or slide is then derived from the driver's whenever the driver is posed, and roll, aim, reach and slide on it are refused. record is JSON. {\"driver\": name, \"kind\": \"ratio\", \"k\": number, \"offset\": number}: the value is k x the driver's value + offset (a kneecap at k 0.5, a pinion at minus ring over pinion, a crosshead's slide in metres per degree of a roll); the driver states limits, so its value is one number. {\"driver\": name, \"kind\": \"loop\"}: object_name is a part that states a closure that holds; its joint and its parent's are the two unknowns solved so the closure keeps holding (a rocker and coupler closing on a crank; a ram's barrel and rod closing on the part it pushes; a torque link's two arms), and both follow the driver. Exactly one end of the loop, the parent's parent or the part closed on, moves with the driver: it is the driver, follows it, or hangs from one that does. The driver is the one input the two ends depend on: every revolute or prismatic joint between an end and the part both ends hang from is the driver, follows it, or is held by limits of one value (a torque link's lug on its rod: limits [90, 90]). The loop is planar: its pins are parallel. null clears the statement, and a loop partner's with it. The follower moves at once and the report's followers lists every follower of the driver as {part, value}. Refuses, with nothing changed: a rigid connection; a driver that is the follower, below it, or itself a follower; a follower that already follows or that drives another; a ratio whose driver states no limits; a value outside the follower's own limits; a loop with no closure that holds, with both ends or neither moving with the driver, whose ends depend on more than one driver (another driver's follower, or a joint with travel that follows nothing: both are named), that is not planar, or at or past a dead centre (its two joints in line, a ram's rod end on its barrel's pin, or a step that would take the pair to its other assembly). Nothing stores a pin or a linkage: a loop is solved from the kits' socket frames each time, and no Blender driver or constraint is made.",
"changesScene": true,
"editModeSafe": false,
"result": "brokkr_mesh_polish_result",

View file

@ -12,10 +12,13 @@ inside one try: an uncaught error is a failed check that names the check before
The scene, every strut 0.09 wide so its pins take a ram's: a four-bar (Crank on the root Ground, Rocker on the root
Base, Coupler closing on the crank); a ram (A_Barrel on the root Pad, A_Rod in its bore, closing on the rocker), named
to sort before the four-bar it waits on; ratio followers of the crank (Cap, Pinion, and X_Rod's slide in X_Barrel); a
torque link (T_Rod sliding in the root T_Barrel, T_Upper and T_Lower closing on T_Lug, a strut pinned on the rod's
rod_end_back: a strut's two pins face one way, so two arms from the barrel's pin cannot face the rod's own); Idle
and Tip for the refusals; a chain of 80 struts for a joints report over a receipt. Bounds follow
lodur:ruling:deterministic-bound-margin, both readings beside each; the result file carries the readings.
torque link (T_Rod sliding in the root T_Barrel, T_Upper and T_Lower closing on T_Lug, a strut on the rod's
rod_end_back held at 90 degrees by limits of that one value: a strut's two pins face one way, so two arms from the
barrel's pin cannot face the rod's own, and the kit has no rigid lug); a second crank (Crank2 on the root Ground2)
whose ram closes on the rocker, and a loop hung from its own driver (K3, B3, Rk3, Cp3 on the root G3), for the
one-driver refusals; Idle and Tip for the refusals; a tree of 264 struts with 62-character names for a joints
report over several receipts. Bounds follow lodur:ruling:deterministic-bound-margin, both readings beside each; the
result file carries the readings.
"""
import importlib.util
import json
@ -207,6 +210,8 @@ try:
return core.close_loop(world(base), four_bar, socket(coupler, "end_b"), crank_pin(roll), seed)
# --- parts for the refusals ---------------------------------------------------------------------------------------------
far = np.eye(4)
far[:3, 3] = [0.0, -8.0, 0.0]
place("Idle", "strut", W), place("Tip", "strut", W), place("Loose", "strut", W)
attach("Idle", "end_a", "Ground", "end_b", 15.0)
attach("Tip", "end_a", "Idle", "end_b", 0.0)
@ -216,6 +221,24 @@ try:
loop = '{"driver": "Crank", "kind": "loop"}'
refused("a loop whose two ends both stand still when the driver moves (F7)", "brokkr_kitbash.follow", {"object_name": "Coupler", "record": '{"driver": "Idle", "kind": "loop"}'},
"'Base' (the base) and 'Crank' (closed on), neither moves with 'Idle'")
place("G3", "strut", W + "length=0.8", far @ far @ far @ turn)
k3, b3, rk3, cp3 = place("K3", "strut", W + "length=0.5"), place("B3", "strut", W + "length=0.8"), place("Rk3", "strut", W + "length=0.9"), place("Cp3", "strut", W + "length=0.7")
attach("K3", "end_a", "G3", "end_a", 10.0)
attach("B3", "end_a", "K3", "end_a_back", 0.0)
hung = None
for guess in ((g0, g1) for g0 in range(-180, 180, 45) for g1 in range(-180, 180, 45)): # a pose at which a rocker and coupler on B3 close on K3
try:
hung, _ = core.close_loop(world(b3), [(socket(b3, "end_b"), socket(rk3, "end_a"), "revolute"), (socket(rk3, "end_b_back"), socket(cp3, "end_a"), "revolute")],
socket(cp3, "end_b"), frame(k3, "end_b"), (float(guess[0]), float(guess[1])))
break
except core.KitError:
continue
attach("Rk3", "end_a", "B3", "end_b", core._wrapped(hung[0]) if hung else 0.0)
attach("Cp3", "end_a", "Rk3", "end_b_back", core._wrapped(hung[1]) if hung else 0.0)
receipt, report = send("brokkr_kitbash.close", object_name="Cp3", socket="end_b", other_name="K3", other_socket="end_b")
check("a loop whose base hangs from the part it closes on stands closed", hung is not None and receipt["status"] == "accepted" and report["closure"]["holds"] is True, [hung, receipt["message"]])
refused("a loop whose two ends both move with the driver (F7, the other half)", "brokkr_kitbash.follow", {"object_name": "Cp3", "record": '{"driver": "K3", "kind": "loop"}'},
"'B3' (the base) and 'K3' (closed on), both move with 'K3'")
refused("a loop follower that states no closure", "brokkr_kitbash.follow", {"object_name": "Rocker", "record": loop}, "'Rocker' states no closure that holds")
refused("a follower on a rigid connection", "brokkr_kitbash.follow", {"object_name": "Brk", "record": '{"driver": "Crank", "kind": "ratio", "k": 1, "offset": 0}'},
"socket type 'mount' states no dof")
@ -331,8 +354,29 @@ try:
seed = stepped(solve_four_bar, seed, 120.0, D0, 5.0)
a_barrel, a_rod = place("A_Barrel", "ram_barrel"), place("A_Rod", "ram_rod")
def rod_end(pad_world, values):
return pad_world @ core.mate(socket(ground, "end_a"), socket(a_barrel, "base"), values[0]) @ core.mate(socket(a_barrel, "bore"), socket(a_rod, "piston"), 0.0, values[1]) @ socket(a_rod, "rod_end")["matrix"]
def rod_end(pad_world, values, pin=None):
return (pad_world @ core.mate(pin or socket(ground, "end_a"), socket(a_barrel, "base"), values[0]) @ core.mate(socket(a_barrel, "bore"), socket(a_rod, "piston"), 0.0, values[1])
@ socket(a_rod, "rod_end")["matrix"])
# one driver: a ram on a second crank closes on the rocker, which follows the first (the probe of finding second-driver-loop-opens)
place("S_Barrel", "ram_barrel"), place("S_Rod", "ram_rod")
crank2 = place("Crank2", "strut", W + "length=0.4")
shift = np.eye(4)
shift[:3, 3] = frame(rocker, "end_b_back")[:3, 3] - rod_end(turn, RAM_REST, socket(crank2, "end_b"))[:3, 3]
place("Ground2", "strut", W + "length=0.8", shift @ turn @ np.linalg.inv(core.mate(socket(ground, "end_a"), socket(crank2, "end_a"), 20.0)))
attach("Crank2", "end_a", "Ground2", "end_a", 20.0)
attach("S_Barrel", "base", "Crank2", "end_b", RAM_REST[0])
attach("S_Rod", "piston", "S_Barrel", "bore", 0.0)
send("brokkr_kitbash.slide", object_name="S_Rod", slide=RAM_REST[1])
receipt, report = send("brokkr_kitbash.close", object_name="S_Rod", socket="rod_end", other_name="Rocker", other_socket="end_b_back")
check("a ram on a second crank stands closed on the rocker", receipt["status"] == "accepted" and report["closure"]["holds"] is True, [receipt["message"], report and report["closure"]])
refused("a loop whose ends depend on two drivers: its base is its own driver and the part it closes on follows another", "brokkr_kitbash.follow",
{"object_name": "S_Rod", "record": '{"driver": "Crank2", "kind": "loop"}'},
"'Crank2' (the base) and 'Rocker' (closed on), depend on more than one driver: 'Crank2' and 'Crank' ('Rocker' follows it)", "A follower takes its value from one driver")
refused("and with the crank as the driver: the ram's base hangs from the second crank, which is posed by hand", "brokkr_kitbash.follow", {"object_name": "S_Rod", "record": loop},
"depend on more than one driver: 'Crank' and 'Crank2' (it follows nothing and its joint has travel, so it is posed by hand)")
receipt, _ = send("brokkr_kitbash.detach", object_name="S_Rod")
check("the refused ram is detached, and the rocker's pin is free again", receipt["status"] == "accepted" and "kit_close" not in bpy.data.objects["S_Rod"], receipt["message"])
shift = np.eye(4)
shift[:3, 3] = frame(rocker, "end_b_back")[:3, 3] - rod_end(turn, RAM_REST)[:3, 3]
@ -363,8 +407,6 @@ try:
and [row for row in report["closures"] if not row["holds"]] == [], [receipt["message"], R["readings"], a_barrel["kit_roll"], a_rod["kit_slide"], ram_seed])
# --- a torque link: a slide drives two arms ---------------------------------------------------------------------------------
far = np.eye(4)
far[:3, 3] = [0.0, -8.0, 0.0]
t_barrel, t_rod = place("T_Barrel", "ram_barrel", "", far @ turn), place("T_Rod", "ram_rod")
t_upper, t_lower, t_lug = place("T_Upper", "strut", W + "length=0.5"), place("T_Lower", "strut", W + "length=0.5"), place("T_Lug", "strut", W + "length=0.3")
attach("T_Rod", "piston", "T_Barrel", "bore", 0.0)
@ -392,6 +434,11 @@ try:
attach("T_Upper", "end_a", "T_Barrel", "base_back", arms[0])
attach("T_Lower", "end_a", "T_Upper", "end_b", arms[1])
send("brokkr_kitbash.close", object_name="T_Lower", socket="end_b", other_name="T_Lug", other_socket="end_b")
refused("a loop that closes on a part hung from the driver by a free pin: the lug's roll is a second input (the probe of finding torque-link-lug-is-a-free-dof)", "brokkr_kitbash.follow",
{"object_name": "T_Lower", "record": '{"driver": "T_Rod", "kind": "loop"}'},
"'T_Barrel' (the base) and 'T_Lug' (closed on), depend on more than one driver: 'T_Rod' and 'T_Lug' (it follows nothing and its joint has travel, so it is posed by hand)")
receipt, report = send("brokkr_kitbash.joint", object_name="T_Lug", record='{"limits": [90, 90], "mechanism": "lug"}')
check("limits of one value hold the lug on the rod: a pin with no travel", receipt["status"] == "accepted" and report["connection"]["limits"] == [90.0, 90.0], receipt["message"])
receipt, report = send("brokkr_kitbash.follow", object_name="T_Lower", record='{"driver": "T_Rod", "kind": "loop"}')
check("the arms follow the rod's slide as a loop: its base is the barrel, above the driver, and it closes on a part that hangs from the driver",
receipt["status"] == "accepted" and [f["part"] for f in report["followers"]] == ["T_Upper", "T_Lower"], [receipt["message"], report and report.get("followers")])
@ -404,6 +451,20 @@ try:
and max(reading("solved", turned(t_upper["kit_roll"], arms[0])), reading("solved", turned(t_lower["kit_roll"], arms[1]))) < SOLVED
and report["closures"][0]["holds"] is True, [receipt["message"], R["readings"], t_upper["kit_roll"], t_lower["kit_roll"], arms])
refused("a slide outside the driver's limits", "brokkr_kitbash.slide", {"object_name": "T_Rod", "slide": 0.4}, "its slide 0.4 is outside the joint's limits 0 to 0.3")
refused("a roll of the held lug: no pose opens the torque link", "brokkr_kitbash.roll", {"object_name": "T_Lug", "roll": 100.0}, "'T_Lug' on 'T_Rod': its roll 100 is outside the joint's limits 90 to 90")
receipt, joints = send("brokkr_kitbash.joints", object_name="T_Barrel")
check("the torque link has one degree of freedom: the rod's slide is its one row with travel that nothing drives, the lug has none, the arms are driven, and no row is unlimited",
receipt["status"] == "accepted" and [(row["id"], row["kind"], row["driven"] and row["driven"]["by"], row["min"], row["max"]) for row in joints["joints"]] == [
("T_Rod", "prismatic", None, -0.11, 0.19), ("T_Lug", "revolute", None, 0.0, 0.0), ("T_Upper", "revolute", "T_Rod", None, None), ("T_Lower", "revolute", "T_Rod", None, None)]
and joints["unlimited"] == [] and reading("closed", apart(t_lower, "end_b", t_lug, "end_b")) < CLOSED, [receipt["message"], joints])
place("T_Mount", "strut", W, far @ far @ far @ far @ turn)
hinged = attach("T_Barrel", "base", "T_Mount", "end_a", 25.0)
receipt, report = send("brokkr_kitbash.follow", object_name="T_Lower", record="null")
cleared = receipt["status"] == "accepted" and report["cleared"] == ["T_Upper", "T_Lower"]
receipt, report = send("brokkr_kitbash.follow", object_name="T_Lower", record='{"driver": "T_Rod", "kind": "loop"}')
check("a joint both ends of a loop hang from is not one the loop depends on: the barrel hung on a free hinge, the arms follow the rod again",
hinged and cleared and receipt["status"] == "accepted" and [f["part"] for f in report["followers"]] == ["T_Upper", "T_Lower"]
and reading("closed", apart(t_lower, "end_b", t_lug, "end_b")) < CLOSED, [hinged, cleared, receipt["message"]])
# --- joints, version 2 ----------------------------------------------------------------------------------------------------------
receipt, joints = send("brokkr_kitbash.joints", object_name="Ground")
@ -422,20 +483,31 @@ try:
and joints["joints"][0]["compliance"] == {"damping_ratio": 0.6, "hertz": 3.0} and joints["rigid"] == 0, joints)
receipt, joints = send("brokkr_kitbash.joints", object_name="Ground", after="Idle")
check("after carries the rows after an id (F12)", receipt["status"] == "accepted" and [row["id"] for row in joints["joints"]] == ["Tip", "Pinion", "X_Barrel", "X_Rod"]
and joints["joints"][0]["parent"] == "Idle" and joints["unlimited"] == ["Idle", "Tip", "Pinion", "X_Barrel"], joints)
and joints["joints"][0]["parent"] == "Idle" and joints["unlimited"] == ["Tip", "Pinion", "X_Barrel"], joints)
refused("after an id that is no row's", "brokkr_kitbash.joints", {"object_name": "Ground", "after": "Base"}, "after 'Base' is not the id of a joint under 'Ground'")
place("L00", "strut", W + "length=0.3", far @ far @ turn)
for index in range(1, 81):
place(f"L{index:02d}", "strut", W + "length=0.3")
attach(f"L{index:02d}", "end_a", f"L{index - 1:02d}", "end_b", 7.0)
receipt, first = send("brokkr_kitbash.joints", object_name="L00")
carried = [row["id"] for row in (first or {}).get("joints", [])]
receipt, second = send("brokkr_kitbash.joints", object_name="L00", after=(first or {}).get("next") or "")
R["readings"]["rows in one receipt"] = len(carried)
check("a tree of 80 joints is two reports: the first counts what it omits and names the last id it carries as next, and after it the second carries the rest",
receipt["status"] == "accepted" and 0 < len(carried) < 80 and first["jointsOmitted"] == 80 - len(carried) and first["next"] == carried[-1]
and carried + [row["id"] for row in second["joints"]] == [f"L{index:02d}" for index in range(1, 81)] and second["next"] is None and "jointsOmitted" not in second
and len(first["unlimited"]) == 80, [receipt["message"], len(carried), first and first.get("next"), second and [row["id"] for row in second["joints"]][:3]])
long = [f"Actuator_joint_name_that_is_long_but_legal_in_blender_{index:04d}_x" for index in range(265)] # 62 characters, of the 63 Blender takes
place(long[0], "strut", W + "length=0.3", far @ far @ turn)
place(long[1], "strut", W + "length=0.3")
attach(long[1], "end_a", long[0], "end_a", 7.0)
for chain, on in enumerate(("end_a", "end_a_back", "end_b", "end_b_back")): # four chains of 66 on the root's four pins: 264 joints, none limited
for index in range(max(2, chain * 66 + 1), chain * 66 + 67): # copies of the one attached by the actions, each stating its own connection: the report reads what is stated
copy = bpy.data.objects[long[1]].copy()
copy.name, copy.parent = long[index], bpy.data.objects[long[0] if index == chain * 66 + 1 else long[index - 1]]
copy["kit_parent_socket"] = on if index == chain * 66 + 1 else "end_b"
bpy.context.scene.collection.objects.link(copy)
pages, after = [], ""
for _ in range(2): # the first two reports; each costs a pass over the 264 parts
receipt, page = send("brokkr_kitbash.joints", object_name=long[0], after=after)
pages.append((receipt["status"], len(receipt.get("hostResult") or ""), page or {}))
after = (page or {}).get("next") or ""
carried = [[row["id"] for row in page.get("joints", [])] for _, _, page in pages]
R["readings"]["rows in the first receipt"], R["readings"]["longest receipt"] = len(carried[0]), max(size for _, size, _ in pages)
check("a tree of 264 unlimited joints with long names, whose ids alone are over a receipt, is many reports and none over a receipt: each carries rows, the ids of its own "
"rows as unlimited, a count of what it omits and the last id it carries as next, and after it the next carries on",
all(status == "accepted" and size <= 16000 and page.get("joints") and page["unlimited"] == ids and page["next"] == ids[-1] for (status, size, page), ids in zip(pages, carried))
and sum(len(json.dumps(name)) + 1 for name in long[1:]) > 16000 and [name for ids in carried for name in ids] == long[1:len(carried[0]) + len(carried[1]) + 1]
and [page["jointsOmitted"] for _, _, page in pages] == [264 - len(carried[0]), 264 - len(carried[0]) - len(carried[1])],
[[(status, size, len(ids), page.get("jointsOmitted"), page.get("next")) for (status, size, page), ids in zip(pages, carried)]])
# --- the joint-records Lows -------------------------------------------------------------------------------------------------
send("brokkr_kitbash.joint", object_name="Idle", record='{"limits": [0, 30]}')

View file

@ -16,6 +16,16 @@
"ok": true,
"detail": null
},
{
"name": "a loop whose base hangs from the part it closes on stands closed",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a loop whose two ends both move with the driver (F7, the other half)",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a loop follower that states no closure",
"ok": true,
@ -196,6 +206,26 @@
"ok": true,
"detail": null
},
{
"name": "a ram on a second crank stands closed on the rocker",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a loop whose ends depend on two drivers: its base is its own driver and the part it closes on follows another",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: and with the crank as the driver: the ram's base hangs from the second crank, which is posed by hand",
"ok": true,
"detail": null
},
{
"name": "the refused ram is detached, and the rocker's pin is free again",
"ok": true,
"detail": null
},
{
"name": "a ram on its own ground pin closes on the rocker and follows the crank: the end it closes on follows the driver",
"ok": true,
@ -221,6 +251,16 @@
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a loop that closes on a part hung from the driver by a free pin: the lug's roll is a second input (the probe of finding torque-link-lug-is-a-free-dof)",
"ok": true,
"detail": null
},
{
"name": "limits of one value hold the lug on the rod: a pin with no travel",
"ok": true,
"detail": null
},
{
"name": "the arms follow the rod's slide as a loop: its base is the barrel, above the driver, and it closes on a part that hangs from the driver",
"ok": true,
@ -246,6 +286,21 @@
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a roll of the held lug: no pose opens the torque link",
"ok": true,
"detail": null
},
{
"name": "the torque link has one degree of freedom: the rod's slide is its one row with travel that nothing drives, the lug has none, the arms are driven, and no row is unlimited",
"ok": true,
"detail": null
},
{
"name": "a joint both ends of a loop hang from is not one the loop depends on: the barrel hung on a free hinge, the arms follow the rod again",
"ok": true,
"detail": null
},
{
"name": "joints is version 2: a driven row names what drives it (F6), and unlimited lists the rows that are not driven and state no limits",
"ok": true,
@ -272,7 +327,7 @@
"detail": null
},
{
"name": "a tree of 80 joints is two reports: the first counts what it omits and names the last id it carries as next, and after it the second carries the rest",
"name": "a tree of 264 unlimited joints with long names, whose ids alone are over a receipt, is many reports and none over a receipt: each carries rows, the ids of its own rows as unlimited, a count of what it omits and the last id it carries as next, and after it the next carries on",
"ok": true,
"detail": null
},
@ -331,6 +386,7 @@
"readings": {
"closed": 6.4e-07,
"jump": 49.0,
"longest receipt": 16000.0,
"ram closed at 110": 2.9e-07,
"ram closed at 45": 5.3e-07,
"ram closed at 60": 2.8e-07,
@ -338,7 +394,7 @@
"ram solved at 45": 0.0,
"ram solved at 60": 0.0,
"ratio": 0.0,
"rows in one receipt": 62.0,
"rows in the first receipt": 33.0,
"slid": 1e-07,
"solved": 3.3e-05
},