093ab883be
Add loaded-standing physics, PPO training, fixed-candidate acceptance, isolated inference, and fail-closed publication. Preserve the original 120-second drift failure and bind the operator-approved exception to the exact candidate and evidence. Include pending Reach training/release infrastructure and archived packages. Leave pre-existing short-worker visualization changes and large generated training artifacts out of this commit.
112 lines
4.8 KiB
Python
112 lines
4.8 KiB
Python
#!/usr/bin/env python3
|
|
"""Build separate floating payload + fixed six-axis sensor boundary + original leg asset."""
|
|
|
|
import argparse
|
|
import json
|
|
import shutil
|
|
from pathlib import Path
|
|
|
|
|
|
def main():
|
|
if not __debug__:
|
|
raise RuntimeError("Asset verification requires assertions enabled")
|
|
from isaaclab.app import AppLauncher
|
|
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
parser.add_argument("--config", type=Path, default=Path("configs/standing/go2_fl_support_v0.json"))
|
|
AppLauncher.add_app_launcher_args(parser)
|
|
args = parser.parse_args()
|
|
from SkillFactory.legs.spec import load_bundle
|
|
from SkillFactory.legs.support import CONTRACT, MOUNT_JOINT, PAYLOAD, load_config, payload_urdf, sha256
|
|
|
|
cfg = load_config(args.config)
|
|
source, output = Path(cfg["source_bundle"]).resolve(), Path(cfg["support_asset"]).resolve()
|
|
bundle = load_bundle(source, require_usd=True)
|
|
if (
|
|
bundle["spec"]["part_id"] != "go2_fl"
|
|
or output.exists()
|
|
or output.is_relative_to(source)
|
|
or source.is_relative_to(output)
|
|
):
|
|
raise ValueError("Require Go2 FL and a new separate output directory")
|
|
output.mkdir(parents=True)
|
|
for name in ["LICENSE", *bundle["resources"]]:
|
|
dest = output / name
|
|
dest.parent.mkdir(parents=True, exist_ok=True)
|
|
shutil.copy2(source / name, dest)
|
|
(output / "loaded_leg.urdf").write_bytes(payload_urdf(source / "leg.urdf", cfg))
|
|
app = AppLauncher(args).app
|
|
code = 0
|
|
try:
|
|
from pxr import PhysxSchema, Usd, UsdPhysics
|
|
|
|
from isaaclab.sim.converters import UrdfConverter, UrdfConverterCfg
|
|
|
|
converter = UrdfConverter(
|
|
UrdfConverterCfg(
|
|
asset_path=str(output / "loaded_leg.urdf"),
|
|
usd_dir=str(output / "usd"),
|
|
fix_base=False,
|
|
merge_fixed_joints=False,
|
|
force_usd_conversion=True,
|
|
joint_drive=UrdfConverterCfg.JointDriveCfg(target_type="none"),
|
|
run_multi_physics_conversion=False,
|
|
)
|
|
)
|
|
stage = Usd.Stage.Open(converter.usd_path)
|
|
prefix = str(stage.GetDefaultPrim().GetPath())
|
|
bodies = {
|
|
p.GetName(): str(p.GetPath()).removeprefix(prefix)
|
|
for p in stage.Traverse()
|
|
if p.HasAPI(UsdPhysics.RigidBodyAPI)
|
|
}
|
|
joints = {
|
|
p.GetName(): str(p.GetPath()).removeprefix(prefix) for p in stage.Traverse() if p.IsA(UsdPhysics.Joint)
|
|
}
|
|
assert PAYLOAD in bodies and bundle["anchor_body"] in bodies and MOUNT_JOINT in joints
|
|
for prim in stage.Traverse():
|
|
if prim.IsA(UsdPhysics.Joint):
|
|
j = UsdPhysics.Joint(prim)
|
|
targets = j.GetBody0Rel().GetTargets() + j.GetBody1Rel().GetTargets()
|
|
assert len(targets) == 2 and all(
|
|
stage.GetPrimAtPath(p).HasAPI(UsdPhysics.RigidBodyAPI) for p in targets
|
|
), "World weld detected"
|
|
joint = UsdPhysics.Joint(stage.GetPrimAtPath(prefix + joints[MOUNT_JOINT]))
|
|
assert joint.GetBody0Rel().GetTargets()[0].name == PAYLOAD
|
|
assert joint.GetBody1Rel().GetTargets()[0].name == bundle["anchor_body"]
|
|
# Nested rigid-body hierarchy: spawn-time activation alone does not reach the foot.
|
|
foot = stage.GetPrimAtPath(prefix + bodies[bundle["foot"]["body"]])
|
|
PhysxSchema.PhysxContactReportAPI.Apply(foot).CreateThresholdAttr(0.0)
|
|
stage.GetRootLayer().Save()
|
|
layers = [Path(layer.realPath).resolve() for layer in stage.GetUsedLayers() if layer.realPath]
|
|
assert all(p.is_relative_to(output) for p in layers)
|
|
report = {
|
|
"contract": CONTRACT,
|
|
"fixed_to_world": False,
|
|
"mount_joint": MOUNT_JOINT,
|
|
"source_manifest_sha256": sha256(source / "manifest.json"),
|
|
"usd_path": str(Path(converter.usd_path).relative_to(output)),
|
|
"body_paths": bodies,
|
|
"joint_paths": joints,
|
|
"missing_source_inertial_links": bundle["missing_inertial_links"],
|
|
**{k: cfg[k] for k in ("payload_mass_kg", "payload_size_m", "payload_com_m", "sensor_carrier_mass_kg")},
|
|
}
|
|
# USD, meshes, source and license, excluding importer's mutable cache/log files.
|
|
files = (
|
|
set(layers)
|
|
| {output / "loaded_leg.urdf", output / "LICENSE"}
|
|
| {output / name for name in bundle["resources"]}
|
|
)
|
|
report["files"] = {str(p.relative_to(output)): sha256(p) for p in sorted(files)}
|
|
(output / "support.json").write_text(json.dumps(report, indent=2) + "\n")
|
|
print(json.dumps(report, indent=2))
|
|
except BaseException:
|
|
code = 1
|
|
raise
|
|
finally:
|
|
app.close(exit_code=code)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|