DECISION: Bound compliant-control requests by posture torque budgets
DECISION: Expose a finite-input SI-unit impedance scaffold and limit normal-force requests through the pad Jacobian and provisional output torque budgets. WHY: The owner prioritized precision and compliance, but no motor, current calibration, tactile feedback or thermal limit is yet qualified. As recorded in design-docs/lh20-tendonless-prototype.md, software must preserve that distinction. The extended middle finger requires approximately 0.92 N m for the 8 N target, above the A joint's provisional 0.90 N m peak target; this failure remains visible. ALTERNATIVE CONSIDERED AND REJECTED: Treating the 3 N / 8 N design goals as achieved forces, or using one force cap for every posture, would hide load-dependent limitations. No real transport or hardware FOC driver is implied. WHAT CHANGES: Add health-gated torque requests, finite input checks, joint target limits, torque saturation, pad-normal feedforward and a 20 percent torque-budget margin. Document the assumed communications and wiring architecture, and tests that follow this decision. Checked: All four control tests pass, covering invalid/fault input handling, output limits, the extended-middle-finger force cap and low-force transparency. These tests do not establish hardware stability, thermal performance or calibrated contact force. Co-Authored-By: Codex <noreply@openai.com>
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
# 控制、传感与内部布线方案
|
||||
|
||||
这是数字原型的接口设计,尚未完成 PCB、固件、ROS 2 驱动或实机调参。控制示例在 `control.py`,使用 SI 单位,输出为关节输出轴 N·m;不能直接当成电机电流命令。
|
||||
|
||||
## 精细操作优先
|
||||
|
||||
控制链为:任务/遥操作 → 20 轴目标位置、速度、刚度、阻尼与前馈力矩 → 关节阻抗 → 电机电流环。输出力矩按 `τ = τff + Kp(qdes−q) + Kd(vdes−v)` 计算;位置和力矩分别限幅。输出角传感用于观察减速器之后的角度,电机侧换相传感另外配置。电流估算力矩需要真实 Kt、传动损失与温度标定,不能直接当作可靠指尖力。
|
||||
|
||||
先以 2 N 连续、6 N 短时的法向接触命令预算调试;3 N / 8 N 保留为需要继续实现的设计目标。`normal_contact_command` 通过接触点雅可比与姿态动态降低力上限,并保留 20% 软件力矩预算。该预算不包含重力、运动惯量或热降额,不能代替硬件限流。没有传感闭环的仿真位置重合不算完成柔顺抓取。
|
||||
|
||||
## 通信预算与电子空间
|
||||
|
||||
规划五条独立的手指通信支路,每条管理四个关节。若每支路每周期各有一帧 64 B 命令和反馈,在 1 kHz 时,原始有效载荷为 1.024 Mbit/s/支路,五支路合计 5.12 Mbit/s。这个数字还没包含仲裁、位填充、CRC、重发和同步开销,因此不能把“单条 5 Mbit/s 总线”直接写成已实现的 20 轴 1 kHz 系统。
|
||||
|
||||
初始架构采用掌部供电/通信板、分布式关节驱动、独立的输出读头和电机换相传感。CAD 的绿色板只是空间预留,MOSFET、栅极驱动、MCU、连接器、保护和散热尚未布局。12 V 是候选母线电压;供电电流和电容必须在电机确认后重新计算。FOC 内环与 1 kHz 外环都属于开发目标,尚没有在硬件上测得频率或延迟。
|
||||
|
||||
当前编码器几何包含环形板、离轴读头和输出磁环包络,已留出轴向空间。多极磁环如何获得无歧义的绝对角、极对数、磁场强度、读头型号与空气间隙必须联合选型。该包络不能视作已经实现绝对角编码器。
|
||||
|
||||
五个指尖各留有 8×10×1 mm 触觉插片空间,骨架和硅胶垫背面设对应凹槽。该体积没有指定触觉单元数量、测力范围或分辨率;压阻/电容/光学方案需结合厚度、线缆与标定选型。当前不宣称已经具有全手电子皮肤。
|
||||
|
||||
## 内部电线与维护
|
||||
|
||||
无腱绳是机械传动要求,关节仍需要内部供电与信号线。各电机壳的背侧出口接入指节内部腔体;跨转轴处采用独立柔性回环,不穿过太阳轮小轴孔,也不靠电线承受拉力。电线/FPC 的材料、线径、弯曲半径、余量和完整运动包络尚未定稿,当前 CAD 不包含经过寿命验证的线缆实体。
|
||||
|
||||
五指可单独更换;外盖、指腹、掌部电路区域分别维护。编码器校准、驱动参数和手指序列号应随模块保存。故障策略至少包含通信超时、过流、过温、编码器异常、位置越界和接触力异常。`healthy=False` 的示例返回零力矩;真实硬件还需要独立看门狗与明确的失电行为。
|
||||
|
||||
## 仿真的边界
|
||||
|
||||
`out/lh20.xml` 和 `out/lh20.urdf` 具有 20 个转动自由度,外观网格来自同一份 CAD。内部齿轮在降阶模型中按所属刚体显示;没有把每个齿轮当成额外主动关节。碰撞采用胶囊体/盒体近似,惯量、摩擦和电机侧惯量为明确标注的初值。加载成功、坐标一致或 200 步数值稳定均不代表真实抓取、反驱性能或控制稳定性通过。
|
||||
@@ -0,0 +1,80 @@
|
||||
"""SI-unit impedance-command scaffold; no transport or hardware driver.
|
||||
|
||||
Caps are provisional design budgets. This software does not certify hardware
|
||||
torque, thermal limits, stability, current calibration, or human-safe contact.
|
||||
"""
|
||||
|
||||
import numpy as np
|
||||
from parameters import FINGERS, SIZES
|
||||
from kinematics import jacobian, pad_contact
|
||||
|
||||
|
||||
def vector20(value, name):
|
||||
a = np.asarray(value, dtype=float)
|
||||
if a.shape != (20,) or not np.isfinite(a).all():
|
||||
raise ValueError(f"{name} must contain 20 finite SI values")
|
||||
return a
|
||||
|
||||
|
||||
def impedance_torque(
|
||||
q, qd, q_target, qd_target, kp, kd, tau_ff, *, healthy=True, peak=False
|
||||
):
|
||||
"""Output-shaft Nm; angles radians. A failed health gate emits zero torque."""
|
||||
arrays = [
|
||||
vector20(v, n)
|
||||
for v, n in zip(
|
||||
(q, qd, q_target, qd_target, kp, kd, tau_ff),
|
||||
("q", "qd", "q_target", "qd_target", "kp", "kd", "tau_ff"),
|
||||
)
|
||||
]
|
||||
q, qd, qt, vt, kp, kd, ff = arrays
|
||||
if np.any(kp < 0) or np.any(kd < 0):
|
||||
raise ValueError("impedance gains must be nonnegative")
|
||||
if not healthy:
|
||||
return np.zeros(20)
|
||||
limits = np.deg2rad([lim for f in FINGERS for lim in f.limits])
|
||||
qt = np.clip(qt, limits[:, 0], limits[:, 1])
|
||||
cap = np.array(
|
||||
[
|
||||
SIZES[s].peak_target if peak else SIZES[s].continuous_target
|
||||
for f in FINGERS
|
||||
for s in f.sizes
|
||||
]
|
||||
)
|
||||
return np.clip(ff + kp * (qt - q) + kd * (vt - qd), -cap, cap)
|
||||
|
||||
|
||||
def normal_contact_command(spec, q, requested_force_N, *, peak=False, margin=0.8):
|
||||
"""Static pad-normal feedforward with a posture-dependent torque-budget cap.
|
||||
|
||||
Does not include gravity or dynamics. Must be combined with calibrated
|
||||
tactile feedback and measured actuator limits before use on hardware.
|
||||
"""
|
||||
if not np.isfinite(requested_force_N) or requested_force_N < 0:
|
||||
raise ValueError("force must be finite and nonnegative")
|
||||
if not 0 < margin <= 1:
|
||||
raise ValueError("margin must be in (0, 1]")
|
||||
q = np.asarray(q, dtype=float)
|
||||
if q.shape != (4,) or not np.isfinite(q).all():
|
||||
raise ValueError("q must contain four finite radians")
|
||||
_, normal = pad_contact(spec, q)
|
||||
unit = jacobian(spec, q).T @ normal
|
||||
cap = (
|
||||
np.array(
|
||||
[
|
||||
SIZES[s].peak_target if peak else SIZES[s].continuous_target
|
||||
for s in spec.sizes
|
||||
]
|
||||
)
|
||||
* margin
|
||||
)
|
||||
active = np.abs(unit) > 1e-9
|
||||
max_force = (
|
||||
float(np.min(cap[active] / np.abs(unit[active]))) if active.any() else 0.0
|
||||
)
|
||||
applied = min(float(requested_force_N), max_force)
|
||||
return {
|
||||
"force_N": applied,
|
||||
"force_limit_N": max_force,
|
||||
"joint_torque_Nm": unit * applied,
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
from pathlib import Path
|
||||
import sys
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
|
||||
import numpy as np
|
||||
import pytest
|
||||
from control import impedance_torque, normal_contact_command
|
||||
from parameters import FINGERS, SIZES
|
||||
|
||||
|
||||
def test_fault_gate_and_finite_validation():
|
||||
z = np.zeros(20)
|
||||
o = np.ones(20)
|
||||
assert np.all(impedance_torque(z, z, o, z, o, o, o, healthy=False) == 0)
|
||||
broken = z.copy()
|
||||
broken[3] = np.nan
|
||||
with pytest.raises(ValueError):
|
||||
impedance_torque(broken, z, o, z, o, o, o)
|
||||
|
||||
|
||||
def test_impedance_respects_output_budget_under_large_error():
|
||||
z = np.zeros(20)
|
||||
o = np.ones(20)
|
||||
result = impedance_torque(z, z, 20 * o, z, 10 * o, o, 10 * o)
|
||||
cap = np.array([SIZES[s].continuous_target for f in FINGERS for s in f.sizes])
|
||||
assert np.all(np.abs(result) <= cap)
|
||||
|
||||
|
||||
def test_extended_middle_finger_force_is_limited_by_moment_arm():
|
||||
f = FINGERS[1]
|
||||
result = normal_contact_command(f, np.zeros(4), 8, peak=True)
|
||||
# Independent planar distance: the farthest pad lies ~115 mm from MCP.
|
||||
assert 5.5 < result["force_N"] < 7.0
|
||||
cap = np.array([SIZES[s].peak_target for s in f.sizes]) * 0.8
|
||||
assert np.all(np.abs(result["joint_torque_Nm"]) <= cap + 1e-12)
|
||||
|
||||
|
||||
def test_compliant_low_force_is_preserved():
|
||||
result = normal_contact_command(FINGERS[1], np.zeros(4), 1.0)
|
||||
assert result["force_N"] == pytest.approx(1.0)
|
||||
Reference in New Issue
Block a user