4242INCLUDE_ROTATION = True
4343ROBOT_IP = "192.168.101.1"
4444ROBOT_INSTANCE = RobotInstance .HARDWARE
45- DEBUG = True
45+ DEBUG = False
46+ STORAGE_PATH = "teleop_data"
47+ # set camera dict to none disable cameras
48+ CAMERA_DICT = {
49+ "wrist" : "244222071045" ,
50+ # "wrist": "218622278131", # new realsense
51+ "bird_eye" : "243522070364" ,
52+ "side" : "243522070385" ,
53+ }
54+ PRODUCE_GIF = True
55+
4656
4757
4858class Button (IntFlag ):
@@ -210,20 +220,20 @@ def environment_step_loop(self):
210220 rate_limiter (0.001 )
211221
212222
213- def input_loop (env_rel , action_server : UDPViveActionServer , camera_set : RealSenseCameraSet ):
223+ def input_loop (env_rel , action_server : UDPViveActionServer , camera_set : RealSenseCameraSet | None ):
214224 while True :
215225 i = input ("> " )
216226 match i :
217227 case "help" :
218228 print ("You can use `quit` to stop the program, `episode` to start a new episode" )
219229 case "quit" :
220- # camera_set.stop()
221230 sys .exit (0 )
222231 case "episode" :
223- # camera_set.clear_buffer()
224232 # record videos
225- video_path = env_rel .path / "videos"
226- video_path .mkdir (parents = True , exist_ok = True )
233+ if camera_set is not None :
234+ video_path = env_rel .path / "videos"
235+ video_path .mkdir (parents = True , exist_ok = True )
236+ camera_set .record_video (env_rel .path / "videos" , env_rel .episode_count )
227237 print (f'{ env_rel .episode_count = } ' )
228238
229239 thread = threading .Thread (target = action_server .environment_step_loop )
@@ -246,14 +256,7 @@ def main():
246256 with resource_manger :
247257
248258 if ROBOT_INSTANCE == RobotInstance .HARDWARE :
249- camera_dict = {
250- "wrist" : "244222071045" ,
251- # "wrist": "218622278131", # new realsense
252- "bird_eye" : "243522070364" ,
253- "side" : "243522070385" ,
254- }
255- camera_set = default_realsense (camera_dict )
256- camera_set = None
259+ camera_set = default_realsense (CAMERA_DICT )
257260 env_rel = fr3_hw_env (
258261 ip = ROBOT_IP ,
259262 camera_set = camera_set ,
@@ -264,7 +267,6 @@ def main():
264267 gripper_cfg = default_fr3_hw_gripper_cfg (),
265268 max_relative_movement = (0.01 , np .deg2rad (5 )),
266269 # max_relative_movement=(0.5, np.deg2rad(90)),
267- # TODO: max should be always according to the last step
268270 # max_relative_movement=np.deg2rad(20),
269271 relative_to = RelativeTo .CONFIGURED_ORIGIN ,
270272 async_control = True ,
@@ -284,7 +286,7 @@ def main():
284286 env_rel .get_wrapper_attr ("sim" ).open_gui ()
285287
286288 if not DEBUG :
287- env_rel = StorageWrapper (env_rel , path = "/home/juelg/code/frankcsy/record_real_christmas" , camera_set = camera_set )
289+ env_rel = StorageWrapper (env_rel , path = STORAGE_PATH , camera_set = camera_set , gif = PRODUCE_GIF )
288290 # ip_secondary = "192.168.102.1"
289291 # with Desk.fci(ip_secondary, user, pw):
290292 # f = rcsss.hw.FR3(ip_secondary)
@@ -300,8 +302,7 @@ def main():
300302 with env_rel :
301303 with UDPViveActionServer (VIVE_HOST , VIVE_PORT , env_rel ) as action_server :
302304 if not DEBUG :
303- input_loop (env_rel , action_server , None )
304-
305+ input_loop (env_rel , action_server , camera_set )
305306 else :
306307 action_server .environment_step_loop ()
307308
0 commit comments