import json, sys, numpy as np, harness1k as h
D = "/workspace/asimov-guide/1k/data"
DES = json.load(open(f"{D}/design.json")); CDS = json.load(open("/workspace/asimov-guide/costdown/data/sim_results.json"))
sys.path.insert(0, "/workspace/asimov-guide/costdown/sim")
BIG = (1e4, 1e4, 1e4)
def cfg(name):
    d = next(x for x in DES["designs"] if x["name"] == name)
    s = d["height"] / 1.2; mf = d["mass_total"] / 35.55
    if name == "Bob Nano":
        lock = {"waist_yaw_joint", "neck_pitch_joint", "left_shoulder_yaw_joint", "right_shoulder_yaw_joint", "left_wrist_yaw_joint", "right_wrist_yaw_joint"}
        a50, a15 = DES["sts3250"], DES["sts3215"]; L = {}; A = {}
        for j in h.J:
            if j in lock: L[j] = BIG; continue
            leg = any(k in j for k in ("hip", "knee", "ankle"))
            L[j] = (a50["peak"], 0.0, a50["w_nl"]) if leg else (a15["peak"], 0.0, a15["w_nl"]); A[j] = 0.01
    elif name == "Bob Mini":
        lock = {"neck_pitch_joint", "left_shoulder_yaw_joint", "right_shoulder_yaw_joint", "left_wrist_yaw_joint", "right_wrist_yaw_joint"}
        m = DES["m50"]; L = {}; A = {}
        for j in h.J:
            if j in lock: L[j] = BIG; continue
            L[j] = (m["peak"], m["w_pk"], m["w_nl"]); A[j] = m["armature"]
    else:
        lock = set(d["drop"]); L = {}; A = {}
        import run_all_lims as ral
        for j in h.J:
            L[j] = BIG if j in lock else tuple(CDS["diy"]["lims"][j]); A[j] = ral.ARM[j]
    return dict(s=s, mf=mf, L=L, A=A, lock=lock, mass=d["mass_total"])
