@@ -142,7 +142,7 @@ def render_scene(
142142 else PointCloudColorMode .DISTANCE
143143 )
144144
145- concurrent . futures . wait (
145+ futures = (
146146 self ._render_lidar_and_ego (
147147 viewer = viewer ,
148148 first_lidar_tokens = first_lidar_tokens ,
@@ -161,23 +161,23 @@ def render_scene(
161161 )
162162 + [
163163 self ._executor .submit (
164- self ._render_annotation3ds (
165- viewer = viewer ,
166- first_sample_token = scene .first_sample_token ,
167- max_timestamp_us = max_timestamp_us ,
168- future_seconds = future_seconds ,
169- )
164+ self ._render_annotation3ds ,
165+ viewer = viewer ,
166+ first_sample_token = scene .first_sample_token ,
167+ max_timestamp_us = max_timestamp_us ,
168+ future_seconds = future_seconds ,
170169 ),
171170 self ._executor .submit (
172- self ._render_annotation2ds (
173- viewer = viewer ,
174- first_sample_token = scene .first_sample_token ,
175- max_timestamp_us = max_timestamp_us ,
176- )
171+ self ._render_annotation2ds ,
172+ viewer = viewer ,
173+ first_sample_token = scene .first_sample_token ,
174+ max_timestamp_us = max_timestamp_us ,
177175 ),
178176 ]
179177 )
180178
179+ _handle_futures (futures )
180+
181181 def render_instance (
182182 self ,
183183 instance_token : str | Sequence [str ],
@@ -244,7 +244,7 @@ def render_instance(
244244 else PointCloudColorMode .DISTANCE
245245 )
246246
247- concurrent . futures . wait (
247+ futures = (
248248 self ._render_lidar_and_ego (
249249 viewer = viewer ,
250250 first_lidar_tokens = first_lidar_tokens ,
@@ -263,25 +263,25 @@ def render_instance(
263263 )
264264 + [
265265 self ._executor .submit (
266- self ._render_annotation3ds (
267- viewer = viewer ,
268- first_sample_token = first_sample .token ,
269- max_timestamp_us = max_timestamp_us ,
270- future_seconds = future_seconds ,
271- instance_tokens = instance_tokens ,
272- )
266+ self ._render_annotation3ds ,
267+ viewer = viewer ,
268+ first_sample_token = first_sample .token ,
269+ max_timestamp_us = max_timestamp_us ,
270+ future_seconds = future_seconds ,
271+ instance_tokens = instance_tokens ,
273272 ),
274273 self ._executor .submit (
275- self ._render_annotation2ds (
276- viewer = viewer ,
277- first_sample_token = first_sample .token ,
278- max_timestamp_us = max_timestamp_us ,
279- instance_tokens = instance_tokens ,
280- )
274+ self ._render_annotation2ds ,
275+ viewer = viewer ,
276+ first_sample_token = first_sample .token ,
277+ max_timestamp_us = max_timestamp_us ,
278+ instance_tokens = instance_tokens ,
281279 ),
282- ],
280+ ]
283281 )
284282
283+ _handle_futures (futures )
284+
285285 def render_pointcloud (
286286 self ,
287287 * ,
@@ -321,27 +321,19 @@ def render_pointcloud(
321321 max_time_seconds
322322 )
323323
324- pointcloud_color_mode = (
325- PointCloudColorMode .SEGMENTATION
326- if self ._has_lidarseg ()
327- else PointCloudColorMode .DISTANCE
324+ # TODO: support rendering segmentation pointcloud on camera
325+ futures = self ._render_lidar_and_ego (
326+ viewer = viewer ,
327+ first_lidar_tokens = [first_lidar_token ],
328+ max_timestamp_us = max_timestamp_us ,
329+ ) + self ._render_points_on_cameras (
330+ first_point_sample_data_token = first_lidar_token ,
331+ max_timestamp_us = max_timestamp_us ,
332+ min_dist = 1.0 ,
333+ ignore_distortion = ignore_distortion ,
328334 )
329335
330- concurrent .futures .wait (
331- self ._render_lidar_and_ego (
332- viewer = viewer ,
333- first_lidar_tokens = [first_lidar_token ],
334- max_timestamp_us = max_timestamp_us ,
335- color_mode = pointcloud_color_mode ,
336- )
337- + self ._render_points_on_cameras (
338- first_point_sample_data_token = first_lidar_token ,
339- max_timestamp_us = max_timestamp_us ,
340- min_dist = 1.0 ,
341- ignore_distortion = ignore_distortion ,
342- color_mode = pointcloud_color_mode ,
343- ),
344- )
336+ _handle_futures (futures )
345337
346338 def _try_render_map (self , viewer : RerunViewer ) -> None :
347339 lanelet_path = osp .join (self ._t4 .map_dir , "lanelet2_map.osm" )
@@ -751,3 +743,19 @@ def _append_mask(
751743 camera_masks [camera ]["class_ids" ] = [class_id ]
752744 camera_masks [camera ]["uuids" ] = [uuid ]
753745 return camera_masks
746+
747+
748+ def _handle_futures (futures : list [Future ]) -> None :
749+ """Wait for all futures and raise exception if any.
750+
751+ Args:
752+ futures (list[Future]): List of futures.
753+ """
754+ if not futures :
755+ return
756+
757+ concurrent .futures .wait (futures )
758+ for future in futures :
759+ if not future .done ():
760+ continue
761+ future .result ()
0 commit comments