8d3415602f
DECISION: Refine R0.3 into a separate R0.4 exterior using the user's physical-hand photographs, preserving all five four-axis finger chains, including the little finger removed from the photographed sample. WHY: On 2026-11-17 the user supplied five close-ups and asked for a comparison-based improvement, explicitly explaining the missing little finger. The photographs reveal curved shells, fork openings, stepped joint caps, black contact pads and a spatial thumb root more clearly than the earlier website screenshot. design-docs/lh20-r04-photo-refinement.md records the interpretation, assumptions, rejected alternatives and checks. No scale marker or internal section was supplied, so the existing dimension baseline remains an original design input and the internal drive remains pending. ALTERNATIVE CONSIDERED AND REJECTED: Merely changing colours, duplicating the missing-finger state, or presenting a concept image would not improve the actual complete CAD model. Reusing earlier verification reports would conceal new geometry and motion failures. WHAT CHANGES: Add curved shells and removable covers, nested fork ears, stepped three-fastener caps, wraparound black pads, segmented flex-circuit placeholders and a canted thumb mounting frame. Preserve native articulated source, binding geometry checks and previews to captured packages. A small export adapter uses the native writer's existing metadata_properties=False option and saves complete descriptive records in a hashed sidecar because >22 kB constraint strings overflow the OCCT STEP reader; geometry and assembly structure remain intact, and the shared SDK is unchanged. Checked: Single finger and complete hand passed positive-volume, BREP validity, constraint and exact interference checks in straight and specified light-flex poses. Diagnosed and removed a 0.256 mm3 knuckle overlap without changing the 0.01 mm3 threshold. All five fingers retain four axes. STEP reimport retained 245 solids with relative volume error 4.03e-7. URDF has 21 links, 20 joints and 84 mesh files. Reviewed actual front/back/oblique/side CAD views and the R0.3 comparison. Packaging verified 102 files, relative mesh paths, source hashes and independent-finger versus nested-finger volumes. Python compilation passed. Full travel, actuator integration, continuous flex routing, manufacturing and hardware performance are not qualified. Co-Authored-By: Codex <noreply@openai.com>
175 lines
6.8 KiB
Python
175 lines
6.8 KiB
Python
"""Package the checked exterior exchange files without replacing an older delivery."""
|
|
|
|
import argparse
|
|
import hashlib
|
|
import json
|
|
from pathlib import Path
|
|
import shutil
|
|
import xml.etree.ElementTree as ET
|
|
import zipfile
|
|
|
|
from parameters import OUT
|
|
|
|
|
|
def digest(path):
|
|
return hashlib.sha256(path.read_bytes()).hexdigest()
|
|
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
parser.add_argument("destination", type=Path)
|
|
args = parser.parse_args()
|
|
dest = args.destination.expanduser().resolve()
|
|
archive = dest.with_name(dest.name + ".zip")
|
|
if dest.exists() or archive.exists():
|
|
raise FileExistsError(
|
|
"Use a new destination; existing deliveries are preserved."
|
|
)
|
|
check = json.loads((OUT / "hand_check.json").read_text())
|
|
exchange = json.loads((OUT / "exchange_check.json").read_text())
|
|
preview = json.loads((OUT / "hand_overview.json").read_text())
|
|
source_hash = digest(OUT / "hand.scadpkg")
|
|
assert source_hash == check["package_sha256"] == exchange["package_sha256"]
|
|
assert preview["package_sha256"] == source_hash
|
|
assert digest(OUT / "hand_overview.png") == preview["image_sha256"]
|
|
assert all(
|
|
check[key] for key in ("geometry_pass", "constraints_pass", "clearance_pass")
|
|
)
|
|
relaxed = json.loads((OUT / "hand_relaxed_check.json").read_text())
|
|
relaxed_build = json.loads((OUT / "hand_relaxed_build.json").read_text())
|
|
assert (
|
|
digest(OUT / "hand_relaxed.scadpkg")
|
|
== relaxed["package_sha256"]
|
|
== relaxed_build["package_sha256"]
|
|
)
|
|
assert all(
|
|
relaxed[key] for key in ("geometry_pass", "constraints_pass", "clearance_pass")
|
|
)
|
|
assert set(check["five_finger_structure"]) == {
|
|
"index",
|
|
"middle",
|
|
"ring",
|
|
"little",
|
|
"thumb",
|
|
}
|
|
finger_check = json.loads((OUT / "finger_check.json").read_text())
|
|
finger_preview = json.loads((OUT / "finger_overview.json").read_text())
|
|
assert (
|
|
digest(OUT / "finger.scadpkg")
|
|
== finger_check["package_sha256"]
|
|
== finger_preview["package_sha256"]
|
|
)
|
|
assert digest(OUT / "finger_overview.png") == finger_preview["image_sha256"]
|
|
assert all(
|
|
finger_check[key]
|
|
for key in ("geometry_pass", "constraints_pass", "clearance_pass")
|
|
)
|
|
hand_index = {
|
|
r["path"].removeprefix("/index"): r
|
|
for r in check["geometry"]
|
|
if r["path"].startswith("/index/")
|
|
}
|
|
assert set(hand_index) == {r["path"] for r in finger_check["geometry"]}
|
|
for row in finger_check["geometry"]:
|
|
assert abs(row["volume_mm3"] - hand_index[row["path"]]["volume_mm3"]) < 1e-5, (
|
|
"Nested finger differs from independently checked geometry"
|
|
)
|
|
step = "LH20_R04_exterior.step"
|
|
urdf = "LH20_R04_exterior.urdf"
|
|
assert digest(OUT / step) == exchange["step_sha256"]
|
|
assert digest(OUT / urdf) == exchange["urdf_sha256"]
|
|
step_metadata = json.loads((OUT / "LH20_R04_exterior_metadata.json").read_text())
|
|
assert step_metadata["package_sha256"] == source_hash
|
|
assert step_metadata["step_sha256"] == exchange["step_sha256"]
|
|
mesh_refs = {
|
|
element.attrib["filename"]
|
|
for element in ET.parse(OUT / urdf).findall(".//mesh")
|
|
}
|
|
for ref in mesh_refs:
|
|
assert ref.startswith("meshes/") and ".." not in Path(ref).parts
|
|
assert (OUT / ref).is_file()
|
|
files = [
|
|
step,
|
|
urdf,
|
|
"LH20_R04_exterior_metadata.json",
|
|
"hand_overview.png",
|
|
"hand_front.png",
|
|
"hand_back.png",
|
|
"hand_profile.png",
|
|
"hand_side.png",
|
|
"r03_r04_comparison.png",
|
|
"finger_overview.png",
|
|
"finger_side.png",
|
|
"hand_build.json",
|
|
"hand_relaxed_build.json",
|
|
"hand_relaxed_check.json",
|
|
"hand_check.json",
|
|
"exchange_check.json",
|
|
"hand_overview.json",
|
|
*sorted(mesh_refs),
|
|
]
|
|
dest.mkdir(parents=True)
|
|
for relative in files:
|
|
target = dest / relative
|
|
target.parent.mkdir(parents=True, exist_ok=True)
|
|
shutil.copy2(OUT / relative, target)
|
|
assert digest(target) == digest(OUT / relative)
|
|
(dest / "先读我.txt").write_text(
|
|
"LH20 Codex R0.4 — 外形重设计\n\n"
|
|
"本版依据用户实物照片改为圆弧指节、独立外盖、错层叉架、三点紧固端盖和黑色指腹。\n"
|
|
"完整五指均保留,包含照片中被拆下的小拇指;照片无标尺,尺寸不是实测还原值。\n"
|
|
"hand_overview.png 是实际 CAD 的三视角图。\n"
|
|
f"STEP 包含 {exchange['step_occurrences']} 个外形实体;URDF 包含 21 个 link、20 个旋转关节。\n"
|
|
"URDF 与 meshes 文件夹须一起移动,网格和关节坐标单位为米。STEP 单位为毫米。\n\n"
|
|
"STEP 中保留实体、颜色与装配层级;较长的装配说明保存在 LH20_R04_exterior_metadata.json 中。\n"
|
|
"这是外形与关节布局交付。旧版内部驱动尚未适配到新外形;\n"
|
|
"橙色分段件只表示柔性电路走线占位,未完成连续电气连接和弯折寿命验证。\n"
|
|
"URDF 用于外观和运动学查看,无惯量、碰撞模型或传动定义,\n"
|
|
"effort/velocity 为零,不用于动力学或驱动能力验证。\n"
|
|
"检查覆盖展开与记录中轻屈姿态的实体、约束和精确干涉,以及 STEP 回读。\n"
|
|
"不代表已完成全运动范围、制造、公差或实物抓取验证。\n\n"
|
|
"本地查看:http://127.0.0.1:8780/hand_launcher/#/chatgpt\n"
|
|
"源码:/Users/jerry/linkhand/SimpleCADAPI/examples/lh20_hand_r04\n",
|
|
encoding="utf-8",
|
|
)
|
|
hashes = {
|
|
p.relative_to(dest).as_posix(): digest(p)
|
|
for p in sorted(dest.rglob("*"))
|
|
if p.is_file()
|
|
}
|
|
(dest / "manifest.json").write_text(
|
|
json.dumps(
|
|
{"source_package_sha256": source_hash, "files": hashes},
|
|
indent=2,
|
|
ensure_ascii=False,
|
|
),
|
|
encoding="utf-8",
|
|
)
|
|
with zipfile.ZipFile(archive, "x", zipfile.ZIP_DEFLATED) as zf:
|
|
for path in sorted(dest.rglob("*")):
|
|
if path.is_file():
|
|
zf.write(path, dest.name + "/" + path.relative_to(dest).as_posix())
|
|
with zipfile.ZipFile(archive) as zf:
|
|
assert zf.testzip() is None
|
|
for relative, expected in hashes.items():
|
|
assert (
|
|
hashlib.sha256(zf.read(dest.name + "/" + relative)).hexdigest()
|
|
== expected
|
|
)
|
|
print(
|
|
json.dumps(
|
|
{
|
|
"folder": str(dest),
|
|
"zip": str(archive),
|
|
"mesh_files": len(mesh_refs),
|
|
"verified_files": len(hashes),
|
|
},
|
|
ensure_ascii=False,
|
|
indent=2,
|
|
)
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|