From f54127a33494bba2084d30036eb8fc606031c1ae Mon Sep 17 00:00:00 2001 From: "oceanpdoshi@g.ucla.edu" <oceanpdoshi@.ucla.edu> Date: Thu, 6 Jun 2019 16:48:56 -0700 Subject: [PATCH] find_measurement() function now finds nearest time index even when no measurement available at a particular time --- .../simulated_dataset_manager.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/CoLo-AT/dataset_manager/simulated_dataset_manager.py b/CoLo-AT/dataset_manager/simulated_dataset_manager.py index ec65933..f31dccb 100644 --- a/CoLo-AT/dataset_manager/simulated_dataset_manager.py +++ b/CoLo-AT/dataset_manager/simulated_dataset_manager.py @@ -193,12 +193,11 @@ class SimulatedDataSetManager: available_measurements.append(measurement['measurment_range']) measurement_indices.append(data_idx) - # Select the "best"=shortest distance measurement - if (len(available_measurements) != 0): - least_index = np.argmin(available_measurements) - idx = measurement_indices[least_index] - return self.measurement_data[robot_idx][idx] - - - # No measurement data available (ex: no landmarks in vision at given time) - return {'time': current_time, 'subject_ID': None, 'measurment_range': None,'bearing': None} \ No newline at end of file + # No exact matches at that time + if (len(available_measurements)== 0): + time_idx = find_nearest_time_idx(self.time_arr['measurement'][robot_idx], current_time) + return self.measurement_data[robot_idx][time_idx] + + least_index = np.argmin(available_measurements) + idx = measurement_indices[least_index] + return self.measurement_data[robot_idx][idx] \ No newline at end of file -- GitLab