123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- """
- @Authors: xieguijin(xieguijin@china-icv.cn), yangzihao(yangzihao@china-icv.cn)
- @Data: 2024/09/20
- @Last Modified: 2024/09/20
- @Summary: Evaluation functions
- """
- class ACCTrigger(object):
- def __init__(self, df_vehState):
- self.df_vehState = df_vehState
- def find_start_end_time(self, change_speed_time_list):
- start_end_time_list = []
-
-
- start_of_sequence = None
- sequence_length = 0
-
- for i in range(1, len(change_speed_time_list)):
-
- if abs(change_speed_time_list[i] - change_speed_time_list[i - 1] - 0.01) < 0.04:
-
- if start_of_sequence is None:
- start_of_sequence = change_speed_time_list[i - 1]
-
- sequence_length += 1
- else:
-
- if start_of_sequence is not None and sequence_length >= 0:
- start_end_time_list.append([start_of_sequence, change_speed_time_list[i - 1]])
-
- start_of_sequence = None
- sequence_length = 0
-
- if start_of_sequence is not None and sequence_length >= 1:
- start_end_time_list.append([start_of_sequence, change_speed_time_list[-1]])
- return start_end_time_list
- def ACC_active_time_statistics(self):
- start_end_time_dict = {}
- ACC_STATUS = "Active"
- ACC_time = self.df_vehState[self.df_vehState['ACC_status'] == ACC_STATUS]['simTime'].tolist()
- ACC_start_end_time_list = self.find_start_end_time(ACC_time)
- start_end_time_dict['ACC_active_time'] = ACC_start_end_time_list
- return start_end_time_dict
- class LKATrigger(object):
- def __init__(self, df_vehState):
- self.df_vehState = df_vehState
- def lane_keep_warning_status(self, left_or_right):
- '''
- :return:
- start_vehstate: 状态机开始的时间,以列表形式存储
- close_vehstate:状态机结束的时间,以列表形式存储
- '''
- groups = (self.df_vehState['LKA_status'] != self.df_vehState['LKA_status'].shift()).cumsum()
- LKA_left_groups = self.df_vehState[self.df_vehState['LKA_status'] == left_or_right].groupby(groups)
-
- result_times = []
-
- for idx, (name, group) in enumerate(LKA_left_groups, start=1):
- result_time = []
-
- sim_times = group['simTime'].tolist()
-
-
-
- if sim_times:
- result_time.append(sim_times[-1])
- result_time.append(sim_times[-1])
- result_times.append(result_time)
- return result_times
- def LKA_active_time_statistics(self):
- warning_status_time_dict = {}
- lka_warning = "Active"
-
-
- LKA_vehstate = self.lane_keep_warning_status(lka_warning)
-
-
- warning_status_time_dict['LKA_active_time'] = LKA_vehstate
-
-
- return warning_status_time_dict
- class ICATrigger():
- def __init__(self, df_vehState):
- self.df_vehState = df_vehState
- def ICA_active_time_statistics(self):
- ICA_start_end_time_dict = {}
-
- ICA_CONSTANT_SPEED = "LLC_Follow_Line"
- ICA_FOLLOW_CAR = "LLC_Follow_Vehicle"
- ICA_LONGITUDINAL = "Only_Longitudinal_Control"
- ICA_LATERAL = ["LLC_Follow_Line", "LLC_Follow_Vehicle"]
- ICA_ACTIVE = ["LLC_Follow_Line", "LLC_Follow_Vehicle", "Only_Longitudinal_Control"]
- constant_speed_time = self.df_vehState[self.df_vehState['ICA_status'] == ICA_CONSTANT_SPEED]['simTime'].tolist()
- follow_car_time = self.df_vehState[self.df_vehState['ICA_status'] == ICA_FOLLOW_CAR]['simTime'].tolist()
- longitudinal_time_list = self.df_vehState[self.df_vehState['ICA_status'] == ICA_LONGITUDINAL][
- 'simTime'].tolist()
- lateral_time_list = self.df_vehState[self.df_vehState['ICA_status'].isin(ICA_LATERAL)]['simTime'].tolist()
- active_time_list = self.df_vehState[self.df_vehState['ICA_status'].isin(ICA_ACTIVE)]['simTime'].tolist()
- ACC = ACCTrigger(self.df_vehState)
- ICA_speed_start_end_time_list = ACC.find_start_end_time(constant_speed_time)
- ICA_dist_start_end_time_list = ACC.find_start_end_time(follow_car_time)
- ICA_longitudinal_start_end_time_list = ACC.find_start_end_time(longitudinal_time_list)
- ICA_lateral_start_end_time_list = ACC.find_start_end_time(lateral_time_list)
- ICA_active_start_end_time_list = ACC.find_start_end_time(active_time_list)
- ICA_start_end_time_dict['ICA_cruise_time'] = ICA_speed_start_end_time_list
- ICA_start_end_time_dict['ICA_follow_time'] = ICA_dist_start_end_time_list
- ICA_start_end_time_dict['ICA_Longitudinal_time'] = ICA_longitudinal_start_end_time_list
- ICA_start_end_time_dict['ICA_Lateral_time'] = ICA_lateral_start_end_time_list
- ICA_start_end_time_dict['ICA_active_time'] = ICA_active_start_end_time_list
- return ICA_start_end_time_dict
|