@@ -118,29 +118,36 @@ def __populate_numerical_data(self, file_object):
118118
119119 def open (self , source : str ) -> bool :
120120 with h5py .File (source , "r" ) as file :
121- root_variable = file .get (self .root_name )
122121 self .data = self .__populate_numerical_data (file )
123122
124- if "log" in root_variable .keys ():
125- self .text_logging_data ["log" ] = self .__populate_text_logging_data (
126- root_variable ["log" ]
127- )
128-
129- for name in file .keys ():
130- if "description_list" in file [name ].keys ():
131- self .root_name = name
132- break
133-
134- joint_ref = root_variable ["description_list" ]
135- self .joints_name = [
136- "" .join (chr (c [0 ]) for c in file [ref ]) for ref in joint_ref [0 ]
137- ]
138- if "yarp_robot_name" in root_variable .keys ():
139- robot_name_ref = root_variable ["yarp_robot_name" ]
140- try :
141- self .robot_name = "" .join (chr (c [0 ]) for c in robot_name_ref )
142- except :
143- pass
123+ # Find the root variable: try the configured name first, then
124+ # search for any top-level group that contains description_list.
125+ root_variable = file .get (self .root_name )
126+ if root_variable is None :
127+ for name in file .keys ():
128+ item = file [name ]
129+ if isinstance (item , h5py ._hl .group .Group ) and "description_list" in item .keys ():
130+ self .root_name = name
131+ root_variable = item
132+ break
133+
134+ if root_variable is not None :
135+ if "log" in root_variable .keys ():
136+ self .text_logging_data ["log" ] = self .__populate_text_logging_data (
137+ root_variable ["log" ]
138+ )
139+
140+ if "description_list" in root_variable .keys ():
141+ joint_ref = root_variable ["description_list" ]
142+ self .joints_name = [
143+ "" .join (chr (c [0 ]) for c in file [ref ]) for ref in joint_ref [0 ]
144+ ]
145+ if "yarp_robot_name" in root_variable .keys ():
146+ robot_name_ref = root_variable ["yarp_robot_name" ]
147+ try :
148+ self .robot_name = "" .join (chr (c [0 ]) for c in robot_name_ref )
149+ except :
150+ pass
144151 self .index = 0
145152
146153 # Pre-compute relative timestamps for binary search in run()
0 commit comments