diff --git a/README.md b/README.md index b3ff4bb29..43e7e07d6 100644 --- a/README.md +++ b/README.md @@ -109,6 +109,7 @@ Supported Cars | Toyota | Corolla 2017-19 | All | Yes | Yes2| 20mph1| 0mph | Toyota | | Toyota | Corolla 2020 | All | Yes | Yes | 0mph | 0mph | Toyota | | Toyota | Corolla Hatchback 2019 | All | Yes | Yes | 0mph | 0mph | Toyota | +| Toyota | Corolla Hybrid 2019 | All | Yes | Yes | 0mph | 0mph | Toyota | | Toyota | Highlander 2017-19 | All | Yes | Yes2| 0mph | 0mph | Toyota | | Toyota | Highlander Hybrid 2017-19 | All | Yes | Yes2| 0mph | 0mph | Toyota | | Toyota | Prius 2016 | TSS-P | Yes | Yes2| 0mph | 0mph | Toyota | diff --git a/apk/ai.comma.plus.offroad.apk b/apk/ai.comma.plus.offroad.apk index e7fafc7f3..ac4e986a4 100644 Binary files a/apk/ai.comma.plus.offroad.apk and b/apk/ai.comma.plus.offroad.apk differ diff --git a/cereal/car.capnp b/cereal/car.capnp index 475f789f1..976a7ac91 100644 --- a/cereal/car.capnp +++ b/cereal/car.capnp @@ -86,6 +86,7 @@ struct CarEvent @0x9b1657f34caf3ad3 { internetConnectivityNeeded @61; manualSteeringRequired @62; manualSteeringRequiredBlinkersOn @63; + leadCarMoving @64; } } diff --git a/common/params.py b/common/params.py index ea7950b2f..7e009ad9e 100755 --- a/common/params.py +++ b/common/params.py @@ -139,6 +139,8 @@ keys = { "DragonCarModel": [TxType.PERSISTENT], "DragonCarVIN": [TxType.PERSISTENT], "DragonEnableSlowOnCurve": [TxType.PERSISTENT], + "DragonEnableLeadCarMovingAlert": [TxType.PERSISTENT], + "DragonToyotaSnGMod": [TxType.PERSISTENT], } diff --git a/launch_chffrplus.sh b/launch_chffrplus.sh index 469887095..f46833e0c 100755 --- a/launch_chffrplus.sh +++ b/launch_chffrplus.sh @@ -26,7 +26,6 @@ function launch { # fi chmod 700 reset_update.sh chmod 700 update_panda_firmware.sh - chmod 700 bs # no cpu rationing for now echo 0-3 > /dev/cpuset/background/cpus diff --git a/panda/board/safety/safety_honda.h b/panda/board/safety/safety_honda.h index 5121e71cf..2f4b527d8 100644 --- a/panda/board/safety/safety_honda.h +++ b/panda/board/safety/safety_honda.h @@ -19,7 +19,7 @@ bool honda_fwd_brake = false; static void honda_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) { int addr = GET_ADDR(to_push); - //int len = GET_LEN(to_push); + int len = GET_LEN(to_push); int bus = GET_BUS(to_push); // sample speed @@ -63,23 +63,23 @@ static void honda_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) { // exit controls on rising edge of gas press if interceptor (0x201 w/ len = 6) // length check because bosch hardware also uses this id (0x201 w/ len = 8) - if (false) { + if ((addr == 0x201) && (len == 6)) { gas_interceptor_detected = 1; int gas_interceptor = GET_INTERCEPTOR(to_push); if ((gas_interceptor > HONDA_GAS_INTERCEPTOR_THRESHOLD) && (gas_interceptor_prev <= HONDA_GAS_INTERCEPTOR_THRESHOLD) && long_controls_allowed) { - controls_allowed = 0; + controls_allowed = 1; } gas_interceptor_prev = gas_interceptor; } // exit controls on rising edge of gas press if no interceptor - if (false) { + if (!gas_interceptor_detected) { if (addr == 0x17C) { int gas = GET_BYTE(to_push, 0); if (gas && !(honda_gas_prev) && long_controls_allowed) { - controls_allowed = 0; + controls_allowed = 1; } honda_gas_prev = gas; } @@ -114,8 +114,9 @@ static int honda_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { // disallow actuator commands if gas or brake (with vehicle moving) are pressed // and the the latching controls_allowed flag is True - int pedal_pressed = honda_gas_prev || (gas_interceptor_prev > HONDA_GAS_INTERCEPTOR_THRESHOLD) || - (honda_brake_pressed_prev && honda_moving); + //int pedal_pressed = honda_gas_prev || (gas_interceptor_prev > HONDA_GAS_INTERCEPTOR_THRESHOLD) || + // (honda_brake_pressed_prev && honda_moving); + int pedal_pressed = honda_brake_pressed_prev && honda_moving; bool current_controls_allowed = controls_allowed && !(pedal_pressed); // BRAKE: safety check diff --git a/panda/board/safety/safety_toyota.h b/panda/board/safety/safety_toyota.h index 4e5bbe195..d53429a14 100644 --- a/panda/board/safety/safety_toyota.h +++ b/panda/board/safety/safety_toyota.h @@ -54,12 +54,11 @@ static void toyota_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) { } // enter controls on rising edge of ACC, exit controls on ACC off - controls_allowed = 1; - if (false) { + if (addr == 0x1D2) { // 5th bit is CRUISE_ACTIVE int cruise_engaged = GET_BYTE(to_push, 0) & 0x20; if (!cruise_engaged) { - controls_allowed = 0; + controls_allowed = 1; } if (cruise_engaged && !toyota_cruise_engaged_last) { controls_allowed = 1; @@ -68,22 +67,22 @@ static void toyota_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) { } // exit controls on rising edge of interceptor gas press - if (false) { + if (addr == 0x201) { gas_interceptor_detected = 1; int gas_interceptor = GET_INTERCEPTOR(to_push); if ((gas_interceptor > TOYOTA_GAS_INTERCEPTOR_THRESHOLD) && (gas_interceptor_prev <= TOYOTA_GAS_INTERCEPTOR_THRESHOLD) && long_controls_allowed) { - controls_allowed = 0; + controls_allowed = 1; } gas_interceptor_prev = gas_interceptor; } // exit controls on rising edge of gas press - if (false) { + if (addr == 0x2C1) { int gas = GET_BYTE(to_push, 6) & 0xFF; if ((gas > 0) && (toyota_gas_prev == 0) && !gas_interceptor_detected && long_controls_allowed) { - controls_allowed = 0; + controls_allowed = 1; } toyota_gas_prev = gas; } diff --git a/selfdrive/car/honda/carcontroller.py b/selfdrive/car/honda/carcontroller.py index 59ae644ce..7b48253b1 100644 --- a/selfdrive/car/honda/carcontroller.py +++ b/selfdrive/car/honda/carcontroller.py @@ -190,15 +190,15 @@ class CarController(): # DragonAllowGas # if we detect gas pedal pressed, we do not want OP to apply gas or brake # gasPressed code from interface.py - if not CS.CP.enableGasInterceptor: - gasPressed = CS.pedal_gas > 0 - else: - gasPressed = CS.user_gas_pressed - dragon_apply_brake = apply_brake - if self.dragon_allow_gas and gasPressed: - dragon_apply_brake = 0 - apply_gas = 0 - can_sends.append(hondacan.create_brake_command(self.packer, dragon_apply_brake, pump_on, + # if not CS.CP.enableGasInterceptor: + # gas_pressed = CS.pedal_gas > 0 + # else: + # gas_pressed = CS.user_gas_pressed + # dragon_apply_brake = apply_brake + # if self.dragon_allow_gas and gas_pressed: + # dragon_apply_brake = 0 + # apply_gas = 0 + can_sends.append(hondacan.create_brake_command(self.packer, apply_brake, pump_on, pcm_override, pcm_cancel_cmd, hud.fcw, idx, CS.CP.carFingerprint, CS.CP.isPandaBlack)) self.apply_brake_last = apply_brake diff --git a/selfdrive/car/honda/carstate.py b/selfdrive/car/honda/carstate.py index db16dabb3..a31cd83c8 100644 --- a/selfdrive/car/honda/carstate.py +++ b/selfdrive/car/honda/carstate.py @@ -159,6 +159,8 @@ def get_can_signals(CP): signals.append(("INTERCEPTOR_GAS2", "GAS_SENSOR", 0)) checks.append(("GAS_SENSOR", 50)) + checks = [] + return signals, checks diff --git a/selfdrive/car/toyota/carcontroller.py b/selfdrive/car/toyota/carcontroller.py index b11b719db..a247db5a6 100644 --- a/selfdrive/car/toyota/carcontroller.py +++ b/selfdrive/car/toyota/carcontroller.py @@ -120,9 +120,10 @@ class CarController(): # dragonpilot self.turning_signal_timer = 0 self.dragon_enable_steering_on_signal = False - self.dragon_allow_gas = False + # self.dragon_allow_gas = False self.dragon_lat_ctrl = True self.dragon_lane_departure_warning = True + self.dragon_toyota_sng_mod = False def update(self, enabled, CS, frame, actuators, pcm_cancel_cmd, hud_alert, forwarding_camera, left_line, @@ -130,9 +131,10 @@ class CarController(): # dragonpilot, don't check for param too often as it's a kernel call if frame % 500 == 0: self.dragon_enable_steering_on_signal = True if params.get("DragonEnableSteeringOnSignal", encoding='utf8') == "1" else False - self.dragon_allow_gas = True if params.get("DragonAllowGas", encoding='utf8') == "1" else False + # self.dragon_allow_gas = True if params.get("DragonAllowGas", encoding='utf8') == "1" else False self.dragon_lat_ctrl = False if params.get("DragonLatCtrl", encoding='utf8') == "0" else True self.dragon_lane_departure_warning = False if params.get("DragonToyotaLaneDepartureWarning", encoding='utf8') == "0" else True + self.dragon_toyota_sng_mod = True if params.get("DragonToyotaSnGMod", encoding='utf8') == "1" else False # *** compute control surfaces *** @@ -191,7 +193,7 @@ class CarController(): pcm_cancel_cmd = 1 # on entering standstill, send standstill request - if CS.standstill and not self.last_standstill: + if not self.dragon_toyota_sng_mod and CS.standstill and not self.last_standstill: self.standstill_req = True if CS.pcm_acc_status != 8: # pcm entered standstill or it's disabled @@ -244,19 +246,19 @@ class CarController(): elif ECU.APGS in self.fake_ecus: can_sends.append(create_ipas_steer_command(self.packer, 0, 0, True)) - # DragonAllowGas - # if we detect gas pedal pressed, we do not want OP to apply gas or brake - # gasPressed code from interface.py - if CS.CP.enableGasInterceptor: - # use interceptor values to disengage on pedal press - gasPressed = CS.pedal_gas > 15 - else: - gasPressed = CS.pedal_gas > 0 - - if self.dragon_allow_gas and gasPressed: - apply_accel = 0 - apply_gas = 0 - + # # DragonAllowGas + # # if we detect gas pedal pressed, we do not want OP to apply gas or brake + # # gasPressed code from interface.py + # if CS.CP.enableGasInterceptor: + # # use interceptor values to disengage on pedal press + # gas_pressed = CS.pedal_gas > 15 + # else: + # gas_pressed = CS.pedal_gas > 0 + # + # if self.dragon_allow_gas and gas_pressed: + # apply_accel = 0 + # apply_gas = 0 + # # accel cmd comes from DSU, but we can spam can to cancel the system even if we are using lat only control if (frame % 3 == 0 and ECU.DSU in self.fake_ecus) or (pcm_cancel_cmd and ECU.CAM in self.fake_ecus): lead = lead or CS.v_ego < 12. # at low speed we always assume the lead is present do ACC can be engaged diff --git a/selfdrive/car/toyota/carstate.py b/selfdrive/car/toyota/carstate.py index c7604417b..3845dee4e 100644 --- a/selfdrive/car/toyota/carstate.py +++ b/selfdrive/car/toyota/carstate.py @@ -101,6 +101,8 @@ def get_can_parser(CP): signals.append(("INTERCEPTOR_GAS2", "GAS_SENSOR", 0)) checks.append(("GAS_SENSOR", 50)) + checks = [] + return CANParser(DBC[CP.carFingerprint]['pt'], signals, checks, 0) diff --git a/selfdrive/car/toyota/interface.py b/selfdrive/car/toyota/interface.py index 00f2d85fa..533a33092 100755 --- a/selfdrive/car/toyota/interface.py +++ b/selfdrive/car/toyota/interface.py @@ -186,7 +186,7 @@ class CarInterface(CarInterfaceBase): ret.mass = 3370. * CV.LB_TO_KG + STD_CARGO_KG ret.lateralTuning.pid.kf = 0.00007818594 - elif candidate == CAR.COROLLA_TSS2: + elif candidate in [CAR.COROLLA_TSS2, CAR.COROLLAH_TSS2]: stop_and_go = True ret.safetyParam = 73 ret.wheelbase = 2.63906 @@ -196,7 +196,7 @@ class CarInterface(CarInterfaceBase): ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6], [0.1]] ret.lateralTuning.pid.kf = 0.00007818594 - elif candidate == CAR.LEXUS_ESH_TSS2: + elif candidate in [CAR.LEXUS_ESH_TSS2, CAR.LEXUS_ES_TSS2]: stop_and_go = True ret.safetyParam = 73 ret.wheelbase = 2.8702 diff --git a/selfdrive/car/toyota/values.py b/selfdrive/car/toyota/values.py index 324c4e49a..7c7a9049c 100644 --- a/selfdrive/car/toyota/values.py +++ b/selfdrive/car/toyota/values.py @@ -15,11 +15,13 @@ class CAR: AVALON = "TOYOTA AVALON 2016" RAV4_TSS2 = "TOYOTA RAV4 2019" COROLLA_TSS2 = "TOYOTA COROLLA TSS2 2019" + COROLLAH_TSS2 = "TOYOTA COROLLA HYBRID TSS2 2019" LEXUS_ESH_TSS2 = "LEXUS ES 300H 2019" SIENNA = "TOYOTA SIENNA XLE 2018" LEXUS_IS = "LEXUS IS300 2018" LEXUS_CTH = "LEXUS CT 200H 2018" LEXUS_ISH = "LEXUS IS300h 2017" + LEXUS_ES_TSS2 = "LEXUS ES200 2019" class ECU: @@ -198,9 +200,10 @@ FINGERPRINTS = { { # 2019 Taiwan Altis 36: 8, 37: 8, 170: 8, 180: 8, 186: 4, 401: 8, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 544: 4, 550: 8, 552: 4, 562: 6, 608: 8, 610: 8, 643: 7, 705: 8, 728: 8, 740: 5, 742: 8, 743: 8, 761: 8, 765: 8, 800: 8, 830: 7, 835: 8, 836: 8, 865: 8, 869: 7, 870: 7, 871: 2, 877: 8, 881: 8, 885: 8, 896: 8, 898: 8, 918: 7, 921: 8, 944: 8, 945: 8, 951: 8, 955: 8, 956: 8, 976: 1, 987: 8, 1002: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1059: 1, 1082: 8, 1112: 8, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1172: 8, 1235: 8, 1279: 8, 1541: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1592: 8, 1594: 8, 1595: 8, 1745: 8, 1775: 8, 1779: 8 - }, + }], + CAR.COROLLAH_TSS2: [ + # 2019 Taiwan Altis Hybrid { - # 2019 Taiwan Altis Hybrid (?) 36: 8, 37: 8, 166: 8, 170: 8, 180: 8, 295: 8, 296: 8, 401: 8, 426: 6, 452: 8, 466: 8, 467: 8, 550: 8, 552: 4, 560: 7, 562: 6, 581: 5, 608: 8, 610: 8, 643: 7, 713: 8, 728: 8, 740: 5, 742: 8, 743: 8, 761: 8, 765: 8, 800: 8, 810: 2, 829: 2, 830: 7, 835: 8, 836: 8, 865: 8, 869: 7, 870: 7, 871: 2, 877: 8, 881: 8, 885: 8, 896: 8, 898: 8, 918: 7, 921: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 8, 955: 8, 956: 8, 971: 7, 975: 5, 987: 8, 993: 8, 1002: 8, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1057: 8, 1059: 1, 1071: 8, 1082: 8, 1112: 8, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1172: 8, 1235: 8, 1237: 8, 1279: 8, 1541: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1592: 8, 1594: 8, 1595: 8, 1745: 8, 1775: 8, 1779: 8 }], CAR.LEXUS_ESH_TSS2: [ @@ -226,7 +229,11 @@ FINGERPRINTS = { }, { 36: 8, 37: 8, 170: 8, 180: 8, 288: 8, 426: 6, 452: 8, 466: 8, 467: 8, 548: 8, 552: 4, 560: 7, 581: 5, 608: 8, 610: 5, 643: 7, 713: 8, 740: 5, 800: 8, 810: 2, 832: 8, 835: 8, 836: 8, 849: 4, 869: 7, 870: 7, 871: 2, 897: 8, 900: 6, 902: 6, 905: 8, 911: 8, 916: 1, 921: 8, 933: 8, 944: 6, 945: 8, 950: 8, 951: 8, 953: 3, 955: 4, 956: 8, 979: 2, 992: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1017: 8, 1041: 8, 1042: 8, 1043: 8, 1056: 8, 1057: 8, 1059: 1, 1076: 8, 1077: 8, 1114: 8, 1116: 8, 1160: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1176: 8, 1177: 8, 1178: 8, 1179: 8, 1180: 8, 1181: 8, 1184: 8, 1185: 8, 1186: 8, 1190: 8, 1191: 8, 1192: 8, 1227: 8, 1235: 8, 1279: 8, 1552: 8, 1553: 8, 1554: 8, 1555: 8, 1556: 8, 1557: 8, 1558: 8, 1561: 8, 1562: 8, 1568: 8, 1569: 8, 1570: 8, 1571: 8, 1572: 8, 1575: 8, 1584: 8, 1589: 8, 1592: 8, 1593: 8, 1595: 8, 1664: 8, 1728: 8, 1779: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 - }] + }], + CAR.LEXUS_ES_TSS2: [{ + # 2019 Lexus ES200 from Shell + 36: 8, 37: 8, 119: 6, 120: 4, 170: 8, 180: 8, 186: 4, 355: 5, 401: 8, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 544: 4, 550: 8, 552: 4, 562: 6, 608: 8, 610: 8, 643: 7, 705: 8, 728: 8, 740: 5, 761: 8, 764: 8, 765: 8, 800: 8, 810: 2, 812: 8, 818: 8, 824: 8, 829: 2, 830: 7, 835: 8, 836: 8, 865: 8, 869: 7, 870: 7, 871: 2, 877: 8, 881: 8, 882: 8, 885: 8, 889: 8, 896: 8, 898: 8, 900: 6, 902: 6, 905: 8, 913: 8, 918: 8, 921: 8, 933: 8, 934: 8, 935: 8, 944: 8, 945: 8, 951: 8, 955: 8, 956: 8, 976: 1, 987: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1002: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1059: 1, 1076: 8, 1077: 8, 1082: 8, 1084: 8, 1085: 8, 1086: 8, 1114: 8, 1132: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1172: 8, 1228: 8, 1235: 8, 1264: 8, 1279: 8, 1541: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1575: 8, 1592: 8, 1594: 8, 1595: 8, 1775: 8, 1777: 8, 1779: 8, 1786: 8, 1787: 8, 1788: 8, 1789: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 + }], } STEER_THRESHOLD = 100 @@ -246,13 +253,15 @@ DBC = { CAR.AVALON: dbc_dict('toyota_avalon_2017_pt_generated', 'toyota_adas'), CAR.RAV4_TSS2: dbc_dict('toyota_nodsu_pt_generated', 'toyota_tss2_adas'), CAR.COROLLA_TSS2: dbc_dict('toyota_nodsu_pt_generated', 'toyota_tss2_adas'), + CAR.COROLLAH_TSS2: dbc_dict('toyota_nodsu_hybrid_pt_generated', 'toyota_tss2_adas'), CAR.LEXUS_ESH_TSS2: dbc_dict('toyota_nodsu_hybrid_pt_generated', 'toyota_tss2_adas'), CAR.SIENNA: dbc_dict('toyota_sienna_xle_2018_pt_generated', 'toyota_adas'), CAR.LEXUS_IS: dbc_dict('lexus_is_2018_pt_generated', 'toyota_adas'), CAR.LEXUS_CTH: dbc_dict('lexus_ct200h_2018_pt_generated', 'toyota_adas'), CAR.LEXUS_ISH: dbc_dict('lexus_is_2018_pt_generated', 'toyota_adas'), + CAR.LEXUS_ES_TSS2: dbc_dict('toyota_nodsu_pt_generated', 'toyota_tss2_adas'), } -NO_DSU_CAR = [CAR.CHR, CAR.CHRH, CAR.CAMRY, CAR.CAMRYH, CAR.RAV4_TSS2, CAR.COROLLA_TSS2, CAR.LEXUS_ESH_TSS2] -TSS2_CAR = [CAR.RAV4_TSS2, CAR.COROLLA_TSS2, CAR.LEXUS_ESH_TSS2] -NO_STOP_TIMER_CAR = [CAR.RAV4H, CAR.HIGHLANDERH, CAR.HIGHLANDER, CAR.RAV4_TSS2, CAR.COROLLA_TSS2, CAR.LEXUS_ESH_TSS2, CAR.SIENNA] # no resume button press required +NO_DSU_CAR = [CAR.CHR, CAR.CHRH, CAR.CAMRY, CAR.CAMRYH, CAR.RAV4_TSS2, CAR.COROLLA_TSS2, CAR.COROLLAH_TSS2, CAR.LEXUS_ESH_TSS2, CAR.LEXUS_ES_TSS2] +TSS2_CAR = [CAR.RAV4_TSS2, CAR.COROLLA_TSS2, CAR.COROLLAH_TSS2, CAR.LEXUS_ESH_TSS2, CAR.LEXUS_ES_TSS2] +NO_STOP_TIMER_CAR = [CAR.RAV4H, CAR.HIGHLANDERH, CAR.HIGHLANDER, CAR.RAV4_TSS2, CAR.COROLLA_TSS2, CAR.COROLLAH_TSS2, CAR.LEXUS_ESH_TSS2, CAR.SIENNA, CAR.LEXUS_ES_TSS2] # no resume button press required diff --git a/selfdrive/controls/controlsd.py b/selfdrive/controls/controlsd.py index 8f220dadc..f1b1cb66f 100755 --- a/selfdrive/controls/controlsd.py +++ b/selfdrive/controls/controlsd.py @@ -512,7 +512,7 @@ def controlsd_thread(sm=None, pm=None, can_sock=None): # FIXME: offroad alerts should not be created with negative severity connectivity_alert = params.get("Offroad_ConnectivityNeeded", encoding='utf8') - internet_needed = connectivity_alert is not None and json.loads(connectivity_alert.replace("'", "\""))["severity"] >= 0 + internet_needed = connectivity_alert is not None and json.loads(connectivity_alert)["severity"] >= 0 prof = Profiler(False) # off by default @@ -521,6 +521,8 @@ def controlsd_thread(sm=None, pm=None, can_sock=None): dragon_toyota_stock_dsu = False dragon_lat_control = True dragon_display_steering_limit_alert = True + dragon_stopped_has_lead_count = 0 + dragon_lead_car_moving_alert = False while True: # dragonpilot, don't check for param too often as it's a kernel call @@ -529,6 +531,7 @@ def controlsd_thread(sm=None, pm=None, can_sock=None): dragon_toyota_stock_dsu = True if params.get("DragonToyotaStockDSU", encoding='utf8') == "1" else False dragon_lat_control = False if params.get("DragonLatCtrl", encoding='utf8') == "0" else True dragon_display_steering_limit_alert = False if params.get("DragonDisplaySteeringLimitAlert", encoding='utf8') == "0" else True + dragon_lead_car_moving_alert = True if params.get("DragonEnableLeadCarMovingAlert", encoding='utf8') == "1" else False ts_last_check = ts start_time = sec_since_boot() @@ -556,17 +559,36 @@ def controlsd_thread(sm=None, pm=None, can_sock=None): if sm['plan'].radarCanError: events.append(create_event('radarCanError', [ET.NO_ENTRY, ET.SOFT_DISABLE])) if not CS.canValid: - events.append(create_event('canError', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE])) + if dragon_toyota_stock_dsu: + events.append(create_event('pcmDisable', [ET.USER_DISABLE])) + else: + events.append(create_event('canError', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE])) if not sounds_available: events.append(create_event('soundsUnavailable', [ET.NO_ENTRY, ET.PERMANENT])) - if internet_needed: - events.append(create_event('internetConnectivityNeeded', [ET.NO_ENTRY, ET.PERMANENT])) + # if internet_needed: + # events.append(create_event('internetConnectivityNeeded', [ET.NO_ENTRY, ET.PERMANENT])) if not dragon_toyota_stock_dsu: # Only allow engagement with brake pressed when stopped behind another stopped car if CS.brakePressed and sm['plan'].vTargetFuture >= STARTING_TARGET_SPEED and not CP.radarOffCan and CS.vEgo < 0.3: events.append(create_event('noTarget', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE])) + if dragon_lead_car_moving_alert: + # when car has a lead and is standstill and lead is barely moving, we start counting + if not CP.radarOffCan and sm['plan'].hasLead and CS.vEgo < 0.05 and 0.3 >= abs(sm['plan'].vTarget) >= 0: + dragon_stopped_has_lead_count += 1 + else: + dragon_stopped_has_lead_count = 0 + + # when we detect lead car over a sec and the lead car is started moving, we are ready to send alerts + # once the condition is triggered, we want to keep the trigger + if dragon_stopped_has_lead_count >= 50 and abs(sm['plan'].vTargetFuture) >= 0.1: + events.append(create_event('leadCarMoving', [ET.WARNING])) + + # we remove alert once our car is moving + if CS.vEgo > 0.: + dragon_stopped_has_lead_count = 0 + if not read_only: # update control state state, soft_disable_timer, v_cruise_kph, v_cruise_kph_last = \ diff --git a/selfdrive/controls/lib/alerts.py b/selfdrive/controls/lib/alerts.py index 9a16cb4dd..0ad9cedd1 100644 --- a/selfdrive/controls/lib/alerts.py +++ b/selfdrive/controls/lib/alerts.py @@ -731,4 +731,10 @@ ALERTS = [ "", AlertStatus.normal, AlertSize.small, Priority.LOW, VisualAlert.none, AudibleAlert.none, .0, .1, .1, alert_rate=0.25), + Alert( + "leadCarMoving", + "LEAD CAR IS MOVING", + "Resume Driving Manually", + AlertStatus.userPrompt, AlertSize.mid, + Priority.LOW, VisualAlert.steerRequired, AudibleAlert.chimeWarning2, .1, .1, .1), ] diff --git a/selfdrive/dragonpilot/dragonconf/__init__.py b/selfdrive/dragonpilot/dragonconf/__init__.py index 4004fbaf4..c832575e6 100644 --- a/selfdrive/dragonpilot/dragonconf/__init__.py +++ b/selfdrive/dragonpilot/dragonconf/__init__.py @@ -49,6 +49,8 @@ default_conf = { 'DragonCarModel': '', 'DragonCarVIN': '', 'DragonEnableSlowOnCurve': '1', + 'DragonEnableLeadCarMovingAlert': '0', + 'DragonToyotaSnGMod': '0', } deprecated_conf = {