-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathutils.py
28 lines (22 loc) · 833 Bytes
/
utils.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
import numpy as np
from pyrep.const import RenderMode
from pyrep.objects import Dummy, VisionSensor
class RLBenchCinematic(object):
def __init__(self):
cam_placeholder = Dummy('cam_cinematic_placeholder')
self._cam_base = Dummy('cam_cinematic_base')
self._cam = VisionSensor.create([640, 480])
self._cam.set_explicit_handling(True)
self._cam.set_pose(cam_placeholder.get_pose())
self._cam.set_parent(cam_placeholder)
self._cam.set_render_mode(RenderMode.OPENGL3)
self._frames = []
def callback(self):
self._cam.handle_explicitly()
cap = (self._cam.capture_rgb() * 255).astype(np.uint8)
self._frames.append(cap)
def empty(self):
self._frames.clear()
@property
def frames(self):
return list(self._frames)