File size: 893 Bytes
4b7148d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
"""Render verification videos: walk_forward and the sleep/stand lifecycle."""
import imageio.v2 as imageio, numpy as np
from model import Params
from sleep_pose import lifecycle, POWER
from run_gaits import evaluate

def save(frames, name, fps=25, step=1):
    imageio.mimsave(f"../results/{name}.gif", frames[::step], duration=1 / fps, loop=0)
    k = np.linspace(0, len(frames) - 1, 8).astype(int)
    sheet = np.vstack([np.hstack([frames[i] for i in k[:4]]), np.hstack([frames[i] for i in k[4:]])])
    imageio.imwrite(f"../results/{name}_sheet.png", sheet[::2, ::2])

p = Params(mu=0.8, **POWER)
r, s = lifecycle(p, 60, record=True, cam=dict(azimuth=0, elevation=-5, distance=0.65))
print(r); save(s.frames, "sleep_standup", step=2)
r, s = evaluate(p, "walk_forward", record=True)
print({k: r[k] for k in ("forward_cm", "max_tilt_deg", "yaw_deg")}); save(s.frames, "walk_forward", step=3)