tars-mini / sim /render_fall_sole90.py
tuanhqv123's picture
TARS mini: CAD, MuJoCo sim, trained policies and 5-action demo
4b7148d verified
Raw History Blame Contribute Delete
1.29 kB
"""GIF segments: get up after a fall (90 mm soles), from lying on its back (screen up) and from lying face-down (screen down).
Same motion as the verified fall_up / fall_down trials (24/24 each): legs over the top to make the V, then close the V."""
import math
from cad_verify_sole90 import CAD, M, TarsSim, s_curve
from render2 import Recorder
def quat_x(deg):
a = math.radians(deg) / 2
return [math.cos(a), math.sin(a), 0, 0]
for q, name, label in ((-90, "seg_fall_back", "fell on its back"), (90, "seg_fall_face", "fell face-down")): # -90 -> screen up (checked)
kw = dict(CAD); kw["pad_D"] = 0.090
p = M.Params(mu=0.8, **kw); s = TarsSim(p)
s.d.qpos[3:7] = quat_x(q); s.d.qpos[2] = p.D / 2 + 0.002
s.set_angles(sL=360, sR=360); s.d.qpos[s.qa["sL"]] = s.d.qpos[s.qa["sR"]] = math.radians(360)
rec = Recorder(s, [("3/4 view", 135, -18, 0.95), ("side view", 90, -6, 0.95)])
rec.caption = f"5. Get up after a fall ({label})"; s.run(1.0)
rec.caption = f"5. Get up ({label}): legs over the top to make the V"; s_curve(s, dict(sL=170, sR=170), 5.0)
rec.caption = f"5. Get up ({label}): close the V"; s_curve(s, dict(sL=0, sR=0), 6.0); s.run(1.0)
rec.save(f"../results/{name}.gif", speedup=3)
print(name, "final tilt", round(s.tilt_deg(), 1))