Files
make-cad/examples/integrated_bldc_joint_actuator/export_mjcf.py
T
NiJingzhe 237702c7a8 feat(examples): unnumbered self-contained layout with per-example out/
- rename every numbered example (04/08/10/11/7ep scripts, 12/16/20/21 dirs)
  to clean names; each example now writes artifacts to its own out/ folder
- examples/README rewritten as a category index (part / assembly / reverse
  engineering / FEM); stale run_examples.py reference removed
- flange_plate gains the quickstart FTC part (model.py + external verify.py
  + README); u_link/ap242/flange demo builders read the new asset paths
- ap242_gmsh_volume_mesh gains render_views.py for the demo gallery

fix(artifacts): round-trip-stable geometry fingerprint bounds

AddOptimal bounds wobble by one shape-tolerance quantum between a fresh
shape and the same shape read back from BRep bytes, so definitions sitting
on a quantization cell edge failed every package re-validation. Quantize
bounds at a fixed 1e-4 mm grid, far coarser than the wobble; full suite
green (1503 passed). Stored packages captured before this change must be
recaptured.
2026-09-07 05:46:15 +08:00

44 lines
1.4 KiB
Python

"""Export the integrated BLDC actuator product package as MuJoCo MJCF."""
from __future__ import annotations
from pathlib import Path
import simplecadapi as scad
OUT_DIR = Path(__file__).resolve().parent / "out"
PACKAGE_PATH = OUT_DIR / "integrated_bldc_joint_actuator.scadpkg"
MJCF_PATH = OUT_DIR / "integrated_bldc_joint_actuator.xml"
MAPPING_PATH = OUT_DIR / "integrated_bldc_joint_actuator.mapping.json"
MESH_DIR = OUT_DIR / "integrated_bldc_joint_actuator_meshes"
DEFAULT_DENSITY_KG_M3 = 7850.0
def main() -> None:
"""Compile the captured .scadpkg into an MJCF model with mapping."""
if not PACKAGE_PATH.is_file():
raise FileNotFoundError(f"Run main.py first: {PACKAGE_PATH}")
report = scad.exporter.export_product_package_to_mjcf(
data=PACKAGE_PATH,
output_path=MJCF_PATH,
mapping_path=MAPPING_PATH,
mesh_directory=MESH_DIR,
linear_deflection=0.15,
default_density_kg_m3=DEFAULT_DENSITY_KG_M3,
)
print("mjcf", report.output_path)
print("mjcf_mapping", report.mapping_path)
print("mjcf_meshes", report.mesh_directory)
print("mjcf_bodies", report.body_count)
print("mjcf_joints", report.joint_count)
print("mjcf_equalities", report.equality_count)
print("mjcf_sites", report.site_count)
print("mjcf_mesh_count", report.mesh_count)
print("mjcf_default_density_parts", report.default_density_count)
if __name__ == "__main__":
main()