feat: add knowledge-driven joint design studio
This commit is contained in:
@@ -55,6 +55,7 @@ ACTUATOR_HOUSING_STEP = ROOT / "input" / "assets" / "housings" / "actuator_v2_kn
|
||||
CHIP_STEP = ROOT / "input" / "assets" / "chip" / "chip.step"
|
||||
REFERENCE_ASSEMBLY_STEP = ROOT / "input" / "assets" / "references" / "actuator_v2_knee_abd_reference.step"
|
||||
FIXED_PLATFORM_PROFILE = ROOT / "input" / "assets" / "platforms" / "actuator_v2_fixed_platform.json"
|
||||
SPLIT_MOTOR_DIR = ROOT / "input" / "assets" / "motors" / "3500_split"
|
||||
FERGUSON_REDUCER_REQ = ROOT / "input" / "requirements" / "reducers" / "ferguson_wolfrom" / "ferguson_wolfrom_ratio_531p25_spur.json"
|
||||
CASCADE_TEMPLATE = ROOT / "src" / "configurations" / "simple_2k_h_cascade" / "topology.template.json"
|
||||
FERGUSON_TEMPLATE = ROOT / "src" / "configurations" / "ferguson_wolfrom" / "topology.template.json"
|
||||
@@ -224,7 +225,12 @@ def test_joint_requirement_loads() -> None:
|
||||
assert Path(requirement.housing_step) == ACTUATOR_HOUSING_STEP
|
||||
assert requirement.chip_step is None
|
||||
assert Path(requirement.reference_assembly_step or "") == REFERENCE_ASSEMBLY_STEP
|
||||
assert requirement.motor_placement_policy == "external_flush_input_end"
|
||||
assert Path(requirement.motor_reference_assembly_step or "") == SPLIT_MOTOR_DIR / "3500_motor_reference.step"
|
||||
assert Path(requirement.motor_stator_housing_step or "") == SPLIT_MOTOR_DIR / "3500-定子外壳.STEP"
|
||||
assert Path(requirement.motor_rotor_housing_step or "") == SPLIT_MOTOR_DIR / "3500-转子外壳.STEP"
|
||||
assert Path(requirement.motor_output_shaft_step or "") == SPLIT_MOTOR_DIR / "输出轴.STEP"
|
||||
assert Path(requirement.motor_windings_step or "") == SPLIT_MOTOR_DIR / "线圈.STEP"
|
||||
assert requirement.motor_placement_policy == "reference_pose"
|
||||
assert requirement.motor_to_reducer_relation == "motor_output_to_sun_keyed_input"
|
||||
assert requirement.housing_relation == "ring_fixed_to_housing"
|
||||
|
||||
@@ -250,7 +256,7 @@ def test_cascade_joint_requirement_loads_and_ports_resolve() -> None:
|
||||
assert requirement.platform_id == "actuator_v2_fixed_platform"
|
||||
assert requirement.chip_step is None
|
||||
assert Path(requirement.reference_assembly_step or "") == REFERENCE_ASSEMBLY_STEP
|
||||
assert requirement.motor_placement_policy == "external_flush_input_end"
|
||||
assert requirement.motor_placement_policy == "reference_pose"
|
||||
assert instance.boundary.input == "s1_sun"
|
||||
assert instance.boundary.output == "s2_carrier"
|
||||
assert instance.boundary.fixed_members == ["s1_ring", "s2_ring"]
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from src.knowledge_adapter import generate_single_gear_variants
|
||||
|
||||
|
||||
def test_single_gear_variants_are_solved_and_keep_baseline_immutable() -> None:
|
||||
result = generate_single_gear_variants()
|
||||
assert result["enabled"] is True
|
||||
assert result["candidateCount"] == 13
|
||||
assert result["baseline"] == {
|
||||
"z_sun": 20,
|
||||
"z_planet": 55,
|
||||
"z_ring": 130,
|
||||
"planet_count": 3,
|
||||
"module_mm": 0.5,
|
||||
}
|
||||
assert len({candidate["ratio"] for candidate in result["candidates"]}) == 13
|
||||
for candidate in result["candidates"]:
|
||||
parameters = candidate["parameters"]
|
||||
assert parameters["zRing"] == parameters["zSun"] + 2 * parameters["zPlanet"]
|
||||
assert candidate["constraints"]["equalSpacing"] is True
|
||||
assert candidate["constraints"]["planetClearance"] is True
|
||||
assert candidate["constraints"]["kinematicResidual"] < 1e-10
|
||||
assert candidate["speeds"]["ring"] == 0.0
|
||||
assert candidate["cadGenerated"] is False
|
||||
@@ -0,0 +1,21 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
BACKEND_ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
|
||||
def test_detached_knowledge_base_is_consistent() -> None:
|
||||
completed = subprocess.run(
|
||||
[sys.executable, "knowledge/tools/validate_knowledge.py"],
|
||||
cwd=BACKEND_ROOT,
|
||||
check=False,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
assert completed.returncode == 0, completed.stdout + completed.stderr
|
||||
assert "integration_state=not_connected" in completed.stdout
|
||||
assert "stable_kernel_imports=0" in completed.stdout
|
||||
Reference in New Issue
Block a user