1818class StorageWrapper (gym .Wrapper ):
1919 # TODO: this should also record the instruction
2020 FILE = "episode_{}.npz"
21- GIF = "{}_episode_{}_{}.gif"
21+ GIF = "gifs/ {}_episode_{}_{}.gif"
2222 FOLDER = "experiment_{}"
2323 GIF_DURATION_S = 0.5
2424
@@ -40,6 +40,7 @@ def __init__(
4040 self .record_numpy = record_numpy
4141 self .gif = gif
4242 self .camera_set = camera_set
43+ print ("camera_set" , self .camera_set )
4344
4445 # make folders
4546 self .path = Path (path ) / self .FOLDER .format (self .timestamp )
@@ -69,9 +70,11 @@ def flush(self):
6970 if self .record_numpy :
7071 np .savez (self .path / self .FILE .format (self .episode_count ), ** self .data )
7172 if self .camera_set is not None and self .camera_set .recording_ongoing ():
73+ print ("stopping video recording" )
7274 self .camera_set .stop_video ()
7375
7476 if self .gif :
77+ print ("saving gifs" )
7578 # for key in ["side", "wrist", "bird_eye", "openvla_view"]:
7679 for key in ["side" , "right_side" , "bird_eye" , "left_side" , "front" ]:
7780 if f"observation.frames.{ key } .rgb" in self .data :
@@ -84,6 +87,7 @@ def flush(self):
8487 continue
8588 previous_timestamp = self .data ["timestamp" ][idx ]
8689 imgs .append (Image .fromarray (img ))
90+ print (self .path / self .GIF .format (self .timestamp , self .episode_count , key ))
8791 imgs [0 ].save (
8892 self .path / self .GIF .format (self .timestamp , self .episode_count , key ),
8993 save_all = True ,
@@ -100,7 +104,8 @@ def step(self, action: dict) -> tuple[Any, SupportsFloat, bool, bool, dict[str,
100104 obs , reward , terminated , truncated , info = super ().step (action )
101105 # write obs and action into data
102106 act_obs = {"action" : action , "observation" : obs }
103- flattened_act_obs = flatten (copy .deepcopy (act_obs ), reducer = "dot" )
107+ # act_obs = {"action": action}
108+ flattened_act_obs = act_obs #flatten(act_obs, reducer="dot")
104109 # add timestamp
105110 flattened_act_obs ["timestamp" ] = datetime .now ().timestamp ()
106111 self .data ["language_instruction" ] = self .language_instruction
@@ -116,8 +121,10 @@ def reset(self, *, seed: int | None = None, options: dict[str, Any] | None = Non
116121 self .flush ()
117122 self .step_count = 0
118123 re = super ().reset (seed = seed , options = options )
119- if self .camera_set is not None :
120- self .camera_set .record_video (self .path , self .episode_count )
124+ # if self.camera_set is not None:
125+ # print("starting video recording")
126+ # self.camera_set.clear_buffer()
127+ # self.camera_set.record_video(self.path / "videos", self.episode_count)
121128 return re
122129
123130 def close (self ):
0 commit comments