File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -176,6 +176,10 @@ def __getitem__(self, index):
176176 image_dict = get_mcap_image (
177177 dataset_path , self .camera_names , self .mcap_camera_topics , start_ts
178178 )
179+ if len (image_dict ) != len (self .camera_names ):
180+ raise RuntimeError (
181+ f"Available attachment names are { get_mcap_attachment_names (dataset_path )} but expected: { self .mcap_camera_topics } ."
182+ )
179183 bias = self .action_bias
180184 action_start = max (0 , start_ts - bias )
181185 action = get_mcap_action (
@@ -574,6 +578,19 @@ def get_mcap_image(
574578 return res
575579
576580
581+ def get_mcap_attachment_names (mcap_file_path : str ) -> List [str ]:
582+ """Extract attachment names from a MCAP file."""
583+ file_path = Path (mcap_file_path )
584+ if not file_path .exists ():
585+ raise FileNotFoundError (f"MCAP file { file_path .absolute ()} not found" )
586+ names = []
587+ with file_path .open ("rb" ) as f :
588+ reader = make_reader (f )
589+ for attach in reader .iter_attachments ():
590+ names .append (attach .name )
591+ return names
592+
593+
577594def get_time_index (mcap_file_path : str ) -> List [int ]:
578595 """Extract time index from a MCAP file."""
579596 file_path = Path (mcap_file_path )
You can’t perform that action at this time.
0 commit comments