@@ -57,18 +57,17 @@ def segmentation_to_rgb(seg_im, random_colors=False):
5757 parser .add_argument ("--video-path" , type = str , default = "/tmp/video.mp4" , help = "Path to video file" )
5858 parser .add_argument ("--random-colors" , action = "store_true" , help = "Radnomize segmentation colors" )
5959 parser .add_argument ("--segmentation-level" , type = str , default = "element" , help = "instance, class, or element" )
60+ parser .add_argument ("--env-name" , type = str , default = "TwoArmHandover" , help = "Environment name" )
61+ parser .add_argument ("--camera" , type = str , default = "frontview" , help = "Camera name" )
6062 args = parser .parse_args ()
6163
6264 # Create dict to hold options that will be passed to env creation call
6365 options = {}
6466
6567 # Choose environment and add it to options
66- options ["env_name" ] = "TwoArmHandover"
68+ options ["env_name" ] = args . env_name
6769 options ["robots" ] = ["Panda" , "Panda" ]
6870
69- # Choose camera
70- camera = "frontview"
71-
7271 # Choose segmentation type
7372 segmentation_level = args .segmentation_level # Options are {instance, class, element}
7473
@@ -80,7 +79,7 @@ def segmentation_to_rgb(seg_im, random_colors=False):
8079 ignore_done = True ,
8180 use_camera_obs = True ,
8281 control_freq = 20 ,
83- camera_names = camera ,
82+ camera_names = args . camera ,
8483 camera_segmentations = segmentation_level ,
8584 camera_heights = 512 ,
8685 camera_widths = 512 ,
@@ -98,7 +97,7 @@ def segmentation_to_rgb(seg_im, random_colors=False):
9897 action = 0.5 * np .random .uniform (low , high )
9998 obs , reward , done , _ = env .step (action )
10099
101- video_img = obs [f"{ camera } _segmentation_{ segmentation_level } " ].squeeze (- 1 )[::- 1 ]
100+ video_img = obs [f"{ args . camera } _segmentation_{ segmentation_level } " ].squeeze (- 1 )[::- 1 ]
102101 np .savetxt ("/tmp/seg_{}.txt" .format (i ), video_img , fmt = "%.2f" )
103102 video_img = segmentation_to_rgb (video_img , args .random_colors )
104103 video_writer .append_data (video_img )
0 commit comments