diff --git a/CHANGELOGS-DEV.md b/CHANGELOGS-DEV.md index 1621d2b75..9a6f62845 100644 --- a/CHANGELOGS-DEV.md +++ b/CHANGELOGS-DEV.md @@ -1,3 +1,10 @@ +dragonpilot 0.7.5.4 +======================== +* 移除方向盤監控設定。(無法取消/關閉方向盤監控) +* Removed Steering monitor timer adjustment in code (timer in settings will no longer work.) +* Dynamic Follow 更新模型。(感謝 @ShaneSmiskol 提供代碼、 @cgw1968 測試) +* Updated Dynamic Follow model. (Special Thanks to @ShaneSmiskol for the feature and @cgw1968 for testing) + dragonpilot 0.7.5.3 ======================== * Dynamic Follow 更新至 ShaneSmiskol:stock_additions 0.7.5 版。(感謝 @ShaneSmiskol 提供代碼、 @Wei 測試) diff --git a/CHANGELOGS-REL.md b/CHANGELOGS-REL.md index 523855b06..95cfe978e 100644 --- a/CHANGELOGS-REL.md +++ b/CHANGELOGS-REL.md @@ -1,3 +1,54 @@ +dragonpilot 0.7.5 +======================== +* 移除方向盤監控設定。(無法取消/關閉方向盤監控) +* Removed Steering monitor timer adjustment in code (timer in settings will no longer work.) +* 優化 Lexus GSH 轉向。(感謝 @簡銘佑 測試) +* Optimize Lexus GSH steering. (Thanks to @簡銘佑) +* C2 支援自動關機「DragonAutoShutdownAt」參數。(感謝 @cgw1968 建議) +* C2 to support auto shutdown "DragonAutoShutDownAt" param. (Thanks to @cgw1968) +* 將剎車狀熊顯示於 dp 資訊欄。 +* Added brake indicator to dp infobar. +* 加入「方向燈取消控制」延遲控制設。(感謝 @wabes 建議) +* Added delay config to "Disable Lat Control on Blinker". (Thanks to @wabes) +* 加入巴西版 2020 Corolla Hybrid 指紋v2。(感謝 @berno22 提供) +* Added Brazil 2020 Corolla Hybrid FPv2. (Thanks to @berno22) +* 加入對 VW MQB/PQ 的支援。(感謝 @dingliangxue 移植) +* Added support to VW MQB/PQ platform. (Thanks to @dingliangxue) +* 加入「允許多次自動換道」功能。(感謝 @阿濤 建議) +* Added "Allow Continuous Auto Lane Change" Toggle. (Thanks to @阿濤) +* 新增 DragonMaxSpeedLimit 設定值 (mph),當如果車速高於此值 op 將會停止操控。(感謝 @Anthony 建議) +* Added DragonMaxSpeedLimit parameter (mph), op will stop controlling when car speed is high than the value. (Thanks to @Anthony) +* 新增加拿大版 2018 Toyota Sienna LTD 指紋(v2)。(感謝 明峰 提供) +* Added Canada 2018 Toyota Sienna LTD fingerprint (v2). (Thanks to 明峰) +* 新增「通過移動網路上傳」開關 +* Added Upload Over Mobile Network toggle. +* 新增「通過熱點上傳」開關 +* Added Upload Over Hotspot toggle. +* 新增加拿大版 2018 Toyota Sienna LTD 指紋(v1)。(感謝 明峰 提供) +* Added Canada 2018 Toyota Sienna LTD fingerprint (v1). (Thanks to 明峰) +* 新增大陸版 Volkswagen Golf GTI 指紋 (v1)。(感謝 easyeiji 提供) +* Added China Volkswagen Golf GTI fingerprint (v1). (Thanks to easyeiji) +* 更新 dp 圖示 (特別感謝 @wabes 的設計與提供)。 +* Updated dp logo, special thanks to @wabes for the design. +* 簡/繁中文版和 i18n 整合成為單一版本。 +* Merged zhs/zht/i18n versions into one. +* 新增大陸版 CAMRY HYBRID 指紋v2。(感謝 @杜子腾) +* Added China Camery Hybrid FPv2. (Thanks to @杜子腾) +* 新增台灣版 Altis HYBRID 指紋v1。(感謝 @Fish) +* Added Taiwan Altis Hybrid FPv1. (Thanks to @Fish) +* 新增行駛時關閉畫面功能。 +* Added Screen off while driving feature. +* 新增倒車時關閉畫面功能。 +* Added Screen off while reversing feature. +* 新增駕駛介面加入「加速模式」切換鈕。 +* Added acceleration profile toggle onto driving UI. +* 新增自定車型功能,取代指紋暫存功能。 +* Replaced fingerprint cache with custom car model selector. +* 新增可調亮度。 +* Added Brightness changer. +* 新增部分德語支持。(特別感謝 @arne182 提供) +* Added partial de_DE language support (Thanks to @arne182) + dragonpilot 0.7.4 ======================== * [2020-04-10] 移除所有的第三方應用改為自動下載。 diff --git a/CHANGELOGS.md b/CHANGELOGS.md index 6fff5e470..3866eb6d6 100644 --- a/CHANGELOGS.md +++ b/CHANGELOGS.md @@ -1,3 +1,13 @@ +2020-06-22 (0.7.5) +======================== +* 移除方向盤監控設定。(無法取消/關閉方向盤監控) +* Removed Steering monitor timer adjustment in code (timer in settings will no longer work.) + +2020-06-18 (0.7.5) +======================== +* Dynamic Follow 更新模型。(感謝 @ShaneSmiskol 提供代碼、 @cgw1968 測試) +* Updated Dynamic Follow model. (Special Thanks to @ShaneSmiskol for the feature and @cgw1968 for testing) + 2020-05-30 (0.7.5) ======================== * Dynamic Follow 更新至 ShaneSmiskol:stock_additions 0.7.5 版。(感謝 @ShaneSmiskol 提供代碼、 @Wei 測試) diff --git a/selfdrive/controls/lib/driver_monitor.py b/selfdrive/controls/lib/driver_monitor.py index 477c13f19..73ef07777 100644 --- a/selfdrive/controls/lib/driver_monitor.py +++ b/selfdrive/controls/lib/driver_monitor.py @@ -117,9 +117,6 @@ class DriverStatus(): self.is_rhd_region = False self.is_rhd_region_checked = False - # dp - self.awareness_time = _AWARENESS_TIME - self._set_timers(active_monitoring=True) def _set_timers(self, active_monitoring): @@ -147,9 +144,9 @@ class DriverStatus(): self.awareness_active = self.awareness self.awareness = self.awareness_passive - self.threshold_pre = _AWARENESS_PRE_TIME_TILL_TERMINAL / self.awareness_time - self.threshold_prompt = _AWARENESS_PROMPT_TIME_TILL_TERMINAL / self.awareness_time - self.step_change = DT_DMON / self.awareness_time + self.threshold_pre = _AWARENESS_PRE_TIME_TILL_TERMINAL / _AWARENESS_TIME + self.threshold_prompt = _AWARENESS_PROMPT_TIME_TILL_TERMINAL / _AWARENESS_TIME + self.step_change = DT_DMON / _AWARENESS_TIME self.active_monitoring_mode = False def _is_driver_distracted(self, pose, blink): diff --git a/selfdrive/controls/lib/dynamic_follow/__init__.py b/selfdrive/controls/lib/dynamic_follow/__init__.py index 78407c7c2..9889681ca 100644 --- a/selfdrive/controls/lib/dynamic_follow/__init__.py +++ b/selfdrive/controls/lib/dynamic_follow/__init__.py @@ -28,10 +28,10 @@ class DynamicFollow: # Model variables mpc_rate = 1 / 20. - self.model_scales = {'v_ego': [-0.06112159043550491, 37.96522521972656], 'v_lead': [0.0, 35.27671432495117], 'x_lead': [2.4600000381469727, 139.52000427246094]} + self.model_scales = {'v_ego': [-0.06112159043550491, 37.96522521972656], 'a_lead': [-3.109330892562866, 3.3612186908721924], 'v_lead': [0.0, 35.27671432495117], 'x_lead': [2.4600000381469727, 141.44000244140625]} self.predict_rate = 1 / 4. - self.skip_every = round(0.2 / mpc_rate) - self.model_input_len = round(35 / mpc_rate) # int: model input time + self.skip_every = round(0.25 / mpc_rate) + self.model_input_len = round(45 / mpc_rate) # Dynamic follow variables self.default_TR = 1.8 @@ -40,6 +40,9 @@ class DynamicFollow: self.v_ego_retention = 2.5 self.v_rel_retention = 1.5 + self.sng_TR = 1.8 # reacceleration stop and go TR + self.sng_speed = 18.0 * CV.MPH_TO_MS + # dp params self.last_ts = 0. self.dp_df_profile = PROFILE_OFF @@ -64,6 +67,7 @@ class DynamicFollow: self.last_cost = 0.0 self.last_predict_time = 0.0 self.auto_df_model_data = [] + self._get_live_params() # so they're defined just in case def update(self, CS, libmpc): self._get_live_params() @@ -135,6 +139,7 @@ class DynamicFollow: # Store data for auto-df model self.auto_df_model_data.append([self._norm(self.car_data.v_ego, 'v_ego'), self._norm(self.lead_data.v_lead, 'v_lead'), + self._norm(self.lead_data.a_lead, 'a_lead'), self._norm(self.lead_data.x_lead, 'x_lead')]) while len(self.auto_df_model_data) > self.model_input_len: del self.auto_df_model_data[0] @@ -220,12 +225,27 @@ class DynamicFollow: return calc_mod return None - def global_profile_mod(self, TR, profile_mod_pos, profile_mod_neg): - if self.global_df_mod is not None: # only apply when not in sng - TR *= self.global_df_mod - profile_mod_pos *= (1 - self.global_df_mod) + 1 - profile_mod_neg *= self.global_df_mod - return TR, profile_mod_pos, profile_mod_neg + def global_profile_mod(self, profile_mod_x, profile_mod_pos, profile_mod_neg, x_vel, y_dist): + """ + This function modifies the y_dist list used by dynamic follow in accordance with global_df_mod + It also intelligently adjusts the profile mods at each breakpoint based on the change in TR + """ + if self.global_df_mod is None: + return profile_mod_pos, profile_mod_neg, y_dist + global_df_mod = 1 - self.global_df_mod + + # Calculate new TRs + speeds = [0, self.sng_speed, 18, x_vel[-1]] # [0, 18 mph, ~40 mph, highest profile mod speed (~78 mph)] + mods = [0, 0.1, 0.7, 1] # how much to limit global_df_mod at each speed, 1 is full effect + y_dist_new = [y - (y * global_df_mod * np.interp(x, speeds, mods)) for x, y in zip(x_vel, y_dist)] + + # Calculate how to change profile mods based on change in TR + # eg. if df mod is 0.7, then increase positive mod and decrease negative mod + calc_profile_mods = [(np.interp(mod_x, x_vel, y_dist) - np.interp(mod_x, x_vel, y_dist_new) + 1) for mod_x in profile_mod_x] + profile_mod_pos = [mod_pos * mod for mod_pos, mod in zip(profile_mod_pos, calc_profile_mods)] + profile_mod_neg = [mod_neg * ((1 - mod) + 1) for mod_neg, mod in zip(profile_mod_neg, calc_profile_mods)] + + return profile_mod_pos, profile_mod_neg, y_dist_new def _get_TR(self): x_vel = [0.0, 1.8627, 3.7253, 5.588, 7.4507, 9.3133, 11.5598, 13.645, 22.352, 31.2928, 33.528, 35.7632, 40.2336] # velocities @@ -261,24 +281,23 @@ class DynamicFollow: else: raise Exception('Unknown profile type: {}'.format(df_profile)) + # Global df mod + profile_mod_pos, profile_mod_neg, y_dist = self.global_profile_mod(profile_mod_x, profile_mod_pos, profile_mod_neg, x_vel, y_dist) + # Profile modifications - Designed so that each profile reacts similarly to changing lead dynamics profile_mod_pos = interp(self.car_data.v_ego, profile_mod_x, profile_mod_pos) profile_mod_neg = interp(self.car_data.v_ego, profile_mod_x, profile_mod_neg) - sng_TR = 1.8 # reacceleration stop and go TR - sng_speed = 18.0 * CV.MPH_TO_MS - - if self.car_data.v_ego > sng_speed: # keep sng distance until we're above sng speed again + if self.car_data.v_ego > self.sng_speed: # keep sng distance until we're above sng speed again self.sng = False - if (self.car_data.v_ego >= sng_speed or self.df_data.v_egos[0]['v_ego'] >= self.car_data.v_ego) and not self.sng: + if (self.car_data.v_ego >= self.sng_speed or self.df_data.v_egos[0]['v_ego'] >= self.car_data.v_ego) and not self.sng: # if above 15 mph OR we're decelerating to a stop, keep shorter TR. when we reaccelerate, use sng_TR and slowly decrease TR = interp(self.car_data.v_ego, x_vel, y_dist) - TR, profile_mod_pos, profile_mod_neg = self.global_profile_mod(TR, profile_mod_pos, profile_mod_neg) # only within normal driving conditions else: # this allows us to get closer to the lead car when stopping, while being able to have smooth stop and go when reaccelerating self.sng = True - x = [sng_speed * 0.7, sng_speed] # decrease TR between 12.6 and 18 mph from 1.8s to defined TR above at 18mph while accelerating - y = [sng_TR, interp(sng_speed, x_vel, y_dist)] + x = [self.sng_speed * 0.7, self.sng_speed] # decrease TR between 12.6 and 18 mph from 1.8s to defined TR above at 18mph while accelerating + y = [self.sng_TR, interp(self.sng_speed, x_vel, y_dist)] TR = interp(self.car_data.v_ego, x, y) TR_mods = [] @@ -297,7 +316,7 @@ class DynamicFollow: if self.lead_data.v_lead - deadzone > self.car_data.v_ego: TR_mods.append(rel_accel_mod) - x = [sng_speed / 5.0, sng_speed] # as we approach 0, apply x% more distance + x = [self.sng_speed / 5.0, self.sng_speed] # as we approach 0, apply x% more distance y = [1.05, 1.0] profile_mod_pos *= interp(self.car_data.v_ego, x, y) # but only for currently positive mods @@ -306,9 +325,10 @@ class DynamicFollow: if self.car_data.left_blinker or self.car_data.right_blinker and df_profile != self.df_profiles.traffic: x = [8.9408, 22.352, 31.2928] # 20, 50, 70 mph - y = [1.0, .75, .65] # reduce TR when changing lanes - TR *= interp(self.car_data.v_ego, x, y) - return clip(TR, 0.9, 2.7) + y = [1.0, .75, .65] + TR *= interp(self.car_data.v_ego, x, y) # reduce TR when changing lanes + + return float(clip(TR, self.min_TR, 2.7)) def update_lead(self, v_lead=None, a_lead=None, x_lead=None, status=False, new_lead=False): self.lead_data.v_lead = v_lead @@ -329,4 +349,5 @@ class DynamicFollow: def _get_live_params(self): self.global_df_mod = None #self.op_params.get('global_df_mod', None) if self.global_df_mod is not None: - self.global_df_mod = np.clip(self.global_df_mod, 0.7, 1.1) + self.global_df_mod = clip(self.global_df_mod, 0.85, 1.2) + self.min_TR = 0.9 # default diff --git a/selfdrive/controls/lib/dynamic_follow/auto_df.py b/selfdrive/controls/lib/dynamic_follow/auto_df.py index d4cc1bc47..a358e4d19 100644 --- a/selfdrive/controls/lib/dynamic_follow/auto_df.py +++ b/selfdrive/controls/lib/dynamic_follow/auto_df.py @@ -16,7 +16,5 @@ def predict(x): l1 = np.dot(l0, w[1]) + b[1] l1 = np.maximum(0, l1) l2 = np.dot(l1, w[2]) + b[2] - l2 = np.maximum(0, l2) - l3 = np.dot(l2, w[3]) + b[3] - l3 = softmax(l3) - return l3 + l2 = softmax(l2) + return l2 diff --git a/selfdrive/controls/lib/dynamic_follow/auto_df_weights.npz b/selfdrive/controls/lib/dynamic_follow/auto_df_weights.npz index 865f3cdc6..da367c5e6 100644 Binary files a/selfdrive/controls/lib/dynamic_follow/auto_df_weights.npz and b/selfdrive/controls/lib/dynamic_follow/auto_df_weights.npz differ