1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
| from dataclasses import dataclass from typing import List, Optional import time
""" L2++ IMS 新增功能需求框架
参考: - Stellantis-Wayve L2++ 合作 (2028目标) - Stellantis 全息投影信任专利 (2026-08) """
@dataclass class TakeoverRequest: """接管请求""" timestamp: float reason: str urgency: str time_to_takeover_s: float driver_state: str hmi_channel: str
class L2PlusPlusIMS: """L2++ IMS 系统""" def __init__(self): self.driver_state = 'alert' self.automation_level = 'L2++' self.takeover_buffer_s = 30 def assess_takeover_readiness(self, gaze_away_s: float, perclos: float, response_latency_s: float) -> dict: """ 评估驾驶员接管准备度 Args: gaze_away_s: 视线离开前方秒数 perclos: PERCLOS 值(%) response_latency_s: 对警告的响应延迟 """ attention_score = 100 if gaze_away_s > 3: attention_score -= min(40, (gaze_away_s - 3) * 8) if perclos > 15: attention_score -= min(30, (perclos - 15) * 2) if response_latency_s > 1: attention_score -= min(20, (response_latency_s - 1) * 10) attention_score = max(0, attention_score) if attention_score >= 80: readiness = 'ready' takeover_time = 2.5 elif attention_score >= 50: readiness = 'partial' takeover_time = 5.0 elif attention_score >= 20: readiness = 'minimal' takeover_time = 10.0 else: readiness = 'unresponsive' takeover_time = 30.0 if readiness == 'ready': hmi = 'visual_cue' elif readiness == 'partial': hmi = 'audio_visual' elif readiness == 'minimal': hmi = 'audio_visual_haptic' else: hmi = 'emergency_stop' return { 'attention_score': attention_score, 'readiness': readiness, 'estimated_takeover_s': takeover_time, 'hmi_strategy': hmi, 'within_buffer': takeover_time < self.takeover_buffer_s } def trust_monitoring(self, passenger_engaged: bool, glance_at_hologram: bool, body_posture_open: bool) -> dict: """ 监控乘客对无人驾驶的信任度 参考: Stellantis 全息投影专利 """ trust_signals = [] if passenger_engaged: trust_signals.append(('passenger_engaged', 0.3)) if glance_at_hologram: trust_signals.append(('looking_at_hologram', 0.2)) if body_posture_open: trust_signals.append(('open_posture', 0.15)) trust_score = sum(w for _, w in trust_signals) if trust_score > 0.5: trust_level = 'high' elif trust_score > 0.2: trust_level = 'moderate' else: trust_level = 'low' return { 'trust_score': round(trust_score, 3), 'trust_level': trust_level, 'signals': trust_signals, 'recommendation': 'increase_hologram_visibility' if trust_level == 'low' else 'maintain' }
if __name__ == "__main__": ims = L2PlusPlusIMS() print("=" * 70) print("L2++ IMS 接管准备度评估测试") print("=" * 70) scenarios = [ ('正常警觉', 0.5, 5.0, 0.3), ('轻微分心', 5.0, 8.0, 0.8), ('中度分心', 12.0, 12.0, 1.5), ('严重分心', 25.0, 20.0, 2.5), ('无响应', 45.0, 35.0, 4.0), ] print(f"\n{'场景':<15} {'视线偏离':>8} {'PERCLOS':>8} {'响应延迟':>8} " f"{'注意力':>8} {'准备度':>12} {'接管时间':>8} {'HMI策略':>20}") print("-" * 90) for name, gaze, perclos, latency in scenarios: r = ims.assess_takeover_readiness(gaze, perclos, latency) print(f"{name:<15} {gaze:>7.1f}s {perclos:>7.1f}% {latency:>7.1f}s " f"{r['attention_score']:>8.0f} {r['readiness']:>12} " f"{r['estimated_takeover_s']:>7.1f}s {r['hmi_strategy']:>20}") print(f"\n{'='*70}") print("乘客信任度监控测试 (全息投影)") print(f"{'='*70}") trust_scenarios = [ ('高信任', True, True, True), ('中信任', True, False, True), ('低信任', False, False, False), ] for name, engaged, glance, posture in trust_scenarios: r = ims.trust_monitoring(engaged, glance, posture) print(f" {name:<10} 信任分: {r['trust_score']:.3f} " f"等级: {r['trust_level']:<10} 建议: {r['recommendation']}")
|