mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-09-30 08:23:41 +08:00
Parse more flags from alt exp, more tests, hyundai main cruise allowed
This commit is contained in:
+2
-1
@@ -203,9 +203,10 @@ std::unordered_map<std::string, uint32_t> keys = {
|
||||
|
||||
// sunnypilot params
|
||||
{"Mads", PERSISTENT},
|
||||
{"MadsCruiseMain", PERSISTENT},
|
||||
{"MadsMainCruiseAllowed", PERSISTENT},
|
||||
{"MadsDisengageLateralOnBrake", PERSISTENT},
|
||||
{"MadsUnifiedEngagementMode", PERSISTENT},
|
||||
{"HyundaiLongitudinalMainCruiseToggleable", PERSISTENT},
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -119,6 +119,7 @@ class Car:
|
||||
data_services = list(self.sm.data.keys()) + ['selfdriveStateSP']
|
||||
self.sm = messaging.SubMaster(data_services, poll='selfdriveStateSP')
|
||||
MadsParams().set_alternative_experience(self.CP)
|
||||
MadsParams().set_car_specific_params(self.CP)
|
||||
|
||||
openpilot_enabled_toggle = self.params.get_bool("OpenpilotEnabledToggle")
|
||||
|
||||
|
||||
@@ -29,8 +29,8 @@ DeveloperPanel::DeveloperPanel(SettingsWindow *parent) : ListWidget(parent) {
|
||||
addItem(madsToggle);
|
||||
|
||||
// TODO-SP: Rename toggle
|
||||
auto madsCruiseMainToggle = new ParamControl("MadsCruiseMain", tr("MADS: Cruise Main"), "", "");
|
||||
addItem(madsCruiseMainToggle);
|
||||
auto madsMainCruiseToggle = new ParamControl("MadsMainCruiseAllowed", tr("MADS: Toggle with Main Cruise"), "", "");
|
||||
addItem(madsMainCruiseToggle);
|
||||
|
||||
auto madsDisengageLateralOnBrakeToggle = new ParamControl("MadsDisengageLateralOnBrake", tr("MADS: Disengage Lateral on Brake"), "", "");
|
||||
addItem(madsDisengageLateralOnBrakeToggle);
|
||||
|
||||
@@ -123,10 +123,6 @@
|
||||
<source>Longitudinal Maneuver Mode</source>
|
||||
<translation>وضع المناورة الطولية</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MADS: Cruise Main</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MADS: Disengage Lateral on Brake</source>
|
||||
<translation type="unfinished"></translation>
|
||||
@@ -139,6 +135,10 @@
|
||||
<source>MADS: Unified Engagement Mode</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MADS: Toggle with Main Cruise</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>DevicePanel</name>
|
||||
|
||||
@@ -123,10 +123,6 @@
|
||||
<source>Longitudinal Maneuver Mode</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MADS: Cruise Main</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MADS: Disengage Lateral on Brake</source>
|
||||
<translation type="unfinished"></translation>
|
||||
@@ -139,6 +135,10 @@
|
||||
<source>MADS: Unified Engagement Mode</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MADS: Toggle with Main Cruise</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>DevicePanel</name>
|
||||
|
||||
@@ -123,10 +123,6 @@
|
||||
<source>Longitudinal Maneuver Mode</source>
|
||||
<translation>Modo de maniobra longitudinal</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MADS: Cruise Main</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MADS: Disengage Lateral on Brake</source>
|
||||
<translation type="unfinished"></translation>
|
||||
@@ -139,6 +135,10 @@
|
||||
<source>MADS: Unified Engagement Mode</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MADS: Toggle with Main Cruise</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>DevicePanel</name>
|
||||
|
||||
@@ -123,10 +123,6 @@
|
||||
<source>Longitudinal Maneuver Mode</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MADS: Cruise Main</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MADS: Disengage Lateral on Brake</source>
|
||||
<translation type="unfinished"></translation>
|
||||
@@ -139,6 +135,10 @@
|
||||
<source>MADS: Unified Engagement Mode</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MADS: Toggle with Main Cruise</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>DevicePanel</name>
|
||||
|
||||
@@ -123,10 +123,6 @@
|
||||
<source>Longitudinal Maneuver Mode</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MADS: Cruise Main</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MADS: Disengage Lateral on Brake</source>
|
||||
<translation type="unfinished"></translation>
|
||||
@@ -139,6 +135,10 @@
|
||||
<source>MADS: Unified Engagement Mode</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MADS: Toggle with Main Cruise</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>DevicePanel</name>
|
||||
|
||||
@@ -123,10 +123,6 @@
|
||||
<source>Longitudinal Maneuver Mode</source>
|
||||
<translation>롱컨 기동 모드</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MADS: Cruise Main</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MADS: Disengage Lateral on Brake</source>
|
||||
<translation type="unfinished"></translation>
|
||||
@@ -139,6 +135,10 @@
|
||||
<source>MADS: Unified Engagement Mode</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MADS: Toggle with Main Cruise</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>DevicePanel</name>
|
||||
|
||||
@@ -123,10 +123,6 @@
|
||||
<source>Longitudinal Maneuver Mode</source>
|
||||
<translation>Modo Longitudinal Maneuver</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MADS: Cruise Main</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MADS: Disengage Lateral on Brake</source>
|
||||
<translation type="unfinished"></translation>
|
||||
@@ -139,6 +135,10 @@
|
||||
<source>MADS: Unified Engagement Mode</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MADS: Toggle with Main Cruise</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>DevicePanel</name>
|
||||
|
||||
@@ -123,10 +123,6 @@
|
||||
<source>Longitudinal Maneuver Mode</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MADS: Cruise Main</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MADS: Disengage Lateral on Brake</source>
|
||||
<translation type="unfinished"></translation>
|
||||
@@ -139,6 +135,10 @@
|
||||
<source>MADS: Unified Engagement Mode</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MADS: Toggle with Main Cruise</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>DevicePanel</name>
|
||||
|
||||
@@ -123,10 +123,6 @@
|
||||
<source>Longitudinal Maneuver Mode</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MADS: Cruise Main</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MADS: Disengage Lateral on Brake</source>
|
||||
<translation type="unfinished"></translation>
|
||||
@@ -139,6 +135,10 @@
|
||||
<source>MADS: Unified Engagement Mode</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MADS: Toggle with Main Cruise</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>DevicePanel</name>
|
||||
|
||||
@@ -123,10 +123,6 @@
|
||||
<source>Longitudinal Maneuver Mode</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MADS: Cruise Main</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MADS: Disengage Lateral on Brake</source>
|
||||
<translation type="unfinished"></translation>
|
||||
@@ -139,6 +135,10 @@
|
||||
<source>MADS: Unified Engagement Mode</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MADS: Toggle with Main Cruise</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>DevicePanel</name>
|
||||
|
||||
@@ -123,10 +123,6 @@
|
||||
<source>Longitudinal Maneuver Mode</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MADS: Cruise Main</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MADS: Disengage Lateral on Brake</source>
|
||||
<translation type="unfinished"></translation>
|
||||
@@ -139,6 +135,10 @@
|
||||
<source>MADS: Unified Engagement Mode</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MADS: Toggle with Main Cruise</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>DevicePanel</name>
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
from panda import ALTERNATIVE_EXPERIENCE
|
||||
from panda import Panda, ALTERNATIVE_EXPERIENCE
|
||||
|
||||
from openpilot.common.params import Params
|
||||
|
||||
from opendbc.car.hyundai.values import HyundaiFlags
|
||||
from opendbc.sunnypilot.car.hyundai.values import HyundaiFlagsSP
|
||||
|
||||
|
||||
class MadsParams:
|
||||
def __init__(self):
|
||||
self.params = Params()
|
||||
self.allow_always = False
|
||||
|
||||
def read_param(self, key: str):
|
||||
return self.params.get_bool(key)
|
||||
@@ -13,9 +17,29 @@ class MadsParams:
|
||||
def set_alternative_experience(self, CP):
|
||||
enabled = self.read_param("Mads")
|
||||
disengage_lateral_on_brake = self.read_param("MadsDisengageLateralOnBrake")
|
||||
main_cruise = self.read_param("MadsMainCruiseAllowed")
|
||||
unified_engagement_mode = self.read_param("MadsUnifiedEngagementMode")
|
||||
|
||||
if enabled:
|
||||
CP.alternativeExperience |= ALTERNATIVE_EXPERIENCE.ENABLE_MADS
|
||||
|
||||
if not disengage_lateral_on_brake:
|
||||
CP.alternativeExperience |= ALTERNATIVE_EXPERIENCE.DISABLE_DISENGAGE_LATERAL_ON_BRAKE
|
||||
|
||||
if main_cruise:
|
||||
CP.alternativeExperience |= ALTERNATIVE_EXPERIENCE.MAIN_CRUISE_ALLOWED
|
||||
|
||||
if unified_engagement_mode:
|
||||
CP.alternativeExperience |= ALTERNATIVE_EXPERIENCE.UNIFIED_ENGAGEMENT_MODE
|
||||
|
||||
def set_car_specific_params(self, CP):
|
||||
if CP.carName == "hyundai":
|
||||
if (CP.sunnypilotFlags & HyundaiFlagsSP.HAS_LFA_BUTTON) or (CP.flags & HyundaiFlags.CANFD):
|
||||
self.allow_always = True
|
||||
CP.safetyConfig[-1].safetyParam |= Panda.FLAG_HYUNDAI_MADS_BUTTON_ALLOWED
|
||||
|
||||
# TODO-SP: This should be separated from MADS module for future implementations
|
||||
hyundai_cruise_main_toggleable = self.read_param("HyundaiLongitudinalMainCruiseToggleable")
|
||||
if hyundai_cruise_main_toggleable:
|
||||
CP.sunnypilotFlags |= HyundaiFlagsSP.LONGITUDINAL_MAIN_CRUISE_TOGGLEABLE.value
|
||||
CP.safetyConfigs[-1].safetyParam |= Panda.FLAG_HYUNDAI_LONG_MAIN_CRUISE_TOGGLEABLE
|
||||
|
||||
@@ -30,7 +30,7 @@ class ModularAssistiveDrivingSystem:
|
||||
self.allow_always = True
|
||||
|
||||
self.enabled_toggle = mads_params.read_param("Mads")
|
||||
self.main_enabled_toggle = mads_params.read_param("MadsCruiseMain")
|
||||
self.main_enabled_toggle = mads_params.read_param("MadsMainCruiseAllowed")
|
||||
self.disengage_lateral_on_brake_toggle = mads_params.read_param("MadsDisengageLateralOnBrake")
|
||||
self.unified_engagement_mode = mads_params.read_param("MadsUnifiedEngagementMode")
|
||||
|
||||
|
||||
@@ -44,9 +44,10 @@ def manager_init() -> None:
|
||||
|
||||
sunnypilot_default_params: list[tuple[str, str | bytes]] = [
|
||||
("Mads", "1"),
|
||||
("MadsCruiseMain", "1"),
|
||||
("MadsMainCruiseAllowed", "1"),
|
||||
("MadsDisengageLateralOnBrake", "0"),
|
||||
("MadsUnifiedEngagementMode", "1"),
|
||||
("HyundaiLongitudinalMainCruiseToggleable", "1"),
|
||||
]
|
||||
|
||||
if params.get_bool("RecordFrontLock"):
|
||||
|
||||
Reference in New Issue
Block a user