-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathreplayer.py
executable file
·68 lines (56 loc) · 1.93 KB
/
replayer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import sys
import numpy as np
from fairmotion.core.motion import Motion
from fairmotion.ops import conversions, motion, math
from fairmotion.data import bvh
from fairmotion.utils import utils
import argparse
import yaml
from fairmotion.viz.utils import TimeChecker
from fairmotion.viz import glut_viewer
from fairmotion.viz import camera
import render_module as rm
rm.initialize()
import importlib.util
import pybullet as pb
import pybullet_data
import sim_agent
from bullet import bullet_client
from bullet import bullet_render
def arg_parser():
parser = argparse.ArgumentParser()
''' Specification file of the expriment '''
parser.add_argument("--spec", required=True, type=str)
return parser
class Replayer(glut_viewer.Viewer):
def __init__(
self,
config,
title="replayer",
cam=None,
size=(1280, 720)):
super().__init__(title, cam, size)
self.config = config
self.rm = rm
self.tex_id_ground = None
self.pb_client = bullet_client.BulletClient(
connection_mode=pb.DIRECT, options=' --opengl2')
self.pb_client.setAdditionalSearchPath(pybullet_data.getDataPath())
spec = importlib.util.spec_from_file_location(
"bullet_char_info", self.config['bullet_char_info'])
bullet_char_info = importlib.util.module_from_spec(spec)
spec.loader.exec_module(bullet_char_info)
self.bullet_agent = sim_agent.SimAgent(
pybullet_client=self.pb_client,
model_file=self.config['bullet_char_file'],
char_info=bullet_char_info,
ref_scale=1.0,
self_collision=False,
kinematic_only=True,
verbose=False)
if __name__ == "__main__":
args = arg_parser().parse_args()
with open(args.spec) as f:
spec = yaml.load(f, Loader=yaml.FullLoader)
replayer = Replayer(title=spec['name'], config=spec['env'])
replayer.run()