diff --git a/README.md b/README.md index 5d84539ef..d611694b1 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,8 @@ installation guides, and software configuration. * Galaxy: StarPilot's portal to configure your comma device using your phone from anywhere. Download models, change settings, update software, visualize live model outputs for tuning. * Always On Lateral (full time steering assist)* -* Learning Speed Limit Controller* +* Speed Limit Controller* +* Learning Curve Speed Controller* * Conditional Experimental Mode (CEM)* * Driving Profiles* * Custom themes* diff --git a/cereal/custom.capnp b/cereal/custom.capnp index 3b6cde3e1..4f071c107 100644 --- a/cereal/custom.capnp +++ b/cereal/custom.capnp @@ -145,6 +145,8 @@ struct StarPilotOnroadEvent @0xa5cd762cd951a455 { vCruise69 @26; yourFrogTriedToKillMe @27; youveGotMail @28; + switchbackModeActive @29; + switchbackModeInactive @30; } } diff --git a/cereal/libcereal.a b/cereal/libcereal.a index 3e40537bf..e04dd8f82 100644 Binary files a/cereal/libcereal.a and b/cereal/libcereal.a differ diff --git a/common/libcommon.a b/common/libcommon.a index 3f8df30eb..64e32724f 100644 Binary files a/common/libcommon.a and b/common/libcommon.a differ diff --git a/common/params_keys.h b/common/params_keys.h index 4ba8dbeed..c9b685562 100644 --- a/common/params_keys.h +++ b/common/params_keys.h @@ -166,6 +166,7 @@ inline static std::unordered_map keys = { {"BuildMetadata", {PERSISTENT, STRING, "", "", 0}}, {"BlindSpotMetrics", {PERSISTENT, BOOL, "1", "0", 3}}, {"BlindSpotPath", {PERSISTENT, BOOL, "1", "0", 1}}, + {"BelowSteerSpeedVolume", {PERSISTENT, INT, "101", "101", 2}}, {"BorderMetrics", {PERSISTENT, BOOL, "0", "0", 3}}, {"CalibratedLateralAcceleration", {PERSISTENT, FLOAT, "2.0", "2.0", 2}}, {"CalibrationProgress", {PERSISTENT, FLOAT, "0.0", "0.0", 3}}, @@ -326,6 +327,7 @@ inline static std::unordered_map keys = { {"MapGears", {PERSISTENT, BOOL, "0", "0", 2}}, {"MapsSelected", {PERSISTENT, STRING, "", "", 0}}, {"MapSpeedLimit", {CLEAR_ON_MANAGER_START, FLOAT, "0.0", "0.0"}}, + {"NextMapSpeedLimit", {CLEAR_ON_MANAGER_START, JSON, "{}", "{}"}}, {"MaxDesiredAcceleration", {PERSISTENT, FLOAT, "4.0", "2.0", 2}}, {"MinimumBackupSize", {PERSISTENT, INT, "0", "0"}}, {"MinimumLaneChangeSpeed", {PERSISTENT, FLOAT, "20.0", "20.0", 2}}, @@ -479,6 +481,8 @@ inline static std::unordered_map keys = { {"StopDistance", {PERSISTENT, FLOAT, "6.0", "6.0", 2}}, {"StoppingDecelRate", {PERSISTENT, FLOAT, "0.0", "0.0", 3}}, {"StoppingDecelRateStock", {PERSISTENT, FLOAT, "0.0", "0.0", 3}}, + {"SwitchbackModeCooldown", {PERSISTENT, INT, "5", "0", 2}}, + {"SwitchbackModeEnabled", {CLEAR_ON_OFFROAD_TRANSITION, BOOL, "0", "0"}}, {"SubaruSNG", {PERSISTENT, BOOL, "1", "0", 2}}, {"TacoTune", {PERSISTENT, BOOL, "0", "0", 2}}, {"TacoTuneHacks", {PERSISTENT, BOOL, "0", "0", 2}}, diff --git a/common/params_pyx.so b/common/params_pyx.so index 97e378674..69c1fd0d6 100755 Binary files a/common/params_pyx.so and b/common/params_pyx.so differ diff --git a/opendbc_repo/opendbc/car/body/carstate.py b/opendbc_repo/opendbc/car/body/carstate.py index bf8c5e0d0..97fc743b9 100644 --- a/opendbc_repo/opendbc/car/body/carstate.py +++ b/opendbc_repo/opendbc/car/body/carstate.py @@ -29,7 +29,6 @@ class CarState(CarStateBase): ret.cruiseState.enabled = True ret.cruiseState.available = True - # StarPilot variables fp_ret = custom.StarPilotCarState.new_message() return ret, fp_ret diff --git a/opendbc_repo/opendbc/car/car_helpers.py b/opendbc_repo/opendbc/car/car_helpers.py index 79b41fd95..506265693 100644 --- a/opendbc_repo/opendbc/car/car_helpers.py +++ b/opendbc_repo/opendbc/car/car_helpers.py @@ -18,7 +18,6 @@ from openpilot.common.params import Params FRAME_FINGERPRINT = 100 # 1s -# StarPilot variables StarPilotCarParams = custom.StarPilotCarParams @@ -46,7 +45,7 @@ def _get_interface_names() -> dict[str, list[str]]: interface_names = _get_interface_names() interfaces = load_interfaces(interface_names) -# Legacy StarPilot Bolt rename migration. Keep here to prevent force-fingerprint +# Legacy Bolt rename migration. Keep here to prevent force-fingerprint # params from selecting a removed platform name and crashing detection. LEGACY_FORCED_CANDIDATE_MAP = { "CHEVROLET_BOLT_CC_2019_2021": "CHEVROLET_BOLT_CC_2018_2021", @@ -300,7 +299,6 @@ def get_car(can_recv: CanRecvCallable, can_send: CanSendCallable, set_obd_multip CP.fingerprintSource = source CP.fuzzyFingerprint = not exact_match - # StarPilot variables FPCP: StarPilotCarParams = CarInterface.get_starpilot_params(candidate, fingerprints, car_fw, CP, starpilot_toggles) if CP.brand == "toyota" and FPCP.flags & ToyotaStarPilotFlags.SMART_DSU.value: diff --git a/opendbc_repo/opendbc/car/chrysler/carstate.py b/opendbc_repo/opendbc/car/chrysler/carstate.py index 60e1ca075..24cc24eb4 100644 --- a/opendbc_repo/opendbc/car/chrysler/carstate.py +++ b/opendbc_repo/opendbc/car/chrysler/carstate.py @@ -28,7 +28,6 @@ class CarState(CarStateBase): # RealFast variables self.button_message = "CRUISE_BUTTONS_ALT" if FPCP.flags & ChryslerStarPilotFlags.RAM_HD_ALT_BUTTONS else "CRUISE_BUTTONS" - # StarPilot variables self.lkas_button = 0 def update(self, can_parsers, starpilot_toggles) -> structs.CarState: @@ -104,7 +103,6 @@ class CarState(CarStateBase): buttonEvents = create_button_events(self.distance_button, prev_distance_button, {1: ButtonType.gapAdjustCruise}) - # StarPilot variables fp_ret = custom.StarPilotCarState.new_message() self.prev_lkas_button = self.lkas_button diff --git a/opendbc_repo/opendbc/car/chrysler/values.py b/opendbc_repo/opendbc/car/chrysler/values.py index 6342e43d7..b3ae3bef3 100644 --- a/opendbc_repo/opendbc/car/chrysler/values.py +++ b/opendbc_repo/opendbc/car/chrysler/values.py @@ -19,7 +19,6 @@ class ChryslerFlags(IntFlag): HIGHER_MIN_STEERING_SPEED = 1 -# StarPilot variables class ChryslerStarPilotFlags(IntFlag): RAM_HD_ALT_BUTTONS = 1 diff --git a/opendbc_repo/opendbc/car/ford/carstate.py b/opendbc_repo/opendbc/car/ford/carstate.py index 714ea56c0..f5d94011c 100644 --- a/opendbc_repo/opendbc/car/ford/carstate.py +++ b/opendbc_repo/opendbc/car/ford/carstate.py @@ -114,7 +114,6 @@ class CarState(CarStateBase): *create_button_events(self.lc_button, prev_lc_button, {1: ButtonType.lkas}), ] - # StarPilot variables fp_ret = custom.StarPilotCarState.new_message() return ret, fp_ret diff --git a/opendbc_repo/opendbc/car/gm/carcontroller.py b/opendbc_repo/opendbc/car/gm/carcontroller.py index a6f74224c..011bc21e8 100644 --- a/opendbc_repo/opendbc/car/gm/carcontroller.py +++ b/opendbc_repo/opendbc/car/gm/carcontroller.py @@ -72,7 +72,6 @@ class CarController(CarControllerBase): self.malibu_button_phase = 0 self.malibu_last_button_ts_nanos = 0 - # OPGM variables def calc_pedal_command(self, accel: float, long_active: bool, v_ego: float): if not long_active: self.planner_regen_hold = False @@ -372,7 +371,7 @@ class CarController(CarControllerBase): else: long_pitch_enabled = bool(getattr(starpilot_toggles, "long_pitch", True)) pedal_long_path = bool(self.CP.enableGasInterceptorDEPRECATED and (self.CP.flags & GMFlags.PEDAL_LONG.value)) - long_pitch_for_powertrain = long_pitch_enabled and not pedal_long_path + long_pitch_for_powertrain = long_pitch_enabled or pedal_long_path if self.is_volt: if long_pitch_for_powertrain and len(CC.orientationNED) == 3 and CS.out.vEgo > self.CP.vEgoStopping: @@ -479,7 +478,6 @@ class CarController(CarControllerBase): resume = actuators.longControlState != LongCtrlState.starting or CC.cruiseControl.resume at_full_stop = at_full_stop and not resume - # StarPilot variables if CC.cruiseControl.resume and CS.pcm_acc_status == AccState.STANDSTILL and starpilot_toggles.volt_sng: acc_engaged = False else: @@ -592,7 +590,6 @@ class CarController(CarControllerBase): self.prev_op_enabled = CC.enabled self.frame += 1 - # OPGM variables new_actuators.speed = self.apply_speed return new_actuators, can_sends diff --git a/opendbc_repo/opendbc/car/gm/carstate.py b/opendbc_repo/opendbc/car/gm/carstate.py index ac4d9e2b0..48cadd7f8 100644 --- a/opendbc_repo/opendbc/car/gm/carstate.py +++ b/opendbc_repo/opendbc/car/gm/carstate.py @@ -30,7 +30,6 @@ STANDSTILL_THRESHOLD = 10 * 0.0311 BUTTONS_DICT = {CruiseButtons.RES_ACCEL: ButtonType.accelCruise, CruiseButtons.DECEL_SET: ButtonType.decelCruise, CruiseButtons.MAIN: ButtonType.mainCruise, CruiseButtons.CANCEL: ButtonType.cancel} -# OPGM variables GearShifter = structs.CarState.GearShifter BOLT_GEN1_CANCEL_PERSONALITY_CARS = { CAR.CHEVROLET_BOLT_CC_2017, @@ -58,7 +57,6 @@ class CarState(CarStateBase): self.prev_distance_button = 0 self.distance_button = 0 - # OPGM variables self.single_pedal_mode = False self.pedal_steady = 0 diff --git a/opendbc_repo/opendbc/car/gm/fingerprints.py b/opendbc_repo/opendbc/car/gm/fingerprints.py index 78539f0ab..e541bca7f 100644 --- a/opendbc_repo/opendbc/car/gm/fingerprints.py +++ b/opendbc_repo/opendbc/car/gm/fingerprints.py @@ -99,27 +99,27 @@ FINGERPRINTS = { { 170: 8, 188: 8, 189: 7, 190: 6, 193: 8, 197: 8, 201: 8, 209: 7, 211: 2, 241: 6, 288: 5, 298: 8, 304: 1, 309: 8, 311: 8, 313: 8, 320: 3, 322: 7, 328: 1, 352: 5, 353: 3, 381: 8, 384: 4, 386: 8, 388: 8, 390: 7, 407: 7, 417: 7, 419: 1, 451: 8, 452: 8, 453: 6, 454: 8, 456: 8, 463: 3, 479: 3, 481: 7, 485: 8, 489: 8, 493: 8, 495: 4, 497: 8, 499: 3, 500: 6, 501: 8, 503: 2, 508: 8, 512: 6, 513: 6, 528: 5, 532: 6, 546: 7, 550: 8, 554: 3, 558: 8, 560: 8, 562: 8, 563: 5, 564: 5, 565: 5, 566: 7, 567: 5, 568: 2, 569: 3, 573: 1, 608: 8, 609: 6, 610: 6, 611: 6, 612: 8, 613: 8, 647: 3, 707: 8, 711: 6, 717: 5, 753: 5, 761: 7, 800: 6, 810: 8, 840: 5, 842: 5, 844: 8, 848: 4, 866: 4, 869: 4, 872: 1, 961: 8, 967: 4, 969: 8, 975: 2, 977: 8, 979: 7, 985: 5, 988: 6, 989: 8, 995: 7, 1001: 8, 1005: 6, 1009: 8, 1013: 3, 1017: 8, 1019: 2, 1020: 8, 1022: 1, 1037: 5, 1105: 5, 1187: 4, 1217: 8, 1221: 5, 1223: 3, 1225: 7, 1227: 4, 1233: 8, 1236: 8, 1243: 3, 1249: 8, 1257: 6, 1265: 8, 1268: 2, 1275: 3, 1279: 4, 1280: 4, 1300: 8, 1322: 6, 1323: 4, 1328: 4, 1904: 7, 1905: 7, 1906: 7, 1907: 7, 1912: 7, 1913: 7, 1927: 7, 2016: 8, 2024: 8 }, - # Bolt EV no ACC 2018-2021 (StarPilot parity variant 1) + # Bolt EV no ACC 2018-2021 (variant 1) { 170: 8, 188: 8, 189: 7, 190: 6, 193: 8, 197: 8, 201: 8, 209: 7, 211: 2, 241: 6, 257: 8, 288: 5, 298: 8, 304: 1, 308: 4, 309: 8, 311: 8, 313: 8, 320: 3, 322: 7, 328: 1, 352: 5, 353: 3, 368: 3, 381: 8, 384: 4, 386: 8, 388: 8, 390: 7, 407: 7, 417: 7, 419: 1, 451: 8, 452: 8, 453: 6, 454: 8, 456: 8, 463: 3, 479: 3, 481: 7, 485: 8, 489: 8, 493: 8, 495: 4, 497: 8, 499: 3, 500: 6, 501: 8, 503: 2, 508: 8, 513: 6, 528: 5, 532: 6, 546: 7, 550: 8, 554: 3, 558: 8, 560: 8, 562: 8, 563: 5, 564: 5, 565: 5, 566: 7, 567: 5, 568: 1, 569: 3, 573: 1, 577: 8, 578: 8, 579: 8, 592: 8, 608: 8, 609: 6, 610: 6, 611: 6, 612: 8, 613: 8, 647: 3, 707: 8, 711: 6, 717: 5, 753: 5, 761: 7, 800: 6, 810: 8, 840: 5, 842: 5, 844: 8, 848: 4, 866: 4, 869: 4, 872: 1, 961: 8, 967: 4, 969: 8, 975: 2, 977: 8, 979: 7, 985: 5, 988: 6, 989: 8, 995: 7, 1001: 8, 1005: 6, 1009: 8, 1013: 3, 1017: 8, 1019: 2, 1020: 8, 1022: 1, 1037: 5, 1105: 5, 1187: 4, 1217: 8, 1221: 5, 1223: 3, 1225: 7, 1227: 4, 1233: 8, 1236: 8, 1243: 3, 1249: 8, 1257: 6, 1265: 8, 1275: 3, 1279: 4, 1280: 4, 1300: 8, 1322: 6, 1323: 4, 1328: 4, 1345: 8, 1346: 8, 1347: 8, 1513: 8, 1516: 8, 1601: 8, 1616: 8, 1904: 7, 1905: 7, 1906: 7, 1907: 7, 1912: 7, 1913: 7, 1922: 7, 1927: 7, 2016: 8, 2017: 8, 2018: 8, 2020: 8, 2023: 8, 2024: 8, 2028: 8, 2031: 8 }, - # Bolt EV no ACC 2018-2021 (StarPilot parity variant 2) + # Bolt EV no ACC 2018-2021 (variant 2) { 170: 8, 188: 8, 189: 7, 190: 6, 193: 8, 197: 8, 201: 8, 209: 7, 211: 2, 241: 6, 288: 5, 298: 8, 304: 1, 308: 4, 309: 8, 311: 8, 313: 8, 320: 3, 322: 7, 328: 1, 352: 5, 353: 3, 368: 3, 381: 8, 386: 8, 388: 8, 390: 7, 407: 7, 417: 7, 419: 1, 451: 8, 452: 8, 453: 6, 454: 8, 456: 8, 463: 3, 479: 3, 481: 7, 485: 8, 489: 8, 493: 8, 495: 4, 497: 8, 499: 3, 500: 6, 501: 8, 503: 2, 508: 8, 512: 6, 513: 6, 528: 5, 532: 6, 546: 7, 550: 8, 554: 3, 558: 8, 560: 8, 562: 8, 563: 5, 564: 5, 565: 5, 566: 7, 567: 5, 568: 2, 569: 3, 573: 1, 608: 8, 609: 6, 610: 6, 611: 6, 612: 8, 613: 8, 647: 3, 707: 8, 711: 6, 753: 5, 761: 7, 810: 8, 840: 5, 842: 5, 844: 8, 848: 4, 866: 4, 872: 1, 961: 8, 967: 4, 969: 8, 975: 2, 977: 8, 979: 7, 985: 5, 988: 6, 989: 8, 995: 7, 1001: 8, 1005: 6, 1009: 8, 1013: 3, 1017: 8, 1019: 2, 1020: 8, 1022: 1, 1037: 5, 1105: 5, 1187: 4, 1217: 8, 1221: 5, 1223: 3, 1225: 7, 1227: 4, 1233: 8, 1236: 8, 1243: 3, 1249: 8, 1257: 6, 1265: 8, 1275: 3, 1279: 4, 1280: 4, 1300: 8, 1322: 6, 1323: 4, 1328: 4, 1904: 7, 1905: 7, 1906: 7, 1907: 7, 1912: 7, 1913: 7, 1922: 7, 1927: 7 }, - # Bolt EV no ACC 2018-2021 (StarPilot parity variant 3) + # Bolt EV no ACC 2018-2021 (variant 3) { 170: 8, 188: 8, 189: 7, 190: 6, 193: 8, 197: 8, 201: 8, 209: 7, 211: 2, 241: 6, 288: 5, 298: 8, 304: 1, 308: 4, 309: 8, 311: 8, 313: 8, 320: 3, 322: 7, 328: 1, 352: 5, 353: 3, 368: 3, 381: 8, 386: 8, 388: 8, 390: 7, 407: 7, 417: 7, 419: 1, 451: 8, 452: 8, 453: 6, 454: 8, 456: 8, 463: 3, 479: 3, 481: 7, 485: 8, 489: 8, 493: 8, 495: 4, 497: 8, 499: 3, 500: 6, 501: 8, 503: 2, 508: 8, 528: 5, 532: 6, 546: 7, 550: 8, 554: 3, 558: 8, 560: 8, 562: 8, 563: 5, 564: 5, 565: 5, 566: 7, 567: 5, 568: 2, 569: 3, 573: 1, 608: 8, 609: 6, 610: 6, 611: 6, 612: 8, 613: 8, 647: 3, 707: 8, 711: 6, 753: 5, 761: 7, 810: 8, 840: 5, 842: 5, 844: 8, 848: 4, 866: 4, 872: 1, 961: 8, 967: 4, 969: 8, 975: 2, 977: 8, 979: 7, 985: 5, 988: 6, 989: 8, 995: 7, 1001: 8, 1005: 6, 1009: 8, 1013: 3, 1017: 8, 1019: 2, 1020: 8, 1022: 1, 1037: 5, 1105: 5, 1187: 4, 1217: 8, 1221: 5, 1223: 3, 1225: 7, 1227: 4, 1233: 8, 1236: 8, 1243: 3, 1249: 8, 1257: 6, 1265: 8, 1275: 3, 1279: 4, 1280: 4, 1300: 8, 1322: 6, 1323: 4, 1328: 4, 1904: 7, 1905: 7, 1906: 7, 1907: 7, 1912: 7, 1913: 7, 1922: 7, 1927: 7 }, - # Bolt EV no ACC 2018-2021 (StarPilot parity variant 4) + # Bolt EV no ACC 2018-2021 (variant 4) { 170: 8, 188: 8, 189: 7, 190: 6, 193: 8, 197: 8, 201: 8, 209: 7, 211: 2, 241: 6, 288: 5, 298: 8, 304: 1, 309: 8, 311: 8, 313: 8, 320: 3, 322: 7, 328: 1, 352: 5, 353: 3, 381: 8, 384: 4, 386: 8, 388: 8, 390: 7, 407: 7, 417: 7, 419: 1, 451: 8, 452: 8, 453: 6, 454: 8, 456: 8, 463: 3, 479: 3, 481: 7, 485: 8, 489: 8, 493: 8, 495: 4, 497: 8, 499: 3, 500: 6, 501: 8, 503: 2, 508: 8, 528: 5, 532: 6, 546: 7, 550: 8, 554: 3, 558: 8, 560: 8, 562: 8, 563: 5, 564: 5, 565: 5, 566: 7, 567: 5, 568: 2, 569: 3, 573: 1, 608: 8, 609: 6, 610: 6, 611: 6, 612: 8, 613: 8, 647: 3, 707: 8, 711: 6, 717: 5, 753: 5, 761: 7, 800: 6, 810: 8, 840: 5, 842: 5, 844: 8, 848: 4, 866: 4, 869: 4, 872: 1, 961: 8, 967: 4, 969: 8, 975: 2, 977: 8, 979: 7, 985: 5, 988: 6, 989: 8, 995: 7, 1001: 8, 1005: 6, 1009: 8, 1013: 3, 1017: 8, 1019: 2, 1020: 8, 1022: 1, 1037: 5, 1105: 5, 1187: 4, 1217: 8, 1221: 5, 1223: 3, 1225: 7, 1227: 4, 1233: 8, 1236: 8, 1243: 3, 1249: 8, 1257: 6, 1265: 8, 1268: 2, 1275: 3, 1279: 4, 1280: 4, 1300: 8, 1322: 6, 1323: 4, 1328: 4, 1904: 7, 1905: 7, 1906: 7, 1907: 7, 1912: 7, 1913: 7, 1927: 7, 2016: 8, 2024: 8 }, - # Bolt EV no ACC 2023 (StarPilot parity variant 5) + # Bolt EV no ACC 2023 (variant 5) { 170: 8, 188: 8, 189: 7, 190: 7, 193: 8, 197: 8, 201: 8, 209: 7, 211: 3, 241: 6, 257: 8, 288: 5, 289: 8, 292: 2, 298: 8, 304: 3, 308: 4, 309: 8, 311: 8, 313: 8, 320: 4, 322: 7, 328: 1, 331: 3, 352: 5, 353: 3, 368: 3, 381: 8, 384: 4, 386: 8, 388: 8, 390: 7, 398: 8, 407: 7, 417: 8, 419: 1, 451: 8, 452: 8, 453: 6, 454: 8, 456: 8, 458: 5, 463: 3, 479: 3, 481: 7, 485: 8, 489: 8, 493: 8, 495: 4, 497: 8, 499: 3, 500: 6, 501: 8, 503: 2, 508: 8, 513: 6, 528: 5, 532: 6, 546: 7, 550: 8, 554: 3, 558: 8, 560: 8, 562: 8, 563: 5, 564: 5, 565: 5, 566: 8, 567: 5, 568: 2, 569: 3, 573: 1, 577: 8, 579: 8, 592: 8, 608: 8, 609: 6, 610: 6, 611: 6, 612: 8, 613: 8, 647: 6, 707: 8, 711: 6, 715: 8, 717: 5, 753: 5, 761: 7, 789: 5, 800: 6, 810: 8, 840: 5, 842: 5, 844: 8, 848: 4, 866: 4, 869: 4, 872: 1, 880: 6, 961: 8, 967: 4, 969: 8, 975: 2, 977: 8, 979: 8, 985: 5, 988: 6, 989: 8, 995: 7, 1001: 8, 1005: 6, 1009: 8, 1010: 8, 1013: 6, 1015: 1, 1017: 8, 1019: 2, 1020: 8, 1037: 5, 1105: 5, 1187: 5, 1217: 8, 1221: 5, 1223: 3, 1225: 7, 1227: 4, 1233: 8, 1236: 8, 1249: 8, 1257: 6, 1265: 8, 1275: 3, 1279: 4, 1280: 4, 1296: 4, 1300: 8, 1322: 6, 1323: 4, 1328: 4, 1345: 8, 1347: 8, 1513: 8, 1516: 8, 1601: 8, 1609: 8, 1613: 8, 1616: 8, 1618: 8, 1649: 8, 1792: 8, 1793: 8, 1798: 8, 1824: 8, 1825: 8, 1840: 8, 1842: 8, 1858: 8, 1860: 8, 1863: 8, 1872: 8, 1875: 8, 1882: 8, 1888: 8, 1889: 8, 1892: 8, 1905: 7, 1906: 7, 1907: 7, 1910: 7, 1912: 7, 1913: 7, 1920: 8, 1922: 7, 1924: 8, 1927: 7, 1930: 7, 1937: 8, 1953: 8, 1968: 8, 1969: 8, 1971: 8, 1975: 8, 1984: 8, 1988: 8, 2000: 8, 2001: 8, 2002: 8, 2017: 8, 2018: 8, 2020: 8, 2023: 8, 2025: 8, 2028: 8, 2031: 8 }, - # Bolt EV no ACC 2023 (StarPilot parity variant 6) + # Bolt EV no ACC 2023 (variant 6) { 170: 8, 188: 8, 189: 7, 190: 7, 193: 8, 197: 8, 201: 8, 209: 7, 211: 3, 241: 6, 257: 8, 288: 5, 289: 8, 292: 2, 298: 8, 304: 3, 308: 4, 309: 8, 311: 8, 313: 8, 320: 4, 322: 7, 328: 1, 331: 3, 352: 5, 353: 3, 368: 3, 381: 8, 384: 4, 386: 8, 388: 8, 390: 7, 398: 8, 407: 7, 417: 8, 419: 1, 451: 8, 452: 8, 453: 6, 454: 8, 456: 8, 458: 5, 463: 3, 479: 3, 481: 7, 485: 8, 489: 8, 493: 8, 495: 4, 497: 8, 499: 3, 500: 6, 501: 8, 503: 2, 508: 8, 528: 5, 532: 6, 546: 7, 550: 8, 554: 3, 558: 8, 560: 8, 562: 8, 563: 5, 564: 5, 565: 5, 566: 8, 567: 5, 568: 2, 569: 3, 573: 1, 577: 8, 592: 8, 608: 8, 609: 6, 610: 6, 611: 6, 612: 8, 613: 8, 647: 6, 707: 8, 711: 6, 715: 8, 717: 5, 753: 5, 761: 7, 789: 5, 800: 6, 810: 8, 840: 5, 842: 5, 844: 8, 848: 4, 866: 4, 869: 4, 872: 1, 880: 6, 961: 8, 967: 4, 969: 8, 975: 2, 977: 8, 979: 8, 985: 5, 988: 6, 989: 8, 995: 7, 1001: 8, 1005: 6, 1009: 8, 1010: 8, 1013: 6, 1015: 1, 1017: 8, 1019: 2, 1020: 8, 1037: 5, 1105: 5, 1187: 5, 1217: 8, 1221: 5, 1223: 3, 1225: 7, 1227: 4, 1233: 8, 1236: 8, 1249: 8, 1257: 6, 1265: 8, 1275: 3, 1279: 4, 1280: 4, 1296: 4, 1300: 8, 1322: 6, 1323: 4, 1328: 4, 1601: 8, 1616: 8, 1618: 8, 1905: 7, 1906: 7, 1907: 7, 1910: 7, 1912: 7, 1913: 7, 1922: 7, 1927: 7, 1930: 7, 2016: 8, 2020: 8, 2023: 8, 2024: 8, 2028: 8, 2031: 8 }], @@ -191,14 +191,13 @@ FINGERPRINTS = { { 190: 6, 193: 8, 197: 8, 199: 4, 201: 8, 208: 8, 209: 7, 211: 2, 241: 6, 249: 8, 288: 5, 298: 8, 304: 1, 309: 8, 313: 8, 320: 3, 322: 7, 328: 1, 352: 5, 353: 3, 381: 6, 384: 4, 386: 8, 388: 8, 393: 7, 398: 8, 407: 7, 413: 8, 417: 7, 419: 1, 422: 4, 426: 7, 431: 8, 442: 8, 451: 8, 452: 8, 453: 6, 454: 8, 455: 7, 462: 4, 463: 3, 479: 3, 481: 7, 485: 8, 487: 8, 489: 8, 495: 4, 497: 8, 499: 3, 500: 6, 501: 8, 503: 1, 508: 8, 510: 8, 532: 6, 554: 3, 560: 8, 562: 8, 563: 5, 564: 5, 567: 5, 647: 3, 707: 8, 717: 5, 723: 2, 753: 5, 761: 7, 800: 6, 840: 5, 842: 5, 844: 8, 866: 4, 869: 4, 872: 1, 961: 8, 967: 4, 969: 8, 977: 8, 979: 8, 985: 5, 1001: 8, 1005: 6, 1009: 8, 1011: 6, 1013: 3, 1017: 8, 1019: 2, 1020: 8, 1022: 1, 1105: 6, 1217: 8, 1221: 5, 1223: 3, 1225: 7, 1233: 8, 1243: 3, 1249: 8, 1257: 6, 1259: 8, 1261: 7, 1263: 4, 1265: 8, 1267: 1, 1280: 4, 1300: 8, 1322: 6, 1328: 4, 1417: 8, 1904: 7, 1906: 7, 1907: 7, 1912: 7, 1913: 7, 1914: 7, 1919: 7, 1920: 7 }], - # StarPilot variables CAR.CHEVROLET_TRAX: [ { 190: 6, 193: 8, 197: 8, 201: 8, 209: 7, 211: 2, 241: 6, 249: 8, 288: 5, 298: 8, 304: 3, 309: 8, 311: 8, 313: 8, 320: 4, 322: 7, 328: 1, 352: 5, 381: 8, 384: 4, 386: 8, 388: 8, 413: 8, 451: 8, 452: 8, 453: 6, 455: 7, 479: 3, 481: 7, 485: 8, 489: 8, 497: 8, 500: 6, 501: 8, 532: 6, 560: 8, 562: 8, 563: 5, 565: 5, 587: 8, 608: 8, 609: 6, 610: 6, 611: 6, 612: 8, 613: 8, 707: 8, 715: 8, 717: 5, 761: 7, 789: 5, 800: 6, 810: 8, 840: 5, 842: 5, 844: 8, 869: 4, 880: 6, 977: 8, 1001: 8, 1011: 6, 1017: 8, 1020: 8, 1217: 8, 1221: 5, 1233: 8, 1249: 8, 1259: 8, 1261: 7, 1263: 4, 1265: 8, 1267: 1, 1271: 8, 1280: 4, 1296: 4, 1300: 8, 1611: 8, 1930: 7 }], } -# StarPilot parity: keep explicit GM platform fingerprints. +# Keep explicit GM platform fingerprints. FINGERPRINTS.update({ CAR.CHEVROLET_VOLT_ASCM: FINGERPRINTS[CAR.CHEVROLET_VOLT], diff --git a/opendbc_repo/opendbc/car/gm/gmcan.py b/opendbc_repo/opendbc/car/gm/gmcan.py index 5562f3ca7..68d417a37 100644 --- a/opendbc_repo/opendbc/car/gm/gmcan.py +++ b/opendbc_repo/opendbc/car/gm/gmcan.py @@ -136,7 +136,7 @@ def create_gas_regen_command(packer, bus, throttle, idx, enabled, at_full_stop, return packer.make_can_msg("ASCMGasRegenCmd", bus, values) - # Keep GM Global A camera-long GasRegen bytes aligned with StarPilot's legacy layout. + # Use the legacy GM Global A camera-long GasRegen byte layout. # The regenerated DBC shape does not expose the same wire-format helper fields. throttle = int(throttle) dat = bytearray(8) diff --git a/opendbc_repo/opendbc/car/gm/interface.py b/opendbc_repo/opendbc/car/gm/interface.py index e91f359ef..6732e4a0f 100755 --- a/opendbc_repo/opendbc/car/gm/interface.py +++ b/opendbc_repo/opendbc/car/gm/interface.py @@ -59,7 +59,6 @@ NON_LINEAR_TORQUE_PARAMS = { }, } -# OPGM variables PEDAL_MSG = 0x201 CAM_MSG = 0x320 ACCELERATOR_POS_MSG = 0xBE @@ -348,6 +347,15 @@ class CarInterface(CarInterfaceBase): ret.steerLimitTimer = 0.4 ret.longitudinalActuatorDelay = 0.5 # large delay to initially start braking + if candidate in ( + CAR.CHEVROLET_VOLT, + CAR.CHEVROLET_VOLT_2019, + CAR.CHEVROLET_VOLT_ASCM, + CAR.CHEVROLET_VOLT_CAMERA, + CAR.CHEVROLET_VOLT_CC, + ): + ret.minSteerSpeed = 7 * CV.MPH_TO_MS + if candidate in (CAR.CHEVROLET_VOLT, CAR.CHEVROLET_VOLT_CC, CAR.CHEVROLET_VOLT_CAMERA): ret.minEnableSpeed = -1 @@ -486,7 +494,6 @@ class CarInterface(CarInterfaceBase): ret.steerActuatorDelay = 0.5 CarInterfaceBase.configure_torque_tune(candidate, ret.lateralTuning) - # OPGM variables elif candidate in (CAR.CHEVROLET_MALIBU, CAR.CHEVROLET_MALIBU_CC, CAR.CHEVROLET_MALIBU_HYBRID_CC): ret.steerActuatorDelay = 0.2 CarInterfaceBase.configure_torque_tune(candidate, ret.lateralTuning) @@ -524,7 +531,7 @@ class CarInterface(CarInterfaceBase): ret.longitudinalTuning.kfDEPRECATED = 0.25 if is_bolt_2022_2023_pedal: - # Gen2 Bolt pedal-long should follow the no-ACC panda path like StarPilot. + # Gen2 Bolt pedal-long should follow the no-ACC panda path. ret.safetyConfigs[0].safetyParam |= GMSafetyFlags.FLAG_GM_NO_ACC.value if candidate in (CAR.CHEVROLET_BOLT_ACC_2022_2023_PEDAL, CAR.CHEVROLET_MALIBU_HYBRID_CC): @@ -627,7 +634,6 @@ class CarInterface(CarInterfaceBase): if remap_cancel_to_distance or malibu_cancel_passthrough: ret.alternativeExperience |= ALTERNATIVE_EXPERIENCE.GM_REMAP_CANCEL_TO_DISTANCE - # StarPilot variables if candidate == CAR.CHEVROLET_TRAX: CarInterfaceBase.configure_torque_tune(candidate, ret.lateralTuning) diff --git a/opendbc_repo/opendbc/car/gm/tests/test_gm.py b/opendbc_repo/opendbc/car/gm/tests/test_gm.py index 14ce81628..d1bc51cc8 100644 --- a/opendbc_repo/opendbc/car/gm/tests/test_gm.py +++ b/opendbc_repo/opendbc/car/gm/tests/test_gm.py @@ -1,9 +1,23 @@ +import pytest from parameterized import parameterized +from opendbc.car.car_helpers import interfaces +from opendbc.car.common.conversions import Conversions as CV from opendbc.car.gm.fingerprints import FINGERPRINTS -from opendbc.car.gm.values import CAMERA_ACC_CAR, CC_ONLY_CAR, GM_RX_OFFSET +from opendbc.car.gm.values import CAMERA_ACC_CAR, CAR, CC_ONLY_CAR, GM_RX_OFFSET CAMERA_DIAGNOSTIC_ADDRESS = 0x24b +VOLT_CARS = ( + CAR.CHEVROLET_VOLT, + CAR.CHEVROLET_VOLT_2019, + CAR.CHEVROLET_VOLT_ASCM, + CAR.CHEVROLET_VOLT_CAMERA, + CAR.CHEVROLET_VOLT_CC, +) + + +def _empty_fingerprint(): + return {bus: {} for bus in range(8)} class TestGMFingerprint: @@ -18,3 +32,12 @@ class TestGMFingerprint: for finger in fingerprints: for required_addr in (CAMERA_DIAGNOSTIC_ADDRESS, CAMERA_DIAGNOSTIC_ADDRESS + GM_RX_OFFSET): assert finger.get(required_addr) == 8, required_addr + + +class TestGMInterface: + @parameterized.expand(VOLT_CARS) + def test_volt_min_steer_speed_is_7_mph(self, car_model): + CarInterface = interfaces[car_model] + car_params = CarInterface.get_params(car_model, _empty_fingerprint(), [], alpha_long=False, is_release=False, docs=False) + + assert car_params.minSteerSpeed == pytest.approx(7 * CV.MPH_TO_MS) diff --git a/opendbc_repo/opendbc/car/gm/values.py b/opendbc_repo/opendbc/car/gm/values.py index 0ba471422..779bd6411 100644 --- a/opendbc_repo/opendbc/car/gm/values.py +++ b/opendbc_repo/opendbc/car/gm/values.py @@ -159,14 +159,13 @@ class GMSafetyFlags(IntFlag): HW_CAM_LONG = 2 EV = 4 - # OPGM variables FLAG_GM_CC_LONG = 8 FLAG_GM_GAS_INTERCEPTOR = 16 FLAG_GM_NO_ACC = 32 FLAG_GM_PEDAL_LONG = 64 HW_ASCM_LONG = 128 - # StarPilot parity variables + # Additional GM hardware and flag values HW_ASCM_INT = 256 FLAG_GM_FORCE_BRAKE_C9 = 512 HW_SDGM = 1024 @@ -437,7 +436,6 @@ class CanBus: DROPPED = 192 -# OPGM variables class GMFlags(IntFlag): PEDAL_LONG = 1 CC_LONG = 2 @@ -567,5 +565,4 @@ STEER_THRESHOLD = 1.0 DBC = CAR.create_dbc_map() -# StarPilot variables CAMERA_ACC_CAR.update({CAR.CHEVROLET_TRAX}) diff --git a/opendbc_repo/opendbc/car/honda/carstate.py b/opendbc_repo/opendbc/car/honda/carstate.py index 0c2706dd6..37f1c928b 100644 --- a/opendbc_repo/opendbc/car/honda/carstate.py +++ b/opendbc_repo/opendbc/car/honda/carstate.py @@ -220,7 +220,6 @@ class CarState(CarStateBase): *create_button_events(self.cruise_setting, prev_cruise_setting, SETTINGS_BUTTONS_DICT), ] - # StarPilot variables fp_ret = custom.StarPilotCarState.new_message() return ret, fp_ret diff --git a/opendbc_repo/opendbc/car/hyundai/carstate.py b/opendbc_repo/opendbc/car/hyundai/carstate.py index e1dce0d61..7c4f3a96a 100644 --- a/opendbc_repo/opendbc/car/hyundai/carstate.py +++ b/opendbc_repo/opendbc/car/hyundai/carstate.py @@ -203,7 +203,6 @@ class CarState(CarStateBase): self.low_speed_alert = False ret.lowSpeedAlert = self.low_speed_alert - # StarPilot variables fp_ret = custom.StarPilotCarState.new_message() return ret, fp_ret @@ -301,7 +300,6 @@ class CarState(CarStateBase): ret.blockPcmEnable = not self.recent_button_interaction() - # StarPilot variables fp_ret = custom.StarPilotCarState.new_message() return ret, fp_ret diff --git a/opendbc_repo/opendbc/car/hyundai/values.py b/opendbc_repo/opendbc/car/hyundai/values.py index d623567b9..6e5a26577 100644 --- a/opendbc_repo/opendbc/car/hyundai/values.py +++ b/opendbc_repo/opendbc/car/hyundai/values.py @@ -68,7 +68,6 @@ class HyundaiSafetyFlags(IntFlag): ALT_LIMITS_2 = 512 -# StarPilot variables class HyundaiStarPilotSafetyFlags(IntFlag): HAS_LDA_BUTTON = 1024 diff --git a/opendbc_repo/opendbc/car/interfaces.py b/opendbc_repo/opendbc/car/interfaces.py index bfde3cb85..fb906c751 100644 --- a/opendbc_repo/opendbc/car/interfaces.py +++ b/opendbc_repo/opendbc/car/interfaces.py @@ -30,7 +30,6 @@ from openpilot.common.params import Params GearShifter = structs.CarState.GearShifter ButtonType = structs.CarState.ButtonEvent.Type -# StarPilot variables Ecu = structs.CarParams.Ecu V_CRUISE_MAX = 145 @@ -133,7 +132,6 @@ class CarInterfaceBase(ABC): dbc_names = {bus: cp.dbc_name for bus, cp in self.can_parsers.items()} self.CC: CarControllerBase = self.CarController(dbc_names, CP) - # StarPilot variables self.FPCP = FPCP self.params_memory = Params(memory=True) @@ -181,14 +179,12 @@ class CarInterfaceBase(ABC): ret.rotationalInertia = scale_rot_inertia(ret.mass, ret.wheelbase) ret.tireStiffnessFront, ret.tireStiffnessRear = scale_tire_stiffness(ret.mass, ret.wheelbase, ret.centerToFront, ret.tireStiffnessFactor) - # StarPilot variables toggles_to_check = ("force_torque_controller", "nnff", "nnff_lite") if ret.steerControlType != structs.CarParams.SteerControlType.angle and any(getattr(starpilot_toggles, toggle, False) for toggle in toggles_to_check): CarInterfaceBase.configure_torque_tune(candidate, ret.lateralTuning) return ret - # StarPilot variables @classmethod def get_starpilot_params(cls, candidate: str, fingerprint: dict[int, dict[int, int]], car_fw: list[structs.CarParams.CarFw], CP: structs.CarParams, starpilot_toggles: SimpleNamespace): fp_ret = custom.StarPilotCarParams.new_message() @@ -343,7 +339,6 @@ class CarInterfaceBase(ABC): # save for next iteration self.CS.out = ret - # StarPilot variables prev_distance_button = self.distance_button self.distance_button = self.params_memory.get_bool("OnroadDistanceButtonPressed") if self.distance_button != prev_distance_button: @@ -383,7 +378,6 @@ class CarStateBase(ABC): K = get_kalman_gain(DT_CTRL, np.array(A), np.array(C), np.array(Q), R) self.v_ego_kf = KF1D(x0=x0, A=A, C=C[0], K=K) - # StarPilot variables self.FPCP = FPCP self.CC: structs.CarControl = structs.CarControl.new_message() diff --git a/opendbc_repo/opendbc/car/mazda/carstate.py b/opendbc_repo/opendbc/car/mazda/carstate.py index bad0d6f15..63668f6b5 100644 --- a/opendbc_repo/opendbc/car/mazda/carstate.py +++ b/opendbc_repo/opendbc/car/mazda/carstate.py @@ -116,7 +116,6 @@ class CarState(CarStateBase): # TODO: add button types for inc and dec ret.buttonEvents = create_button_events(self.distance_button, prev_distance_button, {1: ButtonType.gapAdjustCruise}) - # StarPilot variables fp_ret = custom.StarPilotCarState.new_message() return ret, fp_ret diff --git a/opendbc_repo/opendbc/car/mazda/interface.py b/opendbc_repo/opendbc/car/mazda/interface.py index 4a3d82745..d2f5a49b4 100644 --- a/opendbc_repo/opendbc/car/mazda/interface.py +++ b/opendbc_repo/opendbc/car/mazda/interface.py @@ -29,7 +29,6 @@ class CarInterface(CarInterfaceBase): ret.centerToFront = ret.wheelbase * 0.41 - # StarPilot variables ret.enableBsm = True return ret diff --git a/opendbc_repo/opendbc/car/nissan/carstate.py b/opendbc_repo/opendbc/car/nissan/carstate.py index 6e8532164..57d8fc2cd 100644 --- a/opendbc_repo/opendbc/car/nissan/carstate.py +++ b/opendbc_repo/opendbc/car/nissan/carstate.py @@ -25,7 +25,6 @@ class CarState(CarStateBase): self.distance_button = 0 - # StarPilot variables self.lkas_button = 0 def update(self, can_parsers, starpilot_toggles) -> structs.CarState: @@ -132,7 +131,6 @@ class CarState(CarStateBase): buttonEvents = create_button_events(self.distance_button, prev_distance_button, {1: ButtonType.gapAdjustCruise}) - # StarPilot variables fp_ret = custom.StarPilotCarState.new_message() self.prev_lkas_button = self.lkas_button diff --git a/opendbc_repo/opendbc/car/psa/carstate.py b/opendbc_repo/opendbc/car/psa/carstate.py index 581060c9a..6243a29f1 100644 --- a/opendbc_repo/opendbc/car/psa/carstate.py +++ b/opendbc_repo/opendbc/car/psa/carstate.py @@ -64,7 +64,6 @@ class CarState(CarStateBase): ret.doorOpen = any((cp_cam.vl['Dat_BSI']['DRIVER_DOOR'], cp_cam.vl['Dat_BSI']['PASSENGER_DOOR'])) ret.seatbeltUnlatched = cp_cam.vl['RESTRAINTS']['DRIVER_SEATBELT'] != 2 - # StarPilot variables fp_ret = custom.StarPilotCarState.new_message() return ret, fp_ret diff --git a/opendbc_repo/opendbc/car/rivian/carstate.py b/opendbc_repo/opendbc/car/rivian/carstate.py index 52877fd8b..b3ba0e547 100644 --- a/opendbc_repo/opendbc/car/rivian/carstate.py +++ b/opendbc_repo/opendbc/car/rivian/carstate.py @@ -93,7 +93,6 @@ class CarState(CarStateBase): self.sccm_wheel_touch = copy.copy(cp.vl["SCCM_WheelTouch"]) self.vdm_adas_status = copy.copy(cp.vl["VDM_AdasSts"]) - # StarPilot variables fp_ret = custom.StarPilotCarState.new_message() return ret, fp_ret diff --git a/opendbc_repo/opendbc/car/subaru/carcontroller.py b/opendbc_repo/opendbc/car/subaru/carcontroller.py index 280b200c1..aba1a580f 100644 --- a/opendbc_repo/opendbc/car/subaru/carcontroller.py +++ b/opendbc_repo/opendbc/car/subaru/carcontroller.py @@ -11,7 +11,6 @@ from opendbc.car.subaru.values import DBC, GLOBAL_ES_ADDR, CanBus, CarController MAX_STEER_RATE = 25 # deg/s MAX_STEER_RATE_FRAMES = 7 # tx control frames needed before torque can be cut -# StarPilot variables _SNG_ACC_MIN_DIST = 3 _SNG_ACC_MAX_DIST = 4.5 @@ -27,7 +26,6 @@ class CarController(CarControllerBase): self.p = CarControllerParams(CP) self.packer = CANPacker(DBC[CP.carFingerprint][Bus.pt]) - # StarPilot variables self.manual_hold = False self.prev_standstill = False self.sng_acc_resume = False @@ -71,7 +69,6 @@ class CarController(CarControllerBase): self.apply_torque_last = apply_torque - # StarPilot variables # *** stop and go *** if starpilot_toggles.subaru_sng: throttle_cmd, speed_cmd = self.stop_and_go(CC, CS) @@ -112,7 +109,6 @@ class CarController(CarControllerBase): can_sends.append(subarucan.create_preglobal_es_distance(self.packer, cruise_button, CS.es_distance_msg)) - # StarPilot variables if starpilot_toggles.subaru_sng: can_sends.append(subarucan.create_preglobal_throttle(self.packer, CS.throttle_msg["COUNTER"] + 1, CS.throttle_msg, throttle_cmd)) else: @@ -127,7 +123,6 @@ class CarController(CarControllerBase): if self.CP.flags & SubaruFlags.SEND_INFOTAINMENT: can_sends.append(subarucan.create_es_infotainment(self.packer, self.frame // 10, CS.es_infotainment_msg, hud_control.visualAlert)) - # StarPilot variables if starpilot_toggles.subaru_sng: can_sends.append(subarucan.create_throttle(self.packer, CS.throttle_msg["COUNTER"] + 1, CS.throttle_msg, throttle_cmd)) if self.frame % 2 == 0: @@ -171,7 +166,6 @@ class CarController(CarControllerBase): self.frame += 1 return new_actuators, can_sends - # StarPilot variables def stop_and_go(self, CC, CS, speed_cmd=False, throttle_cmd=False): if self.CP.flags & SubaruFlags.PREGLOBAL: trigger_resume = CC.enabled diff --git a/opendbc_repo/opendbc/car/subaru/carstate.py b/opendbc_repo/opendbc/car/subaru/carstate.py index 1de2e623c..33b9d3eac 100644 --- a/opendbc_repo/opendbc/car/subaru/carstate.py +++ b/opendbc_repo/opendbc/car/subaru/carstate.py @@ -124,7 +124,6 @@ class CarState(CarStateBase): if self.CP.flags & SubaruFlags.SEND_INFOTAINMENT: self.es_infotainment_msg = copy.copy(cp_cam.vl["ES_Infotainment"]) - # StarPilot variables fp_ret = custom.StarPilotCarState.new_message() if starpilot_toggles.subaru_sng: diff --git a/opendbc_repo/opendbc/car/subaru/subarucan.py b/opendbc_repo/opendbc/car/subaru/subarucan.py index c7bfc427e..92cf4e711 100644 --- a/opendbc_repo/opendbc/car/subaru/subarucan.py +++ b/opendbc_repo/opendbc/car/subaru/subarucan.py @@ -336,7 +336,6 @@ def subaru_checksum(address: int, sig, d: bytearray) -> int: return s & 0xFF -# StarPilot variables def create_brake_pedal(packer, frame, brake_pedal_msg, speed_cmd, brake_cmd): values = {s: brake_pedal_msg[s] for s in sorted([ "Brake_Lights", diff --git a/opendbc_repo/opendbc/car/subaru/values.py b/opendbc_repo/opendbc/car/subaru/values.py index 29df2a1d3..923829828 100644 --- a/opendbc_repo/opendbc/car/subaru/values.py +++ b/opendbc_repo/opendbc/car/subaru/values.py @@ -26,7 +26,6 @@ class CarControllerParams: elif CP.carFingerprint == CAR.SUBARU_IMPREZA_2020: self.STEER_DELTA_UP = 35 self.STEER_MAX = 1439 - # StarPilot variables elif CP.carFingerprint == CAR.SUBARU_IMPREZA: self.STEER_MAX = 3071 else: diff --git a/opendbc_repo/opendbc/car/tesla/carstate.py b/opendbc_repo/opendbc/car/tesla/carstate.py index b7b5d48a2..550edbe75 100644 --- a/opendbc_repo/opendbc/car/tesla/carstate.py +++ b/opendbc_repo/opendbc/car/tesla/carstate.py @@ -118,7 +118,6 @@ class CarState(CarStateBase): # Messages needed by carcontroller self.das_control = copy.copy(cp_ap_party.vl["DAS_control"]) - # StarPilot variables fp_ret = custom.StarPilotCarState.new_message() return ret, fp_ret diff --git a/opendbc_repo/opendbc/car/tests/routes.py b/opendbc_repo/opendbc/car/tests/routes.py index ea001bc1e..5dd0678c6 100644 --- a/opendbc_repo/opendbc/car/tests/routes.py +++ b/opendbc_repo/opendbc/car/tests/routes.py @@ -41,7 +41,6 @@ non_tested_cars = [ ] -# OPGM variables non_tested_cars.extend(CC_ONLY_CAR) diff --git a/opendbc_repo/opendbc/car/torque_data/override.toml b/opendbc_repo/opendbc/car/torque_data/override.toml index ef898a9d3..5128f54a9 100644 --- a/opendbc_repo/opendbc/car/torque_data/override.toml +++ b/opendbc_repo/opendbc/car/torque_data/override.toml @@ -104,5 +104,4 @@ legend = ["LAT_ACCEL_FACTOR", "MAX_LAT_ACCEL_MEASURED", "FRICTION"] "HONDA_CIVIC_2022" = [2.5, 1.2, 0.15] "HONDA_HRV_3G" = [2.5, 1.2, 0.2] -# OPGM variables "CHEVROLET_MALIBU_CC" = [1.85, 1.85, 0.075] diff --git a/opendbc_repo/opendbc/car/torque_data/params.toml b/opendbc_repo/opendbc/car/torque_data/params.toml index 6e350a523..fde2ca221 100644 --- a/opendbc_repo/opendbc/car/torque_data/params.toml +++ b/opendbc_repo/opendbc/car/torque_data/params.toml @@ -80,5 +80,3 @@ legend = ["LAT_ACCEL_FACTOR", "MAX_LAT_ACCEL_MEASURED", "FRICTION"] "VOLKSWAGEN_JETTA_MK7" = [1.2271623034089392, 1.216955117387, 0.19437384688370712] "VOLKSWAGEN_PASSAT_MK8" = [1.3432120736752917, 1.7087275587362314, 0.19444383787326647] "VOLKSWAGEN_TIGUAN_MK2" = [0.9711965500094828, 1.0001565939459098, 0.1465626137072916] - -# StarPilot variables diff --git a/opendbc_repo/opendbc/car/torque_data/substitute.toml b/opendbc_repo/opendbc/car/torque_data/substitute.toml index 79f9f62e2..6880ae9f0 100644 --- a/opendbc_repo/opendbc/car/torque_data/substitute.toml +++ b/opendbc_repo/opendbc/car/torque_data/substitute.toml @@ -94,7 +94,6 @@ legend = ["LAT_ACCEL_FACTOR", "MAX_LAT_ACCEL_MEASURED", "FRICTION"] "SUBARU_LEGACY_PREGLOBAL" = "SUBARU_IMPREZA" "SUBARU_ASCENT" = "SUBARU_FORESTER" -# OPGM variables "CADILLAC_CT6_CC" = "CHEVROLET_VOLT" "CADILLAC_XT5_CC" = "GMC_ACADIA" "CHEVROLET_EQUINOX_CC" = "CHEVROLET_EQUINOX" @@ -103,5 +102,4 @@ legend = ["LAT_ACCEL_FACTOR", "MAX_LAT_ACCEL_MEASURED", "FRICTION"] "GMC_YUKON_CC" = "CHEVROLET_SILVERADO" "CHEVROLET_TRAILBLAZER_CC" = "CHEVROLET_TRAILBLAZER" -# StarPilot variables "CHEVROLET_TRAX" = "CHEVROLET_VOLT" diff --git a/opendbc_repo/opendbc/car/toyota/carcontroller.py b/opendbc_repo/opendbc/car/toyota/carcontroller.py index 4eadb8370..78dac3b28 100644 --- a/opendbc_repo/opendbc/car/toyota/carcontroller.py +++ b/opendbc_repo/opendbc/car/toyota/carcontroller.py @@ -35,7 +35,6 @@ MAX_STEER_RATE_FRAMES = 18 # tx control frames needed before torque can be cut # EPS allows user torque above threshold for 50 frames before permanently faulting MAX_USER_TORQUE = 500 -# StarPilot variables PARK = structs.CarState.GearShifter.park # Lock / unlock door commands - Credit goes to AlexandreSato! @@ -86,7 +85,6 @@ class CarController(CarControllerBase): self.secoc_acc_message_counter = 0 self.secoc_prev_reset_counter = 0 - # StarPilot variables self.doors_locked = False def update(self, CC, CS, now_nanos, starpilot_toggles): @@ -334,7 +332,6 @@ class CarController(CarControllerBase): self.frame += 1 - # StarPilot variables if not self.doors_locked and CS.out.gearShifter != PARK: if starpilot_toggles.lock_doors: can_sends.append(CanData(0x750, LOCK_CMD, 0)) diff --git a/opendbc_repo/opendbc/car/toyota/carstate.py b/opendbc_repo/opendbc/car/toyota/carstate.py index 9d1847c8a..9edd2db5d 100644 --- a/opendbc_repo/opendbc/car/toyota/carstate.py +++ b/opendbc_repo/opendbc/car/toyota/carstate.py @@ -67,7 +67,6 @@ class CarState(CarStateBase): self.gvc = 0.0 self.secoc_synchronization = None - # StarPilot variables self.latActive_previous = False self.needs_angle_offset_zss = False @@ -222,7 +221,6 @@ class CarState(CarStateBase): buttonEvents += create_button_events(self.distance_button, prev_distance_button, {1: ButtonType.gapAdjustCruise}) - # StarPilot variables fp_ret = custom.StarPilotCarState.new_message() if self.has_SDSU and not self.has_can_filter: diff --git a/opendbc_repo/opendbc/car/toyota/values.py b/opendbc_repo/opendbc/car/toyota/values.py index 5ff2ccb65..e2ee6519f 100644 --- a/opendbc_repo/opendbc/car/toyota/values.py +++ b/opendbc_repo/opendbc/car/toyota/values.py @@ -80,7 +80,6 @@ class ToyotaFlags(IntFlag): SNG_WITHOUT_DSU_DEPRECATED = 512 -# StarPilot variables class ToyotaStarPilotFlags(IntFlag): RADAR_CAN_FILTER = 1 SMART_DSU = 2 diff --git a/opendbc_repo/opendbc/car/volkswagen/carstate.py b/opendbc_repo/opendbc/car/volkswagen/carstate.py index ba36d1305..11334f941 100644 --- a/opendbc_repo/opendbc/car/volkswagen/carstate.py +++ b/opendbc_repo/opendbc/car/volkswagen/carstate.py @@ -139,7 +139,6 @@ class CarState(CarStateBase): self.frame += 1 - # StarPilot variables fp_ret = custom.StarPilotCarState.new_message() return ret, fp_ret @@ -234,7 +233,6 @@ class CarState(CarStateBase): self.frame += 1 - # StarPilot variables fp_ret = custom.StarPilotCarState.new_message() return ret, fp_ret diff --git a/opendbc_repo/opendbc/safety/__init__.py b/opendbc_repo/opendbc/safety/__init__.py index 436bc507f..c4621bb63 100644 --- a/opendbc_repo/opendbc/safety/__init__.py +++ b/opendbc_repo/opendbc/safety/__init__.py @@ -9,6 +9,5 @@ class ALTERNATIVE_EXPERIENCE: RAISE_LONGITUDINAL_LIMITS_TO_ISO_MAX = 8 ALLOW_AEB = 16 - # StarPilot variables ALWAYS_ON_LATERAL = 32 GM_REMAP_CANCEL_TO_DISTANCE = 64 diff --git a/opendbc_repo/opendbc/safety/declarations.h b/opendbc_repo/opendbc/safety/declarations.h index e0d6be62c..9621d5ee9 100644 --- a/opendbc_repo/opendbc/safety/declarations.h +++ b/opendbc_repo/opendbc/safety/declarations.h @@ -247,7 +247,6 @@ void speed_mismatch_check(const float speed_2); void safety_tick(const safety_config *safety_config); -// OPGM variables bool longitudinal_interceptor_checks(const CANPacket_t *to_send); // This can be set by the safety hooks @@ -268,7 +267,6 @@ extern bool acc_main_on; // referred to as "ACC off" in ISO 15622:2018 extern int cruise_button_prev; extern bool safety_rx_checks_invalid; -// StarPilot variables extern bool aol_allowed; extern bool lkas_button_prev; extern bool lkas_on; @@ -294,7 +292,6 @@ extern uint32_t ts_angle_check_last; extern int desired_angle_last; extern struct sample_t angle_meas; // last 6 steer angles/curvatures -// OPGM variables extern bool enable_gas_interceptor; extern int gas_interceptor_prev; extern bool gm_remote_start_boots_comma; @@ -317,7 +314,6 @@ extern bool gm_remote_start_boots_comma; // This flag allows AEB to be commanded from openpilot. #define ALT_EXP_ALLOW_AEB 16 -// StarPilot variables #define ALT_EXP_ALWAYS_ON_LATERAL 32 #define ALT_EXP_GM_REMAP_CANCEL_TO_DISTANCE 64 diff --git a/opendbc_repo/opendbc/safety/longitudinal.h b/opendbc_repo/opendbc/safety/longitudinal.h index 71495c969..c747d0299 100644 --- a/opendbc_repo/opendbc/safety/longitudinal.h +++ b/opendbc_repo/opendbc/safety/longitudinal.h @@ -34,7 +34,6 @@ bool longitudinal_brake_checks(int desired_brake, const LongitudinalLimits limit return violation; } -// OPGM variables bool longitudinal_interceptor_checks(const CANPacket_t *msg) { return (!get_longitudinal_allowed() || brake_pressed_prev) && (msg->data[0] || msg->data[1]); } diff --git a/opendbc_repo/opendbc/safety/modes/chrysler.h b/opendbc_repo/opendbc/safety/modes/chrysler.h index 67ff9a947..0e210eb07 100644 --- a/opendbc_repo/opendbc/safety/modes/chrysler.h +++ b/opendbc_repo/opendbc/safety/modes/chrysler.h @@ -79,7 +79,6 @@ static void chrysler_rx_hook(const CANPacket_t *msg) { bool cruise_engaged = GET_BIT(msg, 21U); pcm_cruise_check(cruise_engaged); - // StarPilot variables acc_main_on = GET_BIT(msg, 20U); } diff --git a/opendbc_repo/opendbc/safety/modes/ford.h b/opendbc_repo/opendbc/safety/modes/ford.h index 423d9f634..6a2fdb20c 100644 --- a/opendbc_repo/opendbc/safety/modes/ford.h +++ b/opendbc_repo/opendbc/safety/modes/ford.h @@ -159,7 +159,6 @@ static void ford_rx_hook(const CANPacket_t *msg) { bool cruise_engaged = (cruise_state == 4U) || (cruise_state == 5U); pcm_cruise_check(cruise_engaged); - // StarPilot variables acc_main_on = (cruise_state == 3U) || cruise_engaged; } } diff --git a/opendbc_repo/opendbc/safety/modes/gm.h b/opendbc_repo/opendbc/safety/modes/gm.h index bd8846b95..fe333f8b5 100644 --- a/opendbc_repo/opendbc/safety/modes/gm.h +++ b/opendbc_repo/opendbc/safety/modes/gm.h @@ -61,12 +61,11 @@ static bool gm_panda_3d1_sched = false; static bool gm_panda_paddle_sched = false; static bool gm_bolt_2022_pedal = false; -// OPGM variables static bool gm_cc_long = false; static bool gm_has_acc = true; static bool gm_pedal_long = false; -// StarPilot parity scheduler state +// 3D1 spoof scheduler state static bool gm_3d1_spoof_valid = false; static bool gm_3d1_internal_tx = false; static uint8_t gm_3d1_spoof_data[8] = {0U}; @@ -199,7 +198,6 @@ static void gm_try_send_3d1_spoof(uint32_t now_us) { static void gm_rx_hook(const CANPacket_t *msg) { const int GM_STANDSTILL_THRSLD = 10; // 0.311kph - // OPGM variables // Keep panda threshold aligned with carstate to avoid pedal pre-enable mismatches. const int GM_GAS_INTERCEPTOR_THRESHOLD = 595; @@ -275,7 +273,6 @@ static void gm_rx_hook(const CANPacket_t *msg) { cruise_engaged_prev = false; } - // OPGM variables // Cruise check for CC only cars if ((msg->addr == 0x3D1U) && !gm_has_acc) { uint32_t now_us = microsecond_timer_get(); @@ -338,7 +335,7 @@ static void gm_rx_hook(const CANPacket_t *msg) { } } - // Keep camera-bus ACC status behavior aligned with StarPilot camera/SDGM paths. + // Keep camera-bus ACC status behavior consistent across camera and SDGM paths. if ((msg->addr == 0x370U) && (msg->bus == 2U)) { bool cruise_engaged = (msg->data[2] >> 7) != 0U; // ACCCmdActive if (gm_bolt_2022_pedal) { @@ -350,7 +347,6 @@ static void gm_rx_hook(const CANPacket_t *msg) { } } - // StarPilot variables if (msg->addr == 0xC9U) { acc_main_on = GET_BIT(msg, 29U); } @@ -440,7 +436,6 @@ static bool gm_tx_hook(const CANPacket_t *msg) { } } - // OPGM variables // GAS: safety check (interceptor) if (msg->addr == 0x200U) { if (longitudinal_interceptor_checks(msg)) { @@ -556,7 +551,6 @@ static safety_config gm_init(uint16_t param) { static const CanMsg GM_ASCM_TX_MSGS[] = {{0x180, 0, 4, .check_relay = true}, {0x409, 0, 7, .check_relay = false}, {0x40A, 0, 7, .check_relay = false}, {0x2CB, 0, 8, .check_relay = true}, {0x370, 0, 6, .check_relay = false}, // pt bus {0xA1, 1, 7, .check_relay = false}, {0x306, 1, 8, .check_relay = false}, {0x308, 1, 7, .check_relay = false}, {0x310, 1, 2, .check_relay = false}, // obs bus {0x315, 2, 5, .check_relay = false}, // ch bus - // OPGM Variables {0x200, 0, 6, .check_relay = false}, {0x1E1, 0, 7, .check_relay = false}, {0xBD, 0, 7, .check_relay = false}, @@ -573,7 +567,6 @@ static safety_config gm_init(uint16_t param) { // block PSCMStatus (0x184); forwarded through openpilot to hide an alert from the camera static const CanMsg GM_CAM_LONG_TX_MSGS[] = {{0x180, 0, 4, .check_relay = true}, {0x315, 0, 5, .check_relay = true}, {0x2CB, 0, 8, .check_relay = true}, {0x370, 0, 6, .check_relay = true}, {0x3D1, 0, 8, .check_relay = false}, // pt bus {0x184, 2, 8, .check_relay = true}, // camera bus - // OPGM Variables {0x200, 0, 6, .check_relay = false}, {0x1E1, 0, 7, .check_relay = false}, {0xBD, 0, 7, .check_relay = false}, {0x1F5, 0, 8, .check_relay = false}}; // pt bus @@ -581,7 +574,6 @@ static safety_config gm_init(uint16_t param) { static RxCheck gm_rx_checks[] = { GM_COMMON_RX_CHECKS - // OPGM Variables GM_ACC_RX_CHECKS }; @@ -589,7 +581,6 @@ static safety_config gm_init(uint16_t param) { GM_COMMON_RX_CHECKS {.msg = {{0xBD, 0, 7, 40U, .ignore_checksum = true, .ignore_counter = true, .ignore_quality_flag = true}, { 0 }, { 0 }}}, - // OPGM Variables GM_ACC_RX_CHECKS }; @@ -600,12 +591,10 @@ static safety_config gm_init(uint16_t param) { static const CanMsg GM_CAM_TX_MSGS[] = {{0x180, 0, 4, .check_relay = true}, {0x370, 0, 6, .check_relay = false}, {0x3D1, 0, 8, .check_relay = false}, // pt bus {0x1E1, 2, 7, .check_relay = false}, {0x184, 2, 8, .check_relay = true}, // camera bus - // OPGM Variables {0x200, 0, 6, .check_relay = false}, {0x1E1, 0, 7, .check_relay = false}, {0xBD, 0, 7, .check_relay = false}, {0x1F5, 0, 8, .check_relay = false}}; // pt bus - // OPGM Variables static RxCheck gm_no_acc_ev_rx_checks[] = { GM_COMMON_RX_CHECKS {.msg = {{0xBD, 0, 7, 40U, .ignore_checksum = true, .ignore_counter = true, .ignore_quality_flag = true}, { 0 }, { 0 }}}, @@ -646,7 +635,6 @@ static safety_config gm_init(uint16_t param) { gm_sdgm = GET_FLAG(param, GM_PARAM_HW_SDGM); gm_ascm_int = GET_FLAG(param, GM_PARAM_HW_ASCM_INT); - // OPGM Variables gm_cc_long = GET_FLAG(param, GM_PARAM_CC_LONG); gm_has_acc = !GET_FLAG(param, GM_PARAM_NO_ACC); gm_pedal_long = GET_FLAG(param, GM_PARAM_PEDAL_LONG); diff --git a/opendbc_repo/opendbc/safety/modes/hyundai.h b/opendbc_repo/opendbc/safety/modes/hyundai.h index c431997ca..dc8c95b22 100644 --- a/opendbc_repo/opendbc/safety/modes/hyundai.h +++ b/opendbc_repo/opendbc/safety/modes/hyundai.h @@ -52,7 +52,6 @@ const LongitudinalLimits HYUNDAI_LONG_LIMITS = { #define HYUNDAI_FCEV_GAS_ADDR_CHECK \ {.msg = {{0x91, 0, 8, 100U, .ignore_checksum = true, .ignore_counter = true, .ignore_quality_flag = true}, { 0 }, { 0 }}}, \ -// StarPilot variables #define HYUNDAI_LDA_BUTTON_ADDR_CHECK \ {.msg = {{0x391, 0, 8, 100U, .ignore_checksum = true, .ignore_counter = true, .ignore_quality_flag = true}, { 0 }, { 0 }}}, \ @@ -178,7 +177,6 @@ static void hyundai_rx_hook(const CANPacket_t *msg) { brake_pressed = ((msg->data[5] >> 5U) & 0x3U) == 0x2U; } - // StarPilot variables if (msg->addr == 0x391U) { hyundai_lkas_button_check(GET_BIT(msg, 4U)); } @@ -288,7 +286,6 @@ static safety_config hyundai_init(uint16_t param) { HYUNDAI_FCEV_GAS_ADDR_CHECK }; - // StarPilot variables static RxCheck hyundai_long_rx_checks_lda[] = { HYUNDAI_COMMON_RX_CHECKS(false) HYUNDAI_LDA_BUTTON_ADDR_CHECK @@ -325,7 +322,6 @@ static safety_config hyundai_init(uint16_t param) { HYUNDAI_SCC12_ADDR_CHECK(2) }; - // StarPilot variables static RxCheck hyundai_cam_scc_rx_checks_lda[] = { HYUNDAI_COMMON_RX_CHECKS(false) HYUNDAI_SCC12_ADDR_CHECK(2) @@ -349,7 +345,6 @@ static safety_config hyundai_init(uint16_t param) { HYUNDAI_FCEV_GAS_ADDR_CHECK }; - // StarPilot variables static RxCheck hyundai_rx_checks_lda[] = { HYUNDAI_COMMON_RX_CHECKS(false) HYUNDAI_SCC12_ADDR_CHECK(0) diff --git a/opendbc_repo/opendbc/safety/modes/hyundai_canfd.h b/opendbc_repo/opendbc/safety/modes/hyundai_canfd.h index fb5081323..8702b5f00 100644 --- a/opendbc_repo/opendbc/safety/modes/hyundai_canfd.h +++ b/opendbc_repo/opendbc/safety/modes/hyundai_canfd.h @@ -89,13 +89,11 @@ static void hyundai_canfd_rx_hook(const CANPacket_t *msg) { cruise_button = msg->data[2] & 0x7U; main_button = GET_BIT(msg, 19U); - // StarPilot variables hyundai_lkas_button_check(GET_BIT(msg, 23U)); } else { cruise_button = (msg->data[4] >> 4) & 0x7U; main_button = GET_BIT(msg, 34U); - // StarPilot variables hyundai_lkas_button_check(GET_BIT(msg, 39U)); } hyundai_common_cruise_buttons_check(cruise_button, main_button); diff --git a/opendbc_repo/opendbc/safety/modes/hyundai_common.h b/opendbc_repo/opendbc/safety/modes/hyundai_common.h index 4d6648ca6..e81fd56c7 100644 --- a/opendbc_repo/opendbc/safety/modes/hyundai_common.h +++ b/opendbc_repo/opendbc/safety/modes/hyundai_common.h @@ -42,7 +42,6 @@ bool hyundai_fcev_gas_signal = false; extern bool hyundai_alt_limits_2; bool hyundai_alt_limits_2 = false; -// StarPilot variables extern bool hyundai_has_lda_button; bool hyundai_has_lda_button = false; @@ -57,7 +56,6 @@ void hyundai_common_init(uint16_t param) { const uint16_t HYUNDAI_PARAM_FCEV_GAS = 256; const uint16_t HYUNDAI_PARAM_ALT_LIMITS_2 = 512; - // StarPilot variables const int HYUNDAI_PARAM_HAS_LDA_BUTTON = 1024; hyundai_ev_gas_signal = GET_FLAG(param, HYUNDAI_PARAM_EV_GAS); @@ -68,7 +66,6 @@ void hyundai_common_init(uint16_t param) { hyundai_fcev_gas_signal = GET_FLAG(param, HYUNDAI_PARAM_FCEV_GAS); hyundai_alt_limits_2 = GET_FLAG(param, HYUNDAI_PARAM_ALT_LIMITS_2); - // StarPilot variables hyundai_has_lda_button = GET_FLAG(param, HYUNDAI_PARAM_HAS_LDA_BUTTON); hyundai_last_button_interaction = HYUNDAI_PREV_BUTTON_SAMPLES; @@ -121,7 +118,6 @@ void hyundai_common_cruise_buttons_check(const int cruise_button, const bool mai cruise_button_prev = cruise_button; } - // StarPilot variables if (main_button && !main_button_prev) { acc_main_on = !acc_main_on; } @@ -155,7 +151,6 @@ uint32_t hyundai_common_canfd_compute_checksum(const CANPacket_t *msg) { } #endif -// StarPilot variables void hyundai_lkas_button_check(const bool lkas_button) { if (lkas_button && !lkas_button_prev) { lkas_on = !lkas_on; diff --git a/opendbc_repo/opendbc/safety/modes/mazda.h b/opendbc_repo/opendbc/safety/modes/mazda.h index 888e7c6d0..a36d75a40 100644 --- a/opendbc_repo/opendbc/safety/modes/mazda.h +++ b/opendbc_repo/opendbc/safety/modes/mazda.h @@ -35,7 +35,6 @@ static void mazda_rx_hook(const CANPacket_t *msg) { bool cruise_engaged = msg->data[0] & 0x8U; pcm_cruise_check(cruise_engaged); - // StarPilot variables acc_main_on = GET_BIT(msg, 17U); } diff --git a/opendbc_repo/opendbc/safety/modes/nissan.h b/opendbc_repo/opendbc/safety/modes/nissan.h index 350133a09..1bcdbc105 100644 --- a/opendbc_repo/opendbc/safety/modes/nissan.h +++ b/opendbc_repo/opendbc/safety/modes/nissan.h @@ -51,7 +51,6 @@ static void nissan_rx_hook(const CANPacket_t *msg) { pcm_cruise_check(cruise_engaged); } - // StarPilot variables if ((msg->addr == 0x1B6U) && (msg->bus == (nissan_alt_eps ? 2U : 1U))) { acc_main_on = GET_BIT(msg, 36U); } diff --git a/opendbc_repo/opendbc/safety/modes/psa.h b/opendbc_repo/opendbc/safety/modes/psa.h index 8e3a65dae..e348fb08a 100644 --- a/opendbc_repo/opendbc/safety/modes/psa.h +++ b/opendbc_repo/opendbc/safety/modes/psa.h @@ -10,7 +10,6 @@ #define PSA_DAT_BSI 1042U // RX from BSI, brake #define PSA_LANE_KEEP_ASSIST 1010U // TX from OP, EPS -// StarPilot variables #define PSA_HS2_DYN1_MDD_ETAT_2B6 694U // RX from BSI, ACC status // CAN bus @@ -24,7 +23,6 @@ static uint8_t psa_get_counter(const CANPacket_t *msg) { cnt = (msg->data[3] >> 4) & 0xFU; } else if (msg->addr == PSA_HS2_DYN_ABR_38D) { cnt = (msg->data[5] >> 4) & 0xFU; - // StarPilot variables } else if (msg->addr == PSA_HS2_DYN1_MDD_ETAT_2B6) { cnt = (msg->data[7] >> 4) & 0xFU; } else { @@ -38,7 +36,6 @@ static uint32_t psa_get_checksum(const CANPacket_t *msg) { chksum = msg->data[5] & 0xFU; } else if (msg->addr == PSA_HS2_DYN_ABR_38D) { chksum = msg->data[5] & 0xFU; - // StarPilot variables } else if (msg->addr == PSA_HS2_DYN1_MDD_ETAT_2B6) { chksum = msg->data[7] & 0xFU; } else { @@ -68,7 +65,6 @@ static uint32_t psa_compute_checksum(const CANPacket_t *msg) { chk = _psa_compute_checksum(msg, 0x4, 5); } else if (msg->addr == PSA_HS2_DYN_ABR_38D) { chk = _psa_compute_checksum(msg, 0x7, 5); - // StarPilot variables } else if (msg->addr == PSA_HS2_DYN1_MDD_ETAT_2B6) { chk = _psa_compute_checksum(msg, 0x3, 7); } else { @@ -96,7 +92,6 @@ static void psa_rx_hook(const CANPacket_t *msg) { if (msg->addr == PSA_HS2_DAT_MDD_CMD_452) { pcm_cruise_check((msg->data[2U] >> 7U) & 1U); // RVV_ACC_ACTIVATION_REQ } - // StarPilot variables if (msg->addr == PSA_HS2_DYN1_MDD_ETAT_2B6) { acc_main_on = (msg->data[3] & 0x0FU) > 2; } @@ -153,7 +148,6 @@ static safety_config psa_init(uint16_t param) { {.msg = {{PSA_DYN_CMM, PSA_MAIN_BUS, 8, 100U, .ignore_checksum = true, .ignore_counter = true, .ignore_quality_flag = true}, { 0 }, { 0 }}}, // gas pedal {.msg = {{PSA_DAT_BSI, PSA_CAM_BUS, 8, 20U, .ignore_checksum = true, .ignore_counter = true, .ignore_quality_flag = true}, { 0 }, { 0 }}}, // brake - // StarPilot variables {.msg = {{PSA_HS2_DYN1_MDD_ETAT_2B6, PSA_ADAS_BUS, 8, 20U, .max_counter = 15U, .ignore_quality_flag = true}, { 0 }, { 0 }}}, // ACC status }; diff --git a/opendbc_repo/opendbc/safety/modes/rivian.h b/opendbc_repo/opendbc/safety/modes/rivian.h index c55c6e8bc..b9f488ae6 100644 --- a/opendbc_repo/opendbc/safety/modes/rivian.h +++ b/opendbc_repo/opendbc/safety/modes/rivian.h @@ -98,7 +98,6 @@ static void rivian_rx_hook(const CANPacket_t *msg) { const int feature_status = msg->data[2] >> 5U; pcm_cruise_check(feature_status == 1); - // StarPilot variables acc_main_on = (feature_status == 0) || (feature_status == 1); } } diff --git a/opendbc_repo/opendbc/safety/modes/subaru.h b/opendbc_repo/opendbc/safety/modes/subaru.h index be893bbb1..b0a2364d5 100644 --- a/opendbc_repo/opendbc/safety/modes/subaru.h +++ b/opendbc_repo/opendbc/safety/modes/subaru.h @@ -110,7 +110,6 @@ static void subaru_rx_hook(const CANPacket_t *msg) { bool cruise_engaged = (msg->data[5] >> 1) & 1U; pcm_cruise_check(cruise_engaged); - // StarPilot variables acc_main_on = GET_BIT(msg, 40U); } diff --git a/opendbc_repo/opendbc/safety/modes/subaru_preglobal.h b/opendbc_repo/opendbc/safety/modes/subaru_preglobal.h index 77a83065c..19fb907f2 100644 --- a/opendbc_repo/opendbc/safety/modes/subaru_preglobal.h +++ b/opendbc_repo/opendbc/safety/modes/subaru_preglobal.h @@ -34,7 +34,6 @@ static void subaru_preglobal_rx_hook(const CANPacket_t *msg) { bool cruise_engaged = (msg->data[6] >> 1) & 1U; pcm_cruise_check(cruise_engaged); - // StarPilot variables acc_main_on = GET_BIT(msg, 48U); } diff --git a/opendbc_repo/opendbc/safety/modes/tesla.h b/opendbc_repo/opendbc/safety/modes/tesla.h index 9bfc2b5a7..d563128ae 100644 --- a/opendbc_repo/opendbc/safety/modes/tesla.h +++ b/opendbc_repo/opendbc/safety/modes/tesla.h @@ -160,7 +160,6 @@ static void tesla_rx_hook(const CANPacket_t *msg) { pcm_cruise_check(cruise_engaged); - // StarPilot variables acc_main_on = ((cruise_state == 1) || cruise_engaged) && !tesla_autopark; } diff --git a/opendbc_repo/opendbc/safety/modes/toyota.h b/opendbc_repo/opendbc/safety/modes/toyota.h index 912d87278..d084077d3 100644 --- a/opendbc_repo/opendbc/safety/modes/toyota.h +++ b/opendbc_repo/opendbc/safety/modes/toyota.h @@ -162,7 +162,6 @@ static void toyota_rx_hook(const CANPacket_t *msg) { UPDATE_VEHICLE_SPEED(speed / 4.0 * 0.01 * KPH_TO_MS); } - // StarPilot variables if (msg->addr == 0x1D3U) { acc_main_on = GET_BIT(msg, 15U); } diff --git a/opendbc_repo/opendbc/safety/safety.h b/opendbc_repo/opendbc/safety/safety.h index 47709c0b9..9009bc7f0 100644 --- a/opendbc_repo/opendbc/safety/safety.h +++ b/opendbc_repo/opendbc/safety/safety.h @@ -60,7 +60,6 @@ bool acc_main_on = false; // referred to as "ACC off" in ISO 15622:2018 int cruise_button_prev = 0; bool safety_rx_checks_invalid = false; -// StarPilot variables bool aol_allowed = false; bool lkas_button_prev = false; bool lkas_on = false; @@ -97,7 +96,6 @@ uint16_t current_safety_param = 0; static const safety_hooks *current_hooks = &nooutput_hooks; safety_config current_safety_config; -// OPGM variables bool enable_gas_interceptor = false; int gas_interceptor_prev = 0; bool gm_remote_start_boots_comma = false; @@ -375,7 +373,6 @@ static void generic_rx_checks(void) { } steering_disengage_prev = steering_disengage; - // StarPilot variables aol_allowed = (acc_main_on || lkas_on) && (alternative_experience & ALT_EXP_ALWAYS_ON_LATERAL); } @@ -497,11 +494,9 @@ int set_safety_hooks(uint16_t mode, uint16_t param) { } } - // OPGM variables enable_gas_interceptor = false; gas_interceptor_prev = 0; - // StarPilot variables aol_allowed = false; lkas_button_prev = false; lkas_on = false; diff --git a/opendbc_repo/opendbc/safety/tests/common.py b/opendbc_repo/opendbc/safety/tests/common.py index 4be28d7fe..2022b9b8b 100644 --- a/opendbc_repo/opendbc/safety/tests/common.py +++ b/opendbc_repo/opendbc/safety/tests/common.py @@ -310,7 +310,6 @@ class TorqueSteeringSafetyTestBase(SafetyTestBase, abc.ABC): for _ in range(10): self.assertFalse(self._tx(self._torque_cmd_msg(self.MAX_TORQUE, 1))) - # StarPilot variables def _toggle_aol(self, toggle_on): """Toggles "Always On Lateral" On/Off""" pass @@ -851,7 +850,6 @@ class AngleSteeringSafetyTest(VehicleSpeedSafetyTest): for _ in range(5): self.assertTrue(self._tx(self._angle_cmd_msg(0, True, increment_timer=False))) - # StarPilot variables def _toggle_aol(self, toggle_on): """Toggles "Always On Lateral" on/off""" pass @@ -1216,7 +1214,6 @@ class CarSafetyTest(SafetyTest): self.assertFalse(self.safety.safety_config_valid()) -# OPGM variables class GasInterceptorSafetyTest(PandaSafetyTestBase): INTERCEPTOR_THRESHOLD = 0 diff --git a/opendbc_repo/opendbc/safety/tests/hyundai_common.py b/opendbc_repo/opendbc/safety/tests/hyundai_common.py index 9ec336b6c..caa55cbe8 100644 --- a/opendbc_repo/opendbc/safety/tests/hyundai_common.py +++ b/opendbc_repo/opendbc/safety/tests/hyundai_common.py @@ -71,7 +71,6 @@ class HyundaiButtonBase: self.assertEqual(controls_allowed, self.safety.get_controls_allowed()) self._rx(self._button_msg(Buttons.NONE)) - # StarPilot variables def _toggle_aol(self, toggle_on): """ Simulates toggling the main cruise button. The safety model requires a diff --git a/opendbc_repo/opendbc/safety/tests/test_chrysler.py b/opendbc_repo/opendbc/safety/tests/test_chrysler.py index b461b6709..f7f3a111c 100755 --- a/opendbc_repo/opendbc/safety/tests/test_chrysler.py +++ b/opendbc_repo/opendbc/safety/tests/test_chrysler.py @@ -71,7 +71,6 @@ class TestChryslerSafety(common.CarSafetyTest, common.MotorTorqueSteeringSafetyT self.assertFalse(self._tx(self._button_msg(cancel=True, resume=True))) self.assertFalse(self._tx(self._button_msg(cancel=False, resume=False))) - # StarPilot variables def _toggle_aol(self, toggle_on): # DAS_3, bit 20 is ACC_AVAILABLE values = {"ACC_AVAILABLE": 1 if toggle_on else 0} diff --git a/opendbc_repo/opendbc/safety/tests/test_ford.py b/opendbc_repo/opendbc/safety/tests/test_ford.py index b977315fe..292d3c188 100755 --- a/opendbc_repo/opendbc/safety/tests/test_ford.py +++ b/opendbc_repo/opendbc/safety/tests/test_ford.py @@ -378,7 +378,6 @@ class TestFordSafetyBase(common.CarSafetyTest): for bus in (0, 2): self.assertEqual(enabled, self._tx(self._acc_button_msg(Buttons.CANCEL, bus))) - # StarPilot variables def _toggle_aol(self, toggle_on): # EngBrakeData, CcStat_D_Actl is the cruise state # 3 is standby (main on), 5 is active (engaged) diff --git a/opendbc_repo/opendbc/safety/tests/test_gm.py b/opendbc_repo/opendbc/safety/tests/test_gm.py index 5815c37a0..8432e78bc 100755 --- a/opendbc_repo/opendbc/safety/tests/test_gm.py +++ b/opendbc_repo/opendbc/safety/tests/test_gm.py @@ -132,7 +132,6 @@ class TestGmSafetyBase(common.CarSafetyTest, common.DriverTorqueSteeringSafetyTe values = {"ACCButtons": buttons} return self.packer.make_can_msg_safety("ASCMSteeringButton", self.BUTTONS_BUS, values) - # StarPilot variables def _toggle_aol(self, toggle_on): # ECMEngineStatus, bit 29 is CruiseMainOn values = {"CruiseMainOn": 1 if toggle_on else 0} @@ -289,7 +288,6 @@ class TestGmCameraLongitudinalEVSafety(GmCameraAccEVRegenMixin, TestGmCameraLong pass -# OPGM variables def interceptor_msg(gas, addr): to_send = common.make_msg(0, addr, 6) to_send[0].data[0] = (gas & 0xFF00) >> 8 diff --git a/opendbc_repo/opendbc/safety/tests/test_honda.py b/opendbc_repo/opendbc/safety/tests/test_honda.py index c0ab7d59c..e65885774 100755 --- a/opendbc_repo/opendbc/safety/tests/test_honda.py +++ b/opendbc_repo/opendbc/safety/tests/test_honda.py @@ -237,7 +237,6 @@ class HondaBase(common.CarSafetyTest): self.assertTrue(self._tx(self._send_steer_msg(0x0000))) self.assertFalse(self._tx(self._send_steer_msg(0x1000))) - # StarPilot variables def _toggle_aol(self, toggle_on): # SCM_FEEDBACK, bit 28 is MAIN_ON values = {"MAIN_ON": 1 if toggle_on else 0, "COUNTER": self.cnt_acc_state % 4} diff --git a/opendbc_repo/opendbc/safety/tests/test_hyundai_canfd.py b/opendbc_repo/opendbc/safety/tests/test_hyundai_canfd.py index ab894ce44..5c4cbae11 100755 --- a/opendbc_repo/opendbc/safety/tests/test_hyundai_canfd.py +++ b/opendbc_repo/opendbc/safety/tests/test_hyundai_canfd.py @@ -81,7 +81,6 @@ class TestHyundaiCanfdBase(HyundaiButtonBase, common.CarSafetyTest, common.Drive } return self.packer.make_can_msg_safety("CRUISE_BUTTONS", bus, values) - # StarPilot variables def _toggle_aol(self, toggle_on): if not hasattr(self, "_aol_state"): self._aol_state = False @@ -172,7 +171,6 @@ class TestHyundaiCanfdLFASteeringAltButtonsBase(TestHyundaiCanfdLFASteeringBase) self.assertFalse(self._tx(self._acc_cancel_msg(True, accel=1))) self.assertFalse(self._tx(self._acc_cancel_msg(False))) - # StarPilot variables def _toggle_aol(self, toggle_on): if not hasattr(self, "_aol_state"): self._aol_state = False diff --git a/opendbc_repo/opendbc/safety/tests/test_mazda.py b/opendbc_repo/opendbc/safety/tests/test_mazda.py index 533259cfb..9b2c1b306 100755 --- a/opendbc_repo/opendbc/safety/tests/test_mazda.py +++ b/opendbc_repo/opendbc/safety/tests/test_mazda.py @@ -80,7 +80,6 @@ class TestMazdaSafety(common.CarSafetyTest, common.DriverTorqueSteeringSafetyTes self.assertTrue(self._tx(self._button_msg(cancel=True))) self.assertTrue(self._tx(self._button_msg(resume=True))) - # StarPilot variables def _toggle_aol(self, toggle_on): # CRZ_CTRL, CRZ_AVAILABLE is the main on button values = {"CRZ_AVAILABLE": 1 if toggle_on else 0} diff --git a/opendbc_repo/opendbc/safety/tests/test_nissan.py b/opendbc_repo/opendbc/safety/tests/test_nissan.py index 94b2e61e7..b2f05901a 100755 --- a/opendbc_repo/opendbc/safety/tests/test_nissan.py +++ b/opendbc_repo/opendbc/safety/tests/test_nissan.py @@ -79,7 +79,6 @@ class TestNissanSafety(common.CarSafetyTest, common.AngleSteeringSafetyTest): tx = self._tx(self._acc_button_cmd(**args)) self.assertEqual(tx, should_tx) - # StarPilot variables def _toggle_aol(self, toggle_on): # PRO_PILOT, CRUISE_ON is the main on button for X-Trail/Rogue/Altima values = {"CRUISE_ON": 1 if toggle_on else 0} @@ -119,7 +118,6 @@ class TestNissanLeafSafety(TestNissanSafety): def test_acc_buttons(self): pass - # StarPilot variables def _toggle_aol(self, toggle_on): # CRUISE_THROTTLE, CRUISE_AVAILABLE is the main on button for Leaf values = {"CRUISE_AVAILABLE": 1 if toggle_on else 0} diff --git a/opendbc_repo/opendbc/safety/tests/test_subaru.py b/opendbc_repo/opendbc/safety/tests/test_subaru.py index 37a7b1b27..7a0b13a2e 100755 --- a/opendbc_repo/opendbc/safety/tests/test_subaru.py +++ b/opendbc_repo/opendbc/safety/tests/test_subaru.py @@ -111,7 +111,6 @@ class TestSubaruSafetyBase(common.CarSafetyTest): values = {"Cruise_Activated": enable} return self.packer.make_can_msg_safety("CruiseControl", self.ALT_MAIN_BUS, values) - # StarPilot variables def _toggle_aol(self, toggle_on): # CruiseControl, Cruise_On is the main on button values = {"Cruise_On": 1 if toggle_on else 0} diff --git a/opendbc_repo/opendbc/safety/tests/test_subaru_preglobal.py b/opendbc_repo/opendbc/safety/tests/test_subaru_preglobal.py index ec726f3fd..74e5b6d05 100755 --- a/opendbc_repo/opendbc/safety/tests/test_subaru_preglobal.py +++ b/opendbc_repo/opendbc/safety/tests/test_subaru_preglobal.py @@ -59,7 +59,6 @@ class TestSubaruPreglobalSafety(common.CarSafetyTest, common.DriverTorqueSteerin values = {"Cruise_Activated": enable} return self.packer.make_can_msg_safety("CruiseControl", 0, values) - # StarPilot variables def _toggle_aol(self, toggle_on): # CruiseControl, Cruise_On is the main on button values = {"Cruise_On": 1 if toggle_on else 0} diff --git a/opendbc_repo/opendbc/safety/tests/test_tesla.py b/opendbc_repo/opendbc/safety/tests/test_tesla.py index cbca544a0..bf03e50b9 100755 --- a/opendbc_repo/opendbc/safety/tests/test_tesla.py +++ b/opendbc_repo/opendbc/safety/tests/test_tesla.py @@ -353,7 +353,6 @@ class TestTeslaSafetyBase(common.CarSafetyTest, common.AngleSteeringSafetyTest, # Recover self.assertTrue(self._tx(self._angle_cmd_msg(0, True))) - # StarPilot variables def _toggle_aol(self, toggle_on): # DI_state, DI_cruiseState is the cruise state, 1 is standby values = {"DI_cruiseState": 1 if toggle_on else 0} diff --git a/opendbc_repo/opendbc/safety/tests/test_toyota.py b/opendbc_repo/opendbc/safety/tests/test_toyota.py index 59b7dc463..e7fe2bb8e 100644 --- a/opendbc_repo/opendbc/safety/tests/test_toyota.py +++ b/opendbc_repo/opendbc/safety/tests/test_toyota.py @@ -122,7 +122,6 @@ class TestToyotaSafetyBase(common.CarSafetyTest, common.LongitudinalAccelSafetyT self.assertFalse(self._rx(msg)) self.assertFalse(self.safety.get_controls_allowed()) - # StarPilot variables def _toggle_aol(self, toggle_on): # pcm_cruise_2, bit 15 is toggle_on values = {"MAIN_ON": 1 if toggle_on else 0} diff --git a/opendbc_repo/opendbc/safety/tests/test_volkswagen_mqb.py b/opendbc_repo/opendbc/safety/tests/test_volkswagen_mqb.py index 79189d3f6..1af63a540 100755 --- a/opendbc_repo/opendbc/safety/tests/test_volkswagen_mqb.py +++ b/opendbc_repo/opendbc/safety/tests/test_volkswagen_mqb.py @@ -126,7 +126,6 @@ class TestVolkswagenMqbSafetyBase(common.CarSafetyTest, common.DriverTorqueSteer self.assertEqual(0, self.safety.get_torque_driver_max()) self.assertEqual(0, self.safety.get_torque_driver_min()) - # StarPilot variables def _toggle_aol(self, toggle_on): # TSK_06, TSK_Status is the cruise state, 2 is standby return self._tsk_status_msg(False, main_switch=toggle_on) diff --git a/opendbc_repo/opendbc/safety/tests/test_volkswagen_pq.py b/opendbc_repo/opendbc/safety/tests/test_volkswagen_pq.py index 2f472e587..bedc53f71 100755 --- a/opendbc_repo/opendbc/safety/tests/test_volkswagen_pq.py +++ b/opendbc_repo/opendbc/safety/tests/test_volkswagen_pq.py @@ -108,7 +108,6 @@ class TestVolkswagenPqSafetyBase(common.CarSafetyTest, common.DriverTorqueSteeri self.assertEqual(0, self.safety.get_torque_driver_max()) self.assertEqual(0, self.safety.get_torque_driver_min()) - # StarPilot variables def _toggle_aol(self, toggle_on): # Motor_5, GRA_Hauptschalter is the main cruise switch return self._motor_5_msg(main_switch=toggle_on) diff --git a/panda/board/obj/body_h7.bin.signed b/panda/board/obj/body_h7.bin.signed index 5955f71a3..f5ee65ce6 100644 Binary files a/panda/board/obj/body_h7.bin.signed and b/panda/board/obj/body_h7.bin.signed differ diff --git a/panda/board/obj/body_h7/bootstub.elf b/panda/board/obj/body_h7/bootstub.elf index 230b44eec..efcabbb2e 100755 Binary files a/panda/board/obj/body_h7/bootstub.elf and b/panda/board/obj/body_h7/bootstub.elf differ diff --git a/panda/board/obj/body_h7/main.bin b/panda/board/obj/body_h7/main.bin index 3f31650f9..565a907d6 100755 Binary files a/panda/board/obj/body_h7/main.bin and b/panda/board/obj/body_h7/main.bin differ diff --git a/panda/board/obj/body_h7/main.elf b/panda/board/obj/body_h7/main.elf index e33877e1a..c381a42b8 100755 Binary files a/panda/board/obj/body_h7/main.elf and b/panda/board/obj/body_h7/main.elf differ diff --git a/panda/board/obj/bootstub.body_h7.bin b/panda/board/obj/bootstub.body_h7.bin index 4ad66e971..b12510e34 100755 Binary files a/panda/board/obj/bootstub.body_h7.bin and b/panda/board/obj/bootstub.body_h7.bin differ diff --git a/panda/board/obj/bootstub.panda.bin b/panda/board/obj/bootstub.panda.bin index f49b8f618..81f65efd3 100755 Binary files a/panda/board/obj/bootstub.panda.bin and b/panda/board/obj/bootstub.panda.bin differ diff --git a/panda/board/obj/bootstub.panda_h7.bin b/panda/board/obj/bootstub.panda_h7.bin index b81ba748c..584eaf301 100755 Binary files a/panda/board/obj/bootstub.panda_h7.bin and b/panda/board/obj/bootstub.panda_h7.bin differ diff --git a/panda/board/obj/bootstub.panda_h7_remote.bin b/panda/board/obj/bootstub.panda_h7_remote.bin index b81ba748c..584eaf301 100755 Binary files a/panda/board/obj/bootstub.panda_h7_remote.bin and b/panda/board/obj/bootstub.panda_h7_remote.bin differ diff --git a/panda/board/obj/bootstub.panda_jungle_h7.bin b/panda/board/obj/bootstub.panda_jungle_h7.bin index e29d8d893..838481de5 100755 Binary files a/panda/board/obj/bootstub.panda_jungle_h7.bin and b/panda/board/obj/bootstub.panda_jungle_h7.bin differ diff --git a/panda/board/obj/bootstub.panda_remote.bin b/panda/board/obj/bootstub.panda_remote.bin index f49b8f618..81f65efd3 100755 Binary files a/panda/board/obj/bootstub.panda_remote.bin and b/panda/board/obj/bootstub.panda_remote.bin differ diff --git a/panda/board/obj/gitversion.h b/panda/board/obj/gitversion.h index fe7f806d8..f10ee4cc5 100644 --- a/panda/board/obj/gitversion.h +++ b/panda/board/obj/gitversion.h @@ -1,2 +1,2 @@ extern const uint8_t gitversion[19]; -const uint8_t gitversion[19] = "DEV-a97a59be-DEBUG"; +const uint8_t gitversion[19] = "DEV-82619bd7-DEBUG"; diff --git a/panda/board/obj/panda.bin.signed b/panda/board/obj/panda.bin.signed index c38891042..a833d4dee 100644 Binary files a/panda/board/obj/panda.bin.signed and b/panda/board/obj/panda.bin.signed differ diff --git a/panda/board/obj/panda/bootstub.elf b/panda/board/obj/panda/bootstub.elf index 2c1dc2b3b..7253eecc3 100755 Binary files a/panda/board/obj/panda/bootstub.elf and b/panda/board/obj/panda/bootstub.elf differ diff --git a/panda/board/obj/panda/main.bin b/panda/board/obj/panda/main.bin index 4900c9289..e141ed98d 100755 Binary files a/panda/board/obj/panda/main.bin and b/panda/board/obj/panda/main.bin differ diff --git a/panda/board/obj/panda/main.elf b/panda/board/obj/panda/main.elf index 09bf2c9cf..2ec1b4558 100755 Binary files a/panda/board/obj/panda/main.elf and b/panda/board/obj/panda/main.elf differ diff --git a/panda/board/obj/panda_h7.bin.signed b/panda/board/obj/panda_h7.bin.signed index 06342dcdd..03b251481 100644 Binary files a/panda/board/obj/panda_h7.bin.signed and b/panda/board/obj/panda_h7.bin.signed differ diff --git a/panda/board/obj/panda_h7/bootstub.elf b/panda/board/obj/panda_h7/bootstub.elf index 167e26ad7..a3265a685 100755 Binary files a/panda/board/obj/panda_h7/bootstub.elf and b/panda/board/obj/panda_h7/bootstub.elf differ diff --git a/panda/board/obj/panda_h7/main.bin b/panda/board/obj/panda_h7/main.bin index 8013608ad..0529b1413 100755 Binary files a/panda/board/obj/panda_h7/main.bin and b/panda/board/obj/panda_h7/main.bin differ diff --git a/panda/board/obj/panda_h7/main.elf b/panda/board/obj/panda_h7/main.elf index 5bc1cb660..cdc135157 100755 Binary files a/panda/board/obj/panda_h7/main.elf and b/panda/board/obj/panda_h7/main.elf differ diff --git a/panda/board/obj/panda_h7_remote.bin.signed b/panda/board/obj/panda_h7_remote.bin.signed index 93f3f2fc0..a1817cb3e 100644 Binary files a/panda/board/obj/panda_h7_remote.bin.signed and b/panda/board/obj/panda_h7_remote.bin.signed differ diff --git a/panda/board/obj/panda_h7_remote/bootstub.elf b/panda/board/obj/panda_h7_remote/bootstub.elf index 9a1c245d0..fb354cf92 100755 Binary files a/panda/board/obj/panda_h7_remote/bootstub.elf and b/panda/board/obj/panda_h7_remote/bootstub.elf differ diff --git a/panda/board/obj/panda_h7_remote/main.bin b/panda/board/obj/panda_h7_remote/main.bin index 5744c84e1..a1a841736 100755 Binary files a/panda/board/obj/panda_h7_remote/main.bin and b/panda/board/obj/panda_h7_remote/main.bin differ diff --git a/panda/board/obj/panda_h7_remote/main.elf b/panda/board/obj/panda_h7_remote/main.elf index 487b1fc1d..6eea34670 100755 Binary files a/panda/board/obj/panda_h7_remote/main.elf and b/panda/board/obj/panda_h7_remote/main.elf differ diff --git a/panda/board/obj/panda_jungle_h7.bin.signed b/panda/board/obj/panda_jungle_h7.bin.signed index fb0767bd0..89ac3f97b 100644 Binary files a/panda/board/obj/panda_jungle_h7.bin.signed and b/panda/board/obj/panda_jungle_h7.bin.signed differ diff --git a/panda/board/obj/panda_jungle_h7/bootstub.elf b/panda/board/obj/panda_jungle_h7/bootstub.elf index 4d694a1be..b1fd91369 100755 Binary files a/panda/board/obj/panda_jungle_h7/bootstub.elf and b/panda/board/obj/panda_jungle_h7/bootstub.elf differ diff --git a/panda/board/obj/panda_jungle_h7/main.bin b/panda/board/obj/panda_jungle_h7/main.bin index d92f2b6dc..f239891b6 100755 Binary files a/panda/board/obj/panda_jungle_h7/main.bin and b/panda/board/obj/panda_jungle_h7/main.bin differ diff --git a/panda/board/obj/panda_jungle_h7/main.elf b/panda/board/obj/panda_jungle_h7/main.elf index bf53fb758..32f43489e 100755 Binary files a/panda/board/obj/panda_jungle_h7/main.elf and b/panda/board/obj/panda_jungle_h7/main.elf differ diff --git a/panda/board/obj/panda_remote.bin.signed b/panda/board/obj/panda_remote.bin.signed index 6396dc8cd..aa6d1b6c0 100644 Binary files a/panda/board/obj/panda_remote.bin.signed and b/panda/board/obj/panda_remote.bin.signed differ diff --git a/panda/board/obj/panda_remote/bootstub.elf b/panda/board/obj/panda_remote/bootstub.elf index d30defb2c..0a6cba7df 100755 Binary files a/panda/board/obj/panda_remote/bootstub.elf and b/panda/board/obj/panda_remote/bootstub.elf differ diff --git a/panda/board/obj/panda_remote/main.bin b/panda/board/obj/panda_remote/main.bin index 38a7eeebd..bdd2a5915 100755 Binary files a/panda/board/obj/panda_remote/main.bin and b/panda/board/obj/panda_remote/main.bin differ diff --git a/panda/board/obj/panda_remote/main.elf b/panda/board/obj/panda_remote/main.elf index 6265b7e65..ef0590bdc 100755 Binary files a/panda/board/obj/panda_remote/main.elf and b/panda/board/obj/panda_remote/main.elf differ diff --git a/panda/board/obj/version b/panda/board/obj/version index c2ce2ec13..382bc80eb 100644 --- a/panda/board/obj/version +++ b/panda/board/obj/version @@ -1 +1 @@ -DEV-a97a59be-DEBUG \ No newline at end of file +DEV-82619bd7-DEBUG \ No newline at end of file diff --git a/selfdrive/car/car_specific.py b/selfdrive/car/car_specific.py index 44ff06e34..47341a07b 100644 --- a/selfdrive/car/car_specific.py +++ b/selfdrive/car/car_specific.py @@ -140,8 +140,8 @@ class CarSpecificEvents: events.add(EventName.belowSteerSpeed) self.gm_low_speed_alert_shown = True - # Match StarPilot's GM-specific standstill engage behavior. Most camera-ACC cars can - # engage below 5 kph only when stopped with brake applied; SDGM remains narrower. + # Most camera-ACC cars can engage below 5 kph only when stopped with brake applied; + # SDGM remains narrower. standstill_brake_enable_allowed = ( CS.standstill and CS.brake >= 20 and @@ -153,7 +153,7 @@ class CarSpecificEvents: if CS.cruiseState.standstill and not self.CP.autoResumeSng: events.add(EventName.resumeRequired) - # Preserve the prior cycle's cruise-enabled state so low-speed disengage matches StarPilot. + # Preserve the prior cycle's cruise-enabled state for low-speed disengage behavior. if ((self.CP.flags & GMFlags.CC_LONG) and CS.vEgo < self.CP.minEnableSpeed and (CS.cruiseState.enabled or CS_prev.cruiseState.enabled)): diff --git a/selfdrive/car/card.py b/selfdrive/car/card.py index f2a34de88..6f5538b77 100644 --- a/selfdrive/car/card.py +++ b/selfdrive/car/card.py @@ -67,7 +67,6 @@ class Car: RI: RadarInterfaceBase CP: car.CarParams - # StarPilot variables FPCP: custom.StarPilotCarParams def __init__(self, CI=None, RI=None) -> None: @@ -113,7 +112,6 @@ class Car: # continue onto next fingerprinting step in pandad self.params.put_bool("FirmwareQueryDone", True) - # StarPilot variables self.FPCP = self.CI.FPCP else: self.CI, self.CP, self.FPCP = CI, CI.CP, CI.FPCP @@ -169,10 +167,8 @@ class Car: # card is driven by can recv, expected at 100Hz self.rk = Ratekeeper(100, print_delay_threshold=None) - # OPGM variables self.resume_prev_button = False - # StarPilot variables self.starpilot_toggles = get_starpilot_toggles() if self.starpilot_toggles.always_on_lateral: @@ -216,22 +212,33 @@ class Car: if can_rcv_valid and REPLAY: self.can_log_mono_time = messaging.log_from_bytes(can_strs[0]).logMonoTime - self.v_cruise_helper.update_v_cruise(CS, self.sm['carControl'].enabled, self.is_metric, self.starpilot_toggles) + self.v_cruise_helper.update_v_cruise( + CS, + self.sm['carControl'].enabled, + self.is_metric, + self.sm['starpilotPlan'].speedLimitChanged, + self.starpilot_toggles, + ) if self.sm['carControl'].enabled and not self.CC_prev.enabled: # Use CarState w/ buttons from the step selfdrived enables on - self.v_cruise_helper.initialize_v_cruise(self.CS_prev, self.experimental_mode, self.resume_prev_button, self.starpilot_toggles) + desired_speed_limit = self.sm['starpilotPlan'].slcSpeedLimit + self.sm['starpilotPlan'].slcSpeedLimitOffset + self.v_cruise_helper.initialize_v_cruise( + self.CS_prev, + self.experimental_mode, + self.resume_prev_button, + self.starpilot_toggles, + desired_speed_limit=desired_speed_limit, + ) # TODO: mirror the carState.cruiseState struct? CS.vCruise = float(self.v_cruise_helper.v_cruise_kph) CS.vCruiseCluster = float(self.v_cruise_helper.v_cruise_cluster_kph) - # OPGM variables if any(be.type in (ButtonType.accelCruise, ButtonType.resumeCruise) for be in CS.buttonEvents): self.resume_prev_button = True elif any(be.type in (ButtonType.decelCruise, ButtonType.setCruise) for be in CS.buttonEvents): self.resume_prev_button = False - # StarPilot variables FPCS = self.starpilot_card.update(CS, FPCS, self.sm, self.starpilot_toggles) return CS, RD, FPCS @@ -266,7 +273,6 @@ class Car: tracks_msg.liveTracks = RD self.pm.send('liveTracks', tracks_msg) - # StarPilot variables fpcs_send = messaging.new_message('starpilotCarState') fpcs_send.valid = CS.canValid fpcs_send.starpilotCarState = FPCS @@ -303,7 +309,6 @@ class Car: self.initialized_prev = initialized self.CS_prev = CS - # StarPilot variables self.CI.CS.CC = self.sm['carControl'] self.starpilot_toggles = get_starpilot_toggles(self.sm) diff --git a/selfdrive/car/cruise.py b/selfdrive/car/cruise.py index 1ef95bb10..b12081f9a 100644 --- a/selfdrive/car/cruise.py +++ b/selfdrive/car/cruise.py @@ -40,20 +40,30 @@ class VCruiseHelper: self.button_timers = {ButtonType.decelCruise: 0, ButtonType.accelCruise: 0} self.button_change_states = {btn: {"standstill": False, "enabled": False} for btn in self.button_timers} - # OPGM variables self.gm_cc_only = self.CP.carFingerprint in CC_ONLY_CAR and self.CP.flags & GMFlags.CC_LONG.value + def _get_short_press_delta(self, is_metric, starpilot_toggles: SimpleNamespace) -> float: + base_delta = 1. if is_metric else IMPERIAL_INCREMENT + return base_delta * starpilot_toggles.cruise_increase + + def _normalize_initialized_v_cruise(self, v_cruise_kph: float, starpilot_toggles: SimpleNamespace) -> float: + if starpilot_toggles.cruise_increase % 5 != 0: + return v_cruise_kph + + v_cruise_delta = self._get_short_press_delta(starpilot_toggles.is_metric, starpilot_toggles) + return round(round(v_cruise_kph / v_cruise_delta) * v_cruise_delta, 1) + @property def v_cruise_initialized(self): return self.v_cruise_kph != V_CRUISE_UNSET - def update_v_cruise(self, CS, enabled, is_metric, starpilot_toggles): + def update_v_cruise(self, CS, enabled, is_metric, speed_limit_changed, starpilot_toggles): self.v_cruise_kph_last = self.v_cruise_kph if CS.cruiseState.available: if self.gm_cc_only or not self.CP.pcmCruise: # if stock cruise is completely disabled, then we can use our own set speed logic - self._update_v_cruise_non_pcm(CS, enabled, is_metric, starpilot_toggles) + self._update_v_cruise_non_pcm(CS, enabled, is_metric, speed_limit_changed, starpilot_toggles) self.v_cruise_cluster_kph = self.v_cruise_kph self.update_button_timers(CS, enabled) else: @@ -69,7 +79,7 @@ class VCruiseHelper: self.v_cruise_kph = V_CRUISE_UNSET self.v_cruise_cluster_kph = V_CRUISE_UNSET - def _update_v_cruise_non_pcm(self, CS, enabled, is_metric, starpilot_toggles): + def _update_v_cruise_non_pcm(self, CS, enabled, is_metric, speed_limit_changed, starpilot_toggles): # handle button presses. TODO: this should be in state_control, but a decelCruise press # would have the effect of both enabling and changing speed is checked after the state transition if not enabled: @@ -96,6 +106,10 @@ class VCruiseHelper: if button_type is None: return + # Don't adjust speed when pressing to confirm or deny speed limit changes + if speed_limit_changed: + return + # Don't adjust speed when pressing resume to exit standstill cruise_standstill = self.button_change_states[button_type]["standstill"] or CS.cruiseState.standstill if button_type == ButtonType.accelCruise and cruise_standstill: @@ -130,7 +144,8 @@ class VCruiseHelper: self.button_timers[b.type.raw] = 1 if b.pressed else 0 self.button_change_states[b.type.raw] = {"standstill": CS.cruiseState.standstill, "enabled": enabled} - def initialize_v_cruise(self, CS, experimental_mode: bool, resume_prev_button: bool, starpilot_toggles: SimpleNamespace) -> None: + def initialize_v_cruise(self, CS, experimental_mode: bool, resume_prev_button: bool, + starpilot_toggles: SimpleNamespace, desired_speed_limit: float = 0.0) -> None: # initializing is handled by the PCM if self.CP.pcmCruise and not self.gm_cc_only: return @@ -140,6 +155,9 @@ class VCruiseHelper: if (any(b.type in (ButtonType.accelCruise, ButtonType.resumeCruise) for b in CS.buttonEvents) and self.v_cruise_initialized or (self.gm_cc_only and resume_prev_button)): self.v_cruise_kph = self.v_cruise_kph_last + elif desired_speed_limit > 0 and getattr(starpilot_toggles, "set_speed_limit", False): + initialized_speed_limit_kph = self._normalize_initialized_v_cruise(desired_speed_limit * CV.MS_TO_KPH, starpilot_toggles) + self.v_cruise_kph = float(np.clip(initialized_speed_limit_kph, V_CRUISE_MIN, V_CRUISE_MAX)) else: self.v_cruise_kph = int(round(np.clip(CS.vEgo * CV.MS_TO_KPH, engage_floor_kph, V_CRUISE_MAX))) diff --git a/selfdrive/car/tests/test_cruise_speed.py b/selfdrive/car/tests/test_cruise_speed.py index 86965ef14..a71273a0d 100644 --- a/selfdrive/car/tests/test_cruise_speed.py +++ b/selfdrive/car/tests/test_cruise_speed.py @@ -3,6 +3,7 @@ import itertools import numpy as np from parameterized import parameterized_class +from types import SimpleNamespace from cereal import log from openpilot.selfdrive.car.cruise import VCruiseHelper, V_CRUISE_MIN, V_CRUISE_MAX, V_CRUISE_INITIAL, IMPERIAL_INCREMENT from cereal import car @@ -50,16 +51,33 @@ class TestVCruiseHelper: def setup_method(self): self.CP = car.CarParams(pcmCruise=self.pcm_cruise) self.v_cruise_helper = VCruiseHelper(self.CP) + self.starpilot_toggles = SimpleNamespace( + cruise_increase=1, + cruise_increase_long=5, + is_metric=False, + set_speed_limit=False, + ) self.reset_cruise_speed_state() def reset_cruise_speed_state(self): # Two resets previous cruise speed for _ in range(2): - self.v_cruise_helper.update_v_cruise(car.CarState(cruiseState={"available": False}), enabled=False, is_metric=False) + self.v_cruise_helper.update_v_cruise( + car.CarState(cruiseState={"available": False}), + enabled=False, + is_metric=False, + speed_limit_changed=False, + starpilot_toggles=self.starpilot_toggles, + ) def enable(self, v_ego, experimental_mode): # Simulates user pressing set with a current speed - self.v_cruise_helper.initialize_v_cruise(car.CarState(vEgo=v_ego), experimental_mode, False) + self.v_cruise_helper.initialize_v_cruise( + car.CarState(vEgo=v_ego), + experimental_mode, + False, + self.starpilot_toggles, + ) def test_adjust_speed(self): """ @@ -73,7 +91,13 @@ class TestVCruiseHelper: CS = car.CarState(cruiseState={"available": True}) CS.buttonEvents = [ButtonEvent(type=btn, pressed=pressed)] - self.v_cruise_helper.update_v_cruise(CS, enabled=True, is_metric=False) + self.v_cruise_helper.update_v_cruise( + CS, + enabled=True, + is_metric=False, + speed_limit_changed=False, + starpilot_toggles=self.starpilot_toggles, + ) assert pressed == (self.v_cruise_helper.v_cruise_kph == self.v_cruise_helper.v_cruise_kph_last) def test_rising_edge_enable(self): @@ -88,7 +112,13 @@ class TestVCruiseHelper: (True, False)): CS = car.CarState(cruiseState={"available": True}) CS.buttonEvents = [ButtonEvent(type=ButtonType.decelCruise, pressed=pressed)] - self.v_cruise_helper.update_v_cruise(CS, enabled=enabled, is_metric=False) + self.v_cruise_helper.update_v_cruise( + CS, + enabled=enabled, + is_metric=False, + speed_limit_changed=False, + starpilot_toggles=self.starpilot_toggles, + ) if pressed: self.enable(V_CRUISE_INITIAL * CV.KPH_TO_MS, False) @@ -106,7 +136,13 @@ class TestVCruiseHelper: for pressed in (True, False): CS = car.CarState(cruiseState={"available": True, "standstill": standstill}) CS.buttonEvents = [ButtonEvent(type=ButtonType.accelCruise, pressed=pressed)] - self.v_cruise_helper.update_v_cruise(CS, enabled=True, is_metric=False) + self.v_cruise_helper.update_v_cruise( + CS, + enabled=True, + is_metric=False, + speed_limit_changed=False, + starpilot_toggles=self.starpilot_toggles, + ) # speed should only update if not at standstill and button falling edge should_equal = standstill or pressed @@ -129,7 +165,13 @@ class TestVCruiseHelper: CS = car.CarState(vEgo=float(v_ego), gasPressed=True, cruiseState={"available": True}) CS.buttonEvents = [ButtonEvent(type=ButtonType.decelCruise, pressed=False)] - self.v_cruise_helper.update_v_cruise(CS, enabled=True, is_metric=False) + self.v_cruise_helper.update_v_cruise( + CS, + enabled=True, + is_metric=False, + speed_limit_changed=False, + starpilot_toggles=self.starpilot_toggles, + ) # TODO: fix skipping first run due to enabled on rising edge exception if v_ego == 0.0: @@ -149,3 +191,44 @@ class TestVCruiseHelper: self.enable(float(v_ego), experimental_mode) assert V_CRUISE_INITIAL <= self.v_cruise_helper.v_cruise_kph <= V_CRUISE_MAX assert self.v_cruise_helper.v_cruise_initialized + + def test_initialize_v_cruise_matches_speed_limit(self): + self.reset_cruise_speed_state() + self.starpilot_toggles.set_speed_limit = True + + desired_speed_limit = 55 * CV.MPH_TO_MS + self.v_cruise_helper.initialize_v_cruise( + car.CarState(vEgo=70 * CV.MPH_TO_MS), + experimental_mode=False, + resume_prev_button=False, + starpilot_toggles=self.starpilot_toggles, + desired_speed_limit=desired_speed_limit, + ) + + assert self.v_cruise_helper.v_cruise_kph == pytest.approx(55 * CV.MPH_TO_KPH) + + def test_speed_limit_confirmation_does_not_adjust_cruise(self): + self.enable(V_CRUISE_INITIAL * CV.KPH_TO_MS, False) + initial_v_cruise_kph = self.v_cruise_helper.v_cruise_kph + + pressed_cs = car.CarState(cruiseState={"available": True}) + pressed_cs.buttonEvents = [ButtonEvent(type=ButtonType.decelCruise, pressed=True)] + self.v_cruise_helper.update_v_cruise( + pressed_cs, + enabled=True, + is_metric=False, + speed_limit_changed=False, + starpilot_toggles=self.starpilot_toggles, + ) + + released_cs = car.CarState(cruiseState={"available": True}) + released_cs.buttonEvents = [ButtonEvent(type=ButtonType.decelCruise, pressed=False)] + self.v_cruise_helper.update_v_cruise( + released_cs, + enabled=True, + is_metric=False, + speed_limit_changed=True, + starpilot_toggles=self.starpilot_toggles, + ) + + assert self.v_cruise_helper.v_cruise_kph == initial_v_cruise_kph diff --git a/selfdrive/controls/controlsd.py b/selfdrive/controls/controlsd.py index 5149e82ed..375df1f5e 100644 --- a/selfdrive/controls/controlsd.py +++ b/selfdrive/controls/controlsd.py @@ -62,7 +62,6 @@ class Controls: elif self.CP.lateralTuning.which() == 'torque': self.LaC = LatControlTorque(self.CP, self.CI, DT_CTRL) - # StarPilot variables self.sm = self.sm.extend(['liveDelay', 'starpilotCarState', 'starpilotPlan']) self.starpilot_toggles = get_starpilot_toggles() @@ -78,7 +77,6 @@ class Controls: device_pose = Pose.from_live_pose(self.sm['livePose']) self.calibrated_pose = self.pose_calibrator.build_calibrated_pose(device_pose) - # StarPilot variables if hasattr(self.LaC, "pid") and self.CP.lateralTuning.which() != "pid": self.LaC.pid._k_p = self.starpilot_toggles.steerKp @@ -152,7 +150,6 @@ class Controls: actuators.torque = float(steer) actuators.steeringAngleDeg = float(steeringAngleDeg) - # OPGM variables if len(long_plan.speeds): actuators.speed = long_plan.speeds[-1] diff --git a/selfdrive/controls/lib/desire_helper.py b/selfdrive/controls/lib/desire_helper.py index cc984be9f..d7253eacf 100644 --- a/selfdrive/controls/lib/desire_helper.py +++ b/selfdrive/controls/lib/desire_helper.py @@ -29,7 +29,6 @@ DESIRES = { }, } -# StarPilot variables TurnDirection = log.Desire TURN_DESIRES = { @@ -49,7 +48,6 @@ class DesireHelper: self.prev_one_blinker = False self.desire = log.Desire.none - # StarPilot variables self.lane_change_completed = False self.lane_change_wait_timer = 0.0 @@ -86,7 +84,6 @@ class DesireHelper: blindspot_detected = ((carstate.leftBlindspot and self.lane_change_direction == LaneChangeDirection.left) or (carstate.rightBlindspot and self.lane_change_direction == LaneChangeDirection.right)) - # StarPilot variables if torque_applied: self.lane_change_wait_timer = starpilot_toggles.lane_change_delay else: @@ -102,12 +99,10 @@ class DesireHelper: elif torque_applied and not blindspot_detected: self.lane_change_state = LaneChangeState.laneChangeStarting - # StarPilot variables self.lane_change_completed = starpilot_toggles.one_lane_change self.lane_change_wait_timer = 0.0 - # StarPilot variables self.lane_change_wait_timer += DT_MDL # LaneChangeState.laneChangeStarting @@ -155,7 +150,6 @@ class DesireHelper: elif self.desire in (log.Desire.keepLeft, log.Desire.keepRight): self.desire = log.Desire.none - # StarPilot variables if not one_blinker: self.lane_change_completed = False diff --git a/selfdrive/controls/lib/drive_helpers.py b/selfdrive/controls/lib/drive_helpers.py index 7cab0243d..ad23f9ec7 100644 --- a/selfdrive/controls/lib/drive_helpers.py +++ b/selfdrive/controls/lib/drive_helpers.py @@ -55,7 +55,7 @@ def get_accel_from_plan(speeds, accels, t_idxs, action_t=DT_MDL, vEgoStopping=0. return a_target, should_stop -# Backward-compatible alias used by StarPilot tinygrad_modeld. +# Backward-compatible alias used by tinygrad_modeld. get_accel_from_plan_tomb_raider = get_accel_from_plan def curv_from_psis(psi_target, psi_rate, vego, action_t): diff --git a/selfdrive/controls/lib/latcontrol_torque.py b/selfdrive/controls/lib/latcontrol_torque.py index f4467ed26..0598df6df 100644 --- a/selfdrive/controls/lib/latcontrol_torque.py +++ b/selfdrive/controls/lib/latcontrol_torque.py @@ -59,7 +59,7 @@ BOLT_CARS = BOLT_2022_2023_CARS + BOLT_2018_2021_CARS + BOLT_2017_CARS def get_friction_threshold(v_ego: float) -> float: - # Keep StarPilot's speed-scaled friction threshold behavior. + # Keep the speed-scaled friction threshold behavior. return float(np.interp(v_ego, [1 * CV.MPH_TO_MS, 20 * CV.MPH_TO_MS, 75 * CV.MPH_TO_MS], [0.16, 0.19, 0.27])) diff --git a/selfdrive/controls/lib/longitudinal_planner.py b/selfdrive/controls/lib/longitudinal_planner.py index 33db44bda..4a90ae9eb 100755 --- a/selfdrive/controls/lib/longitudinal_planner.py +++ b/selfdrive/controls/lib/longitudinal_planner.py @@ -18,8 +18,8 @@ from openpilot.common.swaglog import cloudlog LON_MPC_STEP = 0.2 # first step is 0.2s A_CRUISE_MIN = -1.0 -A_CRUISE_MAX_BP = [0., 10.0, 25., 40.] -A_CRUISE_MAX_VALS = [1.6, 1.2, 0.8, 0.6] +A_CRUISE_MAX_BP = [0.0, 5., 10., 15., 20., 25., 40.] +A_CRUISE_MAX_VALS = [1.125, 1.125, 1.125, 1.125, 1.25, 1.25, 1.5] CONTROL_N_T_IDX = ModelConstants.T_IDXS[:CONTROL_N] ALLOW_THROTTLE_THRESHOLD = 0.4 MIN_ALLOW_THROTTLE_SPEED = 2.5 diff --git a/selfdrive/controls/plannerd.py b/selfdrive/controls/plannerd.py index 99ab149e1..d427dbcf1 100755 --- a/selfdrive/controls/plannerd.py +++ b/selfdrive/controls/plannerd.py @@ -24,7 +24,6 @@ def main(): sm = messaging.SubMaster(['carControl', 'carState', 'controlsState', 'liveParameters', 'radarState', 'modelV2', 'selfdriveState'], poll='modelV2') - # StarPilot variables sm = sm.extend(['starpilotCarState', 'starpilotPlan']) starpilot_toggles = get_starpilot_toggles() @@ -42,7 +41,6 @@ def main(): msg.driverAssistance.rightLaneDeparture = ldw.right pm.send('driverAssistance', msg) - # StarPilot variables starpilot_toggles = get_starpilot_toggles(sm) diff --git a/selfdrive/controls/radard.py b/selfdrive/controls/radard.py index 73a393a6a..3103564fc 100644 --- a/selfdrive/controls/radard.py +++ b/selfdrive/controls/radard.py @@ -59,7 +59,6 @@ class Track: self.K_K = kalman_params.K self.kf = KF1D([[v_lead], [0.0]], self.K_A, self.K_C, self.K_K) - # StarPilot variables self.leadTrackID = 0 self.radarfulFilter = FirstOrderFilter(0, 0.5, self.K_A[0][1]) @@ -223,7 +222,6 @@ def get_lead(v_ego: float, ready: bool, tracks: dict[int, Track], lead_msg: capn closest_track = min(far_lead_tracks, key=lambda c: c.dRel) lead_dict = closest_track.get_RadarState() - # StarPilot variables for track in tracks.values(): track.leadTrackID = lead_dict.get('radarTrackId', -1) @@ -260,7 +258,6 @@ class RadarD: self.ready = False - # StarPilot variables self.starpilot_radar_state = custom.StarPilotRadarState.new_message() self.starpilot_toggles = get_starpilot_toggles() @@ -311,7 +308,6 @@ class RadarD: self.radar_state.leadTwo = get_lead(self.v_ego, self.ready, self.tracks, leads_v3[1], model_v_ego, sm['modelV2'], sm['carState'].standstill, sm['starpilotPlan'], self.starpilot_toggles, low_speed_override=False) - # StarPilot variables if self.ready and (self.starpilot_toggles.adjacent_lead_tracking or self.starpilot_toggles.human_lane_changes): self.starpilot_radar_state.leadLeft = get_adjacent_lead(self.tracks, sm['carState'].standstill, sm['modelV2'], left=True) self.starpilot_radar_state.leadRight = get_adjacent_lead(self.tracks, sm['carState'].standstill, sm['modelV2'], left=False) @@ -326,7 +322,6 @@ class RadarD: radar_msg.radarState = self.radar_state pm.send("radarState", radar_msg) - # StarPilot variables starpilot_radar_msg = messaging.new_message("starpilotRadarState") starpilot_radar_msg.valid = self.radar_state_valid starpilot_radar_msg.starpilotRadarState = self.starpilot_radar_state @@ -349,7 +344,6 @@ def main() -> None: RD = RadarD(CP.radarDelay) - # StarPilot variables sm = sm.extend(['starpilotPlan']) pm = pm.extend(['starpilotRadarState']) diff --git a/selfdrive/locationd/lagd.py b/selfdrive/locationd/lagd.py index b84c27aff..c07af908e 100755 --- a/selfdrive/locationd/lagd.py +++ b/selfdrive/locationd/lagd.py @@ -378,7 +378,6 @@ def main(): lag, valid_blocks = initial_lag_params lag_learner.reset(lag, valid_blocks) - # StarPilot variables sm = sm.extend(['starpilotPlan']) lag_learner.starpilot_toggles = get_starpilot_toggles() @@ -402,5 +401,4 @@ def main(): if sm.frame % 1200 == 0: # cache every 60 seconds params.put_nonblocking("LiveDelay", lag_msg_dat) - # StarPilot variables lag_learner.starpilot_toggles = get_starpilot_toggles(sm) diff --git a/selfdrive/locationd/paramsd.py b/selfdrive/locationd/paramsd.py index 2a29bc64e..4e73a67fb 100755 --- a/selfdrive/locationd/paramsd.py +++ b/selfdrive/locationd/paramsd.py @@ -59,7 +59,6 @@ class VehicleParamsLearner: self.reset(None) - # StarPilot variables self.CP = CP def reset(self, t: float | None): @@ -192,7 +191,6 @@ class VehicleParamsLearner: liveParameters.debugFilterState.value = x.tolist() liveParameters.debugFilterState.std = P.tolist() - # StarPilot variables if self.CP.carFingerprint == "RAM_HD": liveParameters.valid = True @@ -285,7 +283,6 @@ def main(): steer_ratio, stiffness_factor, angle_offset_deg, pInitial = retrieve_initial_vehicle_params(params, CP, REPLAY, DEBUG) learner = VehicleParamsLearner(CP, steer_ratio, stiffness_factor, np.radians(angle_offset_deg), pInitial) - # StarPilot variables sm = sm.extend(['starpilotPlan']) learner.starpilot_toggles = get_starpilot_toggles() @@ -307,7 +304,6 @@ def main(): pm.send('liveParameters', msg_dat) - # StarPilot variables learner.starpilot_toggles = get_starpilot_toggles(sm) diff --git a/selfdrive/locationd/torqued.py b/selfdrive/locationd/torqued.py index d14d959fe..1ceba9e6f 100755 --- a/selfdrive/locationd/torqued.py +++ b/selfdrive/locationd/torqued.py @@ -253,7 +253,6 @@ def main(demo=False): params = Params() estimator = TorqueEstimator(messaging.log_from_bytes(params.get("CarParams", block=True), car.CarParams)) - # StarPilot variables sm = sm.extend(['starpilotPlan']) starpilot_toggles = get_starpilot_toggles() @@ -280,7 +279,6 @@ def main(demo=False): msg = estimator.get_msg(valid=sm.all_checks(), with_points=True) params.put_nonblocking("LiveTorqueParameters", msg.to_bytes()) - # StarPilot variables estimator.starpilot_toggles = get_starpilot_toggles(sm) diff --git a/selfdrive/modeld/modeld.py b/selfdrive/modeld/modeld.py index 414b1e75b..307386a25 100755 --- a/selfdrive/modeld/modeld.py +++ b/selfdrive/modeld/modeld.py @@ -258,7 +258,6 @@ class ModelState: def main(demo=False): cloudlog.warning("modeld init") - # StarPilot variables starpilot_toggles = get_starpilot_toggles() if not USBGPU: @@ -332,7 +331,6 @@ def main(demo=False): DH = DesireHelper() - # StarPilot variables sm = sm.extend(['starpilotPlan']) pm = pm.extend(['starpilotModelV2']) @@ -440,14 +438,12 @@ def main(demo=False): pm.send('drivingModelData', drivingdata_send) pm.send('cameraOdometry', posenet_send) - # StarPilot variables starpilot_modelv2_send = messaging.new_message('starpilotModelV2') starpilot_modelv2_send.starpilotModelV2.turnDirection = DH.turn_direction pm.send('starpilotModelV2', starpilot_modelv2_send) last_vipc_frame_id = meta_main.frame_id - # StarPilot variables starpilot_toggles = get_starpilot_toggles(sm) diff --git a/selfdrive/monitoring/dmonitoringd.py b/selfdrive/monitoring/dmonitoringd.py index 10bfde1ae..17e03cf3d 100644 --- a/selfdrive/monitoring/dmonitoringd.py +++ b/selfdrive/monitoring/dmonitoringd.py @@ -18,7 +18,6 @@ def dmonitoringd_thread(): DM = DriverMonitoring(rhd_saved=params.get_bool("IsRhdDetected"), always_on=params.get_bool("AlwaysOnDM")) demo_mode=False - # StarPilot variables sm = sm.extend(['starpilotCarState']) driver_view_enabled = params.get_bool("IsDriverViewEnabled") @@ -35,7 +34,6 @@ def dmonitoringd_thread(): DM.run_step(sm, demo=demo_mode) elif valid: DM.run_step(sm, demo=demo_mode) - # StarPilot variables elif driver_view_enabled: DM.face_detected = sm['driverStateV2'].leftDriverData.faceProb > DM.settings._FACE_THRESHOLD or sm['driverStateV2'].rightDriverData.faceProb > DM.settings._FACE_THRESHOLD diff --git a/selfdrive/pandad/panda_safety.cc b/selfdrive/pandad/panda_safety.cc index f7893887d..b3fe74a3e 100644 --- a/selfdrive/pandad/panda_safety.cc +++ b/selfdrive/pandad/panda_safety.cc @@ -65,7 +65,6 @@ void PandaSafety::setSafetyMode(const std::string ¶ms_string) { auto safety_configs = car_params.getSafetyConfigs(); uint16_t alternative_experience = car_params.getAlternativeExperience(); - // StarPilot variables std::string starpilot_params_string = params_.get("StarPilotCarParams"); AlignedBuffer starpilot_aligned_buf; @@ -84,7 +83,6 @@ void PandaSafety::setSafetyMode(const std::string ¶ms_string) { safety_param = safety_configs[i].getSafetyParam(); } - // StarPilot variables if (i < starpilot_safety_configs.size()) { safety_param |= starpilot_safety_configs[i].getSafetyParam(); } diff --git a/selfdrive/pandad/pandad b/selfdrive/pandad/pandad index 2880d3b07..6b7b87c8c 100755 Binary files a/selfdrive/pandad/pandad and b/selfdrive/pandad/pandad differ diff --git a/selfdrive/pandad/pandad.cc b/selfdrive/pandad/pandad.cc index c96fbb362..96f2587b1 100644 --- a/selfdrive/pandad/pandad.cc +++ b/selfdrive/pandad/pandad.cc @@ -43,7 +43,6 @@ ExitHandler do_exit; -// StarPilot variables static uint64_t last_door_lock_command_time = 0; bool check_all_connected(const std::vector &pandas) { @@ -111,7 +110,6 @@ void can_send_thread(std::vector pandas, bool fake_send) { LOGE("sendcan too old to send: %" PRIu64 ", %" PRIu64, nanos_since_boot(), event.getLogMonoTime()); } - // StarPilot variables for (const cereal::CanData::Reader &can : event.getSendcan()) { if (can.getAddress() == 0x750) { last_door_lock_command_time = nanos_since_boot(); diff --git a/selfdrive/selfdrived/events.py b/selfdrive/selfdrived/events.py index e33159845..e9e5d1edb 100644 --- a/selfdrive/selfdrived/events.py +++ b/selfdrive/selfdrived/events.py @@ -24,7 +24,6 @@ VisualAlert = car.CarControl.HUDControl.VisualAlert AudibleAlert = car.CarControl.HUDControl.AudibleAlert EventName = log.OnroadEvent.EventName -# StarPilot variables StarPilotAlertStatus = custom.StarPilotSelfdriveState.AlertStatus StarPilotAudibleAlert = custom.StarPilotCarControl.HUDControl.AudibleAlert StarPilotEventName = custom.StarPilotOnroadEvent.EventName @@ -57,7 +56,6 @@ class ET: # get event name from enum EVENT_NAME = {v: k for k, v in EventName.schema.enumerants.items()} -# StarPilot variables STARPILOT_EVENT_NAME = {v: k for k, v in StarPilotEventName.schema.enumerants.items()} @@ -67,7 +65,6 @@ class Events: self.static_events: list[int] = [] self.event_counters = dict.fromkeys((STARPILOT_EVENTS if starpilot else EVENTS).keys(), 0) - # StarPilot variables self.starpilot = starpilot @property @@ -406,7 +403,6 @@ def invalid_lkas_setting_alert(CP: car.CarParams, CS: car.CarState, sm: messagin return NormalPermanentAlert("Invalid LKAS setting", text) -# StarPilot variables def custom_startup_alert(CP: car.CarParams, CS: car.CarState, sm: messaging.SubMaster, metric: bool, soft_disable_time: int, personality, starpilot_toggles: SimpleNamespace) -> Alert: return StartupAlert(starpilot_toggles.startup_alert_top, starpilot_toggles.startup_alert_bottom, alert_status=StarPilotAlertStatus.starpilot) @@ -1104,7 +1100,6 @@ EVENTS: dict[int, dict[str, Alert | AlertCallbackType]] = { }, } -# StarPilot variables STARPILOT_EVENTS: dict[int, dict[str, Alert | AlertCallbackType]] = { StarPilotEventName.blockUser: { ET.PERMANENT: Alert( @@ -1204,6 +1199,22 @@ STARPILOT_EVENTS: dict[int, dict[str, Alert | AlertCallbackType]] = { Priority.LOW, VisualAlert.none, AudibleAlert.prompt, 3.), }, + StarPilotEventName.switchbackModeActive: { + ET.WARNING: Alert( + "Switchback Mode", + "", + StarPilotAlertStatus.starpilot, AlertSize.small, + Priority.LOW, VisualAlert.none, AudibleAlert.prompt, 3.), + }, + + StarPilotEventName.switchbackModeInactive: { + ET.WARNING: Alert( + "Switchback Mode Disabled", + "", + StarPilotAlertStatus.starpilot, AlertSize.small, + Priority.LOW, VisualAlert.none, AudibleAlert.prompt, 3.), + }, + StarPilotEventName.turningLeft: { ET.WARNING: Alert( "Turning Left", diff --git a/selfdrive/selfdrived/selfdrived.py b/selfdrive/selfdrived/selfdrived.py index af5c88bcb..9a18443c0 100644 --- a/selfdrive/selfdrived/selfdrived.py +++ b/selfdrive/selfdrived/selfdrived.py @@ -44,7 +44,6 @@ EventName = log.OnroadEvent.EventName ButtonType = car.CarState.ButtonEvent.Type SafetyModel = car.CarParams.SafetyModel -# StarPilot variables StarPilotEventName = custom.StarPilotOnroadEvent.EventName IGNORED_SAFETY_MODES = (SafetyModel.silent, SafetyModel.noOutput) @@ -53,6 +52,7 @@ IGNORED_SAFETY_MODES = (SafetyModel.silent, SafetyModel.noOutput) class SelfdriveD: def __init__(self, CP=None): self.params = Params() + self.params_memory = Params(memory=True) # Ensure the current branch is cached, otherwise the first cycle lags build_metadata = get_build_metadata() @@ -147,7 +147,6 @@ class SelfdriveD: elif self.CP.passive: self.events.add(EventName.dashcamMode, static=True) - # StarPilot variables self.sm = self.sm.extend(['starpilotCarState', 'starpilotPlan']) self.pm = self.pm.extend(['starpilotOnroadEvents', 'starpilotSelfdriveState']) @@ -159,6 +158,8 @@ class SelfdriveD: self.distance_pressed_previously = False self.display_timer = 0 + self.last_below_steer_speed_alert_time = -float("inf") + self.last_steer_saturated_alert_time = -float("inf") self.starpilot_events_prev = [] @@ -172,6 +173,13 @@ class SelfdriveD: self.events.clear() self.starpilot_events.clear() + switchback_mode_enabled = self.params_memory.get_bool("SwitchbackModeEnabled") + switchback_mode_cooldown = max(0.0, float(getattr(self.starpilot_toggles, "switchback_mode_cooldown", 0.0))) + + if not self.sm['deviceState'].started or not switchback_mode_enabled: + self.last_below_steer_speed_alert_time = -float("inf") + self.last_steer_saturated_alert_time = -float("inf") + if self.sm['controlsState'].lateralControlState.which() == 'debugState': self.events.add(EventName.joystickDebug) self.startup_event = None @@ -215,6 +223,14 @@ class SelfdriveD: # Add car events, ignore if CAN isn't valid if CS.canValid: car_events = self.car_events.update(CS, self.CS_prev, self.sm['carControl']).to_msg() + has_below_steer_speed_event = any(e.name.raw == EventName.belowSteerSpeed for e in car_events) + if has_below_steer_speed_event: + now = time.monotonic() + cooldown_active = switchback_mode_enabled and switchback_mode_cooldown > 0.0 + if cooldown_active and (now - self.last_below_steer_speed_alert_time) < switchback_mode_cooldown: + car_events = [e for e in car_events if e.name.raw != EventName.belowSteerSpeed] + elif switchback_mode_enabled: + self.last_below_steer_speed_alert_time = now self.events.add_from_msg(car_events) if self.CP.notCar: @@ -416,10 +432,16 @@ class SelfdriveD: commanded_torque_at_max = abs(lac.output) > 0.99 # TODO: lac.saturated includes speed and other checks, should be pulled out if undershooting and turning and (lac.saturated or commanded_torque_at_max): - if self.starpilot_toggles.goat_scream_alert: - self.starpilot_events.add(StarPilotEventName.goatSteerSaturated) - else: - self.events.add(EventName.steerSaturated) + now = time.monotonic() + cooldown_active = switchback_mode_enabled and switchback_mode_cooldown > 0.0 + if not cooldown_active or (now - self.last_steer_saturated_alert_time) >= switchback_mode_cooldown: + if switchback_mode_enabled: + self.last_steer_saturated_alert_time = now + + if self.starpilot_toggles.goat_scream_alert: + self.starpilot_events.add(StarPilotEventName.goatSteerSaturated) + else: + self.events.add(EventName.steerSaturated) # Check for FCW stock_long_is_braking = self.enabled and not self.CP.openpilotLongitudinalControl and CS.aEgo < -1.25 @@ -466,7 +488,6 @@ class SelfdriveD: self.display_timer -= 1 - # StarPilot variables self.starpilot_events.add_from_msg(self.sm['starpilotPlan'].starpilotEvents) if self.starpilot_toggles.conditional_experimental_mode: @@ -535,7 +556,6 @@ class SelfdriveD: self.AM.add_many(self.sm.frame, alerts) self.AM.process_alerts(self.sm.frame, clear_event_types) - # StarPilot variables starpilot_alerts = self.starpilot_events.create_alerts(self.state_machine.current_alert_types, [self.CP, CS, self.sm, self.is_metric, self.state_machine.soft_disable_timer, pers, self.starpilot_toggles]) @@ -572,7 +592,6 @@ class SelfdriveD: self.pm.send('onroadEvents', ce_send) self.events_prev = self.events.names.copy() - # StarPilot variables fpss_msg = messaging.new_message('starpilotSelfdriveState') fpss_msg.valid = True fpss = fpss_msg.starpilotSelfdriveState @@ -604,7 +623,6 @@ class SelfdriveD: self.CS_prev = CS - # StarPilot variables self.starpilot_toggles = get_starpilot_toggles(self.sm) def params_thread(self, evt): diff --git a/selfdrive/ui/SConscript b/selfdrive/ui/SConscript index ef8077524..8a888b72e 100644 --- a/selfdrive/ui/SConscript +++ b/selfdrive/ui/SConscript @@ -4,7 +4,6 @@ Import('env', 'qt_env', 'arch', 'common', 'messaging', 'visionipc', 'transformat base_libs = [common, messaging, visionipc, transformations, 'm', 'OpenCL', 'ssl', 'crypto', 'pthread'] + qt_env["LIBS"] -# StarPilot variables base_libs += ['avcodec', 'avformat', 'avutil', 'swresample', 'yuv', 'OmxCore'] if arch == 'larch64': @@ -26,7 +25,6 @@ widgets_src = ["qt/widgets/input.cc", "qt/widgets/wifi.cc", "qt/prime_state.cc", "qt/widgets/scrollview.cc", "qt/widgets/cameraview.cc", "#third_party/qrcode/QrCode.cc", "qt/request_repeater.cc", "qt/qt_window.cc", "qt/network/networking.cc", "qt/network/wifi_manager.cc"] -# StarPilot variables starpilot_widgets_src = ["../../starpilot/ui/qt/widgets/starpilot_controls.cc"] widgets_src += starpilot_widgets_src @@ -41,7 +39,6 @@ qt_src = ["main.cc", "ui.cc", "qt/sidebar.cc", "qt/body.cc", "qt/onroad/onroad_home.cc", "qt/onroad/annotated_camera.cc", "qt/onroad/model.cc", "qt/onroad/buttons.cc", "qt/onroad/alerts.cc", "qt/onroad/driver_monitoring.cc", "qt/onroad/hud.cc"] -# StarPilot variables qt_env['CPPPATH'] += ["../../starpilot/ui/screenrecorder/openmax/include/"] starpilot_src = ["../../starpilot/ui/starpilot_ui.cc", "../../starpilot/ui/qt/offroad/data_settings.cc", diff --git a/selfdrive/ui/layouts/settings/settings.py b/selfdrive/ui/layouts/settings/settings.py index 0f5ec1987..3cf32140a 100644 --- a/selfdrive/ui/layouts/settings/settings.py +++ b/selfdrive/ui/layouts/settings/settings.py @@ -56,7 +56,7 @@ class SettingsLayout(Widget): self._current_panel = PanelType.DEVICE # Panel depth tracking for hierarchical back navigation - # 0 = top level (settings main), 1+ = sub-panels (StarPilot categories) + # 0 = top level (settings main), 1+ = nested custom panels self._panel_depth = 0 # Panel configuration @@ -73,7 +73,7 @@ class SettingsLayout(Widget): PanelType.STARPILOT: PanelInfo(tr_noop("StarPilot"), StarPilotLayout()), } - # Connect StarPilot depth callback for hierarchical back navigation + # Connect the custom-panel depth callback for hierarchical back navigation self._panels[PanelType.STARPILOT].instance.set_depth_callback(self.set_panel_depth) self._panels[PanelType.STARPILOT].instance.set_settings_layout(self) diff --git a/selfdrive/ui/layouts/settings/starpilot/longitudinal.py b/selfdrive/ui/layouts/settings/starpilot/longitudinal.py index bf471c9f4..2309e0efe 100644 --- a/selfdrive/ui/layouts/settings/starpilot/longitudinal.py +++ b/selfdrive/ui/layouts/settings/starpilot/longitudinal.py @@ -596,23 +596,55 @@ class StarPilotSpeedLimitControllerLayout(StarPilotPanel): { "title": tr_noop("Source Priority"), "type": "value", - "get_value": lambda: self._params.get("SLCPriority1", encoding='utf-8') or "Dashboard", + "get_value": self._get_priority_value, "on_click": self._on_priority_clicked, "color": "#1BA1E2", }, ] self._rebuild_grid() - def _on_priority_clicked(self): - options = ["Dashboard", "Map Data", "Highest", "Lowest"] + def _get_priority_value(self): + primary = self._params.get("SLCPriority1", encoding='utf-8') or "Map Data" + secondary = self._params.get("SLCPriority2", encoding='utf-8') or "None" + if primary in ("Highest", "Lowest") or secondary in ("", "None", primary): + return primary + return f"{primary}, {secondary}" - def on_select(res, val): + def _on_priority_clicked(self): + primary_options = ["Dashboard", "Map Data", "Highest", "Lowest"] + current_primary = self._params.get("SLCPriority1", encoding='utf-8') or "Map Data" + current_secondary = self._params.get("SLCPriority2", encoding='utf-8') or "None" + + def on_secondary_select(primary, res, val): if res == DialogResult.CONFIRM: - self._params.put("SLCPriority1", val) + self._params.put("SLCPriority1", primary) + self._params.put("SLCPriority2", val) self._rebuild_grid() + def show_secondary_dialog(primary): + secondary_options = ["None"] + [option for option in ("Dashboard", "Map Data") if option != primary] + selected_secondary = current_secondary if current_secondary in secondary_options else "None" + gui_app.set_modal_overlay( + SelectionDialog( + tr("SLC Secondary Priority"), + secondary_options, + selected_secondary, + on_close=lambda res, val: on_secondary_select(primary, res, val), + ) + ) + + def on_primary_select(res, val): + if res != DialogResult.CONFIRM: + return + if val in ("Highest", "Lowest"): + self._params.put("SLCPriority1", val) + self._params.put("SLCPriority2", "None") + self._rebuild_grid() + return + show_secondary_dialog(val) + gui_app.set_modal_overlay( - SelectionDialog(tr("SLC Priority"), options, self._params.get("SLCPriority1", encoding='utf-8') or "Dashboard", on_close=on_select) + SelectionDialog(tr("SLC Primary Priority"), primary_options, current_primary, on_close=on_primary_select) ) def _show_selection(self, key, options): diff --git a/selfdrive/ui/layouts/settings/starpilot/sounds.py b/selfdrive/ui/layouts/settings/starpilot/sounds.py index e92cdf492..bfc0db2d4 100644 --- a/selfdrive/ui/layouts/settings/starpilot/sounds.py +++ b/selfdrive/ui/layouts/settings/starpilot/sounds.py @@ -14,7 +14,9 @@ from openpilot.selfdrive.ui.layouts.settings.starpilot.panel import StarPilotPan from openpilot.selfdrive.ui.layouts.settings.starpilot.metro import TileGrid, ToggleTile, SliderDialog class StarPilotSoundsLayout(StarPilotPanel): + COOLDOWN_KEY = "SwitchbackModeCooldown" VOLUME_KEYS = [ + "BelowSteerSpeedVolume", "DisengageVolume", "EngageVolume", "PromptVolume", @@ -70,7 +72,9 @@ class StarPilotSoundsLayout(StarPilotPanel): panel.refresh_visibility() class StarPilotVolumeControlLayout(StarPilotPanel): + COOLDOWN_INFO = {"title": tr_noop("Switchback Mode Cooldown"), "icon": "toggle_icons/icon_mute.png", "min": 0, "max": 60} VOLUME_INFO = { + "BelowSteerSpeedVolume": {"title": tr_noop("Min Steer Speed Alert"), "icon": "toggle_icons/icon_mute.png", "min": 0}, "DisengageVolume": {"title": tr_noop("Disengage Volume"), "icon": "toggle_icons/icon_mute.png", "min": 0}, "EngageVolume": {"title": tr_noop("Engage Volume"), "icon": "toggle_icons/icon_green_light.png", "min": 0}, "PromptVolume": {"title": tr_noop("Prompt Volume"), "icon": "toggle_icons/icon_message.png", "min": 0}, @@ -108,6 +112,23 @@ class StarPilotVolumeControlLayout(StarPilotPanel): "color": "#FF0097" }) + def get_cooldown_val(): + v = self._params.get_int(StarPilotSoundsLayout.COOLDOWN_KEY, return_default=True, default=0) + if v == 0: + return tr("Off") + if v == 1: + return tr("1 second") + return f"{v} {tr('seconds')}" + + self.CATEGORIES.append({ + "title": self.COOLDOWN_INFO["title"], + "type": "value", + "get_value": get_cooldown_val, + "on_click": self._show_cooldown_selector, + "icon": self.COOLDOWN_INFO["icon"], + "color": "#FF0097" + }) + self._rebuild_grid() def _show_volume_selector(self, key: str, info: dict): @@ -127,6 +148,19 @@ class StarPilotVolumeControlLayout(StarPilotPanel): unit="%", labels={0: tr("Muted"), 101: tr("Auto")}, color="#FF0097" )) + def _show_cooldown_selector(self): + current_v = self._params.get_int(StarPilotSoundsLayout.COOLDOWN_KEY, return_default=True, default=0) + + def on_close(res, val): + if res == DialogResult.CONFIRM: + self._params.put_int(StarPilotSoundsLayout.COOLDOWN_KEY, int(val)) + self._rebuild_grid() + + gui_app.set_modal_overlay(SliderDialog( + tr(self.COOLDOWN_INFO["title"]), 0, self.COOLDOWN_INFO["max"], 1, current_v, on_close, + unit=" s", labels={0: tr("Off")}, color="#FF0097" + )) + @classmethod def _init_sound_player(cls): if cls._sound_player_process is not None: return @@ -151,13 +185,15 @@ while True: def _test_sound(self, key: str): base_name = key.replace("Volume", "") if ui_state.started: - self._params_memory.put("TestAlert", base_name[0].lower() + base_name[1:]) + alert_name = "belowSteerSpeed" if base_name == "BelowSteerSpeed" else base_name[0].lower() + base_name[1:] + self._params_memory.put("TestAlert", alert_name) else: self._play_sound_offroad(key) def _play_sound_offroad(self, key: str): base_name = key.replace("Volume", "") - snake_case = "".join(["_" + c.lower() if c.isupper() else c for c in base_name]).lstrip("_") + preview_base_name = "Prompt" if base_name == "BelowSteerSpeed" else base_name + snake_case = "".join(["_" + c.lower() if c.isupper() else c for c in preview_base_name]).lstrip("_") stock_path = Path(BASEDIR) / "selfdrive" / "assets" / "sounds" / f"{snake_case}.wav" theme_path = ACTIVE_THEME_PATH / "sounds" / f"{snake_case}.wav" sound_path = theme_path if theme_path.exists() else stock_path diff --git a/selfdrive/ui/layouts/settings/starpilot/wheel.py b/selfdrive/ui/layouts/settings/starpilot/wheel.py index 102c40240..1055a8135 100644 --- a/selfdrive/ui/layouts/settings/starpilot/wheel.py +++ b/selfdrive/ui/layouts/settings/starpilot/wheel.py @@ -6,8 +6,19 @@ from openpilot.system.ui.widgets import DialogResult from openpilot.system.ui.widgets.selection_dialog import SelectionDialog from openpilot.selfdrive.ui.layouts.settings.starpilot.panel import StarPilotPanel -ACTION_NAMES = ["No Action", "Change Personality", "Force Coast", "Pause Steering", "Pause Accel/Brake", "Toggle Experimental", "Toggle Traffic"] -ACTION_IDS = {name: i for i, name in enumerate(ACTION_NAMES)} +ACTION_OPTIONS = [ + {"id": 0, "name": "No Action"}, + {"id": 1, "name": "Change Personality", "requires_longitudinal": True}, + {"id": 2, "name": "Force Coast", "requires_longitudinal": True}, + {"id": 3, "name": "Pause Steering"}, + {"id": 4, "name": "Pause Accel/Brake", "requires_longitudinal": True}, + {"id": 5, "name": "Toggle Experimental", "requires_longitudinal": True}, + {"id": 6, "name": "Toggle Traffic", "requires_longitudinal": True}, + {"id": 7, "name": "Toggle Switchback"}, +] +ACTION_NAMES = [option["name"] for option in ACTION_OPTIONS] +ACTION_IDS = {option["name"]: option["id"] for option in ACTION_OPTIONS} +ACTION_NAME_BY_ID = {option["id"]: option["name"] for option in ACTION_OPTIONS} class StarPilotWheelLayout(StarPilotPanel): @@ -55,16 +66,14 @@ class StarPilotWheelLayout(StarPilotPanel): def _get_action_name(self, key): idx = self._params.get_int(key) - if 0 <= idx < len(ACTION_NAMES): - return ACTION_NAMES[idx] - return ACTION_NAMES[0] + return ACTION_NAME_BY_ID.get(idx, ACTION_NAMES[0]) def _get_available_actions(self): - actions = list(ACTION_NAMES[:1]) # No Action cs = starpilot_state.car_state - if cs.hasOpenpilotLongitudinal: - actions.extend(ACTION_NAMES[1:]) - return actions + return [ + option["name"] for option in ACTION_OPTIONS + if cs.hasOpenpilotLongitudinal or not option.get("requires_longitudinal", False) + ] def _show_action_picker(self, key): actions = self._get_available_actions() diff --git a/selfdrive/ui/mici/onroad/starpilot_status.py b/selfdrive/ui/mici/onroad/starpilot_status.py index 02d272506..564adfb98 100644 --- a/selfdrive/ui/mici/onroad/starpilot_status.py +++ b/selfdrive/ui/mici/onroad/starpilot_status.py @@ -11,6 +11,7 @@ ENGAGED_COLOR = rl.Color(22, 127, 64, 255) OVERRIDE_COLOR = rl.Color(137, 146, 141, 255) EXPERIMENTAL_COLOR = rl.Color(218, 111, 37, 255) CEM_OVERRIDE_COLOR = rl.Color(255, 214, 0, 255) +SWITCHBACK_COLOR = rl.Color(139, 108, 197, 255) TRAFFIC_COLOR = rl.Color(201, 34, 49, 255) @@ -18,6 +19,8 @@ def get_border_color(state: UIState): enabled = state.sm["selfdriveState"].enabled if state.status == UIStatus.OVERRIDE: return OVERRIDE_COLOR + if state.switchback_mode_enabled and enabled: + return SWITCHBACK_COLOR if state.traffic_mode_enabled and enabled: return TRAFFIC_COLOR if state.always_on_lateral_active: diff --git a/selfdrive/ui/qt/home.cc b/selfdrive/ui/qt/home.cc index 3aaea4689..a01c90193 100644 --- a/selfdrive/ui/qt/home.cc +++ b/selfdrive/ui/qt/home.cc @@ -46,7 +46,6 @@ HomeWindow::HomeWindow(QWidget* parent) : QWidget(parent) { QObject::connect(uiState(), &UIState::offroadTransition, this, &HomeWindow::offroadTransition); QObject::connect(uiState(), &UIState::offroadTransition, sidebar, &Sidebar::offroadTransition); - // StarPilot variables developer_sidebar = new DeveloperSidebar(this); main_layout->addWidget(developer_sidebar); developer_sidebar->setVisible(false); @@ -65,7 +64,6 @@ void HomeWindow::updateState(const UIState &s, const StarPilotUIState &fs) { slayout->setCurrentWidget(body); } - // StarPilot variables const StarPilotUIScene &starpilot_scene = fs.starpilot_scene; const QJsonObject &starpilot_toggles = starpilot_scene.starpilot_toggles; @@ -86,7 +84,6 @@ void HomeWindow::updateState(const UIState &s, const StarPilotUIState &fs) { } void HomeWindow::offroadTransition(bool offroad) { - // StarPilot variables StarPilotUIState &fs = *starpilotUIState(); StarPilotUIScene &starpilot_scene = fs.starpilot_scene; QJsonObject &starpilot_toggles = starpilot_scene.starpilot_toggles; @@ -96,7 +93,6 @@ void HomeWindow::offroadTransition(bool offroad) { if (offroad) { slayout->setCurrentWidget(home); - // StarPilot variables developer_sidebar->setVisible(false); } else { slayout->setCurrentWidget(onroad); @@ -114,7 +110,6 @@ void HomeWindow::showDriverView(bool show, bool started) { } sidebar->setVisible(show == false); - // StarPilot variables developer_sidebar->setVisible(false); } @@ -123,7 +118,6 @@ void HomeWindow::mousePressEvent(QMouseEvent* e) { if ((onroad->isVisible() || body->isVisible()) && (!sidebar->isVisible() || e->x() > sidebar->width())) { sidebar->setVisible(!sidebar->isVisible()); - // StarPilot variables params.putBool("SidebarOpen", sidebar->isVisible()); } } @@ -152,7 +146,6 @@ OffroadHome::OffroadHome(QWidget* parent) : QFrame(parent) { header_layout->setContentsMargins(0, 0, 0, 0); header_layout->setSpacing(16); - // StarPilot variables date = new ElidedLabel(); header_layout->addWidget(date, 0, Qt::AlignHCenter | Qt::AlignLeft); @@ -306,7 +299,6 @@ void OffroadHome::refresh() { alert_notif->setText(QString::number(alerts) + (alerts > 1 ? tr(" ALERTS") : tr(" ALERT"))); } - // StarPilot variables StarPilotUIState &fs = *starpilotUIState(); StarPilotUIScene &starpilot_scene = fs.starpilot_scene; QJsonObject &starpilot_toggles = starpilot_scene.starpilot_toggles; diff --git a/selfdrive/ui/qt/home.h b/selfdrive/ui/qt/home.h index b88a189dd..36bb20a4d 100644 --- a/selfdrive/ui/qt/home.h +++ b/selfdrive/ui/qt/home.h @@ -42,7 +42,6 @@ private: QPushButton* alert_notif; QPushButton* update_notif; - // StarPilot variables ElidedLabel* date; }; @@ -73,7 +72,6 @@ private: DriverViewWindow *driver_view; QStackedLayout *slayout; - // StarPilot variables DeveloperSidebar *developer_sidebar; Params params; diff --git a/selfdrive/ui/qt/network/wifi_manager.h b/selfdrive/ui/qt/network/wifi_manager.h index f0c533d60..70e15f45b 100644 --- a/selfdrive/ui/qt/network/wifi_manager.h +++ b/selfdrive/ui/qt/network/wifi_manager.h @@ -69,7 +69,6 @@ public: void changeTetheringPassword(const QString &newPassword); QString getTetheringPassword(); - // StarPilot variables QString getIp4Address(); private: diff --git a/selfdrive/ui/qt/offroad/developer_panel.cc b/selfdrive/ui/qt/offroad/developer_panel.cc index 7aeffa630..db3a60708 100644 --- a/selfdrive/ui/qt/offroad/developer_panel.cc +++ b/selfdrive/ui/qt/offroad/developer_panel.cc @@ -69,7 +69,6 @@ DeveloperPanel::DeveloperPanel(SettingsWindow *parent) : QFrame(parent) { // Toggles should be not available to change in onroad state QObject::connect(uiState(), &UIState::offroadTransition, this, &DeveloperPanel::updateToggles); - // StarPilot variables QJsonObject shownDescriptions = QJsonDocument::fromJson(QString::fromStdString(params.get("ShownToggleDescriptions")).toUtf8()).object(); QString className = this->metaObject()->className(); @@ -282,7 +281,6 @@ void DeveloperPanel::updateToggles(bool _offroad) { btn->setEnabled(_offroad); } - // StarPilot variables for (auto &[key, toggle] : toggles) { if (toggle == btn) { btn->setEnabled(true); @@ -317,7 +315,6 @@ void DeveloperPanel::updateToggles(bool _offroad) { longManeuverToggle->setEnabled((showAllToggles || hasLongitudinalControl(CP)) && _offroad); - // StarPilot variables hasOpenpilotLongitudinal = hasLongitudinalControl(CP); hasRadar = !CP.getRadarUnavailable(); @@ -331,7 +328,6 @@ void DeveloperPanel::updateToggles(bool _offroad) { offroad = _offroad; - // StarPilot variables tuningLevel = params.getInt("TuningLevel"); for (auto &[key, toggle] : toggles) { @@ -388,7 +384,6 @@ void DeveloperPanel::updateToggles(bool _offroad) { void DeveloperPanel::showEvent(QShowEvent *event) { updateToggles(offroad); - // StarPilot variables for (int i = 0; i < sidebarMetricsToggles.size(); ++i) { if (params.getBool(sidebarMetricsToggles[i].toStdString())) { sidebarMetricsToggle->setCheckedButton(i); diff --git a/selfdrive/ui/qt/offroad/developer_panel.h b/selfdrive/ui/qt/offroad/developer_panel.h index 652b7dcd4..dc9665b9a 100644 --- a/selfdrive/ui/qt/offroad/developer_panel.h +++ b/selfdrive/ui/qt/offroad/developer_panel.h @@ -10,7 +10,6 @@ public: explicit DeveloperPanel(SettingsWindow *parent); void showEvent(QShowEvent *event) override; -// StarPilot variables signals: void openSubPanel(); void openSubSubPanel(); @@ -25,7 +24,6 @@ private: bool is_release; bool offroad = false; - // StarPilot variables bool forceOpenDescriptions = false; bool hasBSM = true; bool hasOpenpilotLongitudinal = true; diff --git a/selfdrive/ui/qt/offroad/settings.cc b/selfdrive/ui/qt/offroad/settings.cc index 996409c38..23f292a83 100644 --- a/selfdrive/ui/qt/offroad/settings.cc +++ b/selfdrive/ui/qt/offroad/settings.cc @@ -128,7 +128,6 @@ TogglesPanel::TogglesPanel(SettingsWindow *parent) : ListWidget(parent) { toggles["ExperimentalMode"]->setActiveIcon("../assets/icons/experimental.svg"); toggles["ExperimentalMode"]->setConfirmation(true, true); - // StarPilot variables connect(toggles["IsMetric"], &ToggleControl::toggleFlipped, [=](bool isMetric) { updateMetric(isMetric); }); @@ -216,7 +215,6 @@ void TogglesPanel::updateToggles() { experimental_mode_toggle->setDescription(e2e_description); } - // StarPilot variables StarPilotUIState &fs = *starpilotUIState(); StarPilotUIScene &starpilot_scene = fs.starpilot_scene; QJsonObject &starpilot_toggles = starpilot_scene.starpilot_toggles; @@ -567,7 +565,6 @@ void SettingsWindow::showEvent(QShowEvent *event) { setCurrentPanel(0); } -// StarPilot variables void SettingsWindow::hideEvent(QHideEvent *event) { closePanel(); closeSubPanel(); @@ -628,7 +625,6 @@ SettingsWindow::SettingsWindow(QWidget *parent) : QFrame(parent) { sidebar_layout->addSpacing(10); sidebar_layout->addWidget(close_btn, 0, Qt::AlignRight); QObject::connect(close_btn, &QPushButton::clicked, [this]() { - // StarPilot variables if (subSubSubPanelOpen) { closeSubSubSubPanel(); subSubSubPanelOpen = false; @@ -658,7 +654,6 @@ SettingsWindow::SettingsWindow(QWidget *parent) : QFrame(parent) { auto networking = new Networking(this); QObject::connect(uiState()->prime_state, &PrimeState::changed, networking, &Networking::setPrimeType); - // StarPilot variables QObject::connect(toggles, &TogglesPanel::updateMetric, this, &SettingsWindow::updateMetric); StarPilotSettingsWindow *starpilotSettingsWindow = new StarPilotSettingsWindow(this); @@ -715,7 +710,6 @@ SettingsWindow::SettingsWindow(QWidget *parent) : QFrame(parent) { panel_widget->addWidget(panel_frame); QObject::connect(btn, &QPushButton::clicked, [=, w = panel_frame]() { - // StarPilot variables if (w->widget() == starpilotSettingsWindow) { bool tuningLevelConfirmed = params.getBool("TuningLevelConfirmed"); @@ -805,11 +799,9 @@ SettingsWindow::SettingsWindow(QWidget *parent) : QFrame(parent) { } )"); - // StarPilot variables updateDeveloperToggle(params.getInt("TuningLevel")); } -// StarPilot variables void SettingsWindow::updateDeveloperToggle(int tuningLevel) { for (QAbstractButton *btn : nav_btns->buttons()) { if (btn->text() == tr("Developer")) { diff --git a/selfdrive/ui/qt/offroad/settings.h b/selfdrive/ui/qt/offroad/settings.h index 247f247de..5ef631a66 100644 --- a/selfdrive/ui/qt/offroad/settings.h +++ b/selfdrive/ui/qt/offroad/settings.h @@ -26,7 +26,6 @@ public: protected: void showEvent(QShowEvent *event) override; - // StarPilot variables void hideEvent(QHideEvent *event) override; signals: @@ -36,7 +35,6 @@ signals: void expandToggleDescription(const QString ¶m); void scrollToToggle(const QString ¶m); - // StarPilot variables void closePanel(); void closeSubPanel(); void closeSubSubPanel(); @@ -50,7 +48,6 @@ private: QButtonGroup *nav_btns; QStackedWidget *panel_widget; - // StarPilot variables void updateDeveloperToggle(int tuningLevel); bool panelOpen; @@ -104,7 +101,6 @@ public: void showEvent(QShowEvent *event) override; signals: - // StarPilot variables void updateMetric(bool metric, bool bootRun=false); public slots: diff --git a/selfdrive/ui/qt/offroad/software_settings.cc b/selfdrive/ui/qt/offroad/software_settings.cc index 8c20b83e8..62d6ba1a9 100644 --- a/selfdrive/ui/qt/offroad/software_settings.cc +++ b/selfdrive/ui/qt/offroad/software_settings.cc @@ -80,7 +80,6 @@ SoftwarePanel::SoftwarePanel(QWidget* parent) : ListWidget(parent) { targetBranchBtn->setValue(QString::fromStdString(params.get("UpdaterTargetBranch"))); checkForUpdates(); - // StarPilot variables if (selection != cur) { if (StarPilotConfirmationDialog::yesorno(tr("This branch must be downloaded before switching. Would you like to download it now?"), this)) { std::system("pkill -SIGHUP -f system.updated.updated"); @@ -132,7 +131,6 @@ void SoftwarePanel::showEvent(QShowEvent *event) { updateLabels(); - // StarPilot variables StarPilotUIState &fs = *starpilotUIState(); StarPilotUIScene &starpilot_scene = fs.starpilot_scene; @@ -142,7 +140,6 @@ void SoftwarePanel::showEvent(QShowEvent *event) { } void SoftwarePanel::updateLabels() { - // StarPilot variables StarPilotUIState &fs = *starpilotUIState(); StarPilotUIScene &starpilot_scene = fs.starpilot_scene; @@ -155,7 +152,6 @@ void SoftwarePanel::updateLabels() { fs_watch->addParam("UpdateAvailable"); if (!isVisible()) { - // StarPilot variables starpilot_scene.downloading_update = false; return; } @@ -171,7 +167,6 @@ void SoftwarePanel::updateLabels() { downloadBtn->setEnabled(false); downloadBtn->setValue(updater_state); - // StarPilot variables starpilot_scene.downloading_update = true; } else { if (failed) { @@ -191,7 +186,6 @@ void SoftwarePanel::updateLabels() { } downloadBtn->setEnabled(true); - // StarPilot variables starpilot_scene.downloading_update = false; } targetBranchBtn->setValue(QString::fromStdString(params.get("UpdaterTargetBranch"))); diff --git a/selfdrive/ui/qt/onroad/alerts.cc b/selfdrive/ui/qt/onroad/alerts.cc index 2db57494e..1f69b92e9 100644 --- a/selfdrive/ui/qt/onroad/alerts.cc +++ b/selfdrive/ui/qt/onroad/alerts.cc @@ -16,7 +16,6 @@ void OnroadAlerts::updateState(const UIState &s, const StarPilotUIState &fs) { } } - // StarPilot variables sidebarsOpen = fs.starpilot_scene.sidebars_open; } @@ -24,7 +23,6 @@ void OnroadAlerts::clear() { alert = {}; update(); - // StarPilot variables alertHeight = 0; } @@ -32,7 +30,6 @@ OnroadAlerts::Alert OnroadAlerts::getAlert(const SubMaster &sm, const SubMaster const cereal::SelfdriveState::Reader &ss = sm["selfdriveState"].getSelfdriveState(); const uint64_t selfdrive_frame = sm.rcv_frame("selfdriveState"); - // StarPilot variables const cereal::StarPilotSelfdriveState::Reader &fpss = fpsm["starpilotSelfdriveState"].getStarpilotSelfdriveState(); Alert a = {}; @@ -56,7 +53,6 @@ OnroadAlerts::Alert OnroadAlerts::getAlert(const SubMaster &sm, const SubMaster a = {ss.getAlertText1().cStr(), ss.getAlertText2().cStr(), ss.getAlertType().cStr(), ss.getAlertSize(), ss.getAlertStatus()}; - // StarPilot variables if (a.size == cereal::SelfdriveState::AlertSize::NONE) { a = {fpss.getAlertText1().cStr(), fpss.getAlertText2().cStr(), fpss.getAlertType().cStr(), static_cast(fpss.getAlertSize()), static_cast(fpss.getAlertStatus())}; @@ -91,7 +87,6 @@ OnroadAlerts::Alert OnroadAlerts::getAlert(const SubMaster &sm, const SubMaster void OnroadAlerts::paintEvent(QPaintEvent *event) { if (alert.size == cereal::SelfdriveState::AlertSize::NONE) { - // StarPilot variables alertHeight = 0; return; } @@ -100,7 +95,6 @@ void OnroadAlerts::paintEvent(QPaintEvent *event) { {cereal::SelfdriveState::AlertSize::MID, 420}, {cereal::SelfdriveState::AlertSize::FULL, height()}, }; - // StarPilot variables alertHeight = alert_heights[alert.size]; int h = alertHeight; @@ -110,7 +104,6 @@ void OnroadAlerts::paintEvent(QPaintEvent *event) { margin = 0; radius = 0; } - // StarPilot variables alertHeight -= margin; QRect r = QRect(0 + margin, height() - h + margin, width() - margin*2, h - margin*2); diff --git a/selfdrive/ui/qt/onroad/alerts.h b/selfdrive/ui/qt/onroad/alerts.h index a83e15032..26ff06a16 100644 --- a/selfdrive/ui/qt/onroad/alerts.h +++ b/selfdrive/ui/qt/onroad/alerts.h @@ -12,7 +12,6 @@ public: void updateState(const UIState &s, const StarPilotUIState &fs); void clear(); - // StarPilot variables int alertHeight; QJsonObject starpilot_toggles; @@ -42,7 +41,6 @@ protected: QColor bg; Alert alert = {}; - // StarPilot variables bool sidebarsOpen; const QMap starpilot_alert_colors = { diff --git a/selfdrive/ui/qt/onroad/annotated_camera.cc b/selfdrive/ui/qt/onroad/annotated_camera.cc index 1ff00fdcc..7de198512 100644 --- a/selfdrive/ui/qt/onroad/annotated_camera.cc +++ b/selfdrive/ui/qt/onroad/annotated_camera.cc @@ -20,7 +20,6 @@ AnnotatedCameraWidget::AnnotatedCameraWidget(VisionStreamType type, QWidget *par experimental_btn = new ExperimentalButton(this); main_layout->addWidget(experimental_btn, 0, Qt::AlignTop | Qt::AlignRight); - // StarPilot variables personality_btn = new DrivingPersonalityButton(this); personality_btn->setVisible(false); @@ -33,7 +32,6 @@ void AnnotatedCameraWidget::updateState(const UIState &s, const StarPilotUIState experimental_btn->updateState(s, fs); dmon.updateState(s); - // StarPilot variables const SubMaster &sm = *(s.sm); const cereal::CarState::Reader &carState = sm["carState"].getCarState(); @@ -164,7 +162,6 @@ void AnnotatedCameraWidget::paintEvent(QPaintEvent *event) { painter.setRenderHint(QPainter::Antialiasing); painter.setPen(Qt::NoPen); - // StarPilot variables dmon.starpilot_nvg = starpilot_nvg; hud.starpilot_nvg = starpilot_nvg; model.starpilot_nvg = starpilot_nvg; @@ -182,7 +179,6 @@ void AnnotatedCameraWidget::paintEvent(QPaintEvent *event) { hud.updateState(*s); hud.draw(painter, rect()); - // StarPilot variables starpilot_nvg->paintStarPilotWidgets(painter, *s); double cur_draw_t = millis_since_boot(); diff --git a/selfdrive/ui/qt/onroad/annotated_camera.h b/selfdrive/ui/qt/onroad/annotated_camera.h index 9dc49e65c..64c9563de 100644 --- a/selfdrive/ui/qt/onroad/annotated_camera.h +++ b/selfdrive/ui/qt/onroad/annotated_camera.h @@ -18,7 +18,6 @@ public: explicit AnnotatedCameraWidget(VisionStreamType type, QWidget* parent = 0); void updateState(const UIState &s, const StarPilotUIState &fs); - // StarPilot variables double fps; StarPilotAnnotatedCameraWidget *starpilot_nvg; @@ -38,7 +37,6 @@ private: int skip_frame_count = 0; bool wide_cam_requested = false; - // StarPilot variables void paintEvent(QPaintEvent *event) override; DrivingPersonalityButton *personality_btn; diff --git a/selfdrive/ui/qt/onroad/buttons.cc b/selfdrive/ui/qt/onroad/buttons.cc index 2e0cf2483..c5f79582f 100644 --- a/selfdrive/ui/qt/onroad/buttons.cc +++ b/selfdrive/ui/qt/onroad/buttons.cc @@ -27,7 +27,6 @@ ExperimentalButton::ExperimentalButton(QWidget *parent) : experimental_mode(fals experimental_img = loadPixmap("../assets/icons/experimental.svg", {img_size, img_size}); QObject::connect(this, &QPushButton::clicked, this, &ExperimentalButton::changeMode); - // StarPilot variables QObject::connect(starpilotUIState(), &StarPilotUIState::themeUpdated, this, &ExperimentalButton::updateTheme); } @@ -35,7 +34,6 @@ void ExperimentalButton::changeMode() { const auto cp = (*uiState()->sm)["carParams"].getCarParams(); bool can_change = hasLongitudinalControl(cp) && params.getBool("ExperimentalModeConfirmed"); if (can_change) { - // StarPilot variables if (starpilot_toggles.value("conditional_experimental_mode").toBool()) { int override_value = (starpilot_scene.conditional_status == 1 || starpilot_scene.conditional_status == 2) ? 0 : experimental_mode ? 1 : 2; params_memory.putInt("CEStatus", override_value); @@ -54,7 +52,6 @@ void ExperimentalButton::updateState(const UIState &s, const StarPilotUIState &f update(); } - // StarPilot variables const cereal::CarState::Reader &carState = (*s.sm)["carState"].getCarState(); updateBackgroundColor(); @@ -88,7 +85,6 @@ void ExperimentalButton::paintEvent(QPaintEvent *event) { } } -// StarPilot variables void ExperimentalButton::showEvent(QShowEvent *event) { updateTheme(); } @@ -102,6 +98,8 @@ void ExperimentalButton::updateBackgroundColor() { background_color = bg_colors[STATUS_CEM_DISABLED]; } else if (experimental_mode) { background_color = bg_colors[STATUS_EXPERIMENTAL_MODE_ENABLED]; + } else if (starpilot_scene.switchback_mode_enabled) { + background_color = bg_colors[STATUS_SWITCHBACK_MODE_ENABLED]; } else if (starpilot_scene.traffic_mode_enabled) { background_color = bg_colors[STATUS_TRAFFIC_MODE_ENABLED]; } else { diff --git a/selfdrive/ui/qt/onroad/buttons.h b/selfdrive/ui/qt/onroad/buttons.h index 53d52fe86..8e7a10d15 100644 --- a/selfdrive/ui/qt/onroad/buttons.h +++ b/selfdrive/ui/qt/onroad/buttons.h @@ -14,7 +14,6 @@ public: explicit ExperimentalButton(QWidget *parent = 0); void updateState(const UIState &s, const StarPilotUIState &fs); - // StarPilot variables StarPilotUIScene starpilot_scene; QJsonObject starpilot_toggles; @@ -29,7 +28,6 @@ private: bool experimental_mode; bool engageable; - // StarPilot variables void showEvent(QShowEvent *event) override; void updateBackgroundColor(); void updateTheme(); diff --git a/selfdrive/ui/qt/onroad/driver_monitoring.cc b/selfdrive/ui/qt/onroad/driver_monitoring.cc index 2110aae9a..1ccfee5a7 100644 --- a/selfdrive/ui/qt/onroad/driver_monitoring.cc +++ b/selfdrive/ui/qt/onroad/driver_monitoring.cc @@ -73,7 +73,6 @@ void DriverMonitorRenderer::draw(QPainter &painter, const QRect &surface_rect) { float y = surface_rect.height() - offset; float opacity = is_active ? 0.65f : 0.2f; - // StarPilot variables if (onroad_distance_btn_enabled) { if (is_rhd) { x -= UI_BORDER_SIZE + (btn_size + UI_BORDER_SIZE) + UI_BORDER_SIZE; @@ -118,7 +117,6 @@ void DriverMonitorRenderer::draw(QPainter &painter, const QRect &surface_rect) { painter.restore(); - // StarPilot variables if (starpilot_nvg) { starpilot_nvg->dmIconPosition.setX(x); starpilot_nvg->dmIconPosition.setY(y); diff --git a/selfdrive/ui/qt/onroad/driver_monitoring.h b/selfdrive/ui/qt/onroad/driver_monitoring.h index ef9efef4e..773e0617d 100644 --- a/selfdrive/ui/qt/onroad/driver_monitoring.h +++ b/selfdrive/ui/qt/onroad/driver_monitoring.h @@ -12,7 +12,6 @@ public: void updateState(const UIState &s); void draw(QPainter &painter, const QRect &surface_rect); - // StarPilot variables StarPilotAnnotatedCameraWidget *starpilot_nvg; bool onroad_distance_btn_enabled; diff --git a/selfdrive/ui/qt/onroad/hud.cc b/selfdrive/ui/qt/onroad/hud.cc index dd9f7cca1..693c5fc59 100644 --- a/selfdrive/ui/qt/onroad/hud.cc +++ b/selfdrive/ui/qt/onroad/hud.cc @@ -67,7 +67,6 @@ void HudRenderer::drawSetSpeed(QPainter &p, const QRect &surface_rect) { const QSize default_size = {172, 204}; QSize set_speed_size = is_metric ? QSize(200, 204) : default_size; - // StarPilot variables if (starpilot_nvg->speedLimitHeight != 0) { set_speed_size.rheight() += starpilot_nvg->speedLimitHeight; if (starpilot_toggles.value("speed_limit_vienna").toBool()) { @@ -109,7 +108,6 @@ void HudRenderer::drawSetSpeed(QPainter &p, const QRect &surface_rect) { p.drawText(set_speed_rect.adjusted(0, 77, 0, 0), Qt::AlignTop | Qt::AlignHCenter, setSpeedStr); } - // StarPilot variables starpilot_nvg->defaultSize = default_size; starpilot_nvg->isCruiseSet = is_cruise_set; starpilot_nvg->setSpeedRect = set_speed_rect; diff --git a/selfdrive/ui/qt/onroad/hud.h b/selfdrive/ui/qt/onroad/hud.h index 2086cab9f..f7c6a465c 100644 --- a/selfdrive/ui/qt/onroad/hud.h +++ b/selfdrive/ui/qt/onroad/hud.h @@ -13,7 +13,6 @@ public: void updateState(const UIState &s); void draw(QPainter &p, const QRect &surface_rect); - // StarPilot variables StarPilotAnnotatedCameraWidget *starpilot_nvg; QJsonObject starpilot_toggles; diff --git a/selfdrive/ui/qt/onroad/model.cc b/selfdrive/ui/qt/onroad/model.cc index 4c35ce632..dbfc08d9d 100644 --- a/selfdrive/ui/qt/onroad/model.cc +++ b/selfdrive/ui/qt/onroad/model.cc @@ -45,14 +45,12 @@ void ModelRenderer::draw(QPainter &painter, const QRect &surface_rect) { drawLead(painter, lead_one, lead_vertices[0], surface_rect, starpilot_nvg->whiteColor()); } } else { - // StarPilot variables starpilot_nvg->leadTextRect = QRect(); } if (lead_two.getStatus() && (std::abs(lead_one.getDRel() - lead_two.getDRel()) > 3.0)) { drawLead(painter, lead_two, lead_vertices[1], surface_rect, QColor(starpilot_toggles.value("lead_marker_color").toString())); } - // StarPilot variables SubMaster &fpsm = *(starpilotUIState()->sm); const cereal::StarPilotRadarState::Reader &starpilot_radar_state = fpsm["starpilotRadarState"].getStarpilotRadarState(); @@ -76,7 +74,6 @@ void ModelRenderer::draw(QPainter &painter, const QRect &surface_rect) { } } - // StarPilot variables if (starpilot_toggles.value("radar_tracks").toBool()) { updateRadarTracks(model.getPosition()); } @@ -121,7 +118,6 @@ void ModelRenderer::update_model(const cereal::ModelDataV2::Reader &model, const max_distance = std::clamp((float)(lead_d - fmin(lead_d * 0.35, 10.)), 0.0f, max_distance); } max_idx = get_path_length_idx(model_position, max_distance); - // StarPilot variables float path_width = starpilot_toggles.value("path_width").toDouble(); if (starpilot_toggles.value("dynamic_path_width").toBool()) { UIState *s = uiState(); @@ -129,7 +125,6 @@ void ModelRenderer::update_model(const cereal::ModelDataV2::Reader &model, const } mapLineToPolygon(model_position, starpilot_toggles.value("model_ui").toBool() ? path_width * (1 - (starpilot_toggles.value("path_edge_width").toDouble() / 100.0f)) : 0.9, path_offset_z, &track_vertices, max_idx, false); - // StarPilot variables StarPilotUIState *fs = starpilotUIState(); SubMaster &fpsm = *(fs->sm); @@ -207,7 +202,6 @@ void ModelRenderer::drawPath(QPainter &painter, const cereal::ModelDataV2::Reade painter.setBrush(bg); painter.drawPolygon(track_vertices); - // StarPilot variables if (starpilot_toggles.value("adjacent_paths").toBool() || starpilot_toggles.value("adjacent_path_metrics").toBool()) { starpilot_nvg->paintAdjacentPaths(painter); } else if (starpilot_toggles.value("blind_spot_path").toBool()) { @@ -293,7 +287,6 @@ void ModelRenderer::drawLead(QPainter &painter, const cereal::RadarState::LeadDa painter.setBrush(QColor(marker_color.red(), marker_color.green(), marker_color.blue(), fillAlpha)); painter.drawPolygon(chevron, std::size(chevron)); - // StarPilot variables if (starpilot_toggles.value("lead_info").toBool()) { starpilot_nvg->paintLeadMetrics(painter, adjacent, chevron, lead_data); } @@ -329,7 +322,6 @@ void ModelRenderer::mapLineToPolygon(const cereal::XYZTData::Reader &line, float } } -// StarPilot variables void ModelRenderer::mapAveragedLineToPolygon(const cereal::XYZTData::Reader &line1, const cereal::XYZTData::Reader &line2, float y_off, float z_off, QPolygonF *pvd, int max_idx, float height, bool allow_invert) { const auto line_x1 = line1.getX(), line_y1 = line1.getY(), line_z1 = line1.getZ(); diff --git a/selfdrive/ui/qt/onroad/model.h b/selfdrive/ui/qt/onroad/model.h index 4addb5c86..fc9f846d3 100644 --- a/selfdrive/ui/qt/onroad/model.h +++ b/selfdrive/ui/qt/onroad/model.h @@ -13,7 +13,6 @@ public: void setTransform(const Eigen::Matrix3f &transform) { car_space_transform = transform; } void draw(QPainter &painter, const QRect &surface_rect); - // StarPilot variables StarPilotAnnotatedCameraWidget *starpilot_nvg; StarPilotUIScene starpilot_scene; @@ -46,7 +45,6 @@ private: Eigen::Matrix3f car_space_transform = Eigen::Matrix3f::Zero(); QRectF clip_region; - // StarPilot variables void mapAveragedLineToPolygon(const cereal::XYZTData::Reader &line1, const cereal::XYZTData::Reader &line2, float y_off, float z_off, QPolygonF *pvd, int max_idx, float height, bool allow_invert = true); void updateAdjacentLeads(const cereal::StarPilotRadarState::Reader &radar_state, const cereal::XYZTData::Reader &line); diff --git a/selfdrive/ui/qt/onroad/onroad_home.cc b/selfdrive/ui/qt/onroad/onroad_home.cc index 63d3f5481..f62823434 100644 --- a/selfdrive/ui/qt/onroad/onroad_home.cc +++ b/selfdrive/ui/qt/onroad/onroad_home.cc @@ -38,7 +38,6 @@ OnroadWindow::OnroadWindow(QWidget *parent) : QWidget(parent) { QObject::connect(uiState(), &UIState::uiUpdate, this, &OnroadWindow::updateState); QObject::connect(uiState(), &UIState::offroadTransition, this, &OnroadWindow::offroadTransition); - // StarPilot variables starpilot_nvg = new StarPilotAnnotatedCameraWidget(this); starpilot_onroad = new StarPilotOnroadWindow(this); starpilot_onroad->setAttribute(Qt::WA_TransparentForMouseEvents, true); @@ -66,7 +65,6 @@ void OnroadWindow::updateState(const UIState &s, const StarPilotUIState &fs) { update(); } - // StarPilot variables const StarPilotUIScene &starpilot_scene = fs.starpilot_scene; const QJsonObject &starpilot_toggles = starpilot_scene.starpilot_toggles; @@ -101,7 +99,6 @@ void OnroadWindow::paintEvent(QPaintEvent *event) { p.fillRect(rect(), QColor(bg.red(), bg.green(), bg.blue(), 255)); } -// StarPilot variables void OnroadWindow::mousePressEvent(QMouseEvent* mouseEvent) { starpilot_nvg->mousePressEvent(mouseEvent); diff --git a/selfdrive/ui/qt/onroad/onroad_home.h b/selfdrive/ui/qt/onroad/onroad_home.h index 94925bf6a..422f82801 100644 --- a/selfdrive/ui/qt/onroad/onroad_home.h +++ b/selfdrive/ui/qt/onroad/onroad_home.h @@ -18,7 +18,6 @@ private: QColor bg = bg_colors[STATUS_DISENGAGED]; QHBoxLayout* split; - // StarPilot variables void mousePressEvent(QMouseEvent* mouseEvent); StarPilotAnnotatedCameraWidget *starpilot_nvg; diff --git a/selfdrive/ui/qt/sidebar.cc b/selfdrive/ui/qt/sidebar.cc index a8d9ce68b..20b87a681 100644 --- a/selfdrive/ui/qt/sidebar.cc +++ b/selfdrive/ui/qt/sidebar.cc @@ -44,12 +44,10 @@ Sidebar::Sidebar(QWidget *parent) : QFrame(parent), onroad(false), flag_pressed( pm = std::make_unique(std::vector{"bookmarkButton"}); - // StarPilot variables QObject::connect(starpilotUIState(), &StarPilotUIState::themeUpdated, this, &Sidebar::updateTheme); } void Sidebar::mousePressEvent(QMouseEvent *event) { - // StarPilot variables QPoint pos = event->pos(); static constexpr QRect cpuRect = {30, 496, 240, 126}; @@ -118,7 +116,6 @@ void Sidebar::offroadTransition(bool offroad) { void Sidebar::updateState(const UIState &s, const StarPilotUIState &fs) { if (!isVisible()) return; - // StarPilot variables const StarPilotUIScene &starpilot_scene = fs.starpilot_scene; const QJsonObject &starpilot_toggles = starpilot_scene.starpilot_toggles; @@ -172,7 +169,6 @@ void Sidebar::updateState(const UIState &s, const StarPilotUIState &fs) { setProperty("recordingAudio", s.scene.recording_audio); - // StarPilot variables if (starpilot_toggles.value("cpu_metrics").toBool() || starpilot_toggles.value("gpu_metrics").toBool()) { capnp::List::Reader cpu_loads = deviceState.getCpuUsagePercent(); int cpu_usage = cpu_loads.size() != 0 ? std::accumulate(cpu_loads.begin(), cpu_loads.end(), 0) / cpu_loads.size() : 0; @@ -241,7 +237,6 @@ void Sidebar::paintEvent(QPaintEvent *event) { } p.setOpacity(1.0); - // StarPilot variables StarPilotUIState *fs = starpilotUIState(); StarPilotUIScene &starpilot_scene = fs->starpilot_scene; QJsonObject &starpilot_toggles = starpilot_scene.starpilot_toggles; @@ -289,7 +284,6 @@ void Sidebar::paintEvent(QPaintEvent *event) { } } -// StarPilot variables void Sidebar::showEvent(QShowEvent *event) { updateTheme(); } diff --git a/selfdrive/ui/qt/sidebar.h b/selfdrive/ui/qt/sidebar.h index 6b57d0e8f..d999da4f8 100644 --- a/selfdrive/ui/qt/sidebar.h +++ b/selfdrive/ui/qt/sidebar.h @@ -20,7 +20,7 @@ class Sidebar : public QFrame { Q_PROPERTY(int netStrength MEMBER net_strength NOTIFY valueChanged); Q_PROPERTY(bool recordingAudio MEMBER recording_audio NOTIFY valueChanged); - // StarPilot properties + // Additional properties Q_PROPERTY(ItemStatus chipStatus MEMBER chip_status NOTIFY valueChanged) Q_PROPERTY(ItemStatus memoryStatus MEMBER memory_status NOTIFY valueChanged) Q_PROPERTY(ItemStatus storageStatus MEMBER storage_status NOTIFY valueChanged) @@ -65,14 +65,12 @@ protected: QString net_type; int net_strength = 0; - // StarPilot variables ItemStatus chip_status, memory_status, storage_status; private: std::unique_ptr pm; Networking *networking = nullptr; - // StarPilot variables void showEvent(QShowEvent *event); void updateTheme(); diff --git a/selfdrive/ui/qt/widgets/controls.h b/selfdrive/ui/qt/widgets/controls.h index 789e9757d..137b3ef8d 100644 --- a/selfdrive/ui/qt/widgets/controls.h +++ b/selfdrive/ui/qt/widgets/controls.h @@ -67,7 +67,6 @@ public slots: signals: void showDescriptionEvent(); - // StarPilot variables void hideDescriptionEvent(); protected: @@ -135,7 +134,6 @@ public: toggle.update(); } - // StarPilot variables void forceOn(bool force) { toggle.setEnabled(!force); if (force && !toggle.on) { diff --git a/selfdrive/ui/qt/widgets/input.cc b/selfdrive/ui/qt/widgets/input.cc index 3cd6c8fae..ae36123f7 100644 --- a/selfdrive/ui/qt/widgets/input.cc +++ b/selfdrive/ui/qt/widgets/input.cc @@ -142,7 +142,6 @@ InputDialog::InputDialog(const QString &title, QWidget *parent, const QString &s QObject::connect(k, &Keyboard::emitBackspace, this, [=]() { line->backspace(); - // StarPilot variables updateMaxLengthSublabel(line->text()); }); QObject::connect(k, &Keyboard::emitKey, this, [=](const QString &key) { @@ -161,7 +160,6 @@ QString InputDialog::getText(const QString &prompt, QWidget *parent, const QStri d.line->setText(defaultText); d.setMinLength(minLength); - // StarPilot variables d.setMaxLength(maxLength); d.updateMaxLengthSublabel(defaultText); @@ -197,7 +195,6 @@ void InputDialog::setMinLength(int length) { minLength = length; } -// StarPilot variables void InputDialog::setMaxLength(int length) { maxLength = length; } diff --git a/selfdrive/ui/qt/widgets/input.h b/selfdrive/ui/qt/widgets/input.h index ae567c4c6..f1c1f7f8f 100644 --- a/selfdrive/ui/qt/widgets/input.h +++ b/selfdrive/ui/qt/widgets/input.h @@ -34,7 +34,6 @@ public: void setMinLength(int length); void show(); - // StarPilot variables void setMaxLength(int length); private: @@ -46,7 +45,6 @@ private: QVBoxLayout *main_layout; QPushButton *eye_btn; - // StarPilot variables void updateMaxLengthSublabel(const QString &text); int maxLength; diff --git a/selfdrive/ui/qt/window.cc b/selfdrive/ui/qt/window.cc index 4693a58cc..ccc63d546 100644 --- a/selfdrive/ui/qt/window.cc +++ b/selfdrive/ui/qt/window.cc @@ -79,7 +79,6 @@ void MainWindow::closeSettings() { } bool MainWindow::eventFilter(QObject *obj, QEvent *event) { - // StarPilot variables StarPilotUIState &fs = *starpilotUIState(); StarPilotUIScene &starpilot_scene = fs.starpilot_scene; QJsonObject &starpilot_toggles = starpilot_scene.starpilot_toggles; diff --git a/selfdrive/ui/qt/window.h b/selfdrive/ui/qt/window.h index 2b533db19..88f4b2410 100644 --- a/selfdrive/ui/qt/window.h +++ b/selfdrive/ui/qt/window.h @@ -23,6 +23,5 @@ private: SettingsWindow *settingsWindow; OnboardingWindow *onboardingWindow; - // StarPilot variables Params params; }; diff --git a/selfdrive/ui/soundd.py b/selfdrive/ui/soundd.py index 74f5c758a..798237123 100644 --- a/selfdrive/ui/soundd.py +++ b/selfdrive/ui/soundd.py @@ -34,7 +34,6 @@ if HARDWARE.get_device_type() in ("tici", "tizi"): AudibleAlert = car.CarControl.HUDControl.AudibleAlert -# StarPilot variables StarPilotAudibleAlert = custom.StarPilotCarControl.HUDControl.AudibleAlert @@ -51,7 +50,6 @@ sound_list: dict[int, tuple[str, int | None, float]] = { AudibleAlert.warningSoft: ("warning_soft.wav", None, MAX_VOLUME), AudibleAlert.warningImmediate: ("warning_immediate.wav", None, MAX_VOLUME), - # StarPilot variables StarPilotAudibleAlert.angry: ("angry.wav", 1, MAX_VOLUME), StarPilotAudibleAlert.continued: ("continued.wav", 1, MAX_VOLUME), StarPilotAudibleAlert.dejaVu: ("dejaVu.wav", 1, MAX_VOLUME), @@ -86,6 +84,7 @@ def check_selfdrive_timeout_alert(sm): class Soundd: def __init__(self): self.current_alert = AudibleAlert.none + self.current_alert_type = "" self.current_volume = MIN_VOLUME self.current_sound_frame = 0 @@ -93,7 +92,6 @@ class Soundd: self.spl_filter_weighted = FirstOrderFilter(0, 2.5, FILTER_DT, initialized=False) - # StarPilot variables self.params_memory = Params(memory=True) self.starpilot_toggles = get_starpilot_toggles() @@ -174,27 +172,47 @@ class Soundd: def get_audible_alert(self, sm): if self.params_memory.get("TestAlert"): - self.update_alert(getattr(AudibleAlert, self.params_memory.get("TestAlert"))) + test_alert = self.params_memory.get("TestAlert") + if isinstance(test_alert, bytes): + test_alert = test_alert.decode("utf-8", "ignore") + + if test_alert == "belowSteerSpeed": + self.current_alert_type = "belowSteerSpeed/warning" + self.update_alert(AudibleAlert.prompt) + else: + self.current_alert_type = "" + self.update_alert(getattr(AudibleAlert, test_alert)) self.params_memory.remove("TestAlert") elif not self.openpilot_crashed_played and self.error_log.is_file(): + self.current_alert_type = "" self.update_alert(AudibleAlert.prompt) self.openpilot_crashed_played = True elif sm.updated['selfdriveState']: new_alert = sm['selfdriveState'].alertSound.raw + new_alert_type = sm['selfdriveState'].alertType - # StarPilot variables new_starpilot_alert = sm['starpilotSelfdriveState'].alertSound.raw if new_alert == AudibleAlert.none and new_starpilot_alert != StarPilotAudibleAlert.none: new_alert = new_starpilot_alert + new_alert_type = sm['starpilotSelfdriveState'].alertType + self.current_alert_type = new_alert_type self.update_alert(new_alert) elif check_selfdrive_timeout_alert(sm): + self.current_alert_type = "" self.update_alert(AudibleAlert.warningImmediate) self.selfdrive_timeout_alert = True elif self.selfdrive_timeout_alert: + self.current_alert_type = "" self.update_alert(AudibleAlert.none) self.selfdrive_timeout_alert = False + def get_volume_override(self): + if self.current_alert_type.startswith("belowSteerSpeed/"): + return self.starpilot_toggles.below_steer_speed_volume / 100.0 + + return self.volume_map.get(self.current_alert, 1.01) + def calculate_volume(self, weighted_db): volume = ((weighted_db - AMBIENT_DB) / DB_SCALE) * (MAX_VOLUME - MIN_VOLUME) + MIN_VOLUME return math.pow(VOLUME_BASE, (np.clip(volume, MIN_VOLUME, MAX_VOLUME) - 1)) @@ -212,7 +230,6 @@ class Soundd: sm = messaging.SubMaster(['selfdriveState', 'soundPressure']) - # StarPilot variables sm = sm.extend(['starpilotSelfdriveState', 'starpilotPlan']) with self.get_stream(sd) as stream: @@ -230,8 +247,8 @@ class Soundd: self.auto_volume = self.current_volume self.current_volume = 0.0 - elif self.current_alert in self.volume_map and self.starpilot_toggles.alert_volume_controller: - self.current_volume = self.volume_map[self.current_alert] + elif self.current_alert != AudibleAlert.none and self.starpilot_toggles.alert_volume_controller: + self.current_volume = self.get_volume_override() if self.current_volume == 1.01: self.current_volume = self.auto_volume @@ -241,7 +258,6 @@ class Soundd: assert stream.active - # StarPilot variables starpilot_toggles = get_starpilot_toggles(sm) if starpilot_toggles != self.starpilot_toggles: self.starpilot_toggles = starpilot_toggles diff --git a/selfdrive/ui/ui b/selfdrive/ui/ui index e8e6cc370..ba6e54549 100755 Binary files a/selfdrive/ui/ui and b/selfdrive/ui/ui differ diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index 9e70cc04b..51efb3643 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -64,7 +64,6 @@ static void update_state(UIState *s, StarPilotUIState *fs) { auto params = Params(); scene.recording_audio = params.getBool("RecordAudio") && scene.started; - // StarPilot variables StarPilotUIScene &starpilot_scene = fs->starpilot_scene; if (sm.updated("carState")) { @@ -87,7 +86,6 @@ void ui_update_params(UIState *s) { } void UIState::updateStatus(StarPilotUIState *fs) { - // StarPilot variables StarPilotUIScene &starpilot_scene = fs->starpilot_scene; QJsonObject &starpilot_toggles = starpilot_scene.starpilot_toggles; @@ -95,20 +93,20 @@ void UIState::updateStatus(StarPilotUIState *fs) { auto ss = (*sm)["selfdriveState"].getSelfdriveState(); auto state = ss.getState(); - // StarPilot variables const UIStatus previous_status = status; if (state == cereal::SelfdriveState::OpenpilotState::PRE_ENABLED || state == cereal::SelfdriveState::OpenpilotState::OVERRIDING) { status = STATUS_OVERRIDE; } else if (starpilot_scene.always_on_lateral_active) { status = STATUS_ALWAYS_ON_LATERAL_ACTIVE; + } else if (starpilot_scene.switchback_mode_enabled && ss.getEnabled()) { + status = STATUS_SWITCHBACK_MODE_ENABLED; } else if (starpilot_scene.traffic_mode_enabled && ss.getEnabled()) { status = STATUS_TRAFFIC_MODE_ENABLED; } else { status = ss.getEnabled() ? STATUS_ENGAGED : STATUS_DISENGAGED; } - // StarPilot variables starpilot_scene.wake_up_screen = ss.getAlertStatus() != cereal::SelfdriveState::AlertStatus::NORMAL || (status != previous_status && status != STATUS_OVERRIDE); } @@ -126,7 +124,6 @@ void UIState::updateStatus(StarPilotUIState *fs) { started_prev = scene.started; emit offroadTransition(!scene.started); - // StarPilot variables if (starpilot_toggles.value("tethering_config").toInt() == 2) { fs->wifi->setTetheringEnabled(scene.started); } @@ -158,7 +155,6 @@ void UIState::update() { } emit uiUpdate(*this, *starpilotUIState()); - // StarPilot variables StarPilotUIState *fs = starpilotUIState(); StarPilotUIScene &starpilot_scene = fs->starpilot_scene; QJsonObject &starpilot_toggles = starpilot_scene.starpilot_toggles; @@ -195,14 +191,12 @@ void Device::resetInteractiveTimeout(int timeout, int timeout_onroad) { if (timeout == -1) { timeout = (ignition_on ? 10 : 30); } else { - // StarPilot variables timeout = (ignition_on ? timeout_onroad : timeout); } interactive_timeout = timeout * UI_FREQ; } void Device::updateBrightness(const UIState &s, const StarPilotUIState &fs) { - // StarPilot variables const StarPilotUIScene &starpilot_scene = fs.starpilot_scene; const QJsonObject &starpilot_toggles = starpilot_scene.starpilot_toggles; @@ -241,7 +235,6 @@ void Device::updateBrightness(const UIState &s, const StarPilotUIState &fs) { } void Device::updateWakefulness(const UIState &s, const StarPilotUIState &fs) { - // StarPilot variables const StarPilotUIScene &starpilot_scene = fs.starpilot_scene; const QJsonObject &starpilot_toggles = starpilot_scene.starpilot_toggles; diff --git a/selfdrive/ui/ui.h b/selfdrive/ui/ui.h index 1c9cd7bf3..cf02c466e 100644 --- a/selfdrive/ui/ui.h +++ b/selfdrive/ui/ui.h @@ -45,10 +45,10 @@ typedef enum UIStatus { STATUS_OVERRIDE, STATUS_ENGAGED, - // StarPilot variables STATUS_ALWAYS_ON_LATERAL_ACTIVE, STATUS_CEM_DISABLED, STATUS_EXPERIMENTAL_MODE_ENABLED, + STATUS_SWITCHBACK_MODE_ENABLED, STATUS_TRAFFIC_MODE_ENABLED, } UIStatus; @@ -57,10 +57,10 @@ const QColor bg_colors [] = { [STATUS_OVERRIDE] = QColor(0x91, 0x9b, 0x95, 0xf1), [STATUS_ENGAGED] = QColor(0x17, 0x86, 0x44, 0xf1), - // StarPilot variables [STATUS_ALWAYS_ON_LATERAL_ACTIVE] = QColor(0x0a, 0xba, 0xb5, 0xf1), [STATUS_CEM_DISABLED] = QColor(0xff, 0xff, 0x00, 0xf1), [STATUS_EXPERIMENTAL_MODE_ENABLED] = QColor(0xda, 0x6f, 0x25, 0xf1), + [STATUS_SWITCHBACK_MODE_ENABLED] = QColor(0x8b, 0x6c, 0xc5, 0xf1), [STATUS_TRAFFIC_MODE_ENABLED] = QColor(0xc9, 0x22, 0x31, 0xf1), }; diff --git a/selfdrive/ui/ui_state.py b/selfdrive/ui/ui_state.py index b8714e2d0..dbf816f0a 100644 --- a/selfdrive/ui/ui_state.py +++ b/selfdrive/ui/ui_state.py @@ -83,6 +83,7 @@ class UIState: self.light_sensor: float = -1.0 self._param_update_time: float = 0.0 self.always_on_lateral_active: bool = False + self.switchback_mode_enabled: bool = False self.traffic_mode_enabled: bool = False self.conditional_status: int = 0 @@ -148,6 +149,7 @@ class UIState: self.is_metric = self.params.get_bool("IsMetric") self.always_on_dm = self.params.get_bool("AlwaysOnDM") + self.switchback_mode_enabled = self.params_memory.get_bool("SwitchbackModeEnabled") if self.started else False if self.sm.valid.get("starpilotCarState", False): starpilot_car_state = self.sm["starpilotCarState"] self.always_on_lateral_active = (not self.sm["selfdriveState"].enabled and diff --git a/starpilot/common/starpilot_functions.py b/starpilot/common/starpilot_functions.py index 10676e425..ed4d5a795 100644 --- a/starpilot/common/starpilot_functions.py +++ b/starpilot/common/starpilot_functions.py @@ -71,6 +71,7 @@ def install_starpilot(build_metadata, params): ERROR_LOGS_PATH, HD_LOGS_PATH, KONIK_LOGS_PATH, + MAPS_PATH, THEME_SAVE_PATH ] for path in paths: @@ -192,7 +193,7 @@ def update_maps(now, params, params_memory, manual_update=False): is_sunday = now.weekday() == 6 schedule = params.get("PreferredSchedule") - maps_downloaded = MAPS_PATH.exists() + maps_downloaded = MAPS_PATH.exists() and any(path.is_file() for path in MAPS_PATH.rglob("*")) if maps_downloaded and (schedule == 0 or (schedule == 1 and not is_sunday) or (schedule == 2 and not is_first)) and not manual_update: return diff --git a/starpilot/common/starpilot_utilities.py b/starpilot/common/starpilot_utilities.py index 6c4b49ec5..bee39ce79 100644 --- a/starpilot/common/starpilot_utilities.py +++ b/starpilot/common/starpilot_utilities.py @@ -125,7 +125,7 @@ def calculate_lane_width(lane_line1, lane_line2, road_edge=None): # Credit goes to Pfeiferj! -def calculate_road_curvature(modelData): +def calculate_road_curvature(modelData, v_ego): orientation_rate = np.array(modelData.orientationRate.z) timebase = np.array(modelData.orientationRate.t) velocity = np.array(modelData.velocity.x) @@ -135,7 +135,7 @@ def calculate_road_curvature(modelData): predicted_lateral_acc = float(lateral_acceleration[index]) time_to_curve = float(timebase[index]) - return float(predicted_lateral_acc / max(velocity[index], 1)**2), max(time_to_curve, 1) + return float(predicted_lateral_acc / max(v_ego, 1)**2), max(time_to_curve, 1) def clean_model_name(name): diff --git a/starpilot/common/starpilot_variables.py b/starpilot/common/starpilot_variables.py index 1bbc89d8a..43f1dc936 100644 --- a/starpilot/common/starpilot_variables.py +++ b/starpilot/common/starpilot_variables.py @@ -43,7 +43,7 @@ THRESHOLD = 1 - 1 / math.e # Requires the condition to be true fo NON_DRIVING_GEARS = [GearShifter.neutral, GearShifter.park, GearShifter.reverse, GearShifter.unknown] -# Temporary fallback until StarPilot hosts its own weather-compatible API. +# Temporary fallback until the weather-compatible API is hosted locally. STARPILOT_API = os.getenv("STARPILOT_API", "https://frogpilot.com/api") LEGACY_CARMODEL_MIGRATIONS = { @@ -111,7 +111,8 @@ BUTTON_FUNCTIONS = { "PAUSE_LATERAL": 3, "PAUSE_LONGITUDINAL": 4, "EXPERIMENTAL_MODE": 5, - "TRAFFIC_MODE": 6 + "TRAFFIC_MODE": 6, + "SWITCHBACK_MODE": 7, } DEVELOPER_SIDEBAR_METRICS = { @@ -546,6 +547,8 @@ class StarPilotVariables: toggle.vEgoStopping = self.get_value("VEgoStopping", cast=float, condition=advanced_longitudinal_tuning, default=toggle.vEgoStopping, min=0.01, max=1) toggle.alert_volume_controller = self.get_value("AlertVolumeControl") + toggle.below_steer_speed_volume = self.get_value("BelowSteerSpeedVolume", cast=float, condition=toggle.alert_volume_controller) + toggle.switchback_mode_cooldown = self.get_value("SwitchbackModeCooldown", cast=float, min=0, max=60) toggle.disengage_volume = self.get_value("DisengageVolume", cast=float, condition=toggle.alert_volume_controller) toggle.engage_volume = self.get_value("EngageVolume", cast=float, condition=toggle.alert_volume_controller) toggle.prompt_volume = self.get_value("PromptVolume", cast=float, condition=toggle.alert_volume_controller) @@ -709,6 +712,7 @@ class StarPilotVariables: toggle.pause_lateral_via_distance = distance_button_control == BUTTON_FUNCTIONS["PAUSE_LATERAL"] toggle.pause_longitudinal_via_distance = toggle.openpilot_longitudinal and distance_button_control == BUTTON_FUNCTIONS["PAUSE_LONGITUDINAL"] toggle.personality_profile_via_distance = toggle.openpilot_longitudinal and distance_button_control == BUTTON_FUNCTIONS["PERSONALITY_PROFILE"] + toggle.switchback_mode_via_distance = distance_button_control == BUTTON_FUNCTIONS["SWITCHBACK_MODE"] toggle.traffic_mode_via_distance = toggle.openpilot_longitudinal and distance_button_control == BUTTON_FUNCTIONS["TRAFFIC_MODE"] distance_button_control_long = self.get_value("LongDistanceButtonControl", cast=float) @@ -718,6 +722,7 @@ class StarPilotVariables: toggle.pause_lateral_via_distance_long = distance_button_control_long == BUTTON_FUNCTIONS["PAUSE_LATERAL"] toggle.pause_longitudinal_via_distance_long = toggle.openpilot_longitudinal and distance_button_control_long == BUTTON_FUNCTIONS["PAUSE_LONGITUDINAL"] toggle.personality_profile_via_distance_long = toggle.openpilot_longitudinal and distance_button_control_long == BUTTON_FUNCTIONS["PERSONALITY_PROFILE"] + toggle.switchback_mode_via_distance_long = distance_button_control_long == BUTTON_FUNCTIONS["SWITCHBACK_MODE"] toggle.traffic_mode_via_distance_long = toggle.openpilot_longitudinal and distance_button_control_long == BUTTON_FUNCTIONS["TRAFFIC_MODE"] distance_button_control_very_long = self.get_value("VeryLongDistanceButtonControl", cast=float) @@ -727,6 +732,7 @@ class StarPilotVariables: toggle.pause_lateral_via_distance_very_long = distance_button_control_very_long == BUTTON_FUNCTIONS["PAUSE_LATERAL"] toggle.pause_longitudinal_via_distance_very_long = toggle.openpilot_longitudinal and distance_button_control_very_long == BUTTON_FUNCTIONS["PAUSE_LONGITUDINAL"] toggle.personality_profile_via_distance_very_long = toggle.openpilot_longitudinal and distance_button_control_very_long == BUTTON_FUNCTIONS["PERSONALITY_PROFILE"] + toggle.switchback_mode_via_distance_very_long = distance_button_control_very_long == BUTTON_FUNCTIONS["SWITCHBACK_MODE"] toggle.traffic_mode_via_distance_very_long = toggle.openpilot_longitudinal and distance_button_control_very_long == BUTTON_FUNCTIONS["TRAFFIC_MODE"] toggle.frogsgomoo_tweak = self.get_value("FrogsGoMoosTweak", condition=toggle.openpilot_longitudinal and toggle.car_make == "toyota") @@ -764,6 +770,7 @@ class StarPilotVariables: toggle.pause_lateral_via_lkas = lkas_button_control == BUTTON_FUNCTIONS["PAUSE_LATERAL"] toggle.pause_longitudinal_via_lkas = toggle.openpilot_longitudinal and lkas_button_control == BUTTON_FUNCTIONS["PAUSE_LONGITUDINAL"] toggle.personality_profile_via_lkas = toggle.openpilot_longitudinal and lkas_button_control == BUTTON_FUNCTIONS["PERSONALITY_PROFILE"] + toggle.switchback_mode_via_lkas = lkas_button_control == BUTTON_FUNCTIONS["SWITCHBACK_MODE"] toggle.traffic_mode_via_lkas = toggle.openpilot_longitudinal and lkas_button_control == BUTTON_FUNCTIONS["TRAFFIC_MODE"] toggle.lock_doors_timer = self.get_value("LockDoorsTimer", cast=float, condition=(toggle.car_make == "toyota")) diff --git a/starpilot/controls/lib/conditional_experimental_mode.py b/starpilot/controls/lib/conditional_experimental_mode.py index 2874e69b3..0721bf457 100644 --- a/starpilot/controls/lib/conditional_experimental_mode.py +++ b/starpilot/controls/lib/conditional_experimental_mode.py @@ -25,7 +25,7 @@ def interp(x, xp, fp): def scale_threshold(v_ego): - # Keep StarPilot speed-based lead threshold behavior (v_ego in m/s) + # Speed-based lead threshold behavior (v_ego in m/s) return interp(v_ego, [0.0, 17.9, 26.8, 35.8, 44.7], [0.58, 0.60, 0.62, 0.75, 0.90]) diff --git a/starpilot/controls/lib/curve_speed_controller.py b/starpilot/controls/lib/curve_speed_controller.py index 93195cac6..61174a7c9 100644 --- a/starpilot/controls/lib/curve_speed_controller.py +++ b/starpilot/controls/lib/curve_speed_controller.py @@ -1,6 +1,4 @@ #!/usr/bin/env python3 -import json - import numpy as np from openpilot.common.realtime import DT_MDL @@ -9,11 +7,12 @@ from openpilot.starpilot.common.starpilot_variables import CRUISING_SPEED, DEFAU CALIBRATION_PROGRESS_THRESHOLD = 10 / DT_MDL MAX_CURVATURE = 0.1 -MIN_CURVATURE = 0.01 +MIN_CURVATURE = 0.001 PERCENTILE = 90 -ROUNDING_PRECISION = 3 +ROUNDING_PRECISION = 5 STEP = 0.001 + class CurveSpeedController: def __init__(self, StarPilotVCruise): self.starpilot_planner = StarPilotVCruise.starpilot_planner @@ -23,29 +22,17 @@ class CurveSpeedController: self.training_timer = 0 - curvature_data_raw = self.starpilot_planner.params.get("CurvatureData", encoding="utf-8") - try: - self.curvature_data = json.loads(curvature_data_raw or "{}") - except (TypeError, ValueError): - self.curvature_data = {} + curvature_data = self.starpilot_planner.params.get("CurvatureData") + self.curvature_data = curvature_data if isinstance(curvature_data, dict) else {} + + self.required_curvatures = [str(round(road_curvature, ROUNDING_PRECISION)) for road_curvature in np.arange(MIN_CURVATURE, MAX_CURVATURE + STEP, STEP)] - self.calculate_weights() self.update_lateral_acceleration() - def calculate_weights(self): - curvatures = np.arange(MIN_CURVATURE, MAX_CURVATURE + STEP, STEP) - mid_point = (MIN_CURVATURE + MAX_CURVATURE) / 2 - - self.curvature_weights = {} - for curvature in curvatures: - distance = abs(curvature - mid_point) / (MAX_CURVATURE - MIN_CURVATURE) - weight = 1.0 + (4.0 * (1 - distance)) - self.curvature_weights[str(round(curvature, ROUNDING_PRECISION))] = weight - - def log_data(self, long_control_active, v_ego, sm): + def log_data(self, v_ego, sm): self.enable_training = v_ego > CRUISING_SPEED self.enable_training &= not self.starpilot_planner.tracking_lead - self.enable_training &= not long_control_active + self.enable_training &= not sm["carControl"].longActive if self.enable_training: self.training_timer += DT_MDL @@ -70,26 +57,25 @@ class CurveSpeedController: "average": lateral_acceleration, "count": 1 } + + self.update_lateral_acceleration() else: self.enable_training = False elif self.training_timer >= PLANNER_TIME: progress = 0.0 - total_weight = 0.0 - - for key in list(self.curvature_weights.keys()): + for key in self.required_curvatures: if key in self.curvature_data: - progress += min(self.curvature_data[key]["count"] / CALIBRATION_PROGRESS_THRESHOLD, 1.0) * self.curvature_weights[key] + progress += min(self.curvature_data[key]["count"] / CALIBRATION_PROGRESS_THRESHOLD, 1.0) - total_weight += self.curvature_weights[key] - - self.starpilot_planner.params.put_nonblocking("CalibrationProgress", float(min((progress / total_weight) * 100, 100.0))) + self.starpilot_planner.params.put_nonblocking("CalibrationProgress", (progress / len(self.required_curvatures)) * 100) self.starpilot_planner.params.put_nonblocking("CurvatureData", self.curvature_data) - self.update_lateral_acceleration() + self.enable_training = False self.training_timer = 0 else: + self.enable_training = False self.training_timer = 0 def update_lateral_acceleration(self): @@ -111,7 +97,7 @@ class CurveSpeedController: decel_rate = (v_ego - csc_speed) / self.starpilot_planner.time_to_curve self.target -= decel_rate * DT_MDL - self.target = np.clip(self.target, CRUISING_SPEED, csc_speed) + self.target = float(np.clip(self.target, CRUISING_SPEED, csc_speed)) else: self.target_set = True self.target = v_ego diff --git a/starpilot/controls/lib/speed_limit_controller.py b/starpilot/controls/lib/speed_limit_controller.py index db2e75f57..b61f92014 100644 --- a/starpilot/controls/lib/speed_limit_controller.py +++ b/starpilot/controls/lib/speed_limit_controller.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -# PFEIFER - SLC - Modified by FrogAi for StarPilot +# PFEIFER - SLC - Modified by FrogAi import calendar import json import numpy as np @@ -10,7 +10,7 @@ from concurrent.futures import ThreadPoolExecutor from openpilot.common.constants import CV from openpilot.common.realtime import DT_MDL -from openpilot.starpilot.common.starpilot_utilities import calculate_bearing_offset, is_url_pingable +from openpilot.starpilot.common.starpilot_utilities import calculate_bearing_offset, calculate_distance_to_point, is_url_pingable FREE_MAPBOX_REQUESTS = 100_000 @@ -85,6 +85,15 @@ class SpeedLimitController: offset_map = OFFSET_MAP_METRIC if self.starpilot_toggles.is_metric else OFFSET_MAP_IMPERIAL return next((getattr(self.starpilot_toggles, offset) for low, high, offset in offset_map if low < self.target < high), 0) + def _read_next_map_speed_limit(self): + next_map_speed_limit = self.starpilot_planner.params_memory.get("NextMapSpeedLimit") or {} + if isinstance(next_map_speed_limit, (bytes, str)): + try: + next_map_speed_limit = json.loads(next_map_speed_limit) + except (TypeError, ValueError): + next_map_speed_limit = {} + return next_map_speed_limit if isinstance(next_map_speed_limit, dict) else {} + def get_mapbox_speed_limit(self, now, time_validated, v_ego, sm): if not self.starpilot_planner.gps_valid or not self.mapbox_token or (sm["carState"].steeringAngleDeg - sm["liveParameters"].angleOffsetDeg) >= 45: self.mapbox_limit = 0 @@ -311,8 +320,30 @@ class SpeedLimitController: self.unconfirmed_speed_limit = 0 def update_map_speed_limit(self, v_ego, sm): - self.map_speed_limit = sm["mapdOut"].speedLimit - self.next_speed_limit = sm["mapdOut"].nextSpeedLimit + next_speed_limit_distance = sm["mapdOut"].nextSpeedLimitDistance + + if self.starpilot_toggles.speed_limit_filler: + next_map_speed_limit = self._read_next_map_speed_limit() + filler_map_speed_limit = self.starpilot_planner.params_memory.get_float("MapSpeedLimit") + filler_next_speed_limit = next_map_speed_limit.get("speedlimit", 0) + + if filler_map_speed_limit > 0 or filler_next_speed_limit > 0: + self.map_speed_limit = filler_map_speed_limit + self.next_speed_limit = filler_next_speed_limit + next_speed_limit_distance = next_map_speed_limit.get("distance", 0) + + next_latitude = next_map_speed_limit.get("latitude") + next_longitude = next_map_speed_limit.get("longitude") + if self.starpilot_planner.gps_valid and next_latitude is not None and next_longitude is not None: + current_latitude = self.starpilot_planner.gps_position.get("latitude") + current_longitude = self.starpilot_planner.gps_position.get("longitude") + next_speed_limit_distance = calculate_distance_to_point(current_latitude, current_longitude, next_latitude, next_longitude) + else: + self.map_speed_limit = sm["mapdOut"].speedLimit + self.next_speed_limit = sm["mapdOut"].nextSpeedLimit + else: + self.map_speed_limit = sm["mapdOut"].speedLimit + self.next_speed_limit = sm["mapdOut"].nextSpeedLimit if self.next_speed_limit > 0: if self.map_speed_limit < self.next_speed_limit: @@ -322,7 +353,7 @@ class SpeedLimitController: else: max_lookahead = 0 - if sm["mapdOut"].nextSpeedLimitDistance < max_lookahead: + if next_speed_limit_distance < max_lookahead: self.map_speed_limit = self.next_speed_limit def update_override(self, v_cruise, v_cruise_diff, v_ego, v_ego_diff, sm): diff --git a/starpilot/controls/lib/starpilot_events.py b/starpilot/controls/lib/starpilot_events.py index 94c482565..10e910b5e 100644 --- a/starpilot/controls/lib/starpilot_events.py +++ b/starpilot/controls/lib/starpilot_events.py @@ -24,6 +24,7 @@ class StarPilotEvents: self.always_on_lateral_enabled_previously = False self.previous_traffic_mode = False + self.previous_switchback_mode = False self.random_event_playing = False self.startup_seen = False self.stopped_for_light = False @@ -39,11 +40,16 @@ class StarPilotEvents: def update(self, long_control_active, v_cruise, sm, starpilot_toggles): current_alert = sm["selfdriveState"].alertType current_starpilot_alert = sm["selfdriveState"].alertType + switchback_mode_enabled = self.starpilot_planner.params_memory.get_bool("SwitchbackModeEnabled") alerts_empty = all(sm[state].alertText1 == "" and sm[state].alertText2 == "" for state in ["selfdriveState", "starpilotSelfdriveState"]) self.events.clear() + if not sm["deviceState"].started: + self.previous_switchback_mode = False + self.previous_traffic_mode = False + acceleration = sm["carControl"].actuators.accel if long_control_active: @@ -193,6 +199,14 @@ class StarPilotEvents: self.previous_traffic_mode = sm["starpilotCarState"].trafficModeEnabled + if switchback_mode_enabled != self.previous_switchback_mode: + if self.previous_switchback_mode: + self.events.add(StarPilotEventName.switchbackModeInactive) + else: + self.events.add(StarPilotEventName.switchbackModeActive) + + self.previous_switchback_mode = switchback_mode_enabled + if sm["starpilotModelV2"].turnDirection == TurnDirection.turnLeft: self.events.add(StarPilotEventName.turningLeft) elif sm["starpilotModelV2"].turnDirection == TurnDirection.turnRight: diff --git a/starpilot/controls/lib/starpilot_vcruise.py b/starpilot/controls/lib/starpilot_vcruise.py index 9ea2f642a..5cebfc12f 100644 --- a/starpilot/controls/lib/starpilot_vcruise.py +++ b/starpilot/controls/lib/starpilot_vcruise.py @@ -23,8 +23,8 @@ class StarPilotVCruise: self.force_stop_timer = 0.0 self.tracked_model_length = 0.0 - def update(self, long_control_active, now, time_validated, v_cruise, v_ego, sm, starpilot_toggles): - force_stop = self.starpilot_planner.starpilot_cem.stop_light_detected and long_control_active and starpilot_toggles.force_stops + def update(self, controls_enabled, now, time_validated, v_cruise, v_ego, sm, starpilot_toggles): + force_stop = self.starpilot_planner.starpilot_cem.stop_light_detected and controls_enabled and starpilot_toggles.force_stops force_stop &= self.starpilot_planner.model_stopped force_stop &= self.override_force_stop_timer <= 0 @@ -48,14 +48,14 @@ class StarPilotVCruise: v_ego_diff = v_ego_cluster - v_ego # FrogsGoMoo's Curve Speed Controller - if long_control_active and v_ego > CRUISING_SPEED and self.starpilot_planner.road_curvature_detected and starpilot_toggles.curve_speed_controller: + if controls_enabled and v_ego > CRUISING_SPEED and self.starpilot_planner.road_curvature_detected and starpilot_toggles.curve_speed_controller: self.csc.update_target(v_ego) self.csc_controlling_speed = True self.csc_target = self.csc.target else: - self.csc.log_data(long_control_active, v_ego, sm) + self.csc.log_data(v_ego, sm) self.csc_controlling_speed = False self.csc.target_set = False diff --git a/starpilot/controls/starpilot_card.py b/starpilot/controls/starpilot_card.py index 0034b0881..828e3ae28 100644 --- a/starpilot/controls/starpilot_card.py +++ b/starpilot/controls/starpilot_card.py @@ -22,6 +22,7 @@ class StarPilotCard: self.force_coast = False self.pause_lateral = False self.pause_longitudinal = False + self.switchback_mode_enabled = self.params_memory.get_bool("SwitchbackModeEnabled") self.traffic_mode_enabled = False self.gap_counter = 0 @@ -43,6 +44,9 @@ class StarPilotCard: self.pause_lateral = not self.pause_lateral elif getattr(starpilot_toggles, f"pause_longitudinal_via_{key}"): self.pause_longitudinal = not self.pause_longitudinal + elif getattr(starpilot_toggles, f"switchback_mode_via_{key}"): + self.switchback_mode_enabled = not self.switchback_mode_enabled + self.params_memory.put_bool("SwitchbackModeEnabled", self.switchback_mode_enabled) elif sm["carControl"].longActive and getattr(starpilot_toggles, f"traffic_mode_via_{key}"): self.traffic_mode_enabled = not self.traffic_mode_enabled @@ -60,6 +64,8 @@ class StarPilotCard: self.params.put_bool_nonblocking("ExperimentalMode", not sm["selfdriveState"].experimentalMode) def update(self, carState, starpilotCarState, sm, starpilot_toggles): + self.switchback_mode_enabled = self.params_memory.get_bool("SwitchbackModeEnabled") + if self.CP.brand == "hyundai": for be in carState.buttonEvents: if be.type == ButtonType.lkas and be.pressed and starpilot_toggles.always_on_lateral_lkas: diff --git a/starpilot/controls/starpilot_planner.py b/starpilot/controls/starpilot_planner.py index 06b68bd8c..d4521a899 100644 --- a/starpilot/controls/starpilot_planner.py +++ b/starpilot/controls/starpilot_planner.py @@ -115,7 +115,7 @@ class StarPilotPlanner: self.model_stopped = self.model_length < CRUISING_SPEED * PLANNER_TIME self.model_stopped |= self.starpilot_vcruise.forcing_stop - self.road_curvature, self.time_to_curve = calculate_road_curvature(sm["modelV2"]) + self.road_curvature, self.time_to_curve = calculate_road_curvature(sm["modelV2"], v_ego) self.road_curvature_detected = (1 / abs(self.road_curvature))**0.5 < v_ego > CRUISING_SPEED and not (sm["carState"].leftBlinker or sm["carState"].rightBlinker) diff --git a/starpilot/navigation/mapd_wrapper.py b/starpilot/navigation/mapd_wrapper.py index c2a901730..7c7727950 100644 --- a/starpilot/navigation/mapd_wrapper.py +++ b/starpilot/navigation/mapd_wrapper.py @@ -101,6 +101,8 @@ def terminate_child(proc: subprocess.Popen[str]) -> None: def run_mapd_once() -> int: + OFFLINE_ROOT.mkdir(parents=True, exist_ok=True) + proc = subprocess.Popen( [MAPD_BIN.as_posix()], cwd=MAPD_DIR, diff --git a/starpilot/system/speed_limit_filler.py b/starpilot/system/speed_limit_filler.py index b5815b6b5..3a9f470c6 100644 --- a/starpilot/system/speed_limit_filler.py +++ b/starpilot/system/speed_limit_filler.py @@ -23,6 +23,9 @@ MAX_OVERPASS_DATA_BYTES = 1_073_741_824 MAX_OVERPASS_REQUESTS = 10_000 METERS_PER_DEG_LAT = 111_320 VETTING_INTERVAL_DAYS = 7 +ACTIVE_SEGMENT_BUFFER_METERS = 25 +MAX_BEARING_DELTA = 45 +MIN_LATERAL_MATCH_BUFFER = 12 OVERPASS_API_URL = "https://overpass-api.de/api/interpreter" OVERPASS_STATUS_URL = "https://overpass-api.de/api/status" @@ -38,6 +41,7 @@ class MapSpeedLogger: self.cached_segments = {} self.dataset_additions = deque(maxlen=MAX_ENTRIES) + self.filtered_dataset = [] self.overpass_requests = self.params.get("OverpassRequests") self.overpass_requests.setdefault("day", datetime.now(timezone.utc).day) @@ -51,6 +55,7 @@ class MapSpeedLogger: self.gps_location_service = get_gps_location_service(self.params) self.sm = messaging.SubMaster(["deviceState", "starpilotCarState", "starpilotPlan", self.gps_location_service, "mapdOut", "modelV2"]) + self.refresh_filtered_dataset() @property def can_make_overpass_request(self): @@ -89,6 +94,38 @@ class MapSpeedLogger: def meters_to_deg_lon(meters, latitude): return meters / (METERS_PER_DEG_LAT * math.cos(latitude * CV.DEG_TO_RAD)) + @staticmethod + def bearing_delta(bearing1, bearing2): + return abs((bearing1 - bearing2 + 180) % 360 - 180) + + @staticmethod + def has_live_match_fields(entry): + required = {"bearing", "end_coordinates", "road_name", "road_width", "speed_limit", "start_coordinates"} + return required.issubset(entry.keys()) + + @staticmethod + def latlon_to_local_meters(origin_latitude, origin_longitude, latitude, longitude): + average_latitude = ((origin_latitude + latitude) / 2) * CV.DEG_TO_RAD + x = (longitude - origin_longitude) * METERS_PER_DEG_LAT * math.cos(average_latitude) + y = (latitude - origin_latitude) * METERS_PER_DEG_LAT + return x, y + + def clear_live_speed_limits(self): + self.params_memory.remove("MapSpeedLimit") + self.params_memory.remove("NextMapSpeedLimit") + + def refresh_filtered_dataset(self, filtered_dataset=None): + if filtered_dataset is None: + filtered_dataset = self.params.get("SpeedLimitsFiltered") or [] + + live_match_entries = [entry for entry in filtered_dataset if self.has_live_match_fields(entry)] + if live_match_entries: + self.filtered_dataset = live_match_entries + return + + fallback_dataset = self.params.get("SpeedLimits") or [] + self.filtered_dataset = list(self.cleanup_dataset(fallback_dataset)) + def get_speed_limit_source(self): sources = [ (self.sm["starpilotPlan"].slcMapboxSpeedLimit, "Mapbox"), @@ -99,6 +136,15 @@ class MapSpeedLogger: return speed_limit, source return None + def get_live_match_candidates(self, road_name, current_bearing): + return [ + entry for entry in self.filtered_dataset + if self.has_live_match_fields(entry) + and entry["road_name"] == road_name + and entry["speed_limit"] > 0 + and self.bearing_delta(entry["bearing"], current_bearing) <= MAX_BEARING_DELTA + ] + def is_in_cached_box(self, latitude, longitude): if self.cached_box is None: return False @@ -123,6 +169,74 @@ class MapSpeedLogger: self.params.put("SpeedLimits", list(dataset)) self.params.put("SpeedLimitsFiltered", list(filtered_dataset)) + def find_current_speed_limit_entry(self, latitude, longitude, road_name, current_bearing): + best_match = None + best_score = None + + for entry in self.get_live_match_candidates(road_name, current_bearing): + start_latitude = entry["start_coordinates"]["latitude"] + start_longitude = entry["start_coordinates"]["longitude"] + end_latitude = entry["end_coordinates"]["latitude"] + end_longitude = entry["end_coordinates"]["longitude"] + + segment_x, segment_y = self.latlon_to_local_meters(start_latitude, start_longitude, end_latitude, end_longitude) + segment_length_sq = segment_x ** 2 + segment_y ** 2 + if segment_length_sq < 1: + continue + + point_x, point_y = self.latlon_to_local_meters(start_latitude, start_longitude, latitude, longitude) + projection_ratio = (point_x * segment_x + point_y * segment_y) / segment_length_sq + segment_length = math.sqrt(segment_length_sq) + along_track = projection_ratio * segment_length + + clamped_ratio = min(max(projection_ratio, 0.0), 1.0) + closest_x = segment_x * clamped_ratio + closest_y = segment_y * clamped_ratio + cross_track = math.hypot(point_x - closest_x, point_y - closest_y) + + longitudinal_buffer = max(entry["speed_limit"] * 2, ACTIVE_SEGMENT_BUFFER_METERS) + lateral_buffer = max(entry["road_width"] * 2, MIN_LATERAL_MATCH_BUFFER) + if -longitudinal_buffer <= along_track <= segment_length + longitudinal_buffer and cross_track <= lateral_buffer: + score = (cross_track, abs(projection_ratio - 0.5)) + if best_score is None or score < best_score: + best_match = entry + best_score = score + + return best_match + + def find_next_speed_limit_entry(self, latitude, longitude, road_name, current_bearing, current_entry=None): + best_match = None + best_score = None + + heading_rad = current_bearing * CV.DEG_TO_RAD + heading_x = math.sin(heading_rad) + heading_y = math.cos(heading_rad) + + current_segment_id = current_entry.get("segment_id") if current_entry else None + + for entry in self.get_live_match_candidates(road_name, current_bearing): + if current_segment_id is not None and entry.get("segment_id") == current_segment_id: + continue + + start_latitude = entry["start_coordinates"]["latitude"] + start_longitude = entry["start_coordinates"]["longitude"] + + distance_to_start = calculate_distance_to_point(latitude, longitude, start_latitude, start_longitude) + if distance_to_start < 1: + continue + + delta_x, delta_y = self.latlon_to_local_meters(latitude, longitude, start_latitude, start_longitude) + forward_distance = delta_x * heading_x + delta_y * heading_y + if forward_distance <= 0: + continue + + score = (distance_to_start, self.bearing_delta(entry["bearing"], current_bearing)) + if best_score is None or score < best_score: + best_match = entry + best_score = score + + return best_match, best_score[0] if best_score is not None else 0 + def wait_for_api(self): while not is_url_pingable(OVERPASS_STATUS_URL): print("Waiting for Overpass API to be available...") @@ -223,7 +337,7 @@ class MapSpeedLogger: current_speed_source = self.get_speed_limit_source() valid_sources = {source[0] for source in [current_speed_source] if source and source[0] > 0} - map_speed = self.params_memory.get("MapSpeedLimit") + map_speed = self.params_memory.get_float("MapSpeedLimit") is_incorrect_limit = bool(map_speed > 0 and valid_sources and all(abs(map_speed - source) > 1 for source in valid_sources)) if map_speed > 0 and not is_incorrect_limit: @@ -258,6 +372,41 @@ class MapSpeedLogger: self.previous_coordinates = {"latitude": current_latitude, "longitude": current_longitude} + def update_live_speed_limits(self): + gps_location = self.sm[self.gps_location_service] + current_latitude = gps_location.latitude + current_longitude = gps_location.longitude + current_bearing = gps_location.bearingDeg + road_name = self.sm["mapdOut"].roadName + + if (current_latitude == 0 and current_longitude == 0) or not road_name or not self.filtered_dataset: + self.clear_live_speed_limits() + return + + current_entry = self.find_current_speed_limit_entry(current_latitude, current_longitude, road_name, current_bearing) + next_entry, next_distance = self.find_next_speed_limit_entry( + current_latitude, + current_longitude, + road_name, + current_bearing, + current_entry=current_entry, + ) + + if current_entry: + self.params_memory.put_float("MapSpeedLimit", current_entry["speed_limit"]) + else: + self.params_memory.remove("MapSpeedLimit") + + if next_entry: + self.params_memory.put("NextMapSpeedLimit", { + "distance": next_distance, + "latitude": next_entry["start_coordinates"]["latitude"], + "longitude": next_entry["start_coordinates"]["longitude"], + "speedlimit": next_entry["speed_limit"], + }) + else: + self.params_memory.remove("NextMapSpeedLimit") + def process_new_entries(self, dataset, filtered_dataset): existing_segment_ids = {entry["segment_id"] for entry in filtered_dataset if "segment_id" in entry} entries_to_process = list(dataset) @@ -292,8 +441,12 @@ class MapSpeedLogger: continue filtered_dataset.append({ + "bearing": entry["bearing"], + "end_coordinates": entry["end_coordinates"], "incorrect_limit": entry.get("incorrect_limit"), "last_vetted": datetime.now(timezone.utc).isoformat(), + "road_name": entry["road_name"], + "road_width": entry["road_width"], "segment_id": segment_id, "source": entry["source"], "speed_limit": entry["speed_limit"], @@ -324,6 +477,7 @@ class MapSpeedLogger: self.process_new_entries(dataset, filtered_dataset) self.update_params(dataset, filtered_dataset) + self.refresh_filtered_dataset(filtered_dataset) self.params_memory.put("UpdateSpeedLimitsStatus", "Completed!") def update_cached_segments(self, latitude, longitude, vetting=False): @@ -387,6 +541,7 @@ def main(): if logger.sm["deviceState"].started: logger.log_speed_limit() + logger.update_live_speed_limits() previously_started = True elif previously_started: @@ -400,6 +555,7 @@ def main(): logger.params_memory.put_bool("UpdateSpeedLimits", True) logger.dataset_additions.clear() + logger.clear_live_speed_limits() previously_started = False elif logger.params_memory.get_bool("UpdateSpeedLimits"): @@ -407,6 +563,7 @@ def main(): logger.params_memory.remove("UpdateSpeedLimits") else: + logger.clear_live_speed_limits() time.sleep(5) if __name__ == "__main__": diff --git a/starpilot/system/the_pond/assets/components/recordings/dashcam_routes.js b/starpilot/system/the_pond/assets/components/recordings/dashcam_routes.js index 0eec5f34e..e0ccefd2e 100644 --- a/starpilot/system/the_pond/assets/components/recordings/dashcam_routes.js +++ b/starpilot/system/the_pond/assets/components/recordings/dashcam_routes.js @@ -26,6 +26,10 @@ let flushTimerId = null let seenRouteNames = new Set() function formatRouteDate(dateString) { + if (!dateString) { + return "Unknown Date" + } + const date = new Date(dateString) if (isNaN(date.getTime())) { return dateString diff --git a/starpilot/system/the_pond/assets/components/tools/device_settings.js b/starpilot/system/the_pond/assets/components/tools/device_settings.js index 0a2240594..c70ecc89a 100644 --- a/starpilot/system/the_pond/assets/components/tools/device_settings.js +++ b/starpilot/system/the_pond/assets/components/tools/device_settings.js @@ -200,8 +200,13 @@ function formatSliderValue(val, stepStr, precisionInt, key) { const v = parseFloat(val) if (Number.isNaN(v)) return val + if (key === "SwitchbackModeCooldown") { + if (v === 0) return "Off" + return v === 1 ? "1 sec" : `${v} sec` + } + const volumeKeys = [ - "DisengageVolume", "EngageVolume", "PromptVolume", + "BelowSteerSpeedVolume", "DisengageVolume", "EngageVolume", "PromptVolume", "PromptDistractedVolume", "RefuseVolume", "WarningImmediateVolume", "WarningSoftVolume", ] diff --git a/starpilot/system/the_pond/assets/components/tools/device_settings_layout.json b/starpilot/system/the_pond/assets/components/tools/device_settings_layout.json index 025cd0079..a11a5f96f 100644 --- a/starpilot/system/the_pond/assets/components/tools/device_settings_layout.json +++ b/starpilot/system/the_pond/assets/components/tools/device_settings_layout.json @@ -1527,6 +1527,28 @@ "ui_type": "toggle", "is_parent_toggle": true }, + { + "key": "SwitchbackModeCooldown", + "label": "Switchback Mode Cooldown", + "description": "Set the minimum time between repeated steering-limit and minimum-steer-speed alerts while \"Switchback Mode\" is active. Useful on winding roads where \"Turn Exceeds Steering Limit\" and \"Steer Unavailable Under\" can repeat frequently. Set to Off to disable the cooldown even when the mode is on.", + "data_type": "int", + "ui_type": "numeric", + "min": 0.0, + "max": 60.0, + "step": 1.0, + "parent_key": "AlertVolumeControl" + }, + { + "key": "BelowSteerSpeedVolume", + "label": "Min Steer Speed Alert Volume", + "description": "Set the volume for the \"Steer Unavailable Under\" alert shown below the car's minimum steering speed. Set to Muted to silence only this alert.", + "data_type": "int", + "ui_type": "numeric", + "min": 0.0, + "max": 101.0, + "step": 1.0, + "parent_key": "AlertVolumeControl" + }, { "key": "DisengageVolume", "label": "Disengage Volume", diff --git a/starpilot/system/the_pond/the_pond.py b/starpilot/system/the_pond/the_pond.py index 77d9d981d..54d3096f1 100644 --- a/starpilot/system/the_pond/the_pond.py +++ b/starpilot/system/the_pond/the_pond.py @@ -3348,7 +3348,7 @@ def setup(app): "name": name, "segment_urls": segment_urls, "total_duration": round(total_duration), - "date": utilities.get_route_start_time(footage_path), + "date": utilities.get_route_start_time(base_path), "available_cameras": utilities.get_available_cameras(base_path), }, 200 return {"error": "Route not found"}, 404 @@ -3382,8 +3382,7 @@ def setup(app): pass if cleared: - rlog_path = f"{segment_dir}/rlog" - route_timestamp_dt = utilities.get_route_start_time(rlog_path) + route_timestamp_dt = utilities.get_route_start_time(segment_dir) original_timestamp = route_timestamp_dt.isoformat() if route_timestamp_dt else None if cleared: diff --git a/starpilot/system/the_pond/utilities.py b/starpilot/system/the_pond/utilities.py index 10885e7c9..d3a1193fb 100644 --- a/starpilot/system/the_pond/utilities.py +++ b/starpilot/system/the_pond/utilities.py @@ -35,6 +35,17 @@ LOG_CANDIDATES = [ "raw_log.bz2", ] +ROUTE_TIME_LOG_CANDIDATES = [ + "rlog.zst", + "rlog.bz2", + "rlog", + "qlog.zst", + "qlog.bz2", + "qlog", + "raw_log.zst", + "raw_log.bz2", +] + SEGMENT_RE = re.compile(r"^[0-9a-fA-F]{8}--[0-9a-fA-F]{10}--\d+$") TARGET_LOUDNESS = -15.0 @@ -558,12 +569,44 @@ def get_repo_owner(git_normalized_origin): parts = git_normalized_origin.split("/") return parts[1] if len(parts) >= 2 else "unknown" -def get_route_start_time(log_file_path): - if not os.path.exists(log_file_path): +def get_route_log_path(path): + target = Path(path) + if target.is_dir(): + for candidate in ROUTE_TIME_LOG_CANDIDATES: + candidate_path = target / candidate + if candidate_path.exists(): + return candidate_path return None - creation_time = os.path.getctime(log_file_path) - return datetime.fromtimestamp(creation_time) + if target.exists(): + return target + + if target.parent.is_dir(): + for candidate in ROUTE_TIME_LOG_CANDIDATES: + candidate_path = target.parent / candidate + if candidate_path.exists(): + return candidate_path + + return None + + +def get_route_start_time(path): + log_path = get_route_log_path(path) + if log_path is None: + target = Path(path) + if not target.exists(): + return None + log_path = target + + try: + modified_time = log_path.stat().st_mtime + except OSError: + return None + + if modified_time <= 0: + return None + + return datetime.fromtimestamp(modified_time) def get_routes_names(footage_path): segments = get_all_segment_names(footage_path) @@ -608,7 +651,6 @@ def normalize_theme_name(name, for_path=False): def process_route(footage_path, route_name): segment_path = f"{footage_path}{route_name}--0" qcamera_path = f"{segment_path}/qcamera.ts" - rlog_path = f"{segment_path}/rlog" png_output_path = os.path.join(segment_path, "preview.png") if not os.path.exists(png_output_path): @@ -623,7 +665,7 @@ def process_route(footage_path, route_name): route_timestamp_str = custom_name if not custom_name: - route_timestamp_dt = get_route_start_time(rlog_path) + route_timestamp_dt = get_route_start_time(segment_path) route_timestamp_str = route_timestamp_dt.isoformat() if route_timestamp_dt else None return { diff --git a/starpilot/tinygrad_modeld/tinygrad_modeld.py b/starpilot/tinygrad_modeld/tinygrad_modeld.py index 6454a3e2f..5148b466a 100755 --- a/starpilot/tinygrad_modeld/tinygrad_modeld.py +++ b/starpilot/tinygrad_modeld/tinygrad_modeld.py @@ -397,13 +397,16 @@ class ModelState: else: self.off_policy_numpy_inputs[self.off_policy_prev_desired_curv_key][:] = self.full_prev_desired_curv[0, self.temporal_idxs] - combined_outputs_dict = {**vision_outputs_dict, **policy_outputs_dict} + combined_outputs_dict = {**vision_outputs_dict} if self.off_policy_enabled: self.off_policy_output = self.off_policy_run(**self.off_policy_inputs).contiguous().realize().uop.base.buffer.numpy() off_policy_outputs_dict = self.off_policy_parser.parse_policy_outputs( self.slice_outputs(self.off_policy_output, self.off_policy_output_slices) ) - combined_outputs_dict.update(off_policy_outputs_dict) + off_policy_outputs_dict.pop('plan', None) + combined_outputs_dict = {**combined_outputs_dict, **off_policy_outputs_dict, **policy_outputs_dict} + else: + combined_outputs_dict = {**combined_outputs_dict, **policy_outputs_dict} if SEND_RAW_PRED: raw_pred = [self.vision_output.copy(), self.policy_output.copy()] if self.off_policy_enabled and self.off_policy_output is not None: @@ -484,7 +487,6 @@ def main(demo=False): DH = DesireHelper() - # StarPilot variables starpilot_toggles = get_starpilot_toggles(sm) while True: @@ -600,7 +602,7 @@ def main(demo=False): pm.send('cameraOdometry', posenet_send) last_vipc_frame_id = meta_main.frame_id - # Update StarPilot parameters + # Update planner-driven parameters if sm.updated['starpilotPlan']: starpilot_toggles = get_starpilot_toggles(sm) diff --git a/starpilot/ui/qt/offroad/longitudinal_settings.cc b/starpilot/ui/qt/offroad/longitudinal_settings.cc index 41e94b1de..feb5534a0 100644 --- a/starpilot/ui/qt/offroad/longitudinal_settings.cc +++ b/starpilot/ui/qt/offroad/longitudinal_settings.cc @@ -494,22 +494,21 @@ StarPilotLongitudinalPanel::StarPilotLongitudinalPanel(StarPilotSettingsWindow * QString selection = MultiOptionDialog::getSelection(priorityPrompts[i - 1], availablePriorities, "", this); if (selection.isEmpty()) { + if (i == 2 && !selectedPriorities.isEmpty()) { + params.put("SLCPriority2", tr("None").toStdString()); + } break; } selectedPriorities.append(selection); params.put(QString("SLCPriority%1").arg(i).toStdString(), selection.toStdString()); - if (selection == tr("None")) { - for (int j = i + 1; j <= 3; ++j) { + if (selection == tr("None") || selection == tr("Lowest") || selection == tr("Highest")) { + for (int j = i + 1; j <= 2; ++j) { params.put(QString("SLCPriority%1").arg(j).toStdString(), tr("None").toStdString()); } break; } - - if (selection == tr("Lowest") || selection == tr("Highest")) { - break; - } } selectedPriorities.removeAll(tr("None")); @@ -795,8 +794,6 @@ StarPilotLongitudinalPanel::StarPilotLongitudinalPanel(StarPilotSettingsWindow * } void StarPilotLongitudinalPanel::showEvent(QShowEvent *event) { - StarPilotUIState &fs = *starpilotUIState(); - calibratedLateralAccelerationLabel->setText(QString::number(params.getFloat("CalibratedLateralAcceleration"), 'f', 2) + tr(" m/s²")); calibrationProgressLabel->setText(QString::number(params.getFloat("CalibrationProgress"), 'f', 2) + "%"); diff --git a/starpilot/ui/qt/offroad/maps_settings.cc b/starpilot/ui/qt/offroad/maps_settings.cc index b240d3227..24af3c8bb 100644 --- a/starpilot/ui/qt/offroad/maps_settings.cc +++ b/starpilot/ui/qt/offroad/maps_settings.cc @@ -1,7 +1,19 @@ +#include #include #include "starpilot/ui/qt/offroad/maps_settings.h" +namespace { +bool hasDownloadedMaps(const QDir &dir) { + if (!dir.exists()) { + return false; + } + + QDirIterator it(dir.absolutePath(), QDir::Files, QDirIterator::Subdirectories); + return it.hasNext(); +} +} // namespace + StarPilotMapsPanel::StarPilotMapsPanel(StarPilotSettingsWindow *parent, bool forceOpen) : StarPilotListWidget(parent), parent(parent) { forceOpenDescriptions = forceOpen; @@ -145,7 +157,7 @@ void StarPilotMapsPanel::showEvent(QShowEvent *event) { bool parked = !scene.started || starpilot_scene.parked || parent->isFrogsGoMoo; - removeMapsButton->setVisible(mapsFolderPath.exists()); + removeMapsButton->setVisible(hasDownloadedMaps(mapsFolderPath)); if (mapDownloadActive) { downloadMapsButton->setText(tr("CANCEL")); @@ -219,7 +231,7 @@ void StarPilotMapsPanel::cancelDownload() { downloadTimeElapsed->setVisible(false); lastMapsDownload->setVisible(true); - removeMapsButton->setVisible(mapsFolderPath.exists()); + removeMapsButton->setVisible(hasDownloadedMaps(mapsFolderPath)); update(); }); @@ -254,7 +266,7 @@ void StarPilotMapsPanel::updateDownloadLabels(int downloadedFiles, int totalFile downloadTimeElapsed->setVisible(false); lastMapsDownload->setVisible(true); - removeMapsButton->setVisible(true); + removeMapsButton->setVisible(hasDownloadedMaps(mapsFolderPath)); params.put("LastMapsUpdate", formatCurrentDate().toStdString()); diff --git a/starpilot/ui/qt/offroad/sounds_settings.cc b/starpilot/ui/qt/offroad/sounds_settings.cc index 017e2a143..08592f998 100644 --- a/starpilot/ui/qt/offroad/sounds_settings.cc +++ b/starpilot/ui/qt/offroad/sounds_settings.cc @@ -23,6 +23,8 @@ StarPilotSoundsPanel::StarPilotSoundsPanel(StarPilotSettingsWindow *parent, bool const std::vector> soundsToggles { {"AlertVolumeControl", tr("Alert Volume Controller"), tr("Set how loud each type of openpilot alert is to keep routine prompts from becoming distracting."), "../../starpilot/assets/toggle_icons/icon_mute.png"}, + {"SwitchbackModeCooldown", tr("Switchback Mode Cooldown"), tr("Set the minimum time between repeated steering-limit and minimum-steer-speed alerts while \"Switchback Mode\" is active.

Useful on winding roads where \"Turn Exceeds Steering Limit\" and \"Steer Unavailable Under\" can repeat frequently. Set to Off to disable the cooldown even when the mode is on."), ""}, + {"BelowSteerSpeedVolume", tr("Min Steer Speed Alert Volume"), tr("Set the volume for the \"Steer Unavailable Under\" alert shown below the car's minimum steering speed.

Set to Muted to silence only this alert."), ""}, {"DisengageVolume", tr("Disengage Volume"), tr("Set the volume for alerts when openpilot disengages.

Examples include: \"Cruise Fault: Restart the Car\", \"Parking Brake Engaged\", \"Pedal Pressed\"."), ""}, {"EngageVolume", tr("Engage Volume"), tr("Set the volume for the chime when openpilot engages, such as after pressing the \"RESUME\" or \"SET\" steering wheel buttons."), ""}, {"PromptVolume", tr("Prompt Volume"), tr("Set the volume for prompts that need attention.

Examples include: \"Car Detected in Blindspot\", \"Steering Temporarily Unavailable\", \"Turn Exceeds Steering Limit\"."), ""}, @@ -48,6 +50,12 @@ StarPilotSoundsPanel::StarPilotSoundsPanel(StarPilotSettingsWindow *parent, bool soundsLayout->setCurrentWidget(alertVolumeControlPanel); }); soundsToggle = alertVolumeControlToggle; + } else if (alertCooldownKeys.contains(param)) { + std::map cooldownLabels; + for (int i = 0; i <= 60; ++i) { + cooldownLabels[i] = i == 0 ? tr("Off") : i == 1 ? tr("1 second") : QString::number(i) + tr(" seconds"); + } + soundsToggle = new StarPilotParamValueControl(param, title, desc, icon, 0, 60, QString(), cooldownLabels, 1); } else if (alertVolumeControlKeys.contains(param)) { std::map volumeLabels; for (int i = 0; i <= 101; ++i) { @@ -73,7 +81,7 @@ StarPilotSoundsPanel::StarPilotSoundsPanel(StarPilotSettingsWindow *parent, bool toggles[param] = soundsToggle; - if (alertVolumeControlKeys.contains(param)) { + if (alertCooldownKeys.contains(param) || alertVolumeControlKeys.contains(param)) { alertVolumeControlList->addItem(soundsToggle); } else if (customAlertsKeys.contains(param)) { customAlertsList->addItem(soundsToggle); @@ -113,7 +121,7 @@ StarPilotSoundsPanel::StarPilotSoundsPanel(StarPilotSettingsWindow *parent, bool QObject::connect(uiState(), &UIState::uiUpdate, this, &StarPilotSoundsPanel::updateState); for (auto &[key, toggle] : toggles) { - if (alertVolumeControlKeys.contains(key)) { + if (alertCooldownKeys.contains(key) || alertVolumeControlKeys.contains(key)) { toggle->setVisible(true); } } @@ -191,7 +199,7 @@ void StarPilotSoundsPanel::updateToggles() { toggle->setVisible(setVisible); if (setVisible) { - if (alertVolumeControlKeys.contains(key)) { + if (alertCooldownKeys.contains(key) || alertVolumeControlKeys.contains(key)) { toggles["AlertVolumeControl"]->setVisible(true); } else if (customAlertsKeys.contains(key)) { toggles["CustomAlerts"]->setVisible(true); @@ -212,10 +220,11 @@ void StarPilotSoundsPanel::testSound(const QString &key) { util::sleep_for(UI_FREQ); - QString camelCaseAlert = QString(baseName).replace(0, 1, baseName[0].toLower()); + QString camelCaseAlert = baseName == "BelowSteerSpeed" ? "belowSteerSpeed" : QString(baseName).replace(0, 1, baseName[0].toLower()); params_memory.put("TestAlert", camelCaseAlert.toStdString()); } else { - QString snakeCaseAlert = QString(baseName).replace(QRegularExpression("([A-Z])"), "_\\1").toLower().mid(1); + QString previewBaseName = baseName == "BelowSteerSpeed" ? "Prompt" : baseName; + QString snakeCaseAlert = QString(previewBaseName).replace(QRegularExpression("([A-Z])"), "_\\1").toLower().mid(1); QString stockPath = "../../selfdrive/assets/sounds/" + snakeCaseAlert + ".wav"; QString themePath = "../../starpilot/assets/active_theme/sounds/" + snakeCaseAlert + ".wav"; diff --git a/starpilot/ui/qt/offroad/sounds_settings.h b/starpilot/ui/qt/offroad/sounds_settings.h index b95a2f5a4..7329263c6 100644 --- a/starpilot/ui/qt/offroad/sounds_settings.h +++ b/starpilot/ui/qt/offroad/sounds_settings.h @@ -25,7 +25,8 @@ private: std::map toggles; - QSet alertVolumeControlKeys {"DisengageVolume", "EngageVolume", "PromptDistractedVolume", "PromptVolume", "RefuseVolume", "WarningImmediateVolume", "WarningSoftVolume"}; + QSet alertCooldownKeys {"SwitchbackModeCooldown"}; + QSet alertVolumeControlKeys {"BelowSteerSpeedVolume", "DisengageVolume", "EngageVolume", "PromptDistractedVolume", "PromptVolume", "RefuseVolume", "WarningImmediateVolume", "WarningSoftVolume"}; QSet customAlertsKeys {"GoatScream", "GreenLightAlert", "LeadDepartingAlert", "LoudBlindspotAlert", "SpeedLimitChangedAlert"}; QSet parentKeys; diff --git a/starpilot/ui/qt/offroad/wheel_settings.cc b/starpilot/ui/qt/offroad/wheel_settings.cc index b42adab40..7d485dbf1 100644 --- a/starpilot/ui/qt/offroad/wheel_settings.cc +++ b/starpilot/ui/qt/offroad/wheel_settings.cc @@ -13,7 +13,8 @@ StarPilotWheelPanel::StarPilotWheelPanel(StarPilotSettingsWindow *parent, bool f for (const auto &[param, title, desc, icon] : wheelToggles) { QMap functionsMap { {0, tr("No Action")}, - {3, tr("Pause Steering")} + {3, tr("Pause Steering")}, + {7, tr("Toggle \"Switchback Mode\" On/Off")} }; QMap longitudinalFunctionsMap { diff --git a/starpilot/ui/qt/onroad/starpilot_annotated_camera.cc b/starpilot/ui/qt/onroad/starpilot_annotated_camera.cc index 5870ff2f9..1048a0027 100644 --- a/starpilot/ui/qt/onroad/starpilot_annotated_camera.cc +++ b/starpilot/ui/qt/onroad/starpilot_annotated_camera.cc @@ -744,6 +744,8 @@ void StarPilotAnnotatedCameraWidget::paintPathEdges(QPainter &p, int height) { setPathEdgeColors(bg_colors[STATUS_CEM_DISABLED]); } else if (experimentalMode) { setPathEdgeColors(bg_colors[STATUS_EXPERIMENTAL_MODE_ENABLED]); + } else if (starpilot_scene.switchback_mode_enabled) { + setPathEdgeColors(bg_colors[STATUS_SWITCHBACK_MODE_ENABLED]); } else if (starpilot_scene.traffic_mode_enabled) { setPathEdgeColors(bg_colors[STATUS_TRAFFIC_MODE_ENABLED]); } else if (starpilot_toggles.value("color_scheme").toString() != "stock") { diff --git a/starpilot/ui/starpilot_ui.cc b/starpilot/ui/starpilot_ui.cc index 65a2218a2..bda411a0e 100644 --- a/starpilot/ui/starpilot_ui.cc +++ b/starpilot/ui/starpilot_ui.cc @@ -23,6 +23,8 @@ static void update_state(StarPilotUIState *fs) { starpilot_scene.online = deviceState.getNetworkType() != cereal::DeviceState::NetworkType::NONE; } } + starpilot_scene.switchback_mode_enabled = fs->params_memory.getBool("SwitchbackModeEnabled"); + if (fpsm.updated("starpilotCarState")) { const cereal::StarPilotCarState::Reader &starpilotCarState = fpsm["starpilotCarState"].getStarpilotCarState(); starpilot_scene.always_on_lateral_active = !starpilot_scene.enabled && starpilotCarState.getAlwaysOnLateralEnabled(); diff --git a/starpilot/ui/starpilot_ui.h b/starpilot/ui/starpilot_ui.h index 844612405..e31626055 100644 --- a/starpilot/ui/starpilot_ui.h +++ b/starpilot/ui/starpilot_ui.h @@ -15,6 +15,7 @@ struct StarPilotUIScene { bool reverse; bool sidebars_open; bool standstill; + bool switchback_mode_enabled; bool traffic_mode_enabled; bool wake_up_screen; diff --git a/system/camerad/camerad b/system/camerad/camerad index 04da8fde3..a76b26ff2 100755 Binary files a/system/camerad/camerad and b/system/camerad/camerad differ diff --git a/system/loggerd/bootlog b/system/loggerd/bootlog index 430710a9f..05f83baf4 100755 Binary files a/system/loggerd/bootlog and b/system/loggerd/bootlog differ diff --git a/system/loggerd/encoderd b/system/loggerd/encoderd index 38f0654a0..23488e20a 100755 Binary files a/system/loggerd/encoderd and b/system/loggerd/encoderd differ diff --git a/system/loggerd/loggerd b/system/loggerd/loggerd index f84b98d55..ed3fa1b4c 100755 Binary files a/system/loggerd/loggerd and b/system/loggerd/loggerd differ diff --git a/system/manager/build.py b/system/manager/build.py index e4fbcd700..f98a3d6b5 100755 --- a/system/manager/build.py +++ b/system/manager/build.py @@ -17,6 +17,30 @@ CACHE_DIR = Path("/data/scons_cache" if AGNOS else "/tmp/scons_cache") TOTAL_SCONS_NODES = 2705 MAX_BUILD_PROGRESS = 100 +def get_mem_available_kb() -> int | None: + try: + with open("/proc/meminfo") as f: + for line in f: + if line.startswith("MemAvailable:"): + return int(line.split()[1]) + except Exception: + pass + return None + +def choose_agnos_build_attempts(nproc: int) -> list[int]: + override = os.getenv("SP_BUILD_JOBS", "").strip() + if override: + attempts = [max(1, int(override))] + else: + attempts_env = os.getenv("SP_BUILD_ATTEMPTS", "").strip() + if attempts_env: + attempts = [max(1, int(part.strip())) for part in attempts_env.split(",") if part.strip()] + else: + max_jobs = max(1, int(os.getenv("SP_BUILD_MAX_JOBS", "7"))) + attempts = list(range(max_jobs, 0, -1)) + + return list(dict.fromkeys(max(1, min(nproc, n)) for n in attempts)) + def build(spinner: Spinner, dirty: bool = False, minimal: bool = False) -> None: env = os.environ.copy() env['SCONS_PROGRESS'] = "1" @@ -29,8 +53,10 @@ def build(spinner: Spinner, dirty: bool = False, minimal: bool = False) -> None: if AGNOS: HARDWARE.set_power_save(False) os.sched_setaffinity(0, range(8)) # ensure we can use the isolcpus cores - # Extremely conservative on-device compile to avoid lowmemorykiller SIGKILLs. - attempts = [1] + attempts = choose_agnos_build_attempts(nproc) + mem_available_kb = get_mem_available_kb() + attempts_s = ", ".join(f"-j{n}" for n in attempts) + print(f"AGNOS build: attempts {attempts_s} (MemAvailable={mem_available_kb} kB)") else: attempts = [nproc, max(1, nproc // 2), 1] @@ -74,10 +100,22 @@ def build(spinner: Spinner, dirty: bool = False, minimal: bool = False) -> None: last_returncode = run_scons(n, ["--cache-populate"]) if last_returncode == 0: break + if AGNOS: + output_blob = b"\n".join(compile_output) + current_idx = attempts.index(n) + if current_idx + 1 < len(attempts): + next_n = attempts[current_idx + 1] + if b"Error -9" in output_blob: + cloudlog.warning(f"scons likely OOM-killed (Error -9), retrying with -j{next_n} after -j{n}") + print(f"Build retry: detected Error -9 with -j{n}, retrying with -j{next_n}") + else: + cloudlog.warning(f"scons failed with -j{n}, retrying with -j{next_n}") + print(f"Build retry: -j{n} failed, retrying with -j{next_n}") + continue + break if last_returncode != 0: # OOM-ish builds often fail with "Error -9" when clang gets SIGKILL. - # Do one final conservative retry before surfacing a hard failure. output_blob = b"\n".join(compile_output) if AGNOS and b"Error -9" in output_blob: cloudlog.warning("scons likely OOM-killed (Error -9), retrying with -j1 --cache-disable") diff --git a/uncompiledmodels/driving_off_policy.onnx b/uncompiledmodels/driving_off_policy.onnx new file mode 100644 index 000000000..b221dcbe8 Binary files /dev/null and b/uncompiledmodels/driving_off_policy.onnx differ diff --git a/uncompiledmodels/driving_policy.onnx b/uncompiledmodels/driving_policy.onnx index 706c95db9..a1eaf73f2 100644 Binary files a/uncompiledmodels/driving_policy.onnx and b/uncompiledmodels/driving_policy.onnx differ diff --git a/uncompiledmodels/driving_vision.onnx b/uncompiledmodels/driving_vision.onnx index 902f1dd34..484af70f8 100644 Binary files a/uncompiledmodels/driving_vision.onnx and b/uncompiledmodels/driving_vision.onnx differ