DECISION: Use independent geared joint modules for LH20

DECISION: Build an original, parameterized 20-axis hand using three sizes of two-stage planetary joints, with no tendon or pull-cable transmission. Keep unselected motors and electronics explicitly represented as reserved spaces.

WHY: In the 2026-11-16 discussion the owner chose WUJI Hand 2 as the main reference, authorized exterior and internal design, clarified that electrical wiring is allowed, and prioritized precise manipulation and compliant grasping. Public WUJI assets do not disclose a manufacturable internal drivetrain. The resulting design and evidence boundary are recorded in design-docs/lh20-tendonless-prototype.md and examples/lh20_hand/DESIGN.md.

ALTERNATIVE CONSIDERED AND REJECTED: Copying simplified public reference meshes would not establish a working internal layout. Tendon drives contradict the owner's requirement. The initial MR84 support spacing gave an inadequate side-moment screening margin, so the candidate support was widened to the MR104 envelope; catalog rating is still not a module load qualification.

WHAT CHANGES: Add separately named CAD parts, real involute gears, keyed torque interfaces, bearing envelopes, five finger assemblies, palm/frame/cover/pad geometry, tactile reservations, independent kinematics, pinned build inputs and reviewed local collision reliefs. Use unique bearing assembly identities so different joints can be driven at different angles. Generated output and unrelated concurrent work remain outside this commit.

Checked: Final native build contains 1011 solid occurrences and 176 part definitions. Independent BREP validity, canonical constraint solving and external interference checks passed for neutral, four opposition poses and one intermediate state. A/B/C internal checks and an A module at 17.3 degrees passed. Full travel, minimum wall thickness, strength, selected motors, retention details and real performance are not qualified.

Co-Authored-By: Codex <noreply@openai.com>
This commit is contained in:
Jerry
2026-11-16 18:33:00 +08:00
parent 451d7fd3c1
commit 3d07e3c1ae
20 changed files with 4266 additions and 0 deletions
+47
View File
@@ -0,0 +1,47 @@
# LH20 原创无腱绳灵巧手:设计与证据边界
## 2026-11-16 的需求与取舍
用户先比较 WUJI Hand 2、Linker O 系列与 Sharpa,随后明确选择 WUJI 为主要参考,要求从外形到内部开始设计,允许自主做工程取舍。用户澄清“不要线束”是禁止腱绳/拉索机械传动,允许内部电线,并选择精细操作与柔顺抓取优先。
WUJI 的公开结构资料与模型可用于理解五指、20 轴、开发与仿真接口,不能据此声称获得其未公开的电机、传动、制造图或性能。参考资料固定的仓库提交与供应商链接见 `examples/lh20_hand/DESIGN.md`。本工作独立放在 `examples/lh20_hand/`,不修改并行工作的 `examples/dexterous_hand_20dof/` 或 SDK 导出器。
## 决策一:独立关节模块与参数化原始几何
采用三档两级行星关节、五个可替换手指、分节承力框架、外盖与软指腹;20 个主动转轴全部具有独立驱动位置。用真实渐开线齿形、D 形传扭接口、齿圈止转和成对轴承表达内部关系,不把示意圆盘或外壳当成完整传动。电机、编码器、触觉与板卡尚未完成选型的位置均标记为包络,不能把包络密度计作实际器件质量。
比较过 MR84 的紧凑输出支承;侧向弯矩初筛使其余量不足,因此改为 MR104 外形与 3.2 mm 轴承中心距。此筛查不构成承载能力、组合载荷或寿命认证。传动形式没有蜗杆或丝杠自锁结构,但反驱摩擦与柔顺性能仍需台架试验。
零件与装配按 `parts/`、`joint_module.py`、`finger.py`、`hand.py` 分层。拇指零位重定义为平展姿态,角度限位同步变换。标准轴承的装配身份按关节唯一化,解决同一通用定义在不同角度下发生引用身份冲突的问题。
## 决策二:柔顺控制只能使用明确的力矩预算
控制示例采用关节阻抗与雅可比转置力预算,所有量统一为 SI 单位,异常状态输出归零。当前电机和效率仍为假设,因此先把输出视为软件请求而不是硬件保证。3 N / 8 N 是设计目标;伸直中指 8 N 工况超过当前 A 档峰值预算,不能删除这个失败结果。控制示例使用姿态相关的力限幅与 20% 预算余量,不把仿真或公式当成真实传感器闭环。
## 决策三:模型交付由可复查证据约束
采用独立 OCP 实体检查、精确布尔干涉、独立运动学、有限差分雅可比、MuJoCo 坐标对照与短时数值运行,并检查 STEP/FreeCAD 重读。渲染仅显示实际 CAD。原生包、图像、导出与检查记录用 SHA-256 绑定,交付脚本拒绝陈旧或失败的证据。
简化胶囊碰撞曾漏掉局部外盖与叉架的重叠。保留失败报告,以实测交集生成带来源的局部避让特征;限制材料去除与脱落碎片,并重新构建与检查。没有忽略碰撞对来获得通过。避让数据的摘要参与参数和缓存失效。有限姿态检查仍不能证明完整运动范围无碰撞,体积/连通性限制也不能证明最小壁厚与刚度合格。
SDK 的 FreeCAD 原生特征翻译不支持本例的部分工作平面操作,因此 `.FCStd` 明确为 BREP 装配快照。原生特征与构建逻辑保存在笔记本和 `.scadpkg` 中,不能称为完整翻译后的 FreeCAD 特征树。
交换检查最初将原生 SDK 的自适应体积积分与 FreeCAD 的固定阶积分直接比较,误差超过 0.001% 阈值。检查源代码与独立计算后,改为两端使用一致的固定阶积分,保留原生积分估值与差异,阈值不放宽;同时增加全部边界顶点的双向位置检查。顶点比较不能替代完整曲面误差测量,所有原始诊断结果均保留。
## 审计入口与后续边界
| 项目 | 可复查入口 | 边界 |
|---|---|---|
| 需求、构型与材料 | `DESIGN.md`、`parameters.py` | 原创数字原型,非 WUJI 内部复刻 |
| 几何与代表性姿态 | `verify/geometry.py`、`clearance_reliefs.json` | 展开、四组对指、一个中间状态;非连续全行程 |
| 齿轮与关节运动 | `joint_module.py`、独立模块检查 | A/B/C 零位与 A 档 17.3°;非齿面动力学/寿命 |
| 数值与控制 | `verify/engineering.py`、`verify/test_control.py` | 数值一致性与限幅;非实物精度或稳定性 |
| 交换与交付 | `export_model.py`、`release.py` | 检查摘要与实体;未完成制造、公差与实机验证 |
仍需完成电机与热设计、齿轮强度和寿命、轴承配合与轴向固定、紧固件、公差栈、全范围运动间隙、真实布线与电路,以及单关节、单指、整手样机试验。详细结果由 `out/engineering_review.md` 与机器可读记录提供;生成物不进入 Git。
## 提交系列(按主题,不绑定可重写的哈希)
1. `DECISION: Use independent geared joint modules for LH20`:参数化模型和需求记录。
2. `DECISION: Bound compliant-control requests by posture torque budgets`:控制与相应测试。
3. `DECISION: Gate LH20 delivery on reproducible geometry and export checks`:检查、图像、交换与交付工具。
+5
View File
@@ -0,0 +1,5 @@
out/
__pycache__/
.pytest_cache/
!clearance_reliefs.json
!poses_seed.json
+69
View File
@@ -0,0 +1,69 @@
Mode: interactive (the user approved the WUJI reference direction and delegated design decisions)
# LH20 — 无腱绳灵巧手,R0.1
## 已确认的需求
2026-11-16,用户选择 WUJI Hand 2 为主参考,授权开始完整外形和内部设计,明确禁止腱绳/拉索机械传动、允许内部电线,并选择“精细操作与柔顺抓取”作为第一优先用途。
这是原创工程原型,不是 WUJI 内部结构的复刻,也不是已完成样机验证的量产产品。WUJI 公开模型提供构型参照,未公开的电机和传动细节不作为已知事实。
## 设计基线与假设
- 右手,五指、20 个独立主动旋转关节;拇指具有独立对掌轴。
- 单位 mm / degree / kg / N。模型原点位于掌部近腕侧;腕部安装平面中心为 `(0, -22, 0)`。+X 指向拇指,+Y 指向中指,+Z 指向掌心接触侧。
- 采用掌部可拆机架、五个可替换手指、分节可更换指腹及背盖;内部电线走独立通道,不能承担传动力。
- 关节采用可回转的两级直齿行星减速候选方案,无蜗杆、自锁丝杠或拉索。低摩擦与可反驱性属于待测试指标,不能由齿轮形式直接宣布达成。
- 关节按 MCP/CMC、PIP/侧摆、DIP 分成三档,分别采用 36:1、25:1、16:1 减速候选。齿数、模数、中心距和等分装配条件在代码中计算。
- 定制扁平无刷电机目前只有安装包络与需求,不伪造供应商型号、绕组、力矩常数或已达成性能;CAD 中明确标为待选型包络。
- 暂定单指接触力目标:连续 3 N,短时 8 N;最终取决于姿态、传动损失、供应商电机与热测试。不是整手已实现性能。
- 接口采用可换腕部转接盘,暂定 4×M3、32 mm 孔距方形;不宣称直接适配某机械臂。
- 铝合金承力件、PA12 外盖、硅胶指腹、钢齿轮均为材料假设;密度估算不代替实物称重。
## 结构和装配意图
外部为圆润、分节的浅色指背和深色接触垫,关节边缘保留活动间隙,避免一整张紧绷皮肤跨越大角度关节。内部由独立电机包络、双级行星齿轮、支承轴承、输出法兰、编码器板和贯通承力架组成。驱动电路尽量布置在手掌和近端,减少末端质量。软指腹和触觉元件空间可拆换,触觉电子器件仍需选型。
手指的侧摆轴与屈伸轴有实际间距,空间模型必须计入两个驱动单元;不把两个电机画在同一个点。拇指的轴线和安装方向通过对指可达性计算检查。安装面、齿轮轴、输出轴均使用命名连接坐标系。
## 模块边界
- `parameters.py`:尺寸、关节档位、材料及目标,唯一参数来源。
- `kinematics.py`:20 轴树、坐标变换、正运动学和逆运动学。
- `parts/`:可重复使用的参数化零件,按机架、外盖、传动分模块。
- `joint_module.py`、`finger.py`、`hand.py`:SimpleCAD 装配笔记本。
- `verify/`:独立几何检查、运动学、载荷预算与仿真检查。
- `out/`:生成的装配包、STEP、FreeCAD 文件、仿真资产、图像与检查记录。
## 验收方法(建模前确定)
1. 单个零件闭合、有效、正体积;记录几何而非只检查程序返回成功。
2. 关节树恰好 20 个主动自由度,连接完整;没有 tendon/cable 执行机构。
3. 所有关节模数、齿数、减速比、行星中心距及三行星等分条件一致;生成真实齿形,不用光滑圆盘代替齿轮。
4. 命名连接坐标与装配约束残差通过;单关节转动与整体手指运动相符。
5. 检查外形、骨架、拆盖和关节剖视图;检查公开参考几何没有被误标成原创内部设计。
6. 对指位置误差、关节限位和代表性姿态间隙有数值记录;抽样不能宣称全运动空间无碰撞。
7. 几何质量估算逐材料计算,采购器件和缺失电子件另列,不把包络体积直接当成真实电机质量。
8. 通过雅可比转置计算指定姿态和方向的静态关节力矩需求,列出电机端需求和未闭合项。
9. 导出的运动学模型可加载;仿真仅用于结构与控制接口检查,不宣称已完成实机校准。
## 尚不能由本次数字设计闭合的项目
电磁设计与电机选型、齿轮接触/弯曲寿命、轴承额定寿命、热设计、真实触觉标定、柔性线缆寿命、加工公差栈、整手冲击和长期耐久,均需进一步分析或样机试验。任何未通过的检查必须保留结果并修订设计,不能删除检查来获得“通过”。
## 参考来源
- WUJI 官方模型仓库:https://github.com/wuji-technology/wuji-description ,参考检查已固定到 `0f02495611a5e5f71ebac50da7efd4f646cc0a75`。
- WUJI 官方结构说明:https://docs.wuji.tech/docs/zh/wuji-hand/latest/overview 。历史 STEP 与当前仿真外观不能混用。
- 官方参考文件及原始检查记录:`../../output/hand_reference_research/`。
- MR104 开式轴承候选尺寸与静额定载荷:[SMB 供应商数据表](https://www.smbbearings.com/firebrick/ckeditor/plugins/upload/Uploads/Documents/bearingpdfs/MR104-miniature-bearing-4x10x3mm.pdf)。本模型使用 4×10×3 mm 外形,内部滚道/钢球为通用示意,不是供应商制造图。
## R0.1 迭代记录
1. 首次完整干涉检查发现掌部、指腹安装面和指根外盖重叠。增加了指腹座、指根间距、腕颈避让及拇指斜交关节避让;原始失败记录保存在 `out/initial_interference_audit.json`。
2. 初始 MR84 轴承对的中心距仅 2.2 mm。侧向弯矩筛查暴露支承余量不足,因此改为 MR104 包络、3.2 mm 中心距,并加宽三档模块。筛查仍不代替组合载荷与寿命计算。
3. 增加 D 形太阳轮轴孔、级间轴、输出端传扭接口,以及齿圈防转凸耳/壳体槽。轴向固定、压配公差、螺钉和卡簧仍需制造设计闭合。
4. 采用掌面展开的拇指作为零位。旧角度至新角度的偏置为 `[-75, 51.10848241, -34.76298475, 0.9408095]` 度;拇指可达角度集合保持不变,零位和安装坐标重新定义。
5. 对指同时约束接触点位置、接触面法向与胶囊体碰撞。精确 BREP 检查曾发现简化模型遗漏的弯曲干涉;据实测相交区域生成 `clearance_reliefs.json`,对掌部、叉架和外盖添加局部避让,并重新验证。仅检查代表性样本不能宣布全路径或实机抓取通过。
R0.1 是工程布局和运动学原型。完整加工图、公差栈、紧固/轴向固定、定型电机、PCB、固件与实机验证不在“已完成”之列。
+17
View File
@@ -0,0 +1,17 @@
# 定制电机询价与台架输入条件
当前没有已经选定且验证通过的电机型号。以下是与供应商讨论的候选约束,不是已获得的性能。不能只用电机外径匹配,就宣布驱动模块已经成立。
| 档位 | 预留直径 × 长度 | 输出连续/短时目标 | 总减速比 | 按 0.72 效率假设反算的电机连续/短时力矩 |
|---|---|---|---|---|
| A | 20 × 5.2 mm | 0.35 / 0.90 N·m | 36 | 13.50 / 34.72 mN·m |
| B | 17 × 4.7 mm | 0.18 / 0.50 N·m | 25 | 10.00 / 27.78 mN·m |
| C | 14.5 × 4.0 mm | 0.08 / 0.25 N·m | 16 | 6.94 / 21.70 mN·m |
输出 2 rad/s 时,电机转速分别约为 688、477、306 rpm。这只是传动比换算,尚未把转速与电压、绕组和连续力矩同时闭合。候选母线 12 V;连续工作条件、短时持续时间、环境温度和散热接触必须由供应商共同确定。
需要索取:完整外形及轴接口、绕组 Kt/Ke、相电阻/电感、连续/峰值电流定义、转矩转速曲线、热阻与热时间常数、转子惯量、齿槽转矩、换相传感方案、轴承及轴向载荷能力、引线出口、实际重量、制造公差与寿命数据。
现有电机体积占位不得进入采购 BOM 的“已选型号”栏。若供应商无法在这些尺寸里实现目标,应优先重新分配电机尺寸、关节间距、减速比与力目标,不能靠修改软件额定值掩盖缺口。
台架至少记录输出反驱力矩、不同速度/温度下的传动效率、空载噪声、背隙和滞回、稳态温升、短时接触力以及过载后状态。三个档位共享方法,但不能直接用 A 档测试结果替代 B/C 档。
+19
View File
@@ -0,0 +1,19 @@
"""Assembly frames and physical joint datums shared by all notebooks."""
import numpy as np
import simplecadapi as scad
from kinematics import transform
def axis_matrix(axis):
xy = {
"z": ((1, 0, 0), (0, 1, 0)),
"x": ((0, 1, 0), (0, 0, 1)),
"y": ((0, 0, 1), (1, 0, 0)),
}
x, y = map(np.array, xy[axis])
return transform(rotation=np.column_stack([x, y, np.cross(x, y)]))
def ref(component, connector="origin"):
return scad.ConnectorRef(component_id=component, connector_id=connector)
+58
View File
@@ -0,0 +1,58 @@
"""Build with the notebook runtime; store BREP once and omit duplicate scene meshes."""
import argparse, time
import simplecadapi as scad
from simplecadapi.runtime import run_notebook
from parameters import HERE, OUT, validate_parameters
def main(target, cache, size="A", pose=None, angle=0.0):
validate_parameters()
OUT.mkdir(exist_ok=True)
file, stem = {
"hand": ("hand.py", "lh20_right_hand"),
"finger": ("finger.py", "index_finger"),
"joint": ("joint_module.py", "joint_A"),
}[target]
overrides = None
if target == "joint":
overrides = {"SIZE": size, "OUTPUT_ANGLE": float(angle)}
stem = f"joint_{size}" + ("_" + str(float(angle)).replace('.', 'p') if angle else '')
if pose:
if target != "hand":
raise ValueError("--pose is supported for the hand target")
from model_io import pose_angles
import numpy as np
overrides = {
name.upper(): tuple(np.rad2deg(q)) for name, q in pose_angles(pose).items()
}
stem += f"_{pose}"
start = time.time()
print("Building", file, flush=True)
run = run_notebook(path=HERE / file, cache=cache, overrides=overrides)
print("Built in", round(time.time() - start, 2), "seconds; capturing", flush=True)
path = OUT / f"{stem}.scadpkg"
scad.capture(run.definition, path, include_scene=False)
print(
"Captured",
path,
"bytes",
path.stat().st_size,
"hash",
run.definition.content_hash,
flush=True,
)
if __name__ == "__main__":
ap = argparse.ArgumentParser()
ap.add_argument(
"target", choices=["hand", "finger", "joint"], default="hand", nargs="?"
)
ap.add_argument("--no-cache", action="store_true")
ap.add_argument("--size", choices=["A", "B", "C"], default="A")
ap.add_argument("--pose")
ap.add_argument("--angle", type=float, default=0.0, help="joint output angle in degrees")
a = ap.parse_args()
main(a.target, not a.no_cache, a.size, a.pose, a.angle)
File diff suppressed because it is too large Load Diff
+158
View File
@@ -0,0 +1,158 @@
# /// script
# dependencies = ["simplecadapi"]
# [tool.simplecadapi]
# id = "lh20_finger"
# kind = "assembly"
# revision = "0.1.0"
# ///
"""Four active independent rotary joints, replaceable frames and contact pads."""
import marimo
app = marimo.App()
with app.setup:
import simplecadapi as scad
from parameters import FINGERS
from parts.phalanges import link_parts
from parts.common import frame
from assembly_support import ref, axis_matrix
@app.cell
def _():
# ---- params: finger ----
FINGER = "index"
ANGLES = (0.0, 0.0, 0.0, 0.0)
return FINGER, ANGLES
@app.cell
def _(FINGER):
# ---- feature: structural-definitions (build) ----
spec = next(f for f in FINGERS if f.name == FINGER)
links = [link_parts(FINGER, k) for k in range(4)]
return spec, links
@app.cell
def _(spec, ANGLES):
joint0 = scad.use(
"joint_module.py",
id=f"{spec.name}_joint0",
SIZE=spec.sizes[0],
OUTPUT_ANGLE=float(ANGLES[0]),
)
return (joint0,)
@app.cell
def _(spec, ANGLES):
joint1 = scad.use(
"joint_module.py",
id=f"{spec.name}_joint1",
SIZE=spec.sizes[1],
OUTPUT_ANGLE=float(ANGLES[1]),
)
return (joint1,)
@app.cell
def _(spec, ANGLES):
joint2 = scad.use(
"joint_module.py",
id=f"{spec.name}_joint2",
SIZE=spec.sizes[2],
OUTPUT_ANGLE=float(ANGLES[2]),
)
return (joint2,)
@app.cell
def _(spec, ANGLES):
joint3 = scad.use(
"joint_module.py",
id=f"{spec.name}_joint3",
SIZE=spec.sizes[3],
OUTPUT_ANGLE=float(ANGLES[3]),
)
return (joint3,)
@app.cell
def _(spec, links, ANGLES, joint0, joint1, joint2, joint3):
# ---- feature: articulated-finger (build) ----
_assembly = scad.make_assembly_rassembly(
assembly_id=scad.notebook_id(), name=f"LH20 {spec.name} 4-DOF finger"
)
_modules = [joint0, joint1, joint2, joint3]
for _k, _mod in enumerate(_modules):
_mid = f"joint{_k}"
_assembly = scad.add_component_rassembly(
assembly=_assembly,
item=_mod,
component_id=_mid,
placement=frame(axis_matrix(spec.axes[_k])),
)
if _k == 0:
_assembly = scad.ground_component_rassembly(
assembly=_assembly, component_id=_mid
)
else:
_assembly = scad.add_fixed_constraint_rassembly(
assembly=_assembly,
constraint_id=f"mount_{_mid}",
connector_a=ref(f"frame{_k - 1}", "next_joint"),
connector_b=ref(_mid, "mount"),
)
_fid = f"frame{_k}"
_assembly = scad.add_component_rassembly(
assembly=_assembly,
item=links[_k]["frame"].part,
component_id=_fid,
placement=frame(),
)
_assembly = scad.add_revolute_constraint_rassembly(
assembly=_assembly,
constraint_id=f"{spec.name}_active_{_k}",
connector_a=ref(_mid, "mount"),
connector_b=ref(_fid, "joint"),
drive_angle_degrees=float(ANGLES[_k]),
angle_limit=scad.ScalarLimit(
lower_value=spec.limits[_k][0], upper_value=spec.limits[_k][1]
),
)
for _kind in ["cover", "pad"] + (["touch"] if _k == 3 else []):
_cid = f"{_kind}{_k}"
_assembly = scad.add_component_rassembly(
assembly=_assembly,
item=links[_k][_kind].part,
component_id=_cid,
placement=frame(),
)
_assembly = scad.add_fixed_constraint_rassembly(
assembly=_assembly,
constraint_id=f"attach_{_cid}",
connector_a=ref(_fid),
connector_b=ref(_cid),
)
_assembly = scad.set_public_connector_rassembly(
assembly=_assembly,
public_connector_id="mount",
source_component_id="joint0",
source_connector_id="mount",
)
articulated_finger = _assembly
return (articulated_finger,)
@app.cell
def _(articulated_finger):
# ---- feature: solved-finger (modify) ----
solved_finger = scad.solve_assembly_constraints_rassembly(
assembly=articulated_finger, strict=True
)
return (solved_finger,)
if __name__ == "__main__":
app.run()
+127
View File
@@ -0,0 +1,127 @@
# /// script
# dependencies = ["simplecadapi"]
# [tool.simplecadapi]
# id = "lh20_right_hand"
# kind = "assembly"
# revision = "0.1.0"
# ///
"""LH20 original tendonless hand: five fingers, 20 active independent joints."""
import marimo
app = marimo.App()
with app.setup:
import simplecadapi as scad
from parameters import FINGERS
from parts.palm import palm_parts
from parts.common import frame
from assembly_support import ref
@app.cell
def _():
# ---- params: hand-pose ----
INDEX = (0.0, 0.0, 0.0, 0.0)
MIDDLE = (0.0, 0.0, 0.0, 0.0)
RING = (0.0, 0.0, 0.0, 0.0)
LITTLE = (0.0, 0.0, 0.0, 0.0)
THUMB = (0.0, 0.0, 0.0, 0.0)
return INDEX, MIDDLE, RING, LITTLE, THUMB
@app.cell
def _():
# ---- feature: palm-definitions (build) ----
palm = palm_parts()
return (palm,)
@app.cell
def _(INDEX):
index = scad.use("finger.py", id="index_finger", FINGER="index", ANGLES=INDEX)
return (index,)
@app.cell
def _(MIDDLE):
middle = scad.use("finger.py", id="middle_finger", FINGER="middle", ANGLES=MIDDLE)
return (middle,)
@app.cell
def _(RING):
ring = scad.use("finger.py", id="ring_finger", FINGER="ring", ANGLES=RING)
return (ring,)
@app.cell
def _(LITTLE):
little = scad.use("finger.py", id="little_finger", FINGER="little", ANGLES=LITTLE)
return (little,)
@app.cell
def _(THUMB):
thumb = scad.use("finger.py", id="thumb_finger", FINGER="thumb", ANGLES=THUMB)
return (thumb,)
@app.cell
def _(palm, index, middle, ring, little, thumb):
# ---- feature: complete-hand-assembly (build) ----
_assembly = scad.make_assembly_rassembly(
assembly_id=scad.notebook_id(), name="LH20 / precision tendonless hand / R0.1"
)
_assembly = scad.add_component_rassembly(
assembly=_assembly,
item=palm["chassis"].part,
component_id="chassis",
placement=frame(),
)
_assembly = scad.ground_component_rassembly(
assembly=_assembly, component_id="chassis"
)
for _kind in ["dorsal", "volar", "adapter", "board", "pad"]:
_assembly = scad.add_component_rassembly(
assembly=_assembly,
item=palm[_kind].part,
component_id=f"palm_{_kind}",
placement=frame(),
)
_assembly = scad.add_fixed_constraint_rassembly(
assembly=_assembly,
constraint_id=f"attach_palm_{_kind}",
connector_a=ref("chassis"),
connector_b=ref(f"palm_{_kind}"),
)
for _name, _finger in [
("index", index),
("middle", middle),
("ring", ring),
("little", little),
("thumb", thumb),
]:
_assembly = scad.add_component_rassembly(
assembly=_assembly, item=_finger, component_id=_name, placement=frame()
)
_assembly = scad.add_fixed_constraint_rassembly(
assembly=_assembly,
constraint_id=f"mount_{_name}",
connector_a=ref("chassis", f"{_name}_root"),
connector_b=ref(_name, "mount"),
)
assembled_hand = _assembly
return (assembled_hand,)
@app.cell
def _(assembled_hand):
# ---- feature: solved-hand (modify) ----
solved_hand = scad.solve_assembly_constraints_rassembly(
assembly=assembled_hand, strict=True
)
return (solved_hand,)
if __name__ == "__main__":
app.run()
+198
View File
@@ -0,0 +1,198 @@
# /// script
# dependencies = ["simplecadapi"]
# [tool.simplecadapi]
# id = "lh20_joint"
# kind = "assembly"
# revision = "0.1.0"
# ///
"""Editable planetary module; local Z is its revolute axis."""
import marimo
app = marimo.App()
with app.setup:
import math
import simplecadapi as scad
from parameters import SIZES
from parts.drivetrain import parts_for, stack
from parts.common import frame
from assembly_support import ref
@app.cell
def _():
# ---- params: joint ----
SIZE = "A"
OUTPUT_ANGLE = 0.0
return SIZE, OUTPUT_ANGLE
@app.cell
def _(SIZE):
# ---- feature: component-definitions (build) ----
components = parts_for(SIZE)
return (components,)
@app.cell
def _(SIZE, OUTPUT_ANGLE, components):
# ---- feature: module-assembly (build) ----
_s = SIZES[SIZE]
_z = stack(SIZE)
_asm = scad.make_assembly_rassembly(
assembly_id=scad.notebook_id(),
name=f"LH20 {_s.code} {_s.ratio:.0f}:1 planetary joint",
)
_asm = scad.add_component_rassembly(
assembly=_asm,
item=components["case"].part,
component_id="case",
placement=frame(),
)
_asm = scad.ground_component_rassembly(assembly=_asm, component_id="case")
_static = {
"motor": ("motor", _z["motor_z"]),
"ring1": ("ring", _z["g1"]),
"ring2": ("ring", _z["g2"]),
"cap": ("cap", _z["front"] - 0.85),
"encoder": ("encoder", _z["front"] - 2.25),
"encoder_chip": ("encoder_chip", _z["front"] - 1.7),
}
for _cid, (_key, _zz) in _static.items():
_asm = scad.add_component_rassembly(
assembly=_asm,
item=components[_key].part,
component_id=_cid,
placement=frame(origin=(0, 0, _zz)),
)
_asm = scad.add_fixed_constraint_rassembly(
assembly=_asm,
constraint_id=f"fixed_{_cid}",
connector_a=ref("case", _cid),
connector_b=ref(_cid),
)
# MR104 open bearing: SMB catalog envelope 4 x 10 x 3 mm.
# Eight-ball generic raceway is a visualization, not supplier internal CAD.
_mat = scad.make_material_rmaterial(
material_id="steel",
density=7800.0,
density_unit="kg/m^3",
color=(0.42, 0.47, 0.54),
)
_bearing = scad.std.bearing.build_ball_bearing(
bore_diameter=4.0,
outer_diameter=10.0,
bearing_width=3.0,
ball_diameter=1.588,
ball_count=8,
raceway_clearance=0.01,
assembly_id=f"mr104_{scad.notebook_id()}",
drive_angle_degrees=float(OUTPUT_ANGLE),
fuse_rolling_elements=False,
material=_mat,
)
_bearing_solved = scad.solve_assembly_constraints_rassembly(
assembly=_bearing.assembly, strict=True
)
for _cid, _zz in [("bearing1", _z["c2"] + 4.1), ("bearing2", _z["c2"] + 7.3)]:
_asm = scad.add_component_rassembly(
assembly=_asm,
item=_bearing_solved,
component_id=_cid,
placement=frame(origin=(0, 0, _zz)),
)
_asm = scad.add_fixed_constraint_rassembly(
assembly=_asm,
constraint_id=f"fixed_{_cid}",
connector_a=ref("case", _cid),
connector_b=ref(_cid, "outer_axis"),
)
_drives = {
"sun1": ("sun", _z["g1"], OUTPUT_ANGLE * _s.ratio),
"sun2": ("sun", _z["g2"], OUTPUT_ANGLE * _s.stage_ratio),
"carrier1": ("carrier1", _z["c1"], OUTPUT_ANGLE * _s.stage_ratio),
"carrier2": ("carrier2", _z["c2"], OUTPUT_ANGLE),
"output_flange": ("output", _z["front"] - 0.8, OUTPUT_ANGLE),
"input_shaft": ("input_shaft", _z["motor_z"], OUTPUT_ANGLE * _s.ratio),
"interstage_shaft": (
"interstage_shaft",
_z["c1"] + 0.8,
OUTPUT_ANGLE * _s.stage_ratio,
),
}
_drives["encoder_magnet"] = ("encoder_magnet", _z["front"] - 1.25, OUTPUT_ANGLE)
for _cid, (_key, _zz, _angle) in _drives.items():
_asm = scad.add_component_rassembly(
assembly=_asm,
item=components[_key].part,
component_id=_cid,
placement=frame(origin=(0, 0, _zz)),
)
_asm = scad.add_revolute_constraint_rassembly(
assembly=_asm,
constraint_id=f"revolve_{_cid}",
connector_a=ref("case", _cid),
connector_b=ref(_cid),
drive_angle_degrees=float(_angle),
)
for _stage, _sun_angle, _carrier_angle in [
(1, OUTPUT_ANGLE * _s.ratio, OUTPUT_ANGLE * _s.stage_ratio),
(2, OUTPUT_ANGLE * _s.stage_ratio, OUTPUT_ANGLE),
]:
for _i in range(3):
_cid = f"planet{_stage}_{_i}"
_phase = _i * 120 + 180 - 180 / _s.planet
_spin = -(_sun_angle - _carrier_angle) * _s.sun / _s.planet + _phase
_asm = scad.add_component_rassembly(
assembly=_asm,
item=components["planet"].part,
component_id=_cid,
placement=frame(),
)
_asm = scad.add_revolute_constraint_rassembly(
assembly=_asm,
constraint_id=f"revolve_{_cid}",
connector_a=ref(f"carrier{_stage}", f"planet{_i}"),
connector_b=ref(_cid),
drive_angle_degrees=float(_spin),
)
_pin = f"pin{_stage}_{_i}"
_asm = scad.add_component_rassembly(
assembly=_asm,
item=components["pin"].part,
component_id=_pin,
placement=frame(),
)
_asm = scad.add_fixed_constraint_rassembly(
assembly=_asm,
constraint_id=f"fixed_{_pin}",
connector_a=ref(f"carrier{_stage}", f"planet{_i}"),
connector_b=ref(_pin),
)
_asm = scad.set_public_connector_rassembly(
assembly=_asm,
public_connector_id="mount",
source_component_id="case",
source_connector_id="origin",
)
_asm = scad.set_public_connector_rassembly(
assembly=_asm,
public_connector_id="output",
source_component_id="output_flange",
source_connector_id="origin",
)
assembled_module = _asm
return (assembled_module,)
@app.cell
def _(assembled_module):
# ---- feature: solved-module (modify) ----
solved_module = scad.solve_assembly_constraints_rassembly(
assembly=assembled_module, strict=True
)
return (solved_module,)
if __name__ == "__main__":
app.run()
+118
View File
@@ -0,0 +1,118 @@
"""Independent 20-axis kinematics in mm and radians; no CAD imports."""
import numpy as np
from scipy.spatial.transform import Rotation
from scipy.optimize import least_squares
from parameters import FINGERS, SIZES
AXES = {
"x": np.array([1.0, 0, 0]),
"y": np.array([0.0, 1, 0]),
"z": np.array([0.0, 0, 1]),
}
def transform(origin=(0, 0, 0), rotation=None):
t = np.eye(4)
t[:3, 3] = origin
if rotation is not None:
t[:3, :3] = rotation
return t
def rotation(axis, angle):
return Rotation.from_rotvec(AXES[axis] * angle).as_matrix()
def finger_frames(spec, q=None):
q = np.zeros(4) if q is None else np.asarray(q)
parent = transform(
spec.base, Rotation.from_euler("xyz", spec.base_rpy, degrees=True).as_matrix()
)
frames = []
for k, (axis, length) in enumerate(zip(spec.axes, spec.lengths)):
stator = parent @ transform(
rotation=Rotation.from_euler(
"xyz", spec.pre_rotations[k], degrees=True
).as_matrix()
)
moving = stator @ transform(rotation=rotation(axis, q[k]))
frames.append(
{
"name": f"{spec.name}_j{k}",
"stator": stator,
"moving": moving,
"axis_world": stator[:3, :3] @ AXES[axis],
}
)
parent = moving @ transform((0, length, 0))
return frames, parent
def fingertip(spec, q):
return finger_frames(spec, q)[1][:3, 3]
def pad_contact(spec, q):
"""Outermost point and normal of the distal pad used in actual CAD."""
size = SIZES[spec.sizes[-1]]
length = spec.lengths[-1]
start = min(length * 0.38, size.diameter / 2 + 1.2)
end = length - 1.2
z = (size.diameter / 2 + 1.4 + 8.8) / 2 - 0.8 + 2.2
moving = finger_frames(spec, q)[0][-1]["moving"]
p = moving @ np.array([0, (start + end) / 2, z, 1.0])
return p[:3], moving[:3, 2]
def jacobian(spec, q):
"""Translational Jacobian at the actual distal pad point, metres/radian."""
frames, _ = finger_frames(spec, q)
p = pad_contact(spec, q)[0]
return np.column_stack(
[np.cross(f["axis_world"], (p - f["stator"][:3, 3]) / 1000) for f in frames]
)
def solve_opposition(other_name):
"""Find coincident distal pad surfaces with opposing surface normals.
This checks geometric contact intent, not force closure or collision freedom.
"""
thumb = next(f for f in FINGERS if f.name == "thumb")
other = next(f for f in FINGERS if f.name == other_name)
lo = np.deg2rad([p[0] for f in (thumb, other) for p in f.limits])
hi = np.deg2rad([p[1] for f in (thumb, other) for p in f.limits])
target = np.array([(other.base[0] + 10) / 2, 95.0, 45.0])
def residual(q):
a, na = pad_contact(thumb, q[:4])
b, nb = pad_contact(other, q[4:])
return np.r_[a - b, 15 * (na + nb), 0.015 * ((a + b) / 2 - target), 0.001 * q]
seeds = [
[-30, -45, 30, 20, 35, 0, 65, 30],
[45, -40, -30, 20, 45, 0, 70, 25],
[0, 20, 40, -20, 60, 0, 60, 30],
[-40, -60, -30, 40, 30, 0, 80, 10],
]
rng = np.random.default_rng(20)
initial = [np.clip(np.deg2rad(seed), lo + 1e-5, hi - 1e-5) for seed in seeds]
initial.extend(rng.uniform(lo, hi, size=(28, 8)))
runs = [
least_squares(residual, seed, bounds=(lo, hi), max_nfev=350) for seed in initial
]
best = min(runs, key=lambda r: np.linalg.norm(r.fun[:6]))
q = best.x
a, na = pad_contact(thumb, q[:4])
b, nb = pad_contact(other, q[4:])
return {
"finger": other_name,
"thumb_deg": np.rad2deg(q[:4]).tolist(),
"finger_deg": np.rad2deg(q[4:]).tolist(),
"gap_error_mm": float(np.linalg.norm(a - b)),
"normal_dot": float(na @ nb),
"thumb_contact_mm": a.tolist(),
"finger_contact_mm": b.tolist(),
"scope": "pad-point and opposing-normal IK; collision and force closure are separate checks",
}
+131
View File
@@ -0,0 +1,131 @@
"""Read the canonical package, preserve the assembly hierarchy and placements."""
import numpy as np
import simplecadapi as scad
from parameters import OUT, FINGERS, SIZES
def placement_matrix(p):
m = np.eye(4)
m[:3, 0] = p.x_axis
m[:3, 1] = p.y_axis
m[:3, 2] = p.z_axis
m[:3, 3] = p.origin
return m
def flatten(item, parent=None, path=""):
parent = np.eye(4) if parent is None else parent
if isinstance(item, scad.Part):
return [(path or item.part_id, item, parent)]
result = []
for cid in item.component_ids():
c = item.get_component(cid)
result.extend(
flatten(c.item, parent @ placement_matrix(c.placement), f"{path}/{cid}")
)
return result
def read_model(name="lh20_right_hand"):
return scad.materialize_definition(
scad.load_product_package(OUT / f"{name}.scadpkg")
)
def assembly_reports(item, path=""):
if isinstance(item, scad.Part):
return []
report = scad.inspect_assembly_constraints_rconstraintreport(assembly=item)
result = [
{
"path": path,
"solved": bool(report.solved),
"constraints": len(item.constraint_ids()),
"unsolved_components": list(report.unsolved_component_ids),
}
]
for cid in item.component_ids():
result.extend(assembly_reports(item.get_component(cid).item, f"{path}/{cid}"))
return result
def pose_angles(name):
import json
if not name:
return {f.name: np.zeros(4) for f in FINGERS}
pose, fraction_text = (
(name.split("@", 1) + ["1"])[:2] if "@" in name else (name, "1")
)
fraction = float(fraction_text)
if not 0 <= fraction <= 1:
raise ValueError("pose interpolation fraction must be between zero and one")
target = pose.removeprefix("opposition_")
rows = json.loads((OUT / "opposition.json").read_text())
row = next(r for r in rows if r["finger"] == target)
q = {f.name: np.zeros(4) for f in FINGERS}
q[target] = np.deg2rad(row["finger_deg"]) * fraction
q["thumb"] = np.deg2rad(row["thumb_deg"]) * fraction
return q
def flatten_pose(item, pose=None):
"""Evaluate placements from independent FK and the same planetary equations.
This is a posed inspection projection. It does not rewrite the canonical
assembly constraint report, which remains the notebook's neutral solve.
"""
if not pose:
return flatten(item)
from kinematics import finger_frames, transform, rotation
from assembly_support import axis_matrix
angles = pose_angles(pose)
result = []
old = {f.name: finger_frames(f)[0] for f in FINGERS}
new = {f.name: finger_frames(f, angles[f.name])[0] for f in FINGERS}
specs = {f.name: f for f in FINGERS}
for path, p, m in flatten(item):
tokens = path.strip("/").split("/")
name = tokens[0]
if name not in specs:
result.append((path, p, m))
continue
k = int(tokens[1][-1])
spec = specs[name]
q = angles[name][k]
if not tokens[1].startswith("joint"):
matrix = new[name][k]["moving"] @ np.linalg.inv(old[name][k]["moving"]) @ m
else:
basis = axis_matrix(spec.axes[k])
old_module = old[name][k]["stator"] @ basis
new_module = new[name][k]["stator"] @ basis
local = np.linalg.inv(old_module) @ m
cid = tokens[2]
s = SIZES[spec.sizes[k]]
multipliers = {
"sun1": s.ratio,
"input_shaft": s.ratio,
"sun2": s.stage_ratio,
"carrier1": s.stage_ratio,
"interstage_shaft": s.stage_ratio,
"carrier2": 1,
"output_flange": 1,
"encoder_magnet": 1,
}
if cid in multipliers:
local = transform(rotation=rotation("z", q * multipliers[cid])) @ local
elif cid.startswith("planet") or cid.startswith("pin"):
stage = int(cid[6] if cid.startswith("planet") else cid[3])
carrier = q * (s.stage_ratio if stage == 1 else 1.0)
local = transform(rotation=rotation("z", carrier)) @ local
if cid.startswith("planet"):
sun = q * (s.ratio if stage == 1 else s.stage_ratio)
spin = -(sun - carrier) * s.sun / s.planet
local = local @ transform(rotation=rotation("z", spin))
elif cid.startswith("bearing") and tokens[-1] == "inner_ring":
local = transform(rotation=rotation("z", q)) @ local
matrix = new_module @ local
result.append((path, p, matrix))
return result
+148
View File
@@ -0,0 +1,148 @@
"""Single source of dimensions and explicitly unverified actuator targets."""
from dataclasses import dataclass
from pathlib import Path
HERE = Path(__file__).resolve().parent
OUT = HERE / "out"
REVISION = "0.1.0"
CLEARANCE_REVISION = "aa26ab00626b635b68878259a981dbdda3bf6634e5d83df345fd1d11dc4f8029"
@dataclass(frozen=True)
class JointSize:
code: str
diameter: float
width: float
sun: int
planet: int
ring: int
module: float
gear_width: float
motor_diameter: float
motor_length: float
continuous_target: float
peak_target: float
efficiency_assumption: float = 0.72
backlash: float = 0.025
pressure_angle: float = 25.0
@property
def stage_ratio(self):
return 1 + self.ring / self.sun
@property
def ratio(self):
return self.stage_ratio**2
@property
def planet_radius(self):
return self.module * (self.sun + self.planet) / 2
SIZES = {
"A": JointSize("A", 24.0, 22.2, 12, 24, 60, 0.30, 2.2, 20.0, 5.2, 0.35, 0.90),
"B": JointSize("B", 21.0, 21.4, 12, 18, 48, 0.31, 2.0, 17.0, 4.7, 0.18, 0.50),
"C": JointSize("C", 18.0, 20.0, 18, 18, 54, 0.23, 1.7, 14.5, 4.0, 0.08, 0.25),
}
@dataclass(frozen=True)
class FingerSpec:
name: str
base: tuple[float, float, float]
base_rpy: tuple[float, float, float]
lengths: tuple[float, float, float, float]
axes: tuple[str, str, str, str]
sizes: tuple[str, str, str, str]
limits: tuple[tuple[float, float], ...]
pre_rotations: tuple[tuple[float, float, float], ...] = ((0, 0, 0),) * 4
FINGERS = (
FingerSpec(
"index",
(43.5, 76, 0),
(0, 0, -2),
(25, 40, 28, 23),
("x", "z", "x", "x"),
("A", "B", "B", "C"),
((-15, 95), (-25, 25), (0, 115), (0, 85)),
),
FingerSpec(
"middle",
(14.5, 82, 0),
(0, 0, 0),
(25, 44, 30, 24),
("x", "z", "x", "x"),
("A", "B", "B", "C"),
((-15, 95), (-25, 25), (0, 115), (0, 85)),
),
FingerSpec(
"ring",
(-14.5, 77, 0),
(0, 0, 2),
(25, 40, 28, 23),
("x", "z", "x", "x"),
("A", "B", "B", "C"),
((-15, 95), (-25, 25), (0, 115), (0, 85)),
),
FingerSpec(
"little",
(-43.5, 66, 0),
(0, 0, 6),
(25, 34, 25, 21),
("x", "z", "x", "x"),
("A", "B", "B", "C"),
((-15, 95), (-25, 25), (0, 115), (0, 85)),
),
FingerSpec(
"thumb",
(31, 35, 14),
(-40.238411, 21.487069, -139.973387),
(25, 32, 30, 24),
("x", "z", "x", "x"),
("A", "A", "B", "C"),
(
(0.0, 170.0),
(-141.10848241, 13.89151759),
(-35.23701525, 134.76298475),
(-70.9408095, 99.0591905),
),
(
(0, 0, 0),
(5.983855016, -9.110154638, 90.881273173),
(-37.94103175, -32.361208, 5.922358),
(0.9408095, 0.0, 0.0),
),
),
)
MATERIALS = {
"aluminium": (2700.0, (0.66, 0.71, 0.76)),
"steel": (7800.0, (0.42, 0.47, 0.54)),
"polymer": (1010.0, (0.90, 0.92, 0.94)),
"silicone": (1100.0, (0.12, 0.15, 0.18)),
"pcb": (1850.0, (0.08, 0.40, 0.34)),
"motor_envelope": (None, (0.78, 0.46, 0.18)),
"sensor_envelope": (None, (0.15, 0.57, 0.70)),
"magnet_envelope": (None, (0.20, 0.22, 0.26)),
}
PALM_WIDTH = 104.0
PALM_LENGTH = 88.0
PALM_THICKNESS = 34.0
FINGER_WALL = 1.6
RUNNING_CLEARANCE = 0.35
SKIN_THICKNESS = 1.2
CONTACT_FORCE_CONTINUOUS = 3.0
CONTACT_FORCE_PEAK = 8.0
def validate_parameters():
assert len(FINGERS) * 4 == 20
for s in SIZES.values():
assert s.ring == s.sun + 2 * s.planet
assert (s.sun + s.ring) % 3 == 0
assert s.module * s.ring / 2 + 1.25 * s.module + 1.05 < s.diameter / 2 - 0.7
assert s.motor_diameter < s.diameter - 2
assert s.width > s.motor_length + 2 * s.gear_width + 5
return True
+1
View File
@@ -0,0 +1 @@
"""Editable parametric component families for LH20."""
+219
View File
@@ -0,0 +1,219 @@
"""Small public-API construction helpers shared by the part families."""
from pathlib import Path
import math
import json
import hashlib
import numpy as np
import simplecadapi as scad
from scipy.spatial.transform import Rotation
from parameters import MATERIALS, REVISION, CLEARANCE_REVISION
ROOT = Path(__file__).resolve().parents[1]
def rigid_shape(shape, matrix):
"""Use rigid OCCT transforms; an affine GTransform can degrade tiny gears."""
vector = Rotation.from_matrix(matrix[:3, :3]).as_rotvec()
angle = float(np.linalg.norm(vector))
if angle > 1e-12:
shape = scad.rotate_shape(
shape=shape, axis=tuple(vector / angle), angle=math.degrees(angle)
)
return scad.translate_shape(shape=shape, vector=tuple(matrix[:3, 3]))
def frame(matrix=None, origin=(0, 0, 0)):
if matrix is None:
return scad.make_placement_rplacement(origin=origin)
return scad.make_placement_rplacement(
origin=tuple(matrix[:3, 3]),
x_axis=tuple(matrix[:3, 0]),
y_axis=tuple(matrix[:3, 1]),
)
def axis_frame(axis="z", origin=(0, 0, 0)):
axes = {
"z": ((1, 0, 0), (0, 1, 0)),
"x": ((0, 1, 0), (0, 0, 1)),
"y": ((0, 0, 1), (1, 0, 0)),
}
x, y = axes[axis]
return scad.make_placement_rplacement(origin=origin, x_axis=x, y_axis=y)
def annulus(ro, ri, z, height):
outer = scad.make_cylinder_rsolid(
radius=ro, height=height, bottom_face_center=(0, 0, z)
)
inner = scad.make_cylinder_rsolid(
radius=ri, height=height + 2, bottom_face_center=(0, 0, z - 1)
)
return scad.cut_rsolid(outer, inner, on_split="error", skip_non_intersecting=False)
def cylinder_axis(radius, width, axis, center=(0, 0, 0)):
vector = (
{"x": (1, 0, 0), "y": (0, 1, 0), "z": (0, 0, 1)}[axis]
if isinstance(axis, str)
else axis
)
return scad.make_cylinder_rsolid(
radius=radius,
height=width,
axis=vector,
bottom_face_center=tuple(center[i] - width / 2 * vector[i] for i in range(3)),
)
def ellipse_wire(name, y, rx, rz, z=0):
wp = scad.make_workplane_rworkplane(
origin=(0, y, z), normal=(0, 1, 0), x_dir=(1, 0, 0)
)
sk = scad.make_sketch_rsketch(name=name, plane=wp)
major, minor = ((rx, 0), (0, rz)) if rx >= rz else ((0, rz), (rx, 0))
for pid, xx, yy in [("center", 0, 0), ("major", *major), ("minor", *minor)]:
sk = scad.add_point_rsketch(sketch=sk, point_id=pid, x=xx, y=yy)
sk = scad.constrain_fix_rsketch(sketch=sk, target=pid)
sk = scad.add_ellipse_rsketch(
sketch=sk,
entity_id="outline",
center="center",
major_point="major",
minor_point="minor",
)
return scad.make_wire_from_sketch_rwire(sketch=sk, require_fully_constrained=True)
def loft_envelope(name, sections):
return scad.loft_rsolid(
profiles=[ellipse_wire(f"{name}_{i}", *v) for i, v in enumerate(sections)],
ruled=False,
)
def make_part(part_id, body, material, connectors=(), name=None):
p = scad.make_part_rpart(part_id=part_id, body=body, name=name or part_id)
density, color = MATERIALS[material]
mat = scad.make_material_rmaterial(
material_id=material,
name=material,
density=density,
density_unit="kg/m^3" if density else None,
color=color,
)
p = scad.assign_material_rpart(part=p, material=mat)
for cid, placement in connectors:
# A library part owns its own recording session. Copy the frame values,
# never a node belonging to the calling notebook's graph.
local = scad.make_placement_rplacement(
origin=tuple(placement.origin),
x_axis=tuple(placement.x_axis),
y_axis=tuple(placement.y_axis),
)
p = scad.add_connector_rpart(
part=p,
connector=scad.make_placement_connector_rconnector(
connector_id=cid, placement=local, name=cid
),
)
return p
def build_named(part_id, builder, material, connectors=(), label=None, **kwargs):
@scad.part(id=part_id, revision=REVISION, project_root=ROOT)
def build():
body = builder(**kwargs)
# ---- feature: measured-motion-reliefs (subtract, profile=geometry) ----
relief_path = ROOT / "clearance_reliefs.json"
if relief_path.exists():
if (
hashlib.sha256(relief_path.read_bytes()).hexdigest()
!= CLEARANCE_REVISION
):
raise ValueError(
"Clearance source digest mismatch; run verify/design_reliefs.py to refresh the design data"
)
records = json.loads(relief_path.read_text())["parts"].get(part_id, [])
if records:
tools = []
for r in records:
lo, hi = np.asarray(r["min_mm"]), np.asarray(r["max_mm"])
d = hi - lo
tools.append(
scad.make_box_rsolid(
width=float(d[0]),
height=float(d[1]),
depth=float(d[2]),
bottom_face_center=(
float((lo[0] + hi[0]) / 2),
float((lo[1] + hi[1]) / 2),
float(lo[2]),
),
)
)
before = body.get_volume()
pieces = scad.cut_rsolid_list(body, *tools)
if not pieces:
raise ValueError(f"{part_id}: clearance consumes the complete part")
pieces = sorted(pieces, key=lambda p: p.get_volume(), reverse=True)
offcut = sum(p.get_volume() for p in pieces[1:])
offcut_limit = 0.08 if material in ("polymer", "silicone") else 0.02
if offcut / before > offcut_limit:
raise ValueError(
f"{part_id}: relief disconnects {offcut / before:.1%} of the part; redesign the structure"
)
body = pieces[0]
removal = 1 - body.get_volume() / before
if removal > (0.45 if material in ("polymer", "silicone") else 0.25):
raise ValueError(
f"{part_id}: relief removes {removal:.1%}; redesign the structure"
)
if offcut:
print(
f"CLEARANCE OFFCUT {part_id}: {offcut:.4f} mm3, {offcut / before:.2%}",
flush=True,
)
return make_part(
part_id, body, material, connectors or (("origin", frame()),), label
)
return build()
def bolt_tools(radius, pcd, z, height, count=3, phase=0):
return [
scad.make_cylinder_rsolid(
radius=radius,
height=height,
bottom_face_center=(
pcd / 2 * math.cos(math.radians(phase + i * 360 / count)),
pcd / 2 * math.sin(math.radians(phase + i * 360 / count)),
z,
),
)
for i in range(count)
]
def add_fixed(
assembly,
cid,
item,
placement,
parent="case",
parent_connector=None,
child_connector="origin",
):
assembly = scad.add_component_rassembly(
assembly=assembly, item=item, component_id=cid, placement=placement, name=cid
)
return scad.add_fixed_constraint_rassembly(
assembly=assembly,
constraint_id=f"fix_{cid}",
connector_a=scad.ConnectorRef(
component_id=parent, connector_id=parent_connector or cid
),
connector_b=scad.ConnectorRef(component_id=cid, connector_id=child_connector),
)
+309
View File
@@ -0,0 +1,309 @@
"""Two-stage planetary geometry. All motor performance remains unselected."""
from functools import lru_cache
import math
import simplecadapi as scad
from parameters import SIZES
from parts.common import annulus, bolt_tools, build_named, frame
def stack(code):
s = SIZES[code]
rear = -s.width / 2
motor_z = rear + 1.0
g1 = motor_z + s.motor_length + 0.4
c1 = g1 + s.gear_width + 0.15
g2 = c1 + 0.8 + 0.2
c2 = g2 + s.gear_width + 0.15
bearing_z = c2 + 0.8 + 0.15
return dict(
rear=rear,
motor_z=motor_z,
g1=g1,
c1=c1,
g2=g2,
c2=c2,
bearing_z=bearing_z,
front=s.width / 2,
)
def d_shaft(radius, flat, z, height):
"""A positive mechanical torque interface; dimensions remain nominal."""
shaft = scad.make_cylinder_rsolid(
radius=radius, height=height, bottom_face_center=(0, 0, z)
)
cutter = scad.make_box_rsolid(
width=4 * radius,
height=2 * radius,
depth=height + 2,
bottom_face_center=(0, flat + radius, z - 1),
)
return scad.cut_rsolid(shaft, cutter, on_split="error")
def housing_shape(code):
s = SIZES[code]
z = stack(code)
# ---- feature: case-sleeve (build, profile=geometry) ----
body = annulus(s.diameter / 2, s.diameter / 2 - 0.85, z["rear"], s.width - 0.85)
# ---- feature: rear-bearing-seat (add, profile=geometry) ----
seat = annulus(s.diameter / 2 - 0.1, 1.25, z["rear"], 0.75)
body = scad.union_rsolid(body, seat)
# ---- feature: ring-location-seats (add, profile=geometry) ----
ring_ro = s.module * s.ring / 2 + 1.25 * s.module + 1.05
seats = [
annulus(s.diameter / 2 - 0.1, ring_ro + 0.025, z[key], s.gear_width)
for key in ["g1", "g2"]
]
body = scad.union_rsolid(body, *seats)
# ---- feature: ring-anti-rotation-pockets (subtract, profile=geometry) ----
pocket_tools = []
for level in ("g1", "g2"):
pocket_tools.extend(
bolt_tools(0.54, 2 * (ring_ro + 0.15), z[level] - 0.05, s.gear_width + 0.1)
)
body = scad.cut_rsolid(body, *pocket_tools, on_split="error")
# ---- feature: output-bearing-support (add, profile=geometry) ----
support_start = z["c2"] + 0.95
support = annulus(s.diameter / 2 - 0.1, 5.015, support_start, 6.4)
body = scad.union_rsolid(body, support)
# ---- feature: front-cap-thread-bosses (add, profile=geometry) ----
bosses = bolt_tools(1.35, s.diameter - 3.2, z["front"] - 3.0, 2.15)
body = scad.union_rsolid(body, *bosses)
# ---- feature: cap-pilot-bores (subtract, profile=geometry) ----
body = scad.cut_rsolid(
body,
*bolt_tools(0.5, s.diameter - 3.2, z["front"] - 3.1, 2.4),
on_split="error",
skip_non_intersecting=False,
)
# ---- feature: cable-exit (subtract, profile=geometry) ----
exit_tool = scad.make_box_rsolid(
width=3.0,
height=3.5,
depth=2.0,
bottom_face_center=(0, -s.diameter / 2, z["rear"] + 0.8),
)
body = scad.cut_rsolid(body, exit_tool, on_split="error")
return body
def ring_shape(code):
s = SIZES[code]
# ---- feature: internal-gear (build) ----
body = scad.std.gear.make_spur_ring_gear_rsolid(
n_teeth=s.ring,
module=s.module,
pressure_angle=s.pressure_angle,
gear_height=s.gear_width,
rim_thickness=1.05,
backlash=s.backlash,
)
# ---- feature: housing-reaction-lugs (add, profile=geometry) ----
ro = s.module * s.ring / 2 + 1.25 * s.module + 1.05
return scad.union_rsolid(body, *bolt_tools(0.50, 2 * (ro + 0.15), 0, s.gear_width))
def gear_shape(code, kind):
s = SIZES[code]
teeth = s.sun if kind == "sun" else s.planet
# ---- feature: involute-teeth (build) ----
body = scad.std.gear.make_spur_gear_rsolid(
n_teeth=teeth,
module=s.module,
pressure_angle=s.pressure_angle,
gear_height=s.gear_width,
backlash=s.backlash,
)
# ---- feature: shaft-bore (subtract, profile=geometry) ----
bore = (
scad.make_cylinder_rsolid(
radius=0.62, height=s.gear_width + 2, bottom_face_center=(0, 0, -1)
)
if kind == "planet"
else d_shaft(0.81, 0.65, -1, s.gear_width + 2)
)
return scad.cut_rsolid(body, bore, on_split="error", skip_non_intersecting=False)
def carrier_shape(code, stage):
s = SIZES[code]
# ---- feature: carrier-plate (build, profile=geometry) ----
body = scad.make_cylinder_rsolid(radius=s.planet_radius + 1.0, height=0.8)
# ---- feature: planet-pin-holes (subtract, profile=geometry) ----
body = scad.cut_rsolid(
body,
*bolt_tools(0.59, 2 * s.planet_radius, -1, 3),
on_split="error",
skip_non_intersecting=False,
)
# ---- feature: lightening-holes (subtract, profile=geometry) ----
body = scad.cut_rsolid(
body,
*bolt_tools(max(0.5, s.planet_radius * 0.32), s.planet_radius, -1, 3, phase=60),
on_split="error",
skip_non_intersecting=False,
)
# ---- feature: keyed-torque-interface (subtract, profile=geometry) ----
bore = d_shaft(0.81, 0.65, -1, 3) if stage == 1 else d_shaft(2.01, 1.61, -1, 3)
return scad.cut_rsolid(body, bore, on_split="error")
def cap_shape(code):
s = SIZES[code]
# ---- feature: removable-front-cap (build, profile=geometry) ----
body = annulus(s.diameter / 2, 5.85, 0, 0.85)
# ---- feature: cap-fasteners (subtract, profile=geometry) ----
return scad.cut_rsolid(
body,
*bolt_tools(0.65, s.diameter - 3.2, -1, 3),
on_split="error",
skip_non_intersecting=False,
)
def output_shape(code):
s = SIZES[code]
z = stack(code)
shaft_length = z["front"] - z["c2"]
# ---- feature: output-spigot (build, profile=geometry) ----
body = scad.make_cylinder_rsolid(
radius=1.99, height=shaft_length, bottom_face_center=(0, 0, 0.8 - shaft_length)
)
flat = scad.make_box_rsolid(
width=8, height=4, depth=0.8, bottom_face_center=(0, 3.59, 0.8 - shaft_length)
)
body = scad.cut_rsolid(body, flat, on_split="error")
# ---- feature: output-flange (add, profile=geometry) ----
disc = scad.make_cylinder_rsolid(
radius=5.6, height=0.8, bottom_face_center=(0, 0, 0.0)
)
body = scad.union_rsolid(body, disc)
# ---- feature: output-mount-holes (subtract, profile=geometry) ----
return scad.cut_rsolid(
body,
*bolt_tools(0.6, 8.6, -0.1, 1.5),
on_split="error",
skip_non_intersecting=False,
)
def encoder_shape(code):
s = SIZES[code]
# ---- feature: annular-encoder-reserved-space (build, profile=geometry) ----
body = annulus(s.diameter / 2 - 1.2, 4.3, 0, 0.55)
# ---- feature: cap-boss-clearance (subtract, profile=geometry) ----
return scad.cut_rsolid(
body, *bolt_tools(1.5, s.diameter - 3.2, -1, 3), on_split="error"
)
@lru_cache(maxsize=3)
def parts_for(code):
s = SIZES[code]
z = stack(code)
connectors = [
("origin", frame()),
("input", frame()),
("output", frame()),
("rear_cap", frame(origin=(0, 0, z["rear"]))),
]
placements = {
"motor": z["motor_z"],
"ring1": z["g1"],
"ring2": z["g2"],
"sun1": z["g1"],
"sun2": z["g2"],
"carrier1": z["c1"],
"carrier2": z["c2"],
"cap": z["front"] - 0.85,
"encoder": z["front"] - 2.25,
"encoder_chip": z["front"] - 1.7,
"encoder_magnet": z["front"] - 1.25,
"output_flange": z["front"] - 0.8,
"bearing1": z["c2"] + 4.1,
"bearing2": z["c2"] + 7.3,
"input_shaft": z["motor_z"],
"interstage_shaft": z["c1"] + 0.8,
}
connectors += [(name, frame(origin=(0, 0, zz))) for name, zz in placements.items()]
case = build_named(
f"case_{code}", housing_shape, "aluminium", tuple(connectors), code=code
)
carrier_connectors = [("origin", frame())]
for i in range(3):
a = math.radians(i * 120)
x, y = s.planet_radius * math.cos(a), s.planet_radius * math.sin(a)
carrier_connectors.append(
(f"planet{i}", frame(origin=(x, y, -s.gear_width - 0.15)))
)
items = {
"case": case,
"ring": build_named(f"ring_{code}", ring_shape, "steel", code=code),
"sun": build_named(f"sun_{code}", gear_shape, "steel", code=code, kind="sun"),
"planet": build_named(
f"planet_{code}", gear_shape, "steel", code=code, kind="planet"
),
"carrier1": build_named(
f"carrier1_{code}",
carrier_shape,
"steel",
tuple(carrier_connectors),
code=code,
stage=1,
),
"carrier2": build_named(
f"carrier2_{code}",
carrier_shape,
"steel",
tuple(carrier_connectors),
code=code,
stage=2,
),
"cap": build_named(f"cap_{code}", cap_shape, "aluminium", code=code),
"output": build_named(f"output_{code}", output_shape, "steel", code=code),
"motor": build_named(
f"motor_envelope_{code}",
lambda: annulus(s.motor_diameter / 2, 1.1, 0, s.motor_length),
"motor_envelope",
label=f"{code} 定制电机占位:性能和接口待供应商确认",
),
"encoder": build_named(
f"encoder_envelope_{code}",
encoder_shape,
"pcb",
label="输出编码器板空间,未完成电路设计",
code=code,
),
"encoder_chip": build_named(
f"encoder_chip_{code}",
lambda: scad.make_box_rsolid(
width=1.0, height=1.0, depth=0.25, bottom_face_center=(4.9, 0, 0)
),
"sensor_envelope",
label="离轴读头安装包络:型号和磁场待选型",
),
"encoder_magnet": build_named(
f"encoder_magnet_{code}",
lambda: annulus(5.4, 4.4, 0, 0.4),
"magnet_envelope",
label="输出多极磁环包络:极数和绝对角方案待验证",
),
"pin": build_named(
f"planet_pin_{code}",
lambda: scad.make_cylinder_rsolid(radius=0.59, height=s.gear_width + 0.8),
"steel",
),
"input_shaft": build_named(
f"input_shaft_{code}",
lambda: d_shaft(0.8, 0.64, 0, z["g1"] + s.gear_width - z["motor_z"]),
"steel",
),
"interstage_shaft": build_named(
f"interstage_shaft_{code}",
lambda: d_shaft(0.8, 0.64, -0.8, s.gear_width + 1.0),
"steel",
),
}
return items
+187
View File
@@ -0,0 +1,187 @@
"""Serviceable palm chassis, split covers, wrist adapter and electronics bays."""
from functools import lru_cache
import numpy as np
import simplecadapi as scad
from parameters import FINGERS, SIZES
from kinematics import finger_frames
from parts.common import (
loft_envelope,
annulus,
cylinder_axis,
build_named,
frame,
rigid_shape,
)
from assembly_support import axis_matrix
def palm_blank(offset=0):
return loft_envelope(
"palm",
[
(-8, 27 + offset, 13 + offset),
(12, 43 + offset, 17 + offset),
(47, 50 + offset, 16 + offset),
(78, 46 + offset, 13 + offset),
(86, 42 + offset, 11 + offset),
],
)
def roots_cutters(extra=0):
tools = []
for f in FINGERS:
pose = finger_frames(f)[0][0]
s = SIZES[f.sizes[0]]
tools.append(
cylinder_axis(
s.diameter / 2 + 0.3 + extra,
s.width + 0.3 + extra * 2,
pose["axis_world"],
pose["stator"][:3, 3],
)
)
boss_center = pose["stator"][:3, 3] + pose["axis_world"] * (s.width / 2 + 0.9)
tools.append(
cylinder_axis(5.9 + extra, 3.0 + 2 * extra, pose["axis_world"], boss_center)
)
# Clearance for the first moving frame and the second actuator. Their
# real spacing matters at the short little-finger root and oblique thumb.
from parts.phalanges import blank
tools.append(rigid_shape(blank(f, 0, 1.8 + extra), pose["moving"]))
pose1 = finger_frames(f)[0][1]
s1 = SIZES[f.sizes[1]]
tools.append(
cylinder_axis(
s1.diameter / 2 + 0.6 + extra,
s1.width + 3 + extra * 2,
pose1["axis_world"],
pose1["stator"][:3, 3],
)
)
if f.name == "thumb":
tools.append(rigid_shape(blank(f, 1, 1.8 + extra), pose1["moving"]))
return tools
def chassis_shape():
# ---- feature: palm-structure (build, profile=sketch) ----
body = palm_blank()
# ---- feature: wrist-neck (add, profile=geometry) ----
neck = annulus(23, 13, 0, 12)
neck = scad.rotate_shape(shape=neck, angle=-90, axis=(1, 0, 0))
neck = scad.translate_shape(shape=neck, vector=(0, -18, 0))
body = scad.union_rsolid(body, neck)
# ---- feature: palm-service-cavity (subtract, profile=sketch) ----
cavity = loft_envelope(
"palm_cavity",
[(-5, 24, 10), (12, 40, 14), (47, 47, 13), (76, 42.5, 10), (83, 39, 8)],
)
body = scad.cut_rsolid(body, cavity, on_split="error", skip_non_intersecting=False)
# ---- feature: through-wrist-electrical-port (subtract, profile=geometry) ----
body = scad.cut_rsolid(
body, cylinder_axis(12.5, 45, "y", (0, -10, 0)), on_split="error"
)
# ---- feature: finger-module-sockets (subtract, profile=geometry) ----
body = scad.cut_rsolid(body, *roots_cutters(), on_split="error")
# ---- feature: dorsal-service-opening (subtract, profile=geometry) ----
opening = loft_envelope(
"service_window", [(4, 22, 3, -17), (42, 35, 3, -17), (67, 25, 3, -15)]
)
body = scad.cut_rsolid(body, opening, on_split="error")
# ---- feature: palm-pad-seat (subtract, profile=sketch) ----
body = scad.cut_rsolid(body, palm_pad_shape(), on_split="error")
return body
def cover_shape(side):
# ---- feature: replaceable-palm-cover (build, profile=sketch) ----
outer = palm_blank(1.45)
inner = palm_blank(0.25)
body = scad.cut_rsolid(outer, inner, on_split="error", skip_non_intersecting=False)
# ---- feature: split-cover-half (subtract, profile=geometry) ----
z0 = -0.3 if side == "dorsal" else -70
height = 70 if side == "dorsal" else 70.3
body = scad.cut_rsolid(
body,
scad.make_box_rsolid(
width=150, height=140, depth=height, bottom_face_center=(0, 35, z0)
),
on_split="error",
)
# ---- feature: finger-and-thumb-clearances (subtract, profile=geometry) ----
body = scad.cut_rsolid(
body,
*roots_cutters(1.1),
cylinder_axis(23.3, 12.5, "y", (0, -12, 0)),
on_split="error",
)
if side == "volar":
body = scad.cut_rsolid(body, palm_pad_shape(), on_split="error")
return body
def adapter_shape():
# ---- feature: wrist-adapter-ring (build, profile=geometry) ----
body = annulus(28, 13, 0, 4)
# ---- feature: four-M3-interface-holes (subtract, profile=geometry) ----
tools = [
scad.make_cylinder_rsolid(radius=1.7, height=6, bottom_face_center=(x, y, -1))
for x in [-16, 16]
for y in [-16, 16]
]
body = scad.cut_rsolid(body, *tools, on_split="error", skip_non_intersecting=False)
body = scad.rotate_shape(shape=body, angle=-90, axis=(1, 0, 0))
return scad.translate_shape(shape=body, vector=(0, -22, 0))
def board_shape():
# ---- feature: palm-board-reserved-volume (build, profile=geometry) ----
body = scad.make_box_rsolid(
width=57, height=43, depth=1.2, bottom_face_center=(0, 33, -3)
)
# ---- feature: board-mount-holes (subtract, profile=geometry) ----
holes = [
scad.make_cylinder_rsolid(radius=1.1, height=3, bottom_face_center=(x, y, -4))
for x in [-24, 24]
for y in [15, 51]
]
return scad.cut_rsolid(body, *holes, on_split="error", skip_non_intersecting=False)
def palm_pad_shape():
# ---- feature: removable-palm-pad (build, profile=sketch) ----
body = loft_envelope(
"palm_pad", [(11, 14, 1.0, 18), (33, 32, 1.8, 18), (62, 29, 1.4, 16)]
)
return scad.cut_rsolid(body, *roots_cutters(0.8), on_split="error")
@lru_cache(maxsize=1)
def palm_parts():
connectors = [("origin", frame())] + [
(
f"{f.name}_root",
frame(finger_frames(f)[0][0]["stator"] @ axis_matrix(f.axes[0])),
)
for f in FINGERS
]
return {
"chassis": build_named(
"palm_chassis", chassis_shape, "aluminium", tuple(connectors)
),
"dorsal": build_named(
"palm_dorsal_cover", cover_shape, "polymer", side="dorsal"
),
"volar": build_named("palm_volar_cover", cover_shape, "polymer", side="volar"),
"adapter": build_named("wrist_adapter", adapter_shape, "aluminium"),
"board": build_named(
"palm_pcb_envelope",
board_shape,
"pcb",
label="掌部电源和驱动板空间:未完成电路设计",
),
"pad": build_named("palm_contact_pad", palm_pad_shape, "silicone"),
}
+285
View File
@@ -0,0 +1,285 @@
"""Hollow load frames, replaceable dorsal shells and compliant contact pads."""
from functools import lru_cache
import simplecadapi as scad
from parameters import FINGERS, SIZES, FINGER_WALL, RUNNING_CLEARANCE
from parts.common import (
build_named,
loft_envelope,
cylinder_axis,
axis_frame,
frame,
rigid_shape,
)
from kinematics import AXES, transform
from scipy.spatial.transform import Rotation
def next_axis(spec, k):
return (
Rotation.from_euler("xyz", spec.pre_rotations[k + 1], degrees=True).as_matrix()
@ AXES[spec.axes[k + 1]]
)
def dimensions(spec, k):
current = SIZES[spec.sizes[k]]
nxt = SIZES[spec.sizes[k + 1]] if k < 3 else None
# Side walls accommodate the actuator's axial width plus a removable fork.
rx = max(
current.width / 2 + 2.0,
current.diameter / 2 + 0.5 if spec.axes[k] != "x" else 0,
)
rz = max(
current.diameter / 2 + 1.4, current.width / 2 + 2 if spec.axes[k] == "z" else 0
)
if nxt:
end_rx = max(
nxt.width / 2 + 2, nxt.diameter / 2 + 0.5 if spec.axes[k + 1] != "x" else 0
)
end_rz = max(
nxt.diameter / 2 + 1.4, nxt.width / 2 + 2 if spec.axes[k + 1] == "z" else 0
)
else:
end_rx, end_rz = 8.0, 8.8
return current, nxt, rx, rz, end_rx, end_rz
def blank(spec, k, offset=0):
_, _, rx, rz, ex, ez = dimensions(spec, k)
length = spec.lengths[k]
if k == 3:
# Keep the fork wide until it has passed the incoming actuator. An
# immediate taper strands two ears when the bearing package is widened.
shoulder = min(length * 0.55, SIZES[spec.sizes[k]].diameter / 2 + 2.0)
return loft_envelope(
"distal_phalange",
[
(0, rx + offset, rz + offset),
(shoulder, rx + offset, rz + offset),
(length, ex + offset, ez + offset),
],
)
return loft_envelope(
"phalange",
[
(0, rx + offset, rz + offset),
(length * 0.45, (rx + ex) / 2 + offset, (rz + ez) / 2 + offset),
(length, ex + offset, ez + offset),
],
)
def thumb_neighbor_relief(body, spec, k):
if spec.name != "thumb" or k == 3:
return body
pose = transform(
(0, spec.lengths[k], 0),
Rotation.from_euler("xyz", spec.pre_rotations[k + 1], degrees=True).as_matrix(),
)
cutter = rigid_shape(blank(spec, k + 1, 1.75), pose)
return scad.cut_rsolid(body, cutter, on_split="error")
def tactile_y(spec):
s = SIZES[spec.sizes[3]]
length = spec.lengths[3]
return (min(length * 0.38, s.diameter / 2 + 1.2) + length - 1.2) / 2
def tactile_cavity(spec):
return scad.make_box_rsolid(
width=8.6, height=10.6, depth=3.0, bottom_face_center=(0, tactile_y(spec), 5.3)
)
def frame_shape(name, k):
spec = next(f for f in FINGERS if f.name == name)
s, nxt, rx, rz, ex, ez = dimensions(spec, k)
length = spec.lengths[k]
# ---- feature: load-frame-envelope (build, profile=sketch) ----
body = blank(spec, k)
# ---- feature: electronics-and-wire-cavity (subtract, profile=sketch) ----
inner = loft_envelope(
"cavity",
[
(2.0, rx - FINGER_WALL, rz - FINGER_WALL),
(length / 2, (rx + ex) / 2 - FINGER_WALL, (rz + ez) / 2 - FINGER_WALL),
(length - 2, ex - FINGER_WALL, ez - FINGER_WALL),
],
)
body = scad.cut_rsolid(body, inner, on_split="error", skip_non_intersecting=False)
# ---- feature: open-fork-mouth (subtract, profile=geometry) ----
mouth = scad.make_box_rsolid(
width=100, height=4.4, depth=100, bottom_face_center=(0, 0, -50)
)
body = scad.cut_rsolid(body, mouth, on_split="error")
# ---- feature: incoming-joint-clearance (subtract, profile=geometry) ----
body = scad.cut_rsolid(
body,
cylinder_axis(s.diameter / 2 + RUNNING_CLEARANCE, s.width + 0.6, spec.axes[k]),
on_split="error",
skip_non_intersecting=False,
)
if nxt:
# ---- feature: outgoing-joint-seat (subtract, profile=geometry) ----
vec = next_axis(spec, k)
body = scad.cut_rsolid(
body,
cylinder_axis(
nxt.diameter / 2 + 0.15, nxt.width + 0.1, vec, (0, length, 0)
),
on_split="error",
skip_non_intersecting=False,
)
# ---- feature: next-output-boss-relief (subtract, profile=geometry) ----
boss_center = vec * (nxt.width / 2 + 1.0) + [0, length, 0]
body = scad.cut_rsolid(
body, cylinder_axis(5.9, 3.2, vec, boss_center), on_split="error"
)
# The actuator output flange is attached from its positive-axis side.
# ---- feature: output-attachment-boss (add, profile=geometry) ----
axis = spec.axes[k]
vec = {"x": (1, 0, 0), "y": (0, 1, 0), "z": (0, 0, 1)}[axis]
center = tuple(v * (s.width / 2 + 0.8) for v in vec)
boss = cylinder_axis(5.5, 1.6, axis, center)
# The longitudinal thumb module needs a radial bridge into its moving frame.
if axis == "y":
boss = scad.union_rsolid(
boss,
scad.make_box_rsolid(
width=2 * rx,
height=2.0,
depth=2.0,
bottom_face_center=(0, s.width / 2 + 1, -1),
),
)
body = scad.union_rsolid(body, boss)
# ---- feature: output-fastener-holes (subtract, profile=geometry) ----
cutters = []
import math
for j in range(3):
a = math.radians(j * 120)
u, v = 4.3 * math.cos(a), 4.3 * math.sin(a)
point = {
"x": (s.width / 2 + 0.8, u, v),
"y": (v, s.width / 2 + 0.8, u),
"z": (u, v, s.width / 2 + 0.8),
}[axis]
cutters.append(cylinder_axis(0.65, 3.5, axis, point))
body = scad.cut_rsolid(body, *cutters, on_split="error")
# ---- feature: soft-pad-seat (subtract, profile=sketch) ----
body = scad.cut_rsolid(body, pad_shape(name, k), on_split="error")
if k == 3:
# ---- feature: fingertip-sensor-pocket (subtract, profile=geometry) ----
body = scad.cut_rsolid(body, tactile_cavity(spec), on_split="error")
# ---- feature: oblique-thumb-neighbor-clearance (subtract, profile=sketch) ----
return thumb_neighbor_relief(body, spec, k)
def cover_shape(name, k):
spec = next(f for f in FINGERS if f.name == name)
length = spec.lengths[k]
s, nxt, rx, rz, ex, ez = dimensions(spec, k)
# ---- feature: dorsal-cover-envelope (build, profile=sketch) ----
body = blank(spec, k, 1.45)
# ---- feature: cover-inner-clearance (subtract, profile=sketch) ----
body = scad.cut_rsolid(
body, blank(spec, k, 0.25), on_split="error", skip_non_intersecting=False
)
# ---- feature: dorsal-half (subtract, profile=geometry) ----
body = scad.cut_rsolid(
body,
scad.make_box_rsolid(
width=80,
height=length + 30,
depth=60,
bottom_face_center=(0, length / 2, -0.2),
),
on_split="error",
)
# ---- feature: articulation-end-clearances (subtract, profile=geometry) ----
tools = [cylinder_axis(s.diameter / 2 + 1.0, s.width + 10, spec.axes[k])]
if nxt:
tools.append(
cylinder_axis(
nxt.diameter / 2 + 1.0,
nxt.width + 10,
next_axis(spec, k),
(0, length, 0),
)
)
body = scad.cut_rsolid(body, *tools, on_split="error")
# ---- feature: oblique-thumb-cover-clearance (subtract, profile=sketch) ----
return thumb_neighbor_relief(body, spec, k)
def pad_shape(name, k):
spec = next(f for f in FINGERS if f.name == name)
length = spec.lengths[k]
s, nxt, rx, rz, ex, ez = dimensions(spec, k)
start = min(length * 0.38, s.diameter / 2 + 1.2)
end = length - (nxt.diameter / 2 + 1.2 if nxt else 1.2)
if end - start < 3:
start = length * 0.40
end = length * 0.65
# ---- feature: rounded-contact-pad (build, profile=sketch) ----
center = (start + end) / 2
width = (rx + ex) * 0.36
height = (rz + ez) / 2 - 0.8
body = loft_envelope(
"contact_pad",
[
(start, width * 0.45, 1.0, height),
(center, width, 2.2, height),
(end, width * 0.45, 1.0, height),
],
)
if k == 3:
# ---- feature: tactile-insert-recess (subtract, profile=geometry) ----
body = scad.cut_rsolid(body, tactile_cavity(spec), on_split="error")
return body
@lru_cache(maxsize=20)
def link_parts(name, k):
spec = next(f for f in FINGERS if f.name == name)
connectors = [("origin", frame()), ("joint", axis_frame(spec.axes[k]))]
if k < 3:
from assembly_support import axis_matrix
m = transform(
(0, spec.lengths[k], 0),
Rotation.from_euler(
"xyz", spec.pre_rotations[k + 1], degrees=True
).as_matrix(),
) @ axis_matrix(spec.axes[k + 1])
connectors.append(("next_joint", frame(m)))
result = {
"frame": build_named(
f"{name}_frame_{k}",
frame_shape,
"aluminium",
tuple(connectors),
name=name,
k=k,
),
"cover": build_named(
f"{name}_cover_{k}", cover_shape, "polymer", name=name, k=k
),
"pad": build_named(f"{name}_pad_{k}", pad_shape, "silicone", name=name, k=k),
}
if k == 3:
result["touch"] = build_named(
f"{name}_tactile_envelope_3",
lambda: scad.make_box_rsolid(
width=8.0,
height=10.0,
depth=1.0,
bottom_face_center=(0, tactile_y(spec), 6.9),
),
"sensor_envelope",
label="指尖触觉插片空间:器件与标定待验证",
)
return result
+118
View File
@@ -0,0 +1,118 @@
[
{
"finger": "index",
"thumb_deg": [
144.62481049952868,
-64.84780527649247,
66.76329962159488,
-57.28502583078631
],
"finger_deg": [
79.37010899198333,
24.499999999953296,
0.5000000000074702,
12.785511470923884
],
"gap_error_mm": 0.0019929035674505825,
"normal_dot": -0.9999999769086192,
"thumb_contact_mm": [
10.342912193364416,
81.04451611679946,
99.08125277611391
],
"finger_contact_mm": [
10.34256144587257,
81.04514603224924,
99.08311069089997
],
"max_capsule_penetration_mm": 0.0,
"scope": "Pad position/normal IK with capsule penalties; not exact CAD collision qualification"
},
{
"finger": "middle",
"thumb_deg": [
149.08408123266491,
-54.29279696966193,
49.95865427153206,
-70.44080949999999
],
"finger_deg": [
69.65760142996191,
-4.232260320492962,
42.66314923587529,
0.5000000000000001
],
"gap_error_mm": 0.0026102334112360686,
"normal_dot": -0.9999998148089602,
"thumb_contact_mm": [
19.676923672752196,
78.19570597601468,
102.71322233095833
],
"finger_contact_mm": [
19.679044792406014,
78.1971532803845,
102.71369081781665
],
"max_capsule_penetration_mm": 0.0,
"scope": "Pad position/normal IK with capsule penalties; not exact CAD collision qualification"
},
{
"finger": "ring",
"thumb_deg": [
169.5,
-49.57598365022333,
25.612698417310305,
-39.23645153700786
],
"finger_deg": [
57.43933064494848,
-24.273434722627538,
35.20257157447372,
0.5000000000000001
],
"gap_error_mm": 0.0012585787640159059,
"normal_dot": -0.9999999742214666,
"thumb_contact_mm": [
13.141965949508329,
96.57123566914845,
92.26592877988979
],
"finger_contact_mm": [
13.14160986785992,
96.57175973059084,
92.26701624757644
],
"max_capsule_penetration_mm": 0.0,
"scope": "Pad position/normal IK with capsule penalties; not exact CAD collision qualification"
},
{
"finger": "little",
"thumb_deg": [
169.5,
-75.79705661817333,
38.990519553631266,
-30.876685866208575
],
"finger_deg": [
64.3757164632893,
-24.499999999999996,
0.5000000000000001,
15.651028830862995
],
"gap_error_mm": 0.0016358518863465081,
"normal_dot": -0.999999997102599,
"thumb_contact_mm": [
-17.525846847404853,
93.73482201785772,
85.71727724192135
],
"finger_contact_mm": [
-17.52651694620009,
93.73550030697334,
85.71860649091019
],
"max_capsule_penetration_mm": 0.0,
"scope": "Pad position/normal IK with capsule penalties; not exact CAD collision qualification"
}
]
+5
View File
@@ -0,0 +1,5 @@
simplecadapi[verify,editor]==2.3.0
scipy==1.18.1
mujoco==4.0.1
numpy==2.5.5
pytest==9.2.0