55
66import numpy as np
77from avstack import calibration
8+ from avstack .config import DATASETS
89from avstack .datastructs import DataContainer , DataContainerDecoder
910from avstack .environment import ObjectStateDecoder
1011from avstack .geometry import GlobalOrigin3D , ReferenceFrame
@@ -61,6 +62,7 @@ def run_dataset_postprocessing(data_dir):
6162_nominal_ignore_types = []
6263
6364
65+ @DATASETS .register_module ()
6466class CarlaScenesManager (BaseSceneManager ):
6567 name = "CARLA"
6668 nominal_whitelist_types = _nominal_whitelist_types
@@ -239,17 +241,21 @@ def get_object_file(
239241 file_post = self .agent_files ["frame" ][frame ]
240242 else :
241243 file_post = self .npc_files ["frame" ][frame ]
242- if sensor :
244+ if not is_global :
243245 file_post = file_post .replace ("npcs" , "objects" )
244246 else :
245247 raise
246248 if is_global :
247249 filepath = os .path .join (self .obj_folder , file_post )
248250 else :
249- assert sensor is not None
250- filepath = os .path .join (
251- self .obj_local_folder , f"{ sensor } -{ agent } " , file_post
252- )
251+ if sensor is None :
252+ filepath = os .path .join (
253+ self .obj_local_folder , f"agent-{ agent } " , file_post
254+ )
255+ else :
256+ filepath = os .path .join (
257+ self .obj_local_folder , f"{ sensor } -{ agent } " , file_post
258+ )
253259 return filepath
254260
255261 def get_sensor_file (self , frame , timestamp , sensor , agent , file_type ):
@@ -278,6 +284,10 @@ def get_agent(self, frame: int, agent: int):
278284 agents = self .get_agents (frame )
279285 return [ag for ag in agents if ag .ID == agent ][0 ]
280286
287+ def _load_agent_set (self , frame : int ) -> set :
288+ # TODO: this is slow...improve
289+ return {ag .ID for ag in self .get_agents (frame )}
290+
281291 def get_sensor_ID (self , sensor : str , agent : int ):
282292 return f"{ sensor } -{ agent } "
283293
@@ -299,7 +309,7 @@ def _load_frames(self, sensor: str, agent: int):
299309 return self .sensor_frames [agent ][sensor ]
300310
301311 def _load_timestamp (self , frame , sensor = None , agent = None , utime = False ):
302- if ( sensor is None ) and ( agent is None ) :
312+ if sensor is None :
303313 return self .timestamps [self .frames == frame ][0 ]
304314 else :
305315 return self .sensor_frame_to_ts [agent ][sensor ][frame ]
@@ -411,6 +421,9 @@ def _load_objects_global(
411421 agent .change_reference (GlobalOrigin3D , inplace = False )
412422 for agent in self .get_agents (frame )
413423 ]
424+ # HACK: alter the ID of the agents to mitigate conflict
425+ for agent in agents_as_objects :
426+ agent .ID += 99999
414427 if ignore_static_agents :
415428 agents_as_objects = [
416429 agent
0 commit comments