Lot_Remain_Qtime=\ { 410: ['C105',-30] #该Lot在410站已经等待了30分钟 } time={ 'C101':10, 'C102':20, 'C103':30, 'C104':49, 'C107':90, 'C108':30 } import collections # 约束:先到站的先加工 for i in range(1, len(Step_ID)): current_step = Step_ID[i] previous_step = Step_ID[i - 1] if current_step != 390: # print('Step_Lot_Mapping[current_step]=', Step_Lot_Mapping[current_step]) dispatch_pri=collections.defaultdict(list) for lot_id in Step_Lot_Mapping[current_step]: # print('lot_id=',lot_id) if lot_id in Step_Lot_Mapping[previous_step]: print('true_lot_id=',lot_id) dispatch_pri[lot_id].append(time[lot_id]) # Step_Time_E[lot_id, previous_step] # 如果Lot从上一站加工完成到当站,将Lot_ID和上一站的完成时间放入字典 else: if current_step in Lot_Remain_Qtime and lot_id == Lot_Remain_Qtime[current_step][0]: dispatch_pri[lot_id].append(Lot_Remain_Qtime[current_step][1]) print('dispatch_pri=',dispatch_pri) print('===============================') 报错 dispatch_pri[lot_id].append(time[lot_id]) # Step_Time_E[lot_id, previous_step] KeyError: 'C105'

时间: 2025-06-20 16:18:30 AIGC 浏览: 34
<think>好的,我现在需要帮助用户解决他们遇到的Python代码中的KeyError问题。首先,我得仔细看看用户提供的代码和错误信息。用户提到在运行代码时,dispatch_pri[lot_id].append(time[lot_id])这一行出现了KeyError: 'C105'。这说明在访问time字典时,键'C105'不存在。 首先,我需要分析用户的数据结构。用户定义了两个字典:Lot_Remain_Qtime和time。Lot_Remain_Qtime的键是410,对应的值是一个列表,包含'C105'和-30。而time字典的键是'C101'到'C108'中的几个,但没有'C105'。所以当代码尝试访问time[lot_id],而lot_id是'C105'时,就会引发KeyError,因为time里没有这个键。 接下来,我需要看看代码的逻辑。在循环中,对于每个current_step,代码遍历Step_Lot_Mapping[current_step]中的每个lot_id。然后检查该lot_id是否存在于上一站(previous_step)的Step_Lot_Mapping中。如果存在,就尝试将time[lot_id]添加到dispatch_pri字典中。问题就出在这里,因为当lot_id是'C105'时,time字典中没有对应的键。 用户可能没有意识到time字典缺少'C105'的数据。在Step_Lot_Mapping中,某些步骤(如410、465、452、453)包含'C105',所以在处理这些步骤时,代码会遍历到'C105'这个lot_id。当代码检查到'C105'存在于上一站的Step_Lot_Mapping时,就会尝试获取time['C105'],但time字典中没有这个键,导致错误。 接下来,我需要考虑如何解决这个问题。可能的解决方案有两种:一种是确保所有可能的lot_id在time字典中都有对应的键;另一种是在访问time字典时处理缺失的键,比如使用get方法并提供默认值,或者捕获KeyError异常。 用户可能在处理不同步骤时,某些lot_id在time字典中没有对应的数据,特别是'C105'。因此,代码需要处理这种情况。例如,当lot_id不在time中时,可以跳过或者使用默认值。或者用户可能需要补充time字典中的数据,添加'C105'的时间值。 此外,用户还使用了Lot_Remain_Qtime字典,其中410步骤对应的'C105'有一个剩余时间-30。但在当前的代码逻辑中,只有当lot_id不在上一站的Step_Lot_Mapping中时,才会检查Lot_Remain_Qtime。然而,如果'C105'存在于上一站的Step_Lot_Mapping中,代码就会尝试访问time['C105'],从而导致错误。所以,问题可能出在Step_Lot_Mapping的某些步骤包含'C105',而time字典中没有相应的数据。 因此,解决这个问题的关键步骤包括检查所有可能的lot_id是否在time字典中存在,或者在访问时处理缺失的情况。建议用户在time字典中添加'C105'的值,或者在使用time.get(lot_id, default_value)来避免KeyError。此外,可能需要检查代码逻辑,确保处理所有lot_id的情况,特别是在不同步骤之间传递时的数据完整性。 最后,我需要将这些思考整理成一个清晰的步骤说明,帮助用户理解问题所在,并提供修改建议,确保他们能够正确运行代码而不出现KeyError。</think>让我们逐步分析代码报错的原因及解决方法: **错误定位分析**: ``` KeyError: 'C105' ``` 该错误发生在代码行: ```python dispatch_pri[lot_id].append(time[lot_id]) # 这里访问time字典时key不存在 ``` **根本原因诊断**: 1. **数据缺失问题**: - `time`字典中缺少`C105`的键值对 - 当前`time`字典定义: ```python time = { 'C101':10, 'C102':20, 'C103':30, 'C104':49, 'C107':90, 'C108':30 # 缺少C105 } ``` 2. **逻辑触发路径**: - 当处理`current_step=410`时,`Step_Lot_Mapping[410]`包含`C105` - 代码执行路径: ```python if lot_id in Step_Lot_Mapping[previous_step]: # 当previous_step=390时 time[lot_id] # 此时lot_id=C105会触发KeyError ``` **数据流验证**: ```mermaid graph TD A[Step_ID循环] -->|current_step=410| B[遍历lot_id: C101-C108,C105] B --> C{lot_id是否在上一站?} C -->|是| D[访问time字典] D --> E[触发KeyError:C105] ``` **解决方案**: ```python # 方法1:补全time字典数据(推荐) time = { 'C101':10, 'C102':20, 'C103':30, 'C104':49, 'C105':0, # 添加缺省值 'C107':90, 'C108':30 } # 方法2:添加安全访问机制 dispatch_pri[lot_id].append(time.get(lot_id, 0)) # 使用get方法设置默认值 # 方法3:添加条件判断 if lot_id in time: dispatch_pri[lot_id].append(time[lot_id]) else: dispatch_pri[lot_id].append(0) # 或其它处理逻辑 ``` **完整修改建议**: ```python # 修改后的time字典(补全数据) time = { 'C101':10, 'C102':20, 'C103':30, 'C104':49, 'C105':50, # 假设C105的标准加工时间 'C107':90, 'C108':30 } # 修改后的数据处理段 for lot_id in Step_Lot_Mapping[current_step]: if lot_id in Step_Lot_Mapping[previous_step]: # 添加安全访问检查 if lot_id in time: dispatch_pri[lot_id].append(time[lot_id]) else: print(f"Warning: Missing time data for {lot_id}") dispatch_pri[lot_id].append(0) # 使用默认值 else: # 原有逻辑保持不变... ``` **错误预防建议**: 1. 数据完整性检查: ```python required_lots = {'C101','C102','C103','C104','C105','C106','C107','C108'} missing = required_lots - time.keys() if missing: print(f"缺失时间数据: {missing}") ``` 2. 使用`collections.defaultdict`增强健壮性: ```python from collections import defaultdict safe_time = defaultdict(lambda: 0, time) # 缺失key返回0 dispatch_pri[lot_id].append(safe_time[lot_id]) ``` 3. 添加异常处理: ```python try: dispatch_pri[lot_id].append(time[lot_id]) except KeyError as e: print(f"数据缺失警告: Lot {e} 缺少时间配置") dispatch_pri[lot_id].append(0) ``` **修改后代码执行示例**: ``` dispatch_pri= defaultdict(<class 'list'>, { 'C101': [10], 'C102': [20], 'C103': [30], 'C104': [49], 'C105': [50], # 修正后的值 'C107': [90], 'C108': [30] }) ```
阅读全文

相关推荐

Step_ID=[390,410,420,465,448,452,453] Step_Lot_Mapping = { 390: ['C101', 'C102', 'C103', 'C104', 'C107', 'C108'], 410: ['C101', 'C102', 'C103', 'C104', 'C105', 'C107', 'C108'], 420: ['C101', 'C102', 'C103', 'C104', 'C105'], 465: ['C101', 'C102', 'C103', 'C104', 'C105', 'C106', 'C107'], 448: ['C101', 'C102', 'C103', 'C104', 'C105'], 452: ['C101', 'C102', 'C103', 'C104', 'C105', 'C106', 'C107'], 453: ['C101', 'C102', 'C103', 'C104', 'C105', 'C106', 'C107', 'C108', 'D109', 'D110','C112','C113'] } Lot_Remain_Qtime=\ { 410: {'C105':-30}, #该Lot在410站已经等待了30分钟 453: {'C112':-20,'C113':-50} } time={ 'C101':10, 'C102':20, 'C103':30, 'C104':49, 'C107':90, 'C108':30 } import collections # 约束:先到站的先加工 for i in range(1, len(Step_ID)): current_step = Step_ID[i] previous_step = Step_ID[i - 1] if current_step != 390: # print('Step_Lot_Mapping[current_step]=', Step_Lot_Mapping[current_step]) lot_assign_plan=collections.defaultdict(list) for lot_id in Step_Lot_Mapping[current_step]: # print('lot_id=',lot_id) if lot_id in Step_Lot_Mapping[previous_step]: lot_assign_plan[lot_id].append(time[lot_id]) # Step_Time_E[lot_id, previous_step] # 如果Lot从上一站加工完成到当站,将Lot_ID和上一站的完成时间放入字典 else: if current_step in Lot_Remain_Qtime and lot_id == Lot_Remain_Qtime[current_step][0]: lot_assign_plan[lot_id].append(Lot_Remain_Qtime[current_step][1]) sorted_keys = sorted(lot_assign_plan.keys(),key=lambda k: lot_assign_plan[k][0],reverse=False)报错

import data LOT = data.LOT Daily_monitor_lot = data.Daily_monitor_lot Operation = data.Operation Machine_of_operation = data.Machine_of_operation Last_Operation_Machine_inhibit_due_time = data.Last_Operation_Machine_inhibit_due_time Operation_Machine_K = data.Operation_Machine_K Lot_wafer_QTY = data.Lot_wafer_QTY Operation_Machine_Capability = data.Operation_Machine_Capability Lot_release_time = data.Lot_release_time Machine_release_time = data.Machine_release_time Operation_Machine_Lot_transfer_time = data.Operation_Machine_Lot_transfer_time Lot_release_Remain_QT = data.Lot_release_Remain_QT Lot_release_RQT_w = data.Lot_release_RQT_w Loop_QTime = data.Loop_QTime Loop_qt = data.Loop_qt Last_Operation_Machine_SD_PM_Start_time = data.Last_Operation_Machine_SD_PM_Start_time Last_Operation_Machine_SD_PM_End_time = data.Last_Operation_Machine_SD_PM_End_time N = 1e6 # 无限大正数 # lot的最后一道工序映射表 last_Operation = {l: Operation[l][-1] for l in LOT} print('last_Operation=', last_Operation) # 最后一道工序对应机台映射表(最后一步工序包含的machineList) last_Operation_Machine = {op: list(Machine_of_operation[op].keys())for op in set(last_Operation.values())} print('last_Operation_Machine=', last_Operation_Machine) # ================== 模型构建 ================== solver = pywraplp.Solver.CreateSolver('SCIP') # 决策变量(1): Lot l 的第o道工序是否在machine m上加工,0-1变量 from collections import defaultdict x_lom = defaultdict(dict) # x_lom: 1如果lot l的工序o在机器m上加工 for l in LOT: if l not in Operation: continue for o in Operation[l]: machines = Machine_of_operation.get(o, []) for m in machines: if Operation_Machine_K.get((o, m), 0) == 1 : key = (l, o, m) if key not in x_lom: x_lom[key] = solver.BoolVar(f'x_{l}_{o}_{m}') #print(f'x_{l}_{o}_{m}=', x_lom.values()) # 决策变量(2): Lot l 在第o step的start time s_lom = defaultdict(dict) # x_lom: 1如果lot l的工序o在机器m上加工 for l in LOT: if l not in Operation: continue for o in Operation[l]: machines = Machine_of_operation.get(o, []) for m in machines: key = (l, o, m) if key not in s_lom: s_lom[key] = solver.NumVar(0, solver.infinity(), f's_{l}_{o}_{m}') 建立一个简单的ortools求解器求解的柔性车间调度问题

New_Lot_Loop_Info=\ {'C101': {390: {'PSR01': 40, 'PSR03': 35}, 410: {'HCI09': 20, 'HCI0B': 20}, 420: {'SEM04': 6, 'SEM05': 6, 'SEM06': 6, 'SEM07': 6, 'SEM67': 6}, 465: {'WPES07': 12, 'WPES65': 12}, 448: {'OCD02': 8, 'OCD03': 8}, 452: {'WPES04': 12, 'WPES08': 12}, 453: {'EPI07': 110, 'EPI08': 110, 'EPI0k': 130}}, 'C102': {390: {'PSR01': 40, 'PSR03': 35}, 410: {'HCI09': 20, 'HCI0B': 20}, 420: {'SEM04': 6, 'SEM05': 6, 'SEM06': 6, 'SEM07': 6, 'SEM67': 6}, 465: {'WPES07': 12, 'WPES65': 12}, 448: {'OCD02': 8, 'OCD03': 8}, 452: {'WPES04': 12, 'WPES08': 12}, 453: {'EPI07': 110, 'EPI08': 110, 'EPI0k': 130}}, 'C103': {390: {'PSR01': 40, 'PSR03': 35}, 410: {'HCI09': 20, 'HCI0B': 20}, 420: {'SEM04': 6, 'SEM05': 6, 'SEM06': 6, 'SEM07': 6, 'SEM67': 6}, 465: {'WPES07': 12, 'WPES65': 12}, 448: {'OCD02': 8, 'OCD03': 8}, 452: {'WPES04': 12, 'WPES08': 12}, 453: {'EPI07': 110, 'EPI08': 110, 'EPI0k': 130}}, 'C104': {390: {'PSR01': 40, 'PSR03': 35}, 410: {'HCI09': 20, 'HCI0B': 20}, 420: {'SEM04': 6, 'SEM05': 6, 'SEM06': 6, 'SEM07': 6, 'SEM67': 6}, 465: {'WPES07': 12, 'WPES65': 12}, 448: {'OCD02': 8, 'OCD03': 8}, 452: {'WPES04': 12, 'WPES08': 12}, 453: {'EPI07': 110, 'EPI08': 110, 'EPI0k': 130}}} Wait_RemainQtime_list= ['C103', 'C105'] Lot_Wait_RemainQtime=\ { 410: {'C105':30}, #该Lot在410站已经还剩多少Qtime 453: {'C112':40,'C116':20,'C117':-20,'C120':30} } over_time={} # Lot over了多长时间 for lot_id,step_info in New_Lot_Loop_Info.items(): for step_id,machine_info in step_info.items(): over_time[lot_id,step_id] = model.NewIntVar(0, MAX_TIME, f"{lot_id}_in_{step_id}_overqtime") for lot_id, step_info in New_Lot_Loop_Info.items(): if lot_id in Wait_RemainQtime_list: for step_id, qtime_info in Lot_Wait_RemainQtime.items(): for lot_id, remain_qtime in qtime_info.items(): qtime_result = Step_Time_S[lot_id, step_id] - remain_qtime if qtime_result <= 0: model.Add(over_time[lot_id,step_id] == 0) else: model.Add(over_time[lot_id, step_id] == qtime_result)报错: if qtime_result <= 0

#include "EnvInfoProcessor.h" #include <log_custom.h> #include <fmt/format.h> #include "lib/sd_navigation/routing_map_debug.h" namespace cem { namespace fusion { namespace navigation { EnvInfoProcessor::EnvInfoProcessor() : env_info_(std::make_unique<EnvInfo>()), is_switched_to_LD_(false), last_remain_dis_(-1.0), accumulated_distance_(0.0), is_entered_ramp_(false), is_accumulated_valid_(false) { // is_entered_ramp_ = CheckIfInRamp(*INTERNAL_PARAMS.sd_map_data.GetSDRouteInfoPtr()); // if (is_entered_ramp_) { // is_switched_to_LD_ = true; // 如果初始化时已在匝道内,设置标志位为 true // } } void EnvInfoProcessor::Process(const std::vector<cem::message::env_model::StopLine> &stop_line_obj) { auto *sensor_manager = SensorDataManager::Instance(); if (!sensor_manager) { AWARN << "SensorDataManager instance is null"; SD_ENV_INFO_LOG << fmt::format("SensorDataManager instance is null, exiting"); return; } MapEventPtr map_event_ptr; sensor_manager->GetLatestSensorFrame(map_event_ptr); if (!map_event_ptr) { AWARN << "Failed to get latest sensor frame"; SD_ENV_INFO_LOG << fmt::format("Failed to get latest MapEvent, exiting"); return; } const auto &map_event = *map_event_ptr; // 获取 SDRouteInfo if (INTERNAL_PARAMS.sd_map_data.GetSDRouteInfoPtr() == nullptr) { AWARN << "[EnvInfoProcessor] SDRouteInfo is null"; SD_ENV_INFO_LOG << fmt::format("SDRouteInfo is null, exiting"); return; } const auto &sd_route = *INTERNAL_PARAMS.sd_map_data.GetSDRouteInfoPtr(); // SD_ENV_INFO_LOG << fmt::format("{}", sd_route); // 清空并重新初始化 env_info_ // env_info_ = std::make_unique<EnvInfo>(); env_info_->v2_road_classes.clear(); env_info_->v2_turn_info.clear(); env_info_->traffic_flows.clear(); env_info_->v2_curvatures.clear(); env_info_->v2_non_odd_info.clear(); // 从 MapEvent 提取字段 env_info_->v2_valid = (map_event.navi_stat != NaviStatus::NO_NAVAGATION); env_info_->v2_has_navigation = (map_event.navi_stat != NaviStatus::NO_NAVAGATION); SD_ENV_INFO_LOG << fmt::format("Set v2_valid: {}, v2_has_navigation: {}", env_info_->v2_valid, env_info_->v2_has_navigation); // 处理 v2_dist_to_ramp if (CheckIfInRamp(sd_route)) { env_info_->v2_dist_to_ramp = 0.0; SD_ENV_INFO_LOG << fmt::format("Vehicle is in ramp, set v2_dist_to_ramp: 0.0"); } else if (map_event.control_waypoint_type == ControlWayPoint::COMING_LEFT_ONTO_THE_RAMP || map_event.control_waypoint_type == ControlWayPoint::COMING_RIGHT_ONTO_THE_RAMP) { env_info_->v2_dist_to_ramp = map_event.control_waypoint_dis; SD_ENV_INFO_LOG << fmt::format("Approaching ramp, set v2_dist_to_ramp: {}", env_info_->v2_dist_to_ramp); } else { env_info_->v2_dist_to_ramp = DEFAULT_LARGE_DISTANCE; SD_ENV_INFO_LOG << fmt::format("No ramp detected, set v2_dist_to_ramp: {}", DEFAULT_LARGE_DISTANCE); } // 处理 v2_dist_to_toll 和 v2_dist_to_tunnel env_info_->v2_dist_to_toll = DEFAULT_LARGE_DISTANCE; env_info_->v2_dist_to_tunnel = DEFAULT_LARGE_DISTANCE; for (const auto &reminder_info : map_event.reminder_way_info) { if (reminder_info.reminder_waypoint_type == ReminderWayPoint::TOLL_BOOTH) { env_info_->v2_dist_to_toll = reminder_info.reminder_waypoint_dis; SD_ENV_INFO_LOG << fmt::format("Toll booth detected, set v2_dist_to_toll: {}", env_info_->v2_dist_to_toll); } else if (reminder_info.reminder_waypoint_type == ReminderWayPoint::TUNNEL) { env_info_->v2_dist_to_tunnel = reminder_info.reminder_waypoint_dis; SD_ENV_INFO_LOG << fmt::format("Tunnel detected, set v2_dist_to_tunnel: {}", env_info_->v2_dist_to_tunnel); } } // 处理 v2_curvatures env_info_->v2_curvatures.clear(); for (const auto &curvature_info : map_event.curvature_info) { V2Curvature v2_curvature; v2_curvature.distance = curvature_info.remain_dis; v2_curvature.curvature = curvature_info.curvature; env_info_->v2_curvatures.emplace_back(v2_curvature); } SD_ENV_INFO_LOG << fmt::format("Set v2_curvatures with size: {}", env_info_->v2_curvatures.size()); // 处理 traffic_flows env_info_->traffic_flows.clear(); V2TrafficFlow traffic_flow; traffic_flow.start_s = map_event.traffic_info.dist_to_start_traffic_jam; traffic_flow.end_s = traffic_flow.start_s + map_event.traffic_info.traffic_jam_dist; switch (map_event.traffic_info.traffic_jam_status) { case 1: traffic_flow.type = V2TrafficFlow::V2TrafficFlowType::SMOOTH_FLOW; break; case 2: traffic_flow.type = V2TrafficFlow::V2TrafficFlowType::SLOW_FLOW; break; case 3: traffic_flow.type = V2TrafficFlow::V2TrafficFlowType::JAMMED_FLOW; break; case 4: traffic_flow.type = V2TrafficFlow::V2TrafficFlowType::SEVERE_JAMMED_FLOW; break; default: traffic_flow.type = V2TrafficFlow::V2TrafficFlowType::UNKNOWN_FLOW; break; } env_info_->traffic_flows.emplace_back(traffic_flow); SD_ENV_INFO_LOG << fmt::format("Set traffic_flows with size: {}", env_info_->traffic_flows.size()); // 从 sd_route 计算 v2_dist_to_subpath 和 v2_dist_to_split_routelanenum_dec env_info_->v2_dist_to_subpath = CalculateDistanceToSubpath(); env_info_->v2_dist_to_split_routelanenum_dec = CalculateDistanceToSplitRouteLaneNumDec(); SD_ENV_INFO_LOG << fmt::format("Set v2_dist_to_subpath: {}, v2_dist_to_split_routelanenum_dec: {}", env_info_->v2_dist_to_subpath, env_info_->v2_dist_to_split_routelanenum_dec); env_info_->v2_road_classes = CalculateV2RoadClasses(); env_info_->v2_turn_info = CalculateV2TurnInfo(stop_line_obj); env_info_->is_switched_to_LD_ = UpdateIsSwitchedToLD(map_event, sd_route); // SD_ENV_INFO_LOG << fmt::format( // "Exiting ProcessEnvInfo with env_info: v2_valid={}, v2_has_navigation={}, v2_dist_to_ramp={}, v2_dist_to_toll={}, " // "v2_dist_to_tunnel={}, v2_dist_to_subpath={}, v2_dist_to_split_routelanenum_dec={}, v2_curvatures_size={}, " // "traffic_flows_size={}, is_switched_to_LD_={}", // env_info_->v2_valid, env_info_->v2_has_navigation, env_info_->v2_dist_to_ramp, env_info_->v2_dist_to_toll, // env_info_->v2_dist_to_tunnel, env_info_->v2_dist_to_subpath, env_info_->v2_dist_to_split_routelanenum_dec, // env_info_->v2_curvatures.size(), env_info_->traffic_flows.size(), env_info_->is_switched_to_LD_); PrintEnvInfo(*env_info_); } bool EnvInfoProcessor::UpdateIsSwitchedToLD(const MapEvent &map_event, const SDRouteInfo &sd_route) { //城区不更新is_switched_to_LD_高速切图标志位 const bool on_highway = (env_info_ && env_info_->is_on_highway_); if (!on_highway) { is_switched_to_LD_ = false; accumulated_distance_ = 0.0; } ControlWayPoint control_type = map_event.control_waypoint_type; double control_dis = map_event.control_waypoint_dis; double remain_dis = -1.0; for (const auto &remain_info : map_event.remain_dis_info) { if (remain_info.remain_dis_type == RemainType::NAVI_MAP_MATCHED_END) { remain_dis = remain_info.remain_dis; break; } } static double s_last_ego_s = std::numeric_limits<double>::quiet_NaN(); const double ego_s = GetEgoGlobalS(sd_route); double ds = 0.0; if (std::isfinite(s_last_ego_s)) { ds = std::max(0.0, ego_s - s_last_ego_s); // 抗回退 } s_last_ego_s = ego_s; // 判断当前是否在闸道内 const bool in_ramp = CheckIfInRamp(sd_route); // —— 兜底触发用:高速→非高速的下降沿(防止错过“出闸道”边沿)—— static bool s_last_on_highway = false; const bool highway_fall_edge = (!on_highway && s_last_on_highway); // —— 边沿:刚刚“出闸道” —— const bool ramp_exit_edge = (!in_ramp && last_in_ramp_); // 判断是否即将进入闸道(控制点为进入闸道类型且距离小于 800 米) bool approaching_ramp = (control_type == ControlWayPoint::COMING_LEFT_ONTO_THE_RAMP || control_type == ControlWayPoint::COMING_RIGHT_ONTO_THE_RAMP) && control_dis <= LD_MAP_ACTIVATION_DIST_THRESH; // 状态1:在闸道内,切换到 LD 模式 if (in_ramp) { is_switched_to_LD_ = true; is_accumulated_valid_ = false; accumulated_distance_ = 0.0; last_in_ramp_ = in_ramp; last_remain_dis_ = remain_dis; SD_ENV_INFO_LOG << fmt::format("Vehicle is in ramp, set is_switched_to_LD_: true"); return is_switched_to_LD_; } // 状态2:不在闸道内,即将进入闸道(控制点距离 < 800 米) if (approaching_ramp) { is_switched_to_LD_ = true; is_accumulated_valid_ = false; accumulated_distance_ = 0.0; last_in_ramp_ = in_ramp; last_remain_dis_ = remain_dis; SD_ENV_INFO_LOG << fmt::format("Approaching ramp (<= {} m), set is_switched_to_LD_: true", LD_MAP_ACTIVATION_DIST_THRESH); return is_switched_to_LD_; } // 状态3:不在闸道内,控制点距离 > 800 米 // else if (control_type == ControlWayPoint::COMING_LEFT_ONTO_THE_RAMP || control_type == ControlWayPoint::COMING_RIGHT_ONTO_THE_RAMP) { // is_switched_to_LD_ = false; // SD_ENV_INFO_LOG << fmt::format("Control point distance > 800m, set is_switched_to_LD_: false"); // } // 状态4 和 5:不在闸道内,根据离开闸道后的累积距离判断 if (ramp_exit_edge || (highway_fall_edge && is_switched_to_LD_ && !is_accumulated_valid_)) { is_accumulated_valid_ = true; accumulated_distance_ = 0.0; SD_ENV_INFO_LOG << fmt::format("Just exited ramp, reset accumulated_distance_ (edge={}, onHW_fall={})", ramp_exit_edge, highway_fall_edge); } if (is_accumulated_valid_) { // 计算累积行驶距离,过滤异常跳变 // double delta = std::abs(last_remain_dis_ - remain_dis); // if (delta <= MAX_REMAIN_DIS_JUMP) { // accumulated_distance_ += delta; // SD_ENV_INFO_LOG << fmt::format("Normal remain_dis change: {} meters, accumulated_distance_: {}", delta, accumulated_distance_); // } else { // SD_ENV_INFO_LOG << fmt::format("Detected abnormal remain_dis jump: {} meters, skip accumulation", delta); // } accumulated_distance_ += ds; SD_ENV_INFO_LOG << fmt::format("Accumulating: +{:.2f}m → {:.2f}m", ds, accumulated_distance_); // 根据累积距离判断 LD 模式 if (accumulated_distance_ >= LD_MAP_DEACTIVATION_DIST_THRESH) { is_switched_to_LD_ = false; // 状态5:累积距离 >= 300 米 is_accumulated_valid_ = false; SD_ENV_INFO_LOG << fmt::format("Accumulated distance >= 300m, exit LD mode"); } else { is_switched_to_LD_ = true; // 状态4:累积距离 < 300 米 SD_ENV_INFO_LOG << fmt::format("Accumulated distance < 300m, maintain LD mode"); } last_in_ramp_ = in_ramp; last_remain_dis_ = remain_dis; s_last_on_highway = on_highway; return is_switched_to_LD_; } // 不在闸道、无冷却、也不临近闸道, 默认使用感知 is_switched_to_LD_ = false; last_remain_dis_ = remain_dis; s_last_on_highway = on_highway; return is_switched_to_LD_; } const EnvInfo *EnvInfoProcessor::GetEnvInfo() const { return env_info_.get(); } bool EnvInfoProcessor::CheckIfInRamp(const SDRouteInfo &sd_route) { // SD_ENV_INFO_LOG << fmt::format("Entering CheckIfInRamp"); uint64_t ego_section_id = sd_route.navi_start.section_id; for (const auto &sec : sd_route.mpp_sections) { if (sec.id == ego_section_id) { bool is_ramp = IsRampSection(sec); SD_ENV_INFO_LOG << fmt::format("Section {} is_ramp: {}", ego_section_id, is_ramp); return is_ramp; } } // SD_ENV_INFO_LOG << fmt::format("No matching section found, returning false"); return false; } bool EnvInfoProcessor::IsRampSection(const SDSectionInfo §ion_info) { SD_ENV_INFO_LOG << fmt::format("Entering IsRampSection for section_id: {}", section_info.id); // if ((section_info.link_type & static_cast<uint32_t>(SDLinkTypeMask::SDLT_RAMP)) == static_cast<uint32_t>(SDLinkTypeMask::SDLT_RAMP)) { // SD_ENV_INFO_LOG << "Section is ramp due to link_type"; // return true; // } if (section_info.direction == SDDirectionType::BIDIRECTIONAL_PASSABLE) { return false; } uint32_t section_type = section_info.link_type; if ((section_type & (uint32_t)SDLinkTypeMask::SDLT_JCT) == (uint32_t)SDLinkTypeMask::SDLT_JCT || (section_type & (uint32_t)SDLinkTypeMask::SDLT_IC) == (uint32_t)SDLinkTypeMask::SDLT_IC || (section_type & (uint32_t)SDLinkTypeMask::SDLT_SERVICE) == (uint32_t)SDLinkTypeMask::SDLT_SERVICE || (section_type & (uint32_t)SDLinkTypeMask::SDLT_PARK) == (uint32_t)SDLinkTypeMask::SDLT_PARK || (section_type & (uint32_t)SDLinkTypeMask::SDLT_RAMP) == (uint32_t)SDLinkTypeMask::SDLT_RAMP || (section_info.road_class == SDRoadClass::SD_OTHER_ROAD && (section_type & (uint32_t)SDLinkTypeMask::SDLT_POICONNECTION) == (uint32_t)SDLinkTypeMask::SDLT_POICONNECTION)) { return true; } else { return false; } //测试发现ld地图存在非闸道section里面存在lane是RAMP问题,先注销该逻辑 // for (const auto &lg_idx : section_info.lane_group_idx) { // const auto *lane_group = INTERNAL_PARAMS.sd_map_data.GetSDLaneGroupInfoById(lg_idx.id); // if (lane_group) { // for (const auto &lane : lane_group->lane_info) { // if (lane.type == LaneType::LANE_RAMP) { // SD_ENV_INFO_LOG << "Section is ramp due to lane type"; // return true; // } // } // } // } // SD_ENV_INFO_LOG << "Section is not ramp"; return false; } double EnvInfoProcessor::CalculateDistanceToSubpath() { SD_ENV_INFO_LOG << fmt::format("Entering CalculateDistanceToSubpath"); if (INTERNAL_PARAMS.sd_map_data.GetSDRouteInfoPtr() == nullptr) { AWARN << "[EnvInfoProcessor] SDRouteInfo is null in CalculateDistanceToSubpath"; SD_ENV_INFO_LOG << fmt::format("SDRouteInfo is null, returning default large distance"); return DEFAULT_LARGE_DISTANCE; } const auto &sd_route = *INTERNAL_PARAMS.sd_map_data.GetSDRouteInfoPtr(); double ego_global_s = GetEgoGlobalS(sd_route); double min_dist = DEFAULT_LARGE_DISTANCE; std::unordered_set<uint64_t> route_section_ids; for (const auto &sec : sd_route.mpp_sections) { route_section_ids.insert(sec.id); } for (const auto &subpath : sd_route.subpaths) { if (subpath.path_type == SDPathType::MERGE || subpath.path_type == SDPathType::SPLIT) { uint64_t enter_section_id = subpath.enter_section_id; if (route_section_ids.find(enter_section_id) == route_section_ids.end()) { SD_ENV_INFO_LOG << fmt::format("Subpath section_id {} not in route, skipping", enter_section_id); continue; } auto enter_section = INTERNAL_PARAMS.sd_map_data.GetSDSectionInfoById(enter_section_id); if (!enter_section) { SD_ENV_INFO_LOG << fmt::format("Enter section {} not found, skipping", enter_section_id); continue; } double section_start_s = GetSectionStartS(*enter_section, sd_route); double section_end_s = section_start_s + enter_section->length; double target_s = (subpath.path_type == SDPathType::MERGE) ? section_start_s : section_end_s; double dist = target_s - ego_global_s; if (dist >= 0 && dist < min_dist) { min_dist = dist; // SD_ENV_INFO_LOG << "Updated min_dist to " << min_dist << " for subpath section_id: " << enter_section_id; } } } // SD_ENV_INFO_LOG << "Returning min_dist: " << min_dist; return min_dist; } double EnvInfoProcessor::CalculateDistanceToSplitRouteLaneNumDec() { // SD_ENV_INFO_LOG << fmt::format("Entering CalculateDistanceToSplitRouteLaneNumDec"); if (INTERNAL_PARAMS.sd_map_data.GetSDRouteInfoPtr() == nullptr) { AWARN << "[EnvInfoProcessor] SDRouteInfo is null in CalculateDistanceToSplitRouteLaneNumDec"; SD_ENV_INFO_LOG << fmt::format("SDRouteInfo is null, returning default large distance"); return DEFAULT_LARGE_DISTANCE; } const auto &sd_route = *INTERNAL_PARAMS.sd_map_data.GetSDRouteInfoPtr(); double ego_global_s = GetEgoGlobalS(sd_route); double min_dist = DEFAULT_LARGE_DISTANCE; for (const auto &subpath : sd_route.subpaths) { if (subpath.path_type != SDPathType::SPLIT) { // SD_ENV_INFO_LOG << fmt::format("Subpath is not SPLIT, skipping"); continue; } uint64_t enter_section_id = subpath.enter_section_id; auto enter_section = INTERNAL_PARAMS.sd_map_data.GetSDSectionInfoById(enter_section_id); if (!enter_section) { SD_ENV_INFO_LOG << fmt::format("Enter section {} not found, skipping", enter_section_id); continue; } // 获取 enter_section 的最后一个 lanegroup if (enter_section->lane_group_idx.empty()) { // SD_ENV_INFO_LOG << fmt::format("No lane groups in section {}, skipping", enter_section_id); continue; } // 获取 enter_section 的车道数 int enter_lane_num = -1; uint64_t last_lg_id = enter_section->lane_group_idx.back().id; const auto *last_lg = INTERNAL_PARAMS.sd_map_data.GetSDLaneGroupInfoById(last_lg_id); if (!last_lg) { enter_lane_num = GetLaneNumWithoutEmergency(last_lg); } else { // SD_ENV_INFO_LOG << fmt::format("Last lane group {} not found, skipping", last_lg_id); enter_lane_num = static_cast<int>(enter_section->lane_num); } // 遍历后继 section for (uint64_t successor_id : enter_section->successor_section_id_list) { auto successor_section = INTERNAL_PARAMS.sd_map_data.GetSDSectionInfoById(successor_id); if (!successor_section || !successor_section->is_mpp_section) { // SD_ENV_INFO_LOG << fmt::format("Successor section {} not found or not MPP, skipping", successor_id); continue; } // 获取 successor_section 的第一个 lanegroup if (successor_section->lane_group_idx.empty()) { // SD_ENV_INFO_LOG << fmt::format("No lane groups in successor section {}, skipping", successor_id); continue; } uint64_t first_successor_lg_id = successor_section->lane_group_idx.front().id; const auto *first_successor_lg = INTERNAL_PARAMS.sd_map_data.GetSDLaneGroupInfoById(first_successor_lg_id); if (!first_successor_lg) { SD_ENV_INFO_LOG << fmt::format("First successor lane group {} not found, skipping", first_successor_lg_id); continue; } // 检查车道后继 bool all_successors_in_first_lg = true; for (const auto &lane : last_lg->lane_info) { for (uint64_t successor_lane_id : lane.next_lane_ids) { bool found = false; for (const auto &successor_lane : first_successor_lg->lane_info) { if (successor_lane.id == successor_lane_id) { found = true; break; } } if (!found) { all_successors_in_first_lg = false; break; } } if (!all_successors_in_first_lg) { break; } } // 获取 successor_section 的车道数 int next_lane_num = GetSDSectionMinLaneNumNOTEmergency(*successor_section); // 判断条件:车道数减少 或 后继车道不全部在下一个 lanegroup 中 if (enter_lane_num > next_lane_num || !all_successors_in_first_lg) { double split_s = GetSectionStartS(*enter_section, sd_route) + enter_section->length; double dist = split_s - ego_global_s; if (dist >= 0 && dist < min_dist) { min_dist = dist; // SD_ENV_INFO_LOG << fmt::format("Condition met at section {} (lane decrease: {}, successor check: {}), updated min_dist: {}", // enter_section_id, (enter_lane_num > next_lane_num), !all_successors_in_first_lg, min_dist); } } } } // SD_ENV_INFO_LOG << fmt::format("Returning min_dist: {}", min_dist); return min_dist; } double EnvInfoProcessor::GetEgoGlobalS(const SDRouteInfo &sd_route) const { // SD_ENV_INFO_LOG << fmt::format("Entering GetEgoGlobalS"); double ego_global_s = 0.0; uint64_t ego_section_id = sd_route.navi_start.section_id; double ego_s_offset = sd_route.navi_start.s_offset; for (const auto &sec : sd_route.mpp_sections) { if (sec.id == ego_section_id) { ego_global_s += ego_s_offset; break; } ego_global_s += sec.length; } // SD_ENV_INFO_LOG << fmt::format("Returning ego_global_s: {}", ego_global_s); return ego_global_s; } double EnvInfoProcessor::GetSectionStartS(const SDSectionInfo §ion, const SDRouteInfo &sd_route) const { // SD_ENV_INFO_LOG << "Entering GetSectionStartS for section_id: " << section.id; double current_s = 0.0; for (const auto &sec : sd_route.mpp_sections) { if (sec.id == section.id) { // SD_ENV_INFO_LOG << fmt::format("Returning current_s: {}", current_s); return current_s; } current_s += sec.length; } // SD_ENV_INFO_LOG << fmt::format("Section not found, returning current_s: {}", current_s); return current_s; } int EnvInfoProcessor::GetLaneNumWithoutEmergency(const SDLaneGroupInfo *lanegroup) { SD_ENV_INFO_LOG << fmt::format("Entering GetLaneNumWithoutEmergency"); if (!lanegroup) { SD_ENV_INFO_LOG << fmt::format("Lane group is null, returning 0"); return 0; } int count = 0; for (const auto &lane : lanegroup->lane_info) { if (lane.type != LaneType::LANE_EMERGENCY) { count++; } } SD_ENV_INFO_LOG << fmt::format("Returning non-emergency lane count: {}", count); return count; } int EnvInfoProcessor::GetSDSectionMinLaneNumNOTEmergency(const SDSectionInfo §ion_info) { // SD_ENV_INFO_LOG << fmt::format("Entering GetSDSectionMinLaneNumNOTEmergency for section_id: {}", section_info.id); if (section_info.lane_group_idx.empty()) { SD_ENV_INFO_LOG << fmt::format("No lane groups, returning section lane_num: {}", section_info.lane_num); return static_cast<int>(section_info.lane_num); } int min_lane_num = std::numeric_limits<int>::max(); for (const auto &lane_group_id_tmp : section_info.lane_group_idx) { auto lane_group = INTERNAL_PARAMS.sd_map_data.GetSDLaneGroupInfoById(lane_group_id_tmp.id); if (lane_group) { int emergency_lane_count = 0; for (const auto &lane_info_tmp : lane_group->lane_info) { if (lane_info_tmp.type == LaneType::LANE_EMERGENCY) { emergency_lane_count++; } } int current_lane_num = lane_group->lane_info.size() - emergency_lane_count; if (current_lane_num < min_lane_num) { min_lane_num = current_lane_num; } } } if (min_lane_num == std::numeric_limits<int>::max()) { SD_ENV_INFO_LOG << fmt::format("No valid lane groups, returning section lane_num: {}", section_info.lane_num); return section_info.lane_num != 0 ? static_cast<int>(section_info.lane_num) : 0; } int result = min_lane_num == 0 ? static_cast<int>(section_info.lane_num) : min_lane_num; // SD_ENV_INFO_LOG << fmt::format("Returning min non-emergency lane count: {}", result); return result; } V2RoadClassType EnvInfoProcessor::ConvertSDRoadClassToV2RoadClassType(SDRoadClass sd_road_class) const { switch (sd_road_class) { case SDRoadClass::SD_HIGHWAY: return V2RoadClassType::HIGH_WAY_ROAD; case SDRoadClass::SD_CITY_FAST_WAY: return V2RoadClassType::EXPRESS_WAY_ROAD; case SDRoadClass::SD_NATIONAL_ROAD: return V2RoadClassType::NATIOANL_ROAD; case SDRoadClass::SD_PROVINCIAL_ROAD: return V2RoadClassType::PROVINCIAL_ROAD; case SDRoadClass::SD_COUNTY_ROAD: case SDRoadClass::SD_TOWNSHIP_ROAD: return V2RoadClassType::MAIN_ROAD; case SDRoadClass::SD_OTHER_ROAD: case SDRoadClass::SD_LEVEL_9_ROAD: case SDRoadClass::SD_FERRY: case SDRoadClass::SD_WALY_WAY: case SDRoadClass::SD_INVALID: return V2RoadClassType::UNKNOWN_ROAD; default: return V2RoadClassType::UNKNOWN_ROAD; } } std::vector<V2RoadClass> EnvInfoProcessor::CalculateV2RoadClasses() const { if (INTERNAL_PARAMS.sd_map_data.GetSDRouteInfoPtr() == nullptr) { AWARN << "[EnvInfoProcessor] SDRouteInfo is null"; SD_ENV_INFO_LOG << fmt::format("SDRouteInfo is null, exiting"); return {}; } const auto &sd_route = *INTERNAL_PARAMS.sd_map_data.GetSDRouteInfoPtr(); if (sd_route.mpp_sections.empty()) { return {}; } double ego_global_s = GetEgoGlobalS(sd_route); std::vector<V2RoadClass> v2_road_classes; v2_road_classes.clear(); double first_start_s = GetSectionStartS(sd_route.mpp_sections[0], sd_route); double first_end_s = first_start_s + sd_route.mpp_sections[0].length; V2RoadClass current{first_start_s - ego_global_s, first_end_s - ego_global_s, ConvertSDRoadClassToV2RoadClassType(sd_route.mpp_sections[0].road_class)}; // Process remaining sections for (size_t i = 1; i < sd_route.mpp_sections.size(); ++i) { const auto §ion = sd_route.mpp_sections[i]; double start_s = GetSectionStartS(section, sd_route); double end_s = start_s + section.length; auto type = ConvertSDRoadClassToV2RoadClassType(section.road_class); // SD_ENV_INFO_LOG << "Section_id: " << section.id <<" start_s: " << start_s << " end_s: " << end_s << " type: " << static_cast<int>(section.road_class); if (type == current.road_class) { // Same road class type, extend the current segment current.end = end_s - ego_global_s; } else { // Different road class type, save current and start a new segment v2_road_classes.push_back(current); current = {start_s - ego_global_s, // Start relative to ego end_s - ego_global_s, // End relative to ego type}; } } // Add the last segment v2_road_classes.push_back(current); return v2_road_classes; } UTurnPosition EnvInfoProcessor::FindUTurnLanePosition(const std::vector<TurnType> &lane_arrows) { if (lane_arrows.empty()) return UTurnPosition::UNKNOWN; // 查找最左侧和最右侧的 U-turn 车道 bool leftmost_has_uturn = false; bool rightmost_has_uturn = false; for (size_t i = 0; i < lane_arrows.size(); ++i) { if (lane_arrows[i] == TurnType::STRAIGHT_AND_U_TURN || lane_arrows[i] == TurnType::LEFT_TURN_AND_U_TURN || lane_arrows[i] == TurnType::STRAIGHT_AND_LEFT_TURN_AND_U_TURN) { if (i == 0) leftmost_has_uturn = true; } if (lane_arrows[i] == TurnType::STRAIGHT_AND_U_TURN || lane_arrows[i] == TurnType::RIGHT_TURN_AND_U_TURN || lane_arrows[i] == TurnType::STRAIGHT_AND_RIGHT_TURN_AND_U_TURN) { if (i == lane_arrows.size() - 1) rightmost_has_uturn = true; } } if (leftmost_has_uturn) return UTurnPosition::LEFTMOST; if (rightmost_has_uturn) return UTurnPosition::RIGHTMOST; return UTurnPosition::UNKNOWN; } std::pair<V2TurnInfo::V2TurnType, V2TurnInfo::V2DetailTurnType> EnvInfoProcessor::GetTurnInfoForRoadSplit(JunctionAction action) { static const std::map<JunctionAction, std::pair<V2TurnInfo::V2TurnType, V2TurnInfo::V2DetailTurnType>> turn_map = { {JunctionAction::TurnLeft, {V2TurnInfo::V2TurnType::LEFT, V2TurnInfo::V2DetailTurnType::SLIGHT_LEFT}}, {JunctionAction::TurnRight, {V2TurnInfo::V2TurnType::RIGHT, V2TurnInfo::V2DetailTurnType::SLIGHT_RIGHT}}, {JunctionAction::GoStraight, {V2TurnInfo::V2TurnType::STRAIGHT, V2TurnInfo::V2DetailTurnType::CONTINUE}}}; auto it = turn_map.find(action); if (it != turn_map.end()) { return it->second; } return {V2TurnInfo::V2TurnType::UNKNOWN, V2TurnInfo::V2DetailTurnType::NONE}; } std::vector<V2TurnInfo> EnvInfoProcessor::CalculateV2TurnInfo(const std::vector<cem::message::env_model::StopLine> &stop_line_obj) { if (!env_info_) { SD_ENV_INFO_LOG << fmt::format("EnvInfo is null, returning empty turn info"); return {}; } // 根据Master层计算的is_on_highway_ 区分处理高速还是城区逻辑 if (env_info_->is_on_highway_) { SD_ENV_INFO_LOG << fmt::format("is_on_highway_ is: {}, Processing highway logic.", env_info_->is_on_highway_); auto highway_junctions_ptr = INTERNAL_PARAMS.navigation_info_data.GetJunctionInfoPtr(); if (highway_junctions_ptr) { return ProcessHighwayJunctions(stop_line_obj, *highway_junctions_ptr); } else { SD_ENV_INFO_LOG << fmt::format("Highway junctions pointer is null, returning empty turn info"); return {}; } } else { SD_ENV_INFO_LOG << fmt::format("is_on_highway_ is: {}, Processing city logic.", env_info_->is_on_highway_); auto city_junctions_ptr = INTERNAL_PARAMS.navigation_info_data.GetJunctionInfoCityPtr(); if (city_junctions_ptr) { return ProcessCityJunctions(stop_line_obj, *city_junctions_ptr); } else { SD_ENV_INFO_LOG << fmt::format("City junctions pointer is null, returning empty turn info"); return {}; } } } std::vector<V2TurnInfo> EnvInfoProcessor::ProcessCityJunctions(const std::vector<cem::message::env_model::StopLine> &stop_line_obj, const std::vector &city_junctions) { if (city_junctions.empty()) { return {}; } std::vector<V2TurnInfo> turn_infos; turn_infos.clear(); std::vector<uint64_t> v2_junction_ids = INTERNAL_PARAMS.navigation_info_data.get_v2_junction_ids(); for (const auto &junction : city_junctions) { auto find_v2 = std::find(v2_junction_ids.begin(), v2_junction_ids.end(), junction.junction_id); if (find_v2 == v2_junction_ids.end()) { continue; } SD_ENV_INFO_LOG << fmt::format("{}", junction); V2TurnInfo turn_info; turn_info.id = junction.junction_id; turn_info.is_valid = true; // 处理 RoadSplit 路口的特殊逻辑 if (junction.junction_type_city == JunctionTypeCity::RoadSplit) { // 检查是否为右转专用道 if (junction.is_dedicated_right_turn_lane && junction.split_merge_direction == DirectionSplitMerge::Right) { turn_info.turn_type = V2TurnInfo::V2TurnType::RIGHT; turn_info.detail_turn_type = V2TurnInfo::V2DetailTurnType::TURN_RIGHT_ONLY; } else { // 非右转专用道的RoadSplit路口,使用原默认逻辑 auto [turn_type, detail_turn_type] = GetTurnInfoForRoadSplit(junction.junction_action); turn_info.turn_type = turn_type; turn_info.detail_turn_type = detail_turn_type; } } else { // 其他路口类型的原有逻辑 switch (junction.junction_action) { case JunctionAction::TurnLeft: turn_info.turn_type = V2TurnInfo::V2TurnType::LEFT; turn_info.detail_turn_type = V2TurnInfo::V2DetailTurnType::TURN_LEFT; break; case JunctionAction::TurnRight: turn_info.turn_type = V2TurnInfo::V2TurnType::RIGHT; turn_info.detail_turn_type = V2TurnInfo::V2DetailTurnType::TURN_RIGHT; break; case JunctionAction::GoStraight: turn_info.turn_type = V2TurnInfo::V2TurnType::STRAIGHT; turn_info.detail_turn_type = V2TurnInfo::V2DetailTurnType::CONTINUE; break; case JunctionAction::UTurn: { UTurnPosition uturn_pos = FindUTurnLanePosition(junction.map_lane_arrows_plan); if (uturn_pos == UTurnPosition::LEFTMOST) { turn_info.turn_type = V2TurnInfo::V2TurnType::U_TURN_LEFT; } else if (uturn_pos == UTurnPosition::RIGHTMOST) { turn_info.turn_type = V2TurnInfo::V2TurnType::U_TURN_RIGHT; } turn_info.detail_turn_type = V2TurnInfo::V2DetailTurnType::UTURN; break; } default: turn_info.turn_type = V2TurnInfo::V2TurnType::UNKNOWN; turn_info.detail_turn_type = V2TurnInfo::V2DetailTurnType::NONE; break; } } turn_info.v2_dist = junction.offset; if (!stop_line_obj.empty() && (std::fabs(stop_line_obj.at(0).distance_to_stopline - turn_info.v2_dist) < 30.0)) { SD_ENV_INFO_LOG << fmt::format("Using stopline dist to calib dist_v2"); turn_info.dist = stop_line_obj.at(0).distance_to_stopline; } else { turn_info.dist = turn_info.v2_dist; } turn_info.before_turn.lane_num = junction.main_road_lane_nums; turn_info.after_turn.lane_num = junction.target_road_lane_nums; if (!junction.junction_ids.empty()) { uint64_t before_section_id = junction.junction_ids.front(); auto before_section = INTERNAL_PARAMS.sd_map_data.GetSDSectionInfoById(before_section_id); if (before_section) { turn_info.before_turn.road_class = ConvertSDRoadClassToV2RoadClassType(before_section->road_class); } else { turn_info.before_turn.road_class = V2RoadClassType::UNKNOWN_ROAD; SD_ENV_INFO_LOG << fmt::format("Before section {} not found for junction {}", before_section_id, junction.junction_id); } uint64_t after_section_id = junction.junction_ids.back(); auto after_section = INTERNAL_PARAMS.sd_map_data.GetSDSectionInfoById(after_section_id); if (after_section) { turn_info.after_turn.road_class = ConvertSDRoadClassToV2RoadClassType(after_section->road_class); } else { turn_info.after_turn.road_class = V2RoadClassType::UNKNOWN_ROAD; SD_ENV_INFO_LOG << fmt::format("After section {} not found for junction {}", after_section_id, junction.junction_id); } } else { turn_info.before_turn.road_class = V2RoadClassType::UNKNOWN_ROAD; turn_info.after_turn.road_class = V2RoadClassType::UNKNOWN_ROAD; SD_ENV_INFO_LOG << fmt::format("Junction {} has empty junction_ids", junction.junction_id); } turn_infos.push_back(turn_info); } return turn_infos; } std::vector<V2TurnInfo> EnvInfoProcessor::ProcessHighwayJunctions(const std::vector<cem::message::env_model::StopLine> &stop_line_obj, const std::vector &highway_junctions) { std::vector<V2TurnInfo> turn_infos; std::vector<uint64_t> v2_junction_ids = INTERNAL_PARAMS.navigation_info_data.get_v2_junction_ids(); // 定义闸道里分叉路口类型集合 std::unordered_set<JunctionType> split_types = {JunctionType::RampSplitLeft, JunctionType::RampSplitRight, JunctionType::RampSplitMiddle}; for (const auto &junction : highway_junctions) { auto find_v2 = std::find(v2_junction_ids.begin(), v2_junction_ids.end(), junction.junction_id); if (find_v2 == v2_junction_ids.end()) { continue; } SD_ENV_INFO_LOG << fmt::format("Evaluating highway junction ID: {}, type: {}, SplitDirection: {}, offset: {}", junction.junction_id, static_cast<int>(junction.junction_type), static_cast<int>(junction.split_direction), junction.offset); V2TurnInfo turn_info; turn_info.id = junction.junction_id; turn_info.is_valid = true; // 检查是否为闸道里分叉路口类型 if (split_types.count(junction.junction_type)) { // 对于分叉路口,使用 split_direction 设置转向信息 switch (junction.split_direction) { case SplitDirection::Straight: turn_info.turn_type = V2TurnInfo::V2TurnType::STRAIGHT; turn_info.detail_turn_type = V2TurnInfo::V2DetailTurnType::CONTINUE; break; case SplitDirection::SplitLeft: turn_info.turn_type = V2TurnInfo::V2TurnType::LEFT; turn_info.detail_turn_type = V2TurnInfo::V2DetailTurnType::SLIGHT_LEFT; break; case SplitDirection::SplitRight: turn_info.turn_type = V2TurnInfo::V2TurnType::RIGHT; turn_info.detail_turn_type = V2TurnInfo::V2DetailTurnType::SLIGHT_RIGHT; break; default: turn_info.turn_type = V2TurnInfo::V2TurnType::UNKNOWN; turn_info.detail_turn_type = V2TurnInfo::V2DetailTurnType::NONE; break; } } else { // 对于非分叉路口,保留原有 junction_type 逻辑 switch (junction.junction_type) { case JunctionType::RampInto: turn_info.turn_type = V2TurnInfo::V2TurnType::RIGHT; turn_info.detail_turn_type = V2TurnInfo::V2DetailTurnType::SLIGHT_RIGHT; break; case JunctionType::ApproachRampInto: turn_info.turn_type = V2TurnInfo::V2TurnType::STRAIGHT; turn_info.detail_turn_type = V2TurnInfo::V2DetailTurnType::CONTINUE; break; default: turn_info.turn_type = V2TurnInfo::V2TurnType::UNKNOWN; turn_info.detail_turn_type = V2TurnInfo::V2DetailTurnType::NONE; break; } } turn_info.v2_dist = junction.offset; turn_info.dist = turn_info.v2_dist; turn_info.before_turn.lane_num = junction.main_road_lane_nums; turn_info.after_turn.lane_num = junction.target_road_lane_nums; if (!junction.junction_ids.empty()) { uint64_t before_section_id = junction.junction_ids.front(); auto before_section = INTERNAL_PARAMS.sd_map_data.GetSDSectionInfoById(before_section_id); if (before_section) { turn_info.before_turn.road_class = ConvertSDRoadClassToV2RoadClassType(before_section->road_class); } else { turn_info.before_turn.road_class = V2RoadClassType::UNKNOWN_ROAD; SD_ENV_INFO_LOG << fmt::format("Before section {} not found for junction {}", before_section_id, junction.junction_id); } uint64_t after_section_id = junction.junction_ids.back(); auto after_section = INTERNAL_PARAMS.sd_map_data.GetSDSectionInfoById(after_section_id); if (after_section) { turn_info.after_turn.road_class = ConvertSDRoadClassToV2RoadClassType(after_section->road_class); } else { turn_info.after_turn.road_class = V2RoadClassType::UNKNOWN_ROAD; SD_ENV_INFO_LOG << fmt::format("After section {} not found for junction {}", after_section_id, junction.junction_id); } } else { turn_info.before_turn.road_class = V2RoadClassType::UNKNOWN_ROAD; turn_info.after_turn.road_class = V2RoadClassType::UNKNOWN_ROAD; SD_ENV_INFO_LOG << fmt::format("Junction {} has empty junction_ids", junction.junction_id); } turn_infos.push_back(turn_info); } return turn_infos; } void EnvInfoProcessor::SetIsOnHighway(bool is_on_highway) { if (env_info_) { env_info_->is_on_highway_ = is_on_highway; // SD_ENV_INFO_LOG << fmt::format("Set value is_on_highway:{}", env_info_->is_on_highway_); } } void EnvInfoProcessor::PrintEnvInfo(const EnvInfo &env_info) const { SD_ENV_INFO_LOG << fmt::format("{}", env_info); } } // namespace navigation } // namespace fusion } // namespace cem详细解释下代码

import heapq import bisect def main(): import sys input = sys.stdin.read().split() idx = 0 N = int(input[idx]) idx +=1 C = int(input[idx]) idx +=1 schools = [] for _ in range(N): name = input[idx] num = int(input[idx+1]) idx +=2 schools.append( (name, num, num, 0) ) # (缩写, 初始人数, 剩余人数, 监考官数目) # 初始化最大堆,存储(-剩余人数, 学校索引) heap = [] for i in range(N): if schools[i][2] >0: heapq.heappush(heap, (-schools[i][2], i)) total_rooms = 0 # remain字典: key是剩余容量r,value是赛场的编号列表,按编号递增排序 remain = {} while heap: current_neg, idx = heapq.heappop(heap) current_n = -current_neg name, _, remain_n, count = schools[idx] if remain_n != current_n: continue # 过时的记录 if remain_n <=0: continue if current_n >= C: # 处理n >= C的情况 total_rooms +=1 new_remain = current_n - C schools[idx] = (name, schools[idx][1], new_remain, count +1) if new_remain >0: heapq.heappush(heap, (-new_remain, idx)) else: # 处理n < C的情况 found = False for r in range(C, current_n -1, -1): if r in remain and len(remain[r]) >0: # 取出编号最小的赛场 s_id = remain[r].pop(0) # 如果取出后列表为空,可以删除该键(可选) if len(remain[r]) ==0: del remain[r] # 计算新的剩余容量 new_r = r - current_n if new_r >0: if new_r not in remain: remain[new_r] = [] bisect.insort(remain[new_r], s_id) # 更新该学校的监考官数目 schools[idx] = (name, schools[idx][1], 0, count +1) found = True break if not found: # 新开一个赛场 total_rooms +=1 new_r = C - current_n s_id = total_rooms # 新赛场的编号 schools[idx] = (name, schools[idx][1], 0, count +1) if new_r >0: if new_r not in remain: remain[new_r] = [] bisect.insort(remain[new_r], s_id) # 输出结果 for sch in schools: print(f"{sch[0]} {sch[3]}") print(total_rooms) if __name__ == "__main__": main()转c++

while not rospy.is_shutdown(): try: trans, rot = location_listener.lookupTransform('map', 'body_foot', rospy.Time(0)) current_x = trans[0] current_y = trans[1] #返回的是机器人在 map 坐标系下的位置信息和姿态信息(四元数形式的旋转) # print('position',trans,rot) except (tf.LookupException, tf.ConnectivityException, tf.ExtrapolationException): pass # print("logic no TF get !") seq_1 = seq_1 + 1 if seq_1 >= 5: seq_1 = 0 if robot_HP < 200 : require_add_HP = 1 if robot_HP > 350: require_add_HP = 0 wait_attack_cnt = wait_attack_cnt - 1 # print(" wait_attack_cnt :",wait_attack_cnt) #等待攻击时间递减 if wait_attack_cnt <= 0: wait_attack_cnt = 500 attack_cnt = 100 #攻击时间递减 if attack_cnt > 0: attack_cnt = attack_cnt - 1 #锁定计时器递减 if lock_yaw_cnt > 0: lock_yaw_cnt = lock_yaw_cnt - 1 # print(" attack_cnt :",attack_cnt) # target_yaw = target_yaw + 0.475 #0.475 target_pose = PoseStamped() target_pose.header.frame_id = "map" # 加血 if (game_status == 4) and (require_add_HP == 1):#补血区 target_pose.pose.position.x = 7.6 target_pose.pose.position.y = -4.5 target_pose.pose.position.z = 0 #进攻掩护步兵占领中心增益点 elif (game_status == 4) and (robot_HP > 300) and (attack_cnt > 0):#中心增益点靠前部分 target_pose.pose.position.x = 2 target_pose.pose.position.y = -2.9 target_pose.pose.position.z = 0 elif (game_status == 4) and (robot_HP > 300) and (attack_cnt == 0): #没到进攻时间在中心增益点附近 if remain_time > 250: target_pose.pose.position.x = 3.9 target_pose.pose.position.y = -2.9 #退让 elif remain_time > 200: target_pose.pose.position.x = 7.6 target_pose.pose.position.y = -4.5 #比赛最后时段 elif remain_time > 150: target_pose.pose.position.x = 3.9 target_pose.pose.position.y = -2.9 else: target_pose.pose.position.x = 3.9 target_pose.pose.position.y = -2.9 target_pose.pose.position.z = 0 # 否则待在原地 else:#原地 target_pose.pose.position.x = 1 target_pose.pose.position.y = -1 target_pose.pose.position.z = 0 target_quad = quaternion_from_euler(0, 0, target_yaw) target_pose.pose.orientation.x = target_quad[0] target_pose.pose.orientation.y = target_quad[1] target_pose.pose.orientation.z = target_quad[2] target_pose.pose.orientation.w = target_quad[3] distance = math.sqrt((target_pose.pose.position.x - current_x)**2 + (target_pose.pose.position.y - current_y)**2) if distance <= 0.2: print("have got goal! ") cancel_msg = GoalID() cancel_msg.stamp = rospy.Time.now() cancel_pub.publish(cancel_msg) else: location_target_publisher.publish(target_pose) print("distance",distance)请问我这样写可以实现当距离目标点小于0.1m时取消上一个目标点的发布么

================== 数据准备 ================== 集合 LOT = {‘L1’, ‘L2’, ‘L3’} # Lot集合 Operation = [‘O1’, ‘O2’, ‘O3’] # 工序集合 Machine_for_operation = { ‘O1’: [‘M1’, ‘M2’], ‘O2’: [‘M3’, ‘M4’], ‘O3’: [‘M5’, ‘M6’] } # Machine集合 #参数 Daily_monitor_lot = [‘L3’] # //AM lot集合,假设l1是AM lot// last_Operation = [‘O3’] # //O_last,假设O2是最后一道工序 last_Operation_Machine = [‘M5’, ‘M6’] # //M_last,假设M2是最后一道工序对应的机台 Lot_wafer_QTY = {‘L1’: 8, ‘L2’: 8, ‘L3’: 3} # //wafer qty// Operation_Machine_K = { # 是否允许lot的工序在machine上加工,默认为1 (‘O1’, ‘M1’): 1,(‘O1’, ‘M2’): 1,(‘O1’, ‘M3’): 0,(‘O1’, ‘M4’): 0,(‘O1’, ‘M5’): 0,(‘O1’, ‘M6’): 0, (‘O2’, ‘M1’): 0,(‘O2’, ‘M2’): 0,(‘O2’, ‘M3’): 1,(‘O2’, ‘M4’): 1,(‘O2’, ‘M5’): 0,(‘O2’, ‘M6’): 0, (‘O3’, ‘M1’): 0,(‘O3’, ‘M2’): 0,(‘O3’, ‘M3’): 0,(‘O3’, ‘M4’): 0,(‘O3’, ‘M5’): 1,(‘O3’, ‘M6’): 1 } # //k加工能力// Operation_Machine_WPH = {(‘O1’, ‘M1’): 20,(‘O1’, ‘M2’): 25,(‘O2’, ‘M3’): 25,(‘O2’, ‘M4’): 25,(‘03’, ‘M5’): 1.1,(‘03’, ‘M6’): 1} # //machine_WPH// Operation_Machine_Capability = {‘M1’: 22,‘M2’: 24,‘M3’: 22,‘M4’: 22,‘M5’: 24,‘M6’: 23} # //c机台capability// # 机器能力,总可用时间 Lot_release_time = {‘L1’: 0, ‘L2’: 1, ‘L3’: 0} # //lot release time// Machine_release_time = {‘M1’: 0, ‘M2’: 0, ‘M3’: 0, ‘M4’: 0.5, ‘M5’: 0, ‘M6’: 0} # //machine release time// Operation_Machine_Lot_transfer_time = { # buffer + transfer time,假设每工序后0.5小时 (l, o, m): 0.5 for l in LOT for o in Operation for m in Machine_for_operation } # //buffer time + transfer time// Last_Operation_Machine_inhibit_due_time = { ‘M1’:999, ‘M2’: 9999, ‘M3’: 999, ‘M4’: 999, ‘M5’: 2, ‘M6’: 5 } # //machine monitor inhibit// Lot_release_Remain_QT = {‘L1’: 24, ‘L2’: 24, ‘L3’: 20} # //lot release时remain Q time// # 初始Q time剩余 Lot_release_RQT_w = {‘L1’: 1, ‘L2’: 1, ‘L3’: 1} # 初始Q time是否存在 Loop_QTime = {(‘L1’, ‘O1’, ‘O2’): 2,(‘L2’, ‘O1’, ‘O2’): 2,(‘L3’, ‘O1’, ‘O2’): 2,(‘L1’, ‘O2’, ‘O3’): 2,(‘L2’, ‘O2’, ‘O3’): 2,(‘L3’, ‘O2’, ‘O3’): 2,(‘L1’, ‘O1’, ‘O3’): 2,(‘L2’, ‘O1’, ‘O3’): 2,(‘L3’, ‘O1’, ‘O3’): 2,} # //lot loop内的 Q time// # Lot l 在第o step到第o· step的Q time Loop_qt = {(‘L1’, ‘O1’, ‘O2’): 1,(‘L2’, ‘O1’, ‘O2’): 1,(‘L3’, ‘O1’, ‘O2’): 1,(‘L1’, ‘O2’, ‘O3’): 1,(‘L2’, ‘O2’, ‘O3’): 1,(‘L3’, ‘O2’, ‘O3’): 1,(‘L1’, ‘O1’, ‘O3’): 1,(‘L2’, ‘O1’, ‘O3’): 1,(‘L3’, ‘O1’, ‘O3’): 1,} # Lot l 在第o step到第o· step是否有Q time,有Q time则为1,反之为0 Last_Operation_Machine_SD_PM_Start_time = {‘M1’: 98, ‘M2’: 99, ‘M3’: 999, ‘M4’: 999, ‘M5’: 2, ‘M6’: 13} # Machine m 在t时间开始SD_PM Last_Operation_Machine_SD_PM_End_time = {‘M1’: 99, ‘M2’: 100, ‘M3’: 1000, ‘M4’: 1000, ‘M5’: 3, ‘M6’: 15} # Machine m 在t时间结束SD_PM N = 1e6 # 大数 以上数据为代码模型的入参,请整合数据并输出代码

# wpa_supplicant -d -i wlan0 -c /tmp/wifi.conf wpa_supplicant v2.10 random: Trying to read entropy from /dev/random Successfully initialized wpa_supplicant Initializing interface 'wlan0' conf '/tmp/wifi.conf' driver 'default' ctrl_interface 'N/A' bridge 'N/A' Configuration file '/tmp/wifi.conf' -> '/tmp/wifi.conf' Reading configuration file '/tmp/wifi.conf' nl80211: Supported cipher 00-0f-ac:1 nl80211: Supported cipher 00-0f-ac:5 nl80211: Supported cipher 00-0f-ac:2 nl80211: Supported cipher 00-0f-ac:4 nl80211: Supported cipher 00-0f-ac:6 nl80211: Using driver-based off-channel TX nl80211: key_mgmt=0xd0f enc=0x10f auth=0x7 flags=0x800d0c0 rrm_flags=0x0 probe_resp_offloads=0x0 max_stations=0 max_remain_on_chan=5000 max_scan_ssids=9 nl80211: interface wlan0 in phy phy0 nl80211: Set mode ifindex 2 iftype 2 (STATION) nl80211: Subscribe to mgmt frames with non-AP handle 0x56ce68 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x56ce68 match=0801 multicast=0 nl80211: Register frame command failed (type=208): ret=-114 (Operation already in progress) nl80211: Register frame match - hexdump(len=2): 08 01 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x56ce68 match=06 multicast=0 nl80211: Register frame command failed (type=208): ret=-114 (Operation already in progress) nl80211: Register frame match - hexdump(len=1): 06 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x56ce68 match=0a07 multicast=0 nl80211: Register frame command failed (type=208): ret=-114 (Operation already in progress) nl80211: Register frame match - hexdump(len=2): 0a 07 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x56ce68 match=0a11 multicast=0 nl80211: Register frame command failed (type=208): ret=-114 (Operation already in progress) nl80211: Register frame match - hexdump(len=2): 0a 11 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x56ce68 match=1101 multicast=0 nl80211: Register frame command failed (type=208): ret=-114 (Operation already in progress) nl80211: Register frame match - hexdump(len=2): 11 01 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x56ce68 match=1102 multicast=0 nl80211: Register frame command failed (type=208): ret=-114 (Operation already in progress) nl80211: Register frame match - hexdump(len=2): 11 02 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x56ce68 match=0505 multicast=0 nl80211: Register frame command failed (type=208): ret=-114 (Operation already in progress) nl80211: Register frame match - hexdump(len=2): 05 05 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x56ce68 match=0500 multicast=0 nl80211: Register frame command failed (type=208): ret=-114 (Operation already in progress) nl80211: Register frame match - hexdump(len=2): 05 00 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x56ce68 match=1301 multicast=0 nl80211: Register frame command failed (type=208): ret=-114 (Operation already in progress) nl80211: Register frame match - hexdump(len=2): 13 01 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x56ce68 match=1305 multicast=0 nl80211: Register frame command failed (type=208): ret=-114 (Operation already in progress) nl80211: Register frame match - hexdump(len=2): 13 05 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x56ce68 match=7e506f9a1a multicast=0 nl80211: Register frame command failed (type=208): ret=-114 (Operation already in progress) nl80211: Register frame match - hexdump(len=5): 7e 50 6f 9a 1a nl80211: Failed to register Action frame processing - ignore for now rfkill: initial event: idx=0 type=1 op=0 soft=0 hard=0 netlink: Operstate: ifindex=2 linkmode=1 (userspace-control), operstate=5 (IF_OPER_DORMANT) Add interface wlan0 to a new radio phy0 nl80211: Regulatory information - country=00 nl80211: 2402-2472 @ 40 MHz 20 mBm nl80211: 2457-2482 @ 20 MHz 20 mBm (no IR) nl80211: 2474-2494 @ 20 MHz 20 mBm (no OFDM) (no IR) nl80211: 5170-5250 @ 80 MHz 20 mBm (no IR) nl80211: 5250-5330 @ 80 MHz 20 mBm (DFS) (no IR) nl80211: 5490-5730 @ 160 MHz 20 mBm (DFS) (no IR) nl80211: 5735-5835 @ 80 MHz 20 mBm (no IR) nl80211: 57240-63720 @ 2160 MHz 0 mBm nl80211: Added 802.11b mode based on 802.11g information nl80211: Mode IEEE 802.11g: 2412 2417 2422 2427 2432 2437 2442 2447 2452 2457 2462 2467[NO_IR] 2472[NO_IR] 2484[DISABLED] nl80211: Mode IEEE 802.11b: 2412 2417 2422 2427 2432 2437 2442 2447 2452 2457 2462 2467[NO_IR] 2472[NO_IR] 2484[DISABLED] wlan0: Own MAC address: cc:b8:5e:f5:a6:86 wpa_driver_nl80211_set_key: ifindex=2 (wlan0) alg=0 addr=(nil) key_idx=0 set_tx=0 seq_len=0 key_len=0 key_flag=0x10 nl80211: DEL_KEY broadcast key wpa_driver_nl80211_set_key: ifindex=2 (wlan0) alg=0 addr=(nil) key_idx=1 set_tx=0 seq_len=0 key_len=0 key_flag=0x10 nl80211: DEL_KEY broadcast key wpa_driver_nl80211_set_key: ifindex=2 (wlan0) alg=0 addr=(nil) key_idx=2 set_tx=0 seq_len=0 key_len=0 key_flag=0x10 nl80211: DEL_KEY broadcast key wpa_driver_nl80211_set_key: ifindex=2 (wlan0) alg=0 addr=(nil) key_idx=3 set_tx=0 seq_len=0 key_len=0 key_flag=0x10 nl80211: DEL_KEY broadcast key

# [ 33.344784] rtl8723bs: acquire FW from file:rtlwifi/rtl8723bs_nic.bin cat > /tmp/wpa.conf <<EOF > network={ > ssid="Xiaomi_6E67" > psk="15022688" > key_mgmt=WPA-PSK > proto=RSN # 强制使用WPA2 > pairwise=CCMP # 强制AES加密 > group=CCMP > scan_ssid=1 # 扫描隐藏网络 > freq_list=2427 # 指定2.4GHz频段 > } > EOF # wpa_supplicant -d -Dnl80211 -iwlan0 -c/tmp/wpa.conf wpa_supplicant v2.10 random: Trying to read entropy from /dev/random Successfully initialized wpa_supplicant Initializing interface 'wlan0' conf '/tmp/wpa.conf' driver 'nl80211' ctrl_interface 'N/A' bridge 'N/A' Configuration file '/tmp/wpa.conf' -> '/tmp/wpa.conf' Reading configuration file '/tmp/wpa.conf' Priority group 0 id=0 ssid='Xiaomi_6E67' nl80211: Supported cipher 00-0f-ac:1 nl80211: Supported cipher 00-0f-ac:5 nl80211: Supported cipher 00-0f-ac:2 nl80211: Supported cipher 00-0f-ac:4 nl80211: Supported cipher 00-0f-ac:6 nl80211: Using driver-based off-channel TX nl80211: key_mgmt=0xd0f enc=0x10f auth=0x7 flags=0x800d0c0 rrm_flags=0x0 probe_resp_offloads=0x0 max_stations=0 max_remain_on_chan=5000 max_scan_ssids=9 nl80211: interface wlan0 in phy phy0 nl80211: Set mode ifindex 2 iftype 2 (STATION) nl80211: Subscribe to mgmt frames with non-AP handle 0x53cf78 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x53cf78 match=0801 multicast=0 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x53cf78 match=06 multicast=0 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x53cf78 match=0a07 multicast=0 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x53cf78 match=0a11 multicast=0 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x53cf78 match=1101 multicast=0 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x53cf78 match=1102 multicast=0 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x53cf78 match=0505 multicast=0 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x53cf78 match=0500 multicast=0 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x53cf78 match=1301 multicast=0 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x53cf78 match=1305 multicast=0 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x53cf78 match=7e506f9a1a multicast=0 rfkill: initial event: idx=0 type=1 op=0 soft=0 hard=0 netlink: Operstate: ifindex=2 linkmode=1 (userspace-control), operstate=5 (IF_OPER_DORMANT) Add interface wlan0 to a new radio phy0 nl80211: Regulatory information - country=00 nl80211: 2402-2472 @ 40 MHz 20 mBm nl80211: 2457-2482 @ 20 MHz 20 mBm (no IR) nl80211: 2474-2494 @ 20 MHz 20 mBm (no OFDM) (no IR) nl80211: 5170-5250 @ 80 MHz 20 mBm (no IR) nl80211: 5250-5330 @ 80 MHz 20 mBm (DFS) (no IR) nl80211: 5490-5730 @ 160 MHz 20 mBm (DFS) (no IR) nl80211: 5735-5835 @ 80 MHz 20 mBm (no IR) nl80211: 57240-63720 @ 2160 MHz 0 mBm nl80211: Added 802.11b mode based on 802.11g information nl80211: Mode IEEE 802.11g: 2412 2417 2422 2427 2432 2437 2442 2447 2452 2457 2462 2467 2472 2484[DISABLED] nl80211: Mode IEEE 802.11b: 2412 2417 2422 2427 2432 2437 2442 2447 2452 2457 2462 2467 2472 2484[DISABLED] wlan0: Own MAC address: cc:b8:5e:f5:a6:86 wpa_driver_nl80211_set_key: ifindex=2 (wlan0) alg=0 addr=(nil) key_idx=0 set_tx=0 seq_len=0 key_len=0 key_flag=0x10 nl80211: DEL_KEY broadcast key wpa_driver_nl80211_set_key: ifindex=2 (wlan0) alg=0 addr=(nil) key_idx=1 set_tx=0 seq_len=0 key_len=0 key_flag=0x10 nl80211: DEL_KEY broadcast key wpa_driver_nl80211_set_key: ifindex=2 (wlan0) alg=0 addr=(nil) key_idx=2 set_tx=0 seq_len=0 key_len=0 key_flag=0x10 nl80211: DEL_KEY broadcast key wpa_driver_nl80211_set_key: ifindex=2 (wlan0) alg=0 addr=(nil) key_idx=3 set_tx=0 seq_len=0 key_len=0 key_flag=0x10 nl80211: DEL_KEY broadcast key wpa_driver_nl80211_set_key: ifindex=2 (wlan0) alg=0 addr=(nil) key_idx=4 set_tx=0 seq_len=0 key_len=0 key_flag=0x10 nl80211: DEL_KEY broadcast key wpa_driver_nl80211_set_key: ifindex=2 (wlan0) alg=0 addr=(nil) key_idx=5 set_tx=0 seq_len=0 key_len=0 key_flag=0x10 nl80211: DEL_KEY broadcast key wlan0: RSN: flushing PMKID list in the driver nl80211: Flush PMKIDs wlan0: Setting scan request: 0.100000 sec TDLS: TDLS operation not supported by driver TDLS: Driver uses internal link setup TDLS: Driver does not support TDLS channel switching wlan0: Added interface wlan0 wlan0: State: DISCONNECTED -> DISCONNECTED nl80211: Set wlan0 operstate 0->0 (DORMANT) netlink: Operstate: ifindex=2 linkmode=-1 (no change), operstate=5 (IF_OPER_DORMANT) nl80211: Skip set_supp_port(unauthorized) while not associated random: Got 20/20 bytes from /dev/random RTM_NEWLINK: ifi_index=2 ifname=wlan0 operstate=2 linkmode=1 ifi_family=0 ifi_flags=0x1003 ([UP]) wlan0: State: DISCONNECTED -> SCANNING Scan SSID - hexdump_ascii(len=11): 58 69 61 6f 6d 69 5f 36 45 36 37 Xiaomi_6E67 wlan0: Starting AP scan for wildcard SSID wlan0: Add radio work 'scan'@0x53f718 wlan0: First radio work item in the queue - schedule start immediately wlan0: Starting radio work 'scan'@0x53f718 after 0.000095 second wait wlan0: nl80211: scan request Scan requested (ret=0) - scan timeout 10 seconds nl80211: Drv Event 33 (NL80211_CMD_TRIGGER_SCAN) received for wlan0 wlan0: nl80211: Scan trigger wlan0: Event SCAN_STARTED (47) received wlan0: Own scan request started a scan in 0.000210 seconds RTM_NEWLINK: ifi_index=2 ifname=wlan0 wext ifi_family=0 ifi_flags=0x1003 ([UP]) nl80211: Drv Event 34 (NL80211_CMD_NEW_SCAN_RESULTS) received for wlan0 wlan0: nl80211: New scan results available nl80211: Scan probed for SSID 'Xiaomi_6E67' nl80211: Scan probed for SSID '' nl80211: Scan included frequencies: 2412 2417 2422 2427 2432 2437 2442 2447 2452 2457 2462 2467 2472 wlan0: Event SCAN_RESULTS (3) received wlan0: Scan completed in 1.536741 seconds nl80211: Received scan results (1 BSSes) wlan0: BSS: Start scan result update 1 wlan0: BSS: Add new id 0 BSSID cc:d8:43:81:b9:9e SSID 'Xiaomi_6E67' freq 2432 BSS: last_scan_res_used=1/32 wlan0: New scan results available (own=1 ext=0) wlan0: Radio work 'scan'@0x53f718 done in 1.541366 seconds wlan0: radio_work_free('scan'@0x53f718): num_active_works --> 0 wlan0: Selecting BSS from priority group 0 wlan0: 0: cc:d8:43:81:b9:9e ssid='Xiaomi_6E67' wpa_ie_len=0 rsn_ie_len=20 caps=0x1431 level=-66 freq=2432 wps wlan0: selected based on RSN IE wlan0: skip - frequency not allowed wlan0: No suitable network found wlan0: Setting scan request: 5.000000 sec Scan SSID - hexdump_ascii(len=11): 58 69 61 6f 6d 69 5f 36 45 36 37 Xiaomi_6E67 wlan0: Starting AP scan for wildcard SSID wlan0: Add radio work 'scan'@0x5404d8 wlan0: First radio work item in the queue - schedule start immediately wlan0: Starting radio work 'scan'@0x5404d8 after 0.000087 second wait wlan0: nl80211: scan request Scan requested (ret=0) - scan timeout 30 seconds nl80211: Drv Event 33 (NL80211_CMD_TRIGGER_SCAN) received for wlan0 wlan0: nl80211: Scan trigger wlan0: Event SCAN_STARTED (47) received wlan0: Own scan request started a scan in 0.000248 seconds RTM_NEWLINK: ifi_index=2 ifname=wlan0 wext ifi_family=0 ifi_flags=0x1003 ([UP]) nl80211: Drv Event 34 (NL80211_CMD_NEW_SCAN_RESULTS) received for wlan0 wlan0: nl80211: New scan results available nl80211: Scan probed for SSID 'Xiaomi_6E67' nl80211: Scan probed for SSID '' nl80211: Scan included frequencies: 2412 2417 2422 2427 2432 2437 2442 2447 2452 2457 2462 2467 2472 wlan0: Event SCAN_RESULTS (3) received wlan0: Scan completed in 1.761073 seconds nl80211: Received scan results (1 BSSes) wlan0: BSS: Start scan result update 2 BSS: last_scan_res_used=1/32 wlan0: New scan results available (own=1 ext=0) wlan0: Radio work 'scan'@0x5404d8 done in 2.204339 seconds wlan0: radio_work_free('scan'@0x5404d8): num_active_works --> 0 wlan0: Selecting BSS from priority group 0 wlan0: 0: cc:d8:43:81:b9:9e ssid='Xiaomi_6E67' wpa_ie_len=0 rsn_ie_len=20 caps=0x1431 level=-66 freq=2432 wps wlan0: selected based on RSN IE wlan0: skip - frequency not allowed wlan0: No suitable network found wlan0: Setting scan request: 5.000000 sec journalctl -f | grep -E 'wpa_supplicant|rtl8723bs' Scan SSID - hexdump_ascii(len=11): 58 69 61 6f 6d 69 5f 36 45 36 37 Xiaomi_6E67 wlan0: Starting AP scan for wildcard SSID wlan0: Add radio work 'scan'@0x541ff0 wlan0: First radio work item in the queue - schedule start immediately wlan0: Starting radio work 'scan'@0x541ff0 after 0.000076 second wait wlan0: nl80211: scan request Scan requested (ret=0) - scan timeout 30 seconds

void updateTraj(const VelocitySmoothing *predictor__Inport_1, VelocitySmoothing * _predictor_, DW_updateTraj *localDW) { Trajectory trajNonVirtual_BusCreator1; Trajectory trajNonVirtual_BusCreator1_f1; VelocitySmoothing predictor_i0; VelocitySmoothing predictor_t2; float t1; float t_remain; if (localDW->_local_time_IC_LOADING != 0) { localDW->_local_timeInter = predictor__Inport_1->_local_time; } t1 = fminf(localDW->_local_timeInter, predictor__Inport_1->_T1); t_remain = localDW->_local_timeInter - t1; evaluatePoly(predictor__Inport_1->_max_jerk, predictor__Inport_1->_state_init.a, predictor__Inport_1->_state_init.v, predictor__Inport_1->_state_init.x, t1, predictor__Inport_1->_direction, &trajNonVirtual_BusCreator1); predictor_i0 = *predictor__Inport_1; predictor_i0._state = trajNonVirtual_BusCreator1; if (t_remain > 0.0F) { t1 = fminf(predictor__Inport_1->_T2, t_remain); evaluatePoly(cFloat0, trajNonVirtual_BusCreator1.a, trajNonVirtual_BusCreator1.v, trajNonVirtual_BusCreator1.x, t1, cInt0, &trajNonVirtual_BusCreator1_f1); predictor_t2 = predictor_i0; predictor_t2._state = trajNonVirtual_BusCreator1_f1; t1 = t_remain - t1; } else { IfActionSubsystem1(&predictor_i0, t_remain, &predictor_t2, &t1); } if (t1 > 0.0F) { t_remain = fminf(predictor_t2._T3, t1); evaluatePoly(predictor_t2._max_jerk, predictor_t2._state.a, predictor_t2._state.v, predictor_t2._state.x, t_remain, -predictor_t2._direction, &trajNonVirtual_BusCreator1); *_predictor_ = predictor_t2; _predictor_->_state = trajNonVirtual_BusCreator1; t_remain = t1 - t_remain; } else { IfActionSubsystem1(&predictor_t2, t1, _predictor_, &t_remain); } if (t_remain > 0.0F) { evaluatePoly(cFloat0, cFloat0, _predictor_->_state.v, _predictor_->_state.x, t_remain, cInt0, &trajNonVirtual_BusCreator1); _predictor_->_state = trajNonVirtual_BusCreator1; } }

# wpa_supplicant -d -Dnl80211 -c/tmp/wpa.conf -iwlan0 wpa_supplicant v2.10 random: Trying to read entropy from /dev/random Successfully initialized wpa_supplicant Initializing interface 'wlan0' conf '/tmp/wpa.conf' driver 'nl80211' ctrl_interface 'N/A' bridge 'N/A' Configuration file '/tmp/wpa.conf' -> '/tmp/wpa.conf' Reading configuration file '/tmp/wpa.conf' Priority group 0 id=0 ssid='Xiaomi_6E67' nl80211: Supported cipher 00-0f-ac:1 nl80211: Supported cipher 00-0f-ac:5 nl80211: Supported cipher 00-0f-ac:2 nl80211: Supported cipher 00-0f-ac:4 nl80211: Supported cipher 00-0f-ac:6 nl80211: Using driver-based off-channel TX nl80211: key_mgmt=0xd0f enc=0x10f auth=0x7 flags=0x800d0c0 rrm_flags=0x0 probe_resp_offloads=0x0 max_stations=0 max_remain_on_chan=5000 max_scan_ssids=9 nl80211: interface wlan0 in phy phy0 nl80211: Set mode ifindex 2 iftype 2 (STATION) nl80211: Subscribe to mgmt frames with non-AP handle 0x4aef78 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x4aef78 match=0801 multicast=0 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x4aef78 match=06 multicast=0 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x4aef78 match=0a07 multicast=0 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x4aef78 match=0a11 multicast=0 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x4aef78 match=1101 multicast=0 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x4aef78 match=1102 multicast=0 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x4aef78 match=0505 multicast=0 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x4aef78 match=0500 multicast=0 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x4aef78 match=1301 multicast=0 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x4aef78 match=1305 multicast=0 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x4aef78 match=7e506f9a1a multicast=0 rfkill: initial event: idx=0 type=1 op=0 soft=0 hard=0 netlink: Operstate: ifindex=2 linkmode=1 (userspace-control), operstate=5 (IF_OPER_DORMANT) Add interface wlan0 to a new radio phy0 nl80211: Regulatory information - country=00 nl80211: 2402-2472 @ 40 MHz 20 mBm nl80211: 2457-2482 @ 20 MHz 20 mBm (no IR) nl80211: 2474-2494 @ 20 MHz 20 mBm (no OFDM) (no IR) nl80211: 5170-5250 @ 80 MHz 20 mBm (no IR) nl80211: 5250-5330 @ 80 MHz 20 mBm (DFS) (no IR) nl80211: 5490-5730 @ 160 MHz 20 mBm (DFS) (no IR) nl80211: 5735-5835 @ 80 MHz 20 mBm (no IR) nl80211: 57240-63720 @ 2160 MHz 0 mBm nl80211: Added 802.11b mode based on 802.11g information nl80211: Mode IEEE 802.11g: 2412 2417 2422 2427 2432 2437 2442 2447 2452 2457 2462 2467 2472 2484[DISABLED] nl80211: Mode IEEE 802.11b: 2412 2417 2422 2427 2432 2437 2442 2447 2452 2457 2462 2467 2472 2484[DISABLED] wlan0: Own MAC address: cc:b8:5e:f5:a6:86 wpa_driver_nl80211_set_key: ifindex=2 (wlan0) alg=0 addr=(nil) key_idx=0 set_tx=0 seq_len=0 key_len=0 key_flag=0x10 nl80211: DEL_KEY broadcast key wpa_driver_nl80211_set_key: ifindex=2 (wlan0) alg=0 addr=(nil) key_idx=1 set_tx=0 seq_len=0 key_len=0 key_flag=0x10 nl80211: DEL_KEY broadcast key wpa_driver_nl80211_set_key: ifindex=2 (wlan0) alg=0 addr=(nil) key_idx=2 set_tx=0 seq_len=0 key_len=0 key_flag=0x10 nl80211: DEL_KEY broadcast key wpa_driver_nl80211_set_key: ifindex=2 (wlan0) alg=0 addr=(nil) key_idx=3 set_tx=0 seq_len=0 key_len=0 key_flag=0x10 nl80211: DEL_KEY broadcast key wpa_driver_nl80211_set_key: ifindex=2 (wlan0) alg=0 addr=(nil) key_idx=4 set_tx=0 seq_len=0 key_len=0 key_flag=0x10 nl80211: DEL_KEY broadcast key wpa_driver_nl80211_set_key: ifindex=2 (wlan0) alg=0 addr=(nil) key_idx=5 set_tx=0 seq_len=0 key_len=0 key_flag=0x10 nl80211: DEL_KEY broadcast key wlan0: RSN: flushing PMKID list in the driver nl80211: Flush PMKIDs wlan0: Setting scan request: 0.100000 sec TDLS: TDLS operation not supported by driver TDLS: Driver uses internal link setup TDLS: Driver does not support TDLS channel switching wlan0: Added interface wlan0 wlan0: State: DISCONNECTED -> DISCONNECTED nl80211: Set wlan0 operstate 0->0 (DORMANT) netlink: Operstate: ifindex=2 linkmode=-1 (no change), operstate=5 (IF_OPER_DORMANT) nl80211: Skip set_supp_port(unauthorized) while not associated random: Got 20/20 bytes from /dev/random RTM_NEWLINK: ifi_index=2 ifname=wlan0 operstate=2 linkmode=1 ifi_family=0 ifi_flags=0x1003 ([UP]) wlan0: State: DISCONNECTED -> SCANNING Scan SSID - hexdump_ascii(len=11): 58 69 61 6f 6d 69 5f 36 45 36 37 Xiaomi_6E67 wlan0: Starting AP scan for wildcard SSID wlan0: Add radio work 'scan'@0x4b1718 wlan0: First radio work item in the queue - schedule start immediately wlan0: Starting radio work 'scan'@0x4b1718 after 0.000069 second wait wlan0: nl80211: scan request Scan requested (ret=0) - scan timeout 10 seconds nl80211: Drv Event 33 (NL80211_CMD_TRIGGER_SCAN) received for wlan0 wlan0: nl80211: Scan trigger wlan0: Event SCAN_STARTED (47) received wlan0: Own scan request started a scan in 0.000224 seconds RTM_NEWLINK: ifi_index=2 ifname=wlan0 wext ifi_family=0 ifi_flags=0x1003 ([UP]) nl80211: Drv Event 34 (NL80211_CMD_NEW_SCAN_RESULTS) received for wlan0 wlan0: nl80211: New scan results available nl80211: Scan probed for SSID 'Xiaomi_6E67' nl80211: Scan probed for SSID '' nl80211: Scan included frequencies: 2412 2417 2422 2427 2432 2437 2442 2447 2452 2457 2462 2467 2472 wlan0: Event SCAN_RESULTS (3) received wlan0: Scan completed in 1.758358 seconds nl80211: Received scan results (0 BSSes) wlan0: BSS: Start scan result update 1 BSS: last_scan_res_used=0/0 wlan0: New scan results available (own=1 ext=0) wlan0: Radio work 'scan'@0x4b1718 done in 2.200207 seconds wlan0: radio_work_free('scan'@0x4b1718): num_active_works --> 0 wlan0: No suitable network found wlan0: Setting scan request: 5.000000 sec Scan SSID - hexdump_ascii(len=11): 58 69 61 6f 6d 69 5f 36 45 36 37 Xiaomi_6E67 wlan0: Starting AP scan for wildcard SSID wlan0: Add radio work 'scan'@0x4b19d8 wlan0: First radio work item in the queue - schedule start immediately wlan0: Starting radio work 'scan'@0x4b19d8 after 0.000073 second wait wlan0: nl80211: scan request Scan requested (ret=0) - scan timeout 30 seconds nl80211: Drv Event 33 (NL80211_CMD_TRIGGER_SCAN) received for wlan0 wlan0: nl80211: Scan trigger wlan0: Event SCAN_STARTED (47) received wlan0: Own scan request started a scan in 0.000534 seconds RTM_NEWLINK: ifi_index=2 ifname=wlan0 wext ifi_family=0 ifi_flags=0x1003 ([UP]) nl80211: Drv Event 34 (NL80211_CMD_NEW_SCAN_RESULTS) received for wlan0 wlan0: nl80211: New scan results available nl80211: Scan probed for SSID 'Xiaomi_6E67' nl80211: Scan probed for SSID '' nl80211: Scan included frequencies: 2412 2417 2422 2427 2432 2437 2442 2447 2452 2457 2462 2467 2472 wlan0: Event SCAN_RESULTS (3) received wlan0: Scan completed in 1.760674 seconds nl80211: Received scan results (1 BSSes) wlan0: BSS: Start scan result update 2 wlan0: BSS: Add new id 0 BSSID cc:d8:43:81:b9:9e SSID 'Xiaomi_6E67' freq 2427 BSS: last_scan_res_used=1/32 wlan0: New scan results available (own=1 ext=0) wlan0: Radio work 'scan'@0x4b19d8 done in 2.204537 seconds wlan0: radio_work_free('scan'@0x4b19d8): num_active_works --> 0 wlan0: Selecting BSS from priority group 0 wlan0: 0: cc:d8:43:81:b9:9e ssid='Xiaomi_6E67' wpa_ie_len=0 rsn_ie_len=20 caps=0x1431 level=-59 freq=2427 wps wlan0: selected based on RSN IE wlan0: selected BSS cc:d8:43:81:b9:9e ssid='Xiaomi_6E67' wlan0: Considering connect request: reassociate: 0 selected: cc:d8:43:81:b9:9e bssid: 00:00:00:00:00:00 pending: 00:00:00:00:00:00 wpa_state: SCANNING ssid=0x4af4c0 current_ssid=(nil) wlan0: Request association with cc:d8:43:81:b9:9e TDLS: TDLS is allowed in the target BSS TDLS: TDLS channel switch allowed in the target BSS wlan0: No ongoing scan/p2p-scan found to abort wlan0: Add radio work 'connect'@0x4b3c38 wlan0: First radio work item in the queue - schedule start immediately wlan0: Starting radio work 'connect'@0x4b3c38 after 0.000096 second wait wlan0: WPA: clearing own WPA/RSN IE wlan0: RSN: clearing own RSNXE wlan0: RSN: using IEEE 802.11i/D9.0 wlan0: WPA: Selected cipher suites: group 16 pairwise 16 key_mgmt 2 proto 2 wlan0: WPA: Selected mgmt group cipher 32 wlan0: WPA: clearing AP WPA IE WPA: set AP RSN IE - hexdump(len=22): 30 14 01 00 00 0f ac 04 01 00 00 0f ac 04 01 00 00 0f ac 02 00 00 wlan0: WPA: clearing AP RSNXE wlan0: WPA: AP group 0x10 network profile group 0x10; available group 0x10 wlan0: WPA: using GTK CCMP wlan0: WPA: AP pairwise 0x10 network profile pairwise 0x10; available pairwise 0x10 wlan0: WPA: using PTK CCMP wlan0: WPA: AP key_mgmt 0x2 network profile key_mgmt 0x2; available key_mgmt 0x2 wlan0: WPA: using KEY_MGMT WPA-PSK wlan0: WPA: AP mgmt_group_cipher 0x20 network profile mgmt_group_cipher 0x0; available mgmt_group_cipher 0x0 wlan0: WPA: not using MGMT group cipher WPA: Set own WPA IE default - hexdump(len=22): 30 14 01 00 00 0f ac 04 01 00 00 0f ac 04 01 00 00 0f ac 02 00 00 RSN: Set own RSNXE default - hexdump(len=0): WPA: Set PMK based on external data - hexdump(len=32): [REMOVED] wlan0: Automatic auth_alg selection: 0x1 Added supported operating classes IE - hexdump(len=6): 3b 04 51 51 53 54 wlan0: Trying to associate with cc:d8:43:81:b9:9e (SSID='Xiaomi_6E67' freq=2427 MHz) wlan0: Cancelling scan request wlan0: State: SCANNING -> ASSOCIATING nl80211: Set wlan0 operstate 0->0 (DORMANT) netlink: Operstate: ifindex=2 linkmode=-1 (no change), operstate=5 (IF_OPER_DORMANT) nl80211: Skip set_supp_port(unauthorized) while not associated Limit connection to BSSID cc:d8:43:81:b9:9e freq=2427 MHz based on scan results (bssid_set=0 wps=0) nl80211: Set mode ifindex 2 iftype 2 (STATION) nl80211: Unsubscribe mgmt frames handle 0x88c267f1 (mode change) nl80211: Subscribe to mgmt frames with non-AP handle 0x4aef78 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x4aef78 match=0801 multicast=0 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x4aef78 match=06 multicast=0 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x4aef78 match=0a07 multicast=0 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x4aef78 match=0a11 multicast=0 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x4aef78 match=1101 multicast=0 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x4aef78 match=1102 multicast=0 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x4aef78 match=0505 multicast=0 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x4aef78 match=0500 multicast=0 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x4aef78 match=1301 multicast=0 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x4aef78 match=1305 multicast=0 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x4aef78 match=7e506f9a1a multicast=0 nl80211: Connect (ifindex=2) * bssid=cc:d8:43:81:b9:9e * bssid_hint=cc:d8:43:81:b9:9e * freq=2427 * freq_hint=2427 * SSID=Xiaomi_6E67 * IEs - hexdump(len=41): 30 14 01 00 00 0f ac 04 01 00 00 0f ac 04 01 00 00 0f ac 02 00 00 7f 0b 00 00 00 00 00 00 40 00 00 00 20 3b 04 51 51 53 54 * WPA Versions 0x2 * pairwise=0xfac04 * group=0xfac04 * akm=0xfac02 * Auth Type 0 [ 517.151623] RTL8723BS: rtw_set_802_11_connect(wlan0) fw_state = 0x00000008 nl80211: Connect request send successfully wlan0: Setting authentication timeout: 10 sec 0 usec

修改import pandas as pd import numpy as np import os import time #1.参数设置 Kc = float(1.20) c = float(0.16) Im = float(0.003) WM = float(140) WUM = float(20) WLM = float(60) WDM = float(60) b = float(0.3) WU = float(10.0) WL = float(40.0) WD = float(60.0) # 结果存储列表 # results = [] # ====================== 核心功能函数 ====================== def calculate_evapotranspiration(P, E0, WU, WL, WD): """计算三层蒸发模型""" # 计算实际蒸散发能力 Ep = E0 * Kc # 1. 上层蒸发 EU = min(WU + P, Ep) # 上层最大蒸发量 new_WU = max(0, WU + P - EU) # 剩余蒸发能力 EL_remain = Ep - EU # 2. 下层蒸发 if WL > c * WLM: EL = min(EL_remain, WL) else: EL = min(c * EL_remain, WL) new_WL = max(0, WL - EL) # 3. 深层蒸发 ED_remain = EL_remain - EL ED = min(c * ED_remain, WD) new_WD = max(0, WD - ED) total_E = EU + EL + ED return total_E, new_WU, new_WL, new_WD def calculate_runoff(PE, WU, WL, WD): # 当前土壤总含水量 W = WU + WL + WD # 无有效降雨时返回零产流 if PE <= 0: return 0.0, WU, WL, WD # 计算张力水蓄水容量曲线参数 WMM = WM * (1 + b) # 最大蓄水容量 A = WMM * (1 - (1 - min(W / WM, 1.0)) ** (1 / (1 + b))) # 产流量计算 if PE + A < WMM: R = PE - (WM - W) + WM * (1 - (A + PE) / WMM) ** (1 + b) else: R = PE - (WM - W) R = max(R, 0) # 确保产流非负 # 更新土壤含水量 (考虑产流后的净入渗) net_infiltration = PE - R new_W = min(W + net_infiltration, WM) # 更新各层含水量 total_capacity = WUM + WLM + WDM new_WU = min(new_W * WUM / total_capacity, WUM) new_WL = min(new_W * WLM / total_capacity, WLM) new_WD = min(new_W - new_WU - new_WL, WDM) return R, new_WU, new_WL, new_WD # ====================== 数据准备 ====================== # 创建DataFrame data = pd.read_excel(r"C:\Users\80401\Desktop\SHUJU2.xlsx") P = data['P'].values # 转换为 NumPy 数组 E0 = data['E0'].values # 预处理:划分不透水面积和透水面积 P_im = P * Im # 不透水面积降雨 P_soil = P * (1 - Im) # 透水面积降雨 df = pd.DataFrame(data) # ====================== 模拟计算 ====================== # 初始化状态变量 current_WU = WU current_WL = WL current_WD = WD # 存储结果 results = { 'PE': [], 'R': [], 'WU': [], 'WL': [], 'WD': [] } # 主循环 for i, row in df.iterrows(): # 获取当前时段的原始降雨和蒸发能力 current_P_total = row['P'] # 原始总降雨量 current_E0 = row['E0'] # 划分不透水面积和透水面积 current_P_im = P_im[i] # 不透水面积降雨 current_P_soil = P_soil[i] # 透水面积降雨 # 计算实际蒸发能力 current_Ep = current_E0 * Kc # 三层蒸散发计算 (使用透水面积降雨) E, new_WU, new_WL, new_WD = calculate_evapotranspiration( current_P_soil, current_E0, current_WU, current_WL, current_WD ) PE = P_soil - E # 产流计算 (仅透水面积) R_soil, updated_WU, updated_WL, updated_WD = calculate_runoff( PE, new_WU, new_WL, new_WD ) # 总产流 = 透水面积产流 + 不透水面积直接径流 R_total = R_soil + current_P_im # 更新土壤含水量 (仅透水面积部分) current_WU, current_WL, current_WD = updated_WU, updated_WL, updated_WD # 记录结果 results.append({ 'Period': i + 1, 'P_total': round(current_P_total, 3), 'P_im': round(current_P_im, 3), 'P_soil': round(current_P_soil, 3), 'E0': round(current_E0, 2), 'Ep': round(current_Ep, 2), 'EU': round(EU, 3), 'EL': round(EL, 3), 'ED': round(ED, 3), 'E': round(E, 3), 'PE': round(PE, 3), 'R_soil': round(R_soil, 3), 'R_im': round(current_P_im, 3), 'R_total': round(R_total, 3), 'WU': round(new_WU, 3), 'WL': round(new_WL, 3), 'WD': round(new_WD, 3), 'Total_W': round(new_WU + new_WL + new_WD, 3) }) # 更新状态变量 WU, WL, WD = new_WU, new_WL, new_WD # 合并结果到DataFrame for key, values in results.items(): df[key] = values # ====================== 结果保存 ====================== # 创建输出目录 output_dir = os.path.expanduser('~/Desktop/KESHE_results') os.makedirs(output_dir, exist_ok=True) # 保存结果到Excel output_path = os.path.join(output_dir, 'KESHE_simulation_results.xlsx') df.to_excel(output_path, index=False) print(f"模拟结果已保存到: {output_path}")

最新推荐

recommend-type

学习一下二维码相关的,集成下 zxing.zip

学习一下二维码相关的,集成下 zxing.zip
recommend-type

生成二维码,可以带企业logo.zip

生成二维码,可以带企业logo.zip
recommend-type

帝国CMS7.5仿完美游戏台游戏视频网站模板下载.zip

本帝国cms模板由网络收集,整理升级为帝国CMS7.5,去除图片附件BUG和部分广告,已测试完美无错。 非常适合游戏视频网站使用,视频源采集的优酷,采集目标站以关闭,删除原火车头采集规则。 自带几万条测试数据,几百M测试图片,如何不需要可以到后台批量删除即可。
recommend-type

Hyperledger Fabric v2与Accord Project Cicero智能合约开发指南

标题和描述中提到的“hlf-cicero-contract:Accord Project Cicero与Hyperledger Fabric v2签约”以及“半西约合同”暗示了与智能合约和区块链技术相关的知识点。下面详细说明这些知识点: ### 智能合约与区块链技术 智能合约是一套运行在区块链上的程序,当合约条款被触发时,合约会自动执行相应的操作。这种自动执行的特点使得智能合约特别适合于执行多方之间的可信交易,它能减少或消除中介服务的需要,从而降低交易成本并提高效率。 区块链技术是一种分布式账本技术,通过加密算法和共识机制保证了交易数据的不可篡改性和透明性。区块链上的每一笔交易都会被网络中的多个节点验证并记录,确保了交易记录的安全性。 ### Hyperledger Fabric v2 Hyperledger Fabric 是由Linux基金会托管的一个开源项目,它是企业级区块链框架,旨在为商业应用提供安全、模块化、可扩展的区块链平台。Hyperledger Fabric v2.2是该框架的一个版本。 Hyperledger Fabric v2支持链码(Chaincode)概念,链码是部署在Hyperledger Fabric网络上的应用程序,它可以被用来实现各种智能合约逻辑。链码在运行时与网络中的背书节点和排序服务交互,负责验证、执行交易以及维护账本状态。 ### Accord Project Cicero Accord Project Cicero 是一个开源的智能合同模板和执行引擎,它允许开发者使用自然语言来定义合同条款,并将这些合同转换为可以在区块链上执行的智能合约。CiceroMark是基于Markdown格式的一种扩展,它允许在文档中嵌入智能合约逻辑。 通过Accord Project Cicero,可以创建出易于理解、可执行的智能合约。这些合同可以与Hyperledger Fabric集成,利用其提供的安全、透明的区块链网络环境,从而使得合同条款的执行更加可靠。 ### 智能合约的安装与部署 描述中提到了“安装”和“启动”的步骤,这意味着为了使用HLF v2.2和Accord Project Cicero,需要先进行一系列的配置和安装工作。这通常包括设置环境变量(例如HLF_INSTALL_DIR)、安装区块链网络(Test-Net)以及安装其他必需的软件工具(如jq)。 jq是一个轻量级且灵活的命令行JSON处理器,常用于处理JSON数据。在区块链项目中,jq可以帮助开发者处理链码或智能合约的数据,特别是在与网络节点交互时。 ### JavaScript 标签 标签“JavaScript”表明本项目或相关文档中会涉及到JavaScript编程语言。Hyperledger Fabric v2支持多种智能合约语言,其中JavaScript是一个广泛使用的选项。JavaScript在编写链码时提供了灵活的语法和强大的库支持,是进行区块链开发的一个流行选择。 ### 文件结构 文件名称列表“hlf-cicero-contract-master”暗示这是一个包含所有相关文件和资源的项目源代码目录。这个名称通常表明开发者可以从该目录开始探索、安装和配置项目的所有组件。 ### 综合知识点 1. 智能合约与区块链技术可以自动化执行多方面可信交易,降低交易成本并提高效率。 2. Hyperledger Fabric v2为企业提供一个安全、模块化、可扩展的区块链平台。 3. Accord Project Cicero结合Markdown格式的CiceroMark,将自然语言定义的合同条款转换为可执行的智能合约。 4. 智能合约的安装和部署涉及到一系列配置步骤,包括设置环境变量、安装必要的软件工具等。 5. JavaScript是编写智能合约的流行语言之一,为区块链开发提供灵活性和强大的库支持。 6. 项目文件结构表明从一个主目录可以探索和配置所有项目相关文件和资源。 以上是根据文件标题、描述、标签以及文件名称列表所提取的相关知识点。这些知识点对于理解Hyperledger Fabric v2和Accord Project Cicero在智能合约中的应用尤为重要。
recommend-type

深度神经网络优化技巧全解析

# 深度神经网络优化技巧全解析 ## 1 超越 Sigmoid 函数 在神经网络中,Sigmoid 函数曾被广泛使用,但它存在一些问题,如梯度消失。研究人员一直在寻找更好的激活函数,且不同的激活函数在不同场景下表现各异。 ### 1.1 ReLU 函数登场 如今,修正线性单元(ReLU)成为了 Sigmoid 的常用替代函数。与 Sigmoid 相比,ReLU 非常简单,以下是其 Python 实现: ```python def relu(z): if z <= 0: return 0 else: return z ``` ReLU 由两段直
recommend-type

什么是噪声功率密度

<think> 嗯,用户这次问的是噪声功率密度的定义,结合之前的系统指令和站内引用,需要给出清晰准确的中文解释。用户可能是电子工程或通信专业的学生,正在学习噪声相关的理论基础,也可能是工程师需要实际应用概念。从引用来[^1]看,用户对相位噪声的定义有基础认知,但需要系统梳理核心概念。 噪声功率密度最本质的定义应该是单位带宽内的噪声功率。引用[^2]提到电阻热噪声的例子很典型,50Ω电阻在300K环境下功率谱密度是定值(0.9nV/√Hz)²,这说明: 1. 它描述的是噪声功率随频率分布的密度 2. 与带宽强相关(带宽加倍则总功率加倍) 3. 单位通常用W/Hz或V²/Hz 维纳-辛钦定理(
recommend-type

Libshare: Salesforce的高效可重用模块集合

Salesforce是一个云基础的CRM平台,它允许用户构建定制应用程序来满足特定的业务需求。Apex是Salesforce平台上的一个强类型编程语言,用于开发复杂的业务逻辑,通过触发器、类和组件等实现。这些组件使得开发者可以更高效地构建应用程序和扩展Salesforce的功能。 在提到的"libshare:经过测试的Salesforce可重用模块"文件中,首先介绍了一个名为Libshare的工具包。这个工具包包含了一系列已经过测试的可重用模块,旨在简化和加速Salesforce应用程序的开发。 Libshare的各个组成部分的知识点如下: 1. 设置模块:在Salesforce应用程序中,应用程序设置的管理是必不可少的一部分。设置模块提供了一种简便的方式存储应用程序的设置,并提供了一个易用的API来与之交互。这样,开发者可以轻松地为不同的环境配置相同的设置,并且可以快速地访问和修改这些配置。 2. Fluent断言模块:断言是单元测试中的关键组成部分,它们用于验证代码在特定条件下是否表现预期。Fluent断言模块受到Java世界中Assertj的启发,提供了一种更流畅的方式来编写断言。通过这种断言方式,可以编写更易于阅读和维护的测试代码,提高开发效率和测试质量。 3. 秒表模块:在性能调优和效率测试中,记录方法的执行时间是常见的需求。秒表模块为开发者提供了一种方便的方式来记录总时间,并跟踪每种方法所花费的时间。这使得开发者能够识别瓶颈并优化代码性能。 4. JsonMapper模块:随着Web API的广泛应用,JSON数据格式在应用程序开发中扮演了重要角色。JsonMapper模块为开发者提供了一个更高级别的抽象,用于读取和创建JSON内容。这能够大幅简化与JSON数据交互的代码,并提高开发效率。 5. utils模块:在软件开发过程中,经常会遇到需要重复实现一些功能的情况,这些功能可能是通用的,例如日期处理、字符串操作等。utils模块提供了一系列已经编写好的实用工具函数,可以用于节省时间,避免重复劳动,提高开发效率。 6. 记录器模块:记录器通常用于记录应用程序的运行日志,以便于问题诊断和性能监控。系统提供的System.debug功能虽然强大,但在大型应用中,统一的记录器包装器可以使得日志管理更加高效。记录器模块支持记录器名称,并且可以对日志进行适当的封装。 7. App Logger模块:App Logger模块扩展了记录器模块的功能,它允许开发者将日志语句保存到一个精心设计的App Log对象中。此外,App Logger模块支持存储长达56k字符的日志内容,这对于复杂应用的监控和调试非常有用。 8. 应用程序任务模块:在处理异步作业时,例如批量数据处理或定时任务,需要有一个框架来管理和跟踪这些任务。应用程序任务模块提供了一个框架,用于处理可排队的作业,并能够跟踪这些任务的执行情况。 通过Libshare提供的这些模块,Salesforce的开发者能够减少开发工作量,加快开发速度,并提高代码质量。这些模块能够帮助开发者避免重复的“造轮子”工作,专注于核心业务逻辑的实现。同时,由于Libshare作为托管程序包发布,开发者无需担心代码的维护和管理,只需将其添加到自己的Salesforce组织中即可使用。 Libshare的发布也强调了可重用性的重要性,这是软件工程领域中长期提倡的一个原则。通过使用可重用的组件,开发者能够遵循DRY(Don't Repeat Yourself)原则,从而减少代码的冗余,提高生产效率,同时降低因重复编写相同代码而导致错误的风险。 总之,Libshare是一个有价值的资源,对于那些希望在Salesforce平台上快速构建高效、可靠应用程序的开发者来说,这些预置的、经过测试的模块无疑是一个强大的助手。
recommend-type

机器学习技术要点与应用解析

# 机器学习技术要点与应用解析 ## 1. 机器学习基础概念 ### 1.1 数据类型与表示 在编程中,数据类型起着关键作用。Python 具有动态类型特性,允许变量在运行时改变类型。常见的数据类型转换函数包括 `bool()`、`int()`、`str()` 等。例如,`bool()` 函数可将值转换为布尔类型,`int()` 用于将值转换为整数类型。数据类型还包括列表(`lists`)、字典(`dictionaries`)、元组(`tuples`)等集合类型,其中列表使用方括号 `[]` 表示,字典使用花括号 `{}` 表示,元组使用圆括号 `()` 表示。 ### 1.2 变量与命名
recommend-type

点击歌曲没反应

<think> 我们之前已经讨论了如何将音频文件显示在QListView中,并希望实现点击播放。现在遇到的问题是点击列表项没有反应。 原因分析: 1. 我们没有将点击信号连接到播放槽函数。 2. 播放列表(QMediaPlaylist)可能没有正确添加媒体。 3. 媒体路径可能不正确。 解决方案: 按照之前的思路,我们需要做以下几步: 步骤1:确保已经创建了QMediaPlayer和QMediaPlaylist对象,并且播放器设置了播放列表。 步骤2:将QListView的点击信号(clicked)连接到自定义的槽函数,在该槽函数中设置播放列表的当前索引并播放。 步骤3:
recommend-type

SM-CNN-Torch: Torch实现短文本对排名的CNN模型

标题中提到的“SM-CNN-Torch”是一个深度学习框架Torch的实现版本,它基于Severyn和Moschitti在2015年SIGIR会议上发表的一篇论文所描述的卷积神经网络(CNN)模型。这篇论文的内容主要关注的是如何利用CNN对短文本对进行有效的排名,这一点对于问题回答(question-answering, QA)系统来说至关重要。实施该CNN模型的目标是为了更好地处理问答系统中的文本对比较问题,例如,在搜索引擎中确定哪些文档与用户的查询更加相关。 在描述中提到了如何使用该仓库中的代码。首先,用户需要安装Torch库,这是实现和运行SM-CNN-Torch模型的前提条件。接着,用户需要使用提供的脚本(fetch_and_preprocess.sh)下载并预处理GloVe(Global Vectors for Word Representation)字嵌入数据。这一数据集是预先训练好的词向量,能够将单词转换为连续的向量表示,这在深度学习模型中是处理文本的基本步骤。 在模型准备工作中,还需要注意的是Python版本,因为模型运行依赖于Python环境,建议的版本为2.7或更高版本。此外,描述中还提到了并行处理的线程数设置,这表明模型在运行过程中可能会涉及到并行计算,以加速计算过程。通过设置环境变量OMP_NUM_THREADS,可以指定并行计算时的线程数。 文件名称列表中的“SM-CNN-Torch-master”表示这是该仓库的主目录,包含了所有实现Severyn和Moschitti CNN模型的相关文件。 该存储库还包含了一些附加信息,例如,原始Torch实现已经被PyTorch版本所取代。PyTorch是Torch的一个分支,它提供了更多的功能和更易于使用的接口,对研究人员和开发者来说更加友好。此外,该仓库目前仅用于存档目的,这意味着原始的Torch代码不再被积极维护,而是作为一种历史记录保留下来。 标签“deep-learning”表明该项目是一个深度学习项目,所使用的模型是深度神经网络,特别是卷积神经网络。标签“question-answering”则直接指向了问题回答系统,这是深度学习的一个重要应用领域。标签“convolutional-neural-networks”指明了所使用的网络类型是卷积神经网络,它在图像处理和自然语言处理中都有广泛应用。而“Lua”标签则是因为Torch是用Lua语言编写的,尽管它通常与Python一起使用,但也有一个使用Lua的版本。 总的来说,SM-CNN-Torch是一个专门针对短文本对排名的深度学习模型的实现,它允许研究人员和开发者利用已经发表的研究成果来搭建和测试自己的模型,同时为了解其背后原理和实现细节提供了具体的代码和数据处理流程。