Conditional Chill

This commit is contained in:
firestar5683
2026-06-06 21:25:18 -05:00
parent a888c5602a
commit f8934840da
26 changed files with 1152 additions and 1387 deletions
@@ -16,6 +16,7 @@ StarPilotLongitudinalPanel::StarPilotLongitudinalPanel(StarPilotSettingsWindow *
StarPilotListWidget *advancedLongitudinalTuneList = new StarPilotListWidget(this);
StarPilotListWidget *aggressivePersonalityList = new StarPilotListWidget(this);
StarPilotListWidget *conditionalChillList = new StarPilotListWidget(this);
StarPilotListWidget *conditionalExperimentalList = new StarPilotListWidget(this);
StarPilotListWidget *curveSpeedList = new StarPilotListWidget(this);
StarPilotListWidget *customDrivingPersonalityList = new StarPilotListWidget(this);
@@ -36,6 +37,7 @@ StarPilotLongitudinalPanel::StarPilotLongitudinalPanel(StarPilotSettingsWindow *
ScrollView *advancedLongitudinalTunePanel = new ScrollView(advancedLongitudinalTuneList, this);
ScrollView *aggressivePersonalityPanel = new ScrollView(aggressivePersonalityList, this);
ScrollView *conditionalChillPanel = new ScrollView(conditionalChillList, this);
ScrollView *conditionalExperimentalPanel = new ScrollView(conditionalExperimentalList, this);
ScrollView *curveSpeedPanel = new ScrollView(curveSpeedList, this);
ScrollView *customDrivingPersonalityPanel = new ScrollView(customDrivingPersonalityList, this);
@@ -56,6 +58,7 @@ StarPilotLongitudinalPanel::StarPilotLongitudinalPanel(StarPilotSettingsWindow *
longitudinalLayout->addWidget(advancedLongitudinalTunePanel);
longitudinalLayout->addWidget(aggressivePersonalityPanel);
longitudinalLayout->addWidget(conditionalChillPanel);
longitudinalLayout->addWidget(conditionalExperimentalPanel);
longitudinalLayout->addWidget(curveSpeedPanel);
longitudinalLayout->addWidget(customDrivingPersonalityPanel);
@@ -95,6 +98,12 @@ StarPilotLongitudinalPanel::StarPilotLongitudinalPanel(StarPilotSettingsWindow *
{"CEModelStopTime", tr("Predicted Stop In"), tr("<b>Switch to \"Experimental Mode\" when openpilot predicts a stop within the set time.</b> This is usually triggered when the model \"sees\" a red light or stop sign ahead.<br><br><i><b>Disclaimer</b>: openpilot does not explicitly detect traffic lights or stop signs. In \"Experimental Mode\", openpilot makes end-to-end driving decisions from camera input, which means it may stop even when there's no clear reason!</i>"), ""},
{"CESignalSpeed", tr("Turn Signal Below"), tr("<b>Switch to \"Experimental Mode\" when using a turn signal below the set speed</b> to allow the model to choose an appropriate speed for smoother left and right turns."), ""},
{"ShowCEMStatus", tr("Status Widget"), tr("<b>Show which condition triggered \"Experimental Mode\"</b> on the driving screen."), ""},
{"ConditionalChill", tr("Conditional Chill Mode"), tr("<b>Keep \"Experimental Mode\" on by default, but temporarily switch to \"Chill Mode\" in simple cruising scenes where speed holding is usually better.</b>"), "../../starpilot/assets/toggle_icons/icon_conditional.png"},
{"PersistChillState", tr("Persist Chill State"), tr("<b>Keep your manual Conditional Chill override through reboots</b> until you manually clear it."), ""},
{"CCMSpeed", tr("Above"), tr("<b>Switch to \"Chill Mode\" on open roads above this speed when no lead is detected and the car is still below the set speed.</b>"), ""},
{"CCMLead", tr("Stable Lead Ahead"), tr("<b>Switch to \"Chill Mode\" when following a steady, well-tracked lead vehicle at cruising speeds.</b>"), ""},
{"CCMSetSpeedMargin", tr("Set Speed Margin"), tr("<b>How far below the set speed the car must be before open-road Conditional Chill can engage.</b>"), ""},
{"ShowCCMStatus", tr("Status Widget"), tr("<b>Show which condition triggered \"Chill Mode\"</b> on the driving screen."), ""},
{"CurveSpeedController", tr("Curve Speed Controller"), tr("<b>Automatically slow down for upcoming curves</b> using data learned from your driving style, adapting to curves as you would."), "../../starpilot/assets/toggle_icons/icon_speed_map.png"},
{"CalibratedLateralAcceleration", tr("Calibrated Lateral Acceleration"), tr("<b>The learned lateral acceleration from collected driving data.</b> This sets how fast openpilot will take curves. Higher values allow faster cornering; lower values slow the vehicle for gentler turns."), ""},
@@ -253,11 +262,22 @@ StarPilotLongitudinalPanel::StarPilotLongitudinalPanel(StarPilotSettingsWindow *
longitudinalLayout->setCurrentWidget(conditionalExperimentalPanel);
});
longitudinalToggle = conditionalExperimentalToggle;
} else if (param == "ConditionalChill") {
StarPilotManageControl *conditionalChillToggle = new StarPilotManageControl(param, title, desc, icon);
QObject::connect(conditionalChillToggle, &StarPilotManageControl::manageButtonClicked, [longitudinalLayout, conditionalChillPanel]() {
longitudinalLayout->setCurrentWidget(conditionalChillPanel);
});
longitudinalToggle = conditionalChillToggle;
} else if (param == "CESpeed") {
StarPilotParamValueControl *CESpeed = new StarPilotParamValueControl(param, title, desc, icon, 0, 99, tr(" mph"), std::map<float, QString>(), 1, true, 175);
StarPilotParamValueControl *CESpeedLead = new StarPilotParamValueControl("CESpeedLead", tr("With Lead"), tr("<b>Switch to \"Experimental Mode\" when driving below this speed with a lead</b> to help openpilot handle low-speed situations more smoothly."), icon, 0, 99, tr(" mph"), std::map<float, QString>(), 1, true, 175);
StarPilotDualParamValueControl *conditionalSpeeds = new StarPilotDualParamValueControl(CESpeed, CESpeedLead);
longitudinalToggle = reinterpret_cast<AbstractControl*>(conditionalSpeeds);
} else if (param == "CCMSpeed") {
StarPilotParamValueControl *CCMSpeed = new StarPilotParamValueControl(param, title, desc, icon, 0, 99, tr(" mph"), std::map<float, QString>(), 1, true, 175);
StarPilotParamValueControl *CCMSpeedLead = new StarPilotParamValueControl("CCMSpeedLead", tr("With Lead"), tr("<b>Switch to \"Chill Mode\" when a stable lead is being followed above this speed.</b>"), icon, 0, 99, tr(" mph"), std::map<float, QString>(), 1, true, 175);
StarPilotDualParamValueControl *conditionalSpeeds = new StarPilotDualParamValueControl(CCMSpeed, CCMSpeedLead);
longitudinalToggle = reinterpret_cast<AbstractControl*>(conditionalSpeeds);
} else if (param == "CECurves") {
std::vector<QString> curveToggles{"CECurvesLead"};
std::vector<QString> curveToggleNames{tr("With Lead")};
@@ -266,6 +286,8 @@ StarPilotLongitudinalPanel::StarPilotLongitudinalPanel(StarPilotSettingsWindow *
std::vector<QString> leadToggles{"CESlowerLead", "CEStoppedLead"};
std::vector<QString> leadToggleNames{tr("Slower Lead"), tr("Stopped Lead")};
longitudinalToggle = new StarPilotButtonToggleControl(param, title, desc, icon, leadToggles, leadToggleNames);
} else if (param == "CCMSetSpeedMargin") {
longitudinalToggle = new StarPilotParamValueControl(param, title, desc, icon, 0, 15, tr(" mph"), std::map<float, QString>(), 1, true, 175);
} else if (param == "CEModelStopTime") {
std::map<float, QString> stopTimeLabels;
for (int i = 0; i <= 10; ++i) {
@@ -586,6 +608,8 @@ StarPilotLongitudinalPanel::StarPilotLongitudinalPanel(StarPilotSettingsWindow *
advancedLongitudinalTuneList->addItem(longitudinalToggle);
} else if (aggressivePersonalityKeys.contains(param)) {
aggressivePersonalityList->addItem(longitudinalToggle);
} else if (conditionalChillKeys.contains(param)) {
conditionalChillList->addItem(longitudinalToggle);
} else if (conditionalExperimentalKeys.contains(param)) {
conditionalExperimentalList->addItem(longitudinalToggle);
} else if (curveSpeedKeys.contains(param)) {
@@ -658,6 +682,20 @@ StarPilotLongitudinalPanel::StarPilotLongitudinalPanel(StarPilotSettingsWindow *
}
updateToggles();
});
QObject::connect(static_cast<ToggleControl*>(toggles["ConditionalExperimental"]), &ToggleControl::toggleFlipped, this, [this]() {
if (params.getBool("ConditionalExperimental")) {
params.putBool("ConditionalChill", false);
static_cast<ParamControl*>(toggles["ConditionalChill"])->refresh();
}
updateToggles();
});
QObject::connect(static_cast<ToggleControl*>(toggles["ConditionalChill"]), &ToggleControl::toggleFlipped, this, [this]() {
if (params.getBool("ConditionalChill")) {
params.putBool("ConditionalExperimental", false);
static_cast<ParamControl*>(toggles["ConditionalExperimental"])->refresh();
}
updateToggles();
});
StarPilotParamValueControl *trafficFollowToggle = static_cast<StarPilotParamValueControl*>(toggles["TrafficFollow"]);
StarPilotParamValueControl *trafficAccelerationToggle = static_cast<StarPilotParamValueControl*>(toggles["TrafficJerkAcceleration"]);
@@ -831,6 +869,9 @@ void StarPilotLongitudinalPanel::updateMetric(bool metric, bool bootRun) {
params.putIntNonBlocking("IncreasedStoppedDistanceRainStorm", params.getInt("IncreasedStoppedDistanceRainStorm") * distanceConversion);
params.putIntNonBlocking("IncreasedStoppedDistanceSnow", params.getInt("IncreasedStoppedDistanceSnow") * distanceConversion);
params.putIntNonBlocking("CCMSpeed", params.getInt("CCMSpeed") * speedConversion);
params.putIntNonBlocking("CCMSpeedLead", params.getInt("CCMSpeedLead") * speedConversion);
params.putIntNonBlocking("CCMSetSpeedMargin", params.getInt("CCMSetSpeedMargin") * speedConversion);
params.putIntNonBlocking("CESignalSpeed", params.getInt("CESignalSpeed") * speedConversion);
params.putIntNonBlocking("CESpeed", params.getInt("CESpeed") * speedConversion);
params.putIntNonBlocking("CESpeedLead", params.getInt("CESpeedLead") * speedConversion);
@@ -881,7 +922,9 @@ void StarPilotLongitudinalPanel::updateMetric(bool metric, bool bootRun) {
labelsInitialized = true;
}
StarPilotDualParamValueControl *ccmSpeedToggle = reinterpret_cast<StarPilotDualParamValueControl*>(toggles["CCMSpeed"]);
StarPilotDualParamValueControl *ceSpeedToggle = reinterpret_cast<StarPilotDualParamValueControl*>(toggles["CESpeed"]);
StarPilotParamValueControl *ccmSetSpeedMarginToggle = static_cast<StarPilotParamValueControl*>(toggles["CCMSetSpeedMargin"]);
StarPilotParamValueButtonControl *ceSignal = static_cast<StarPilotParamValueButtonControl*>(toggles["CESignalSpeed"]);
StarPilotParamValueControl *customCruiseToggle = static_cast<StarPilotParamValueControl*>(toggles["CustomCruise"]);
StarPilotParamValueControl *customCruiseLongToggle = static_cast<StarPilotParamValueControl*>(toggles["CustomCruiseLong"]);
@@ -922,6 +965,8 @@ void StarPilotLongitudinalPanel::updateMetric(bool metric, bool bootRun) {
increasedStoppedDistanceRainStormToggle->updateControl(0, 3, metricDistanceLabels);
increasedStoppedDistanceSnowToggle->updateControl(0, 3, metricDistanceLabels);
ccmSpeedToggle->updateControl(0, 150, metricSpeedLabels);
ccmSetSpeedMarginToggle->updateControl(0, 25, metricSpeedLabels);
ceSignal->updateControl(0, 150, metricSpeedLabels);
ceSpeedToggle->updateControl(0, 150, metricSpeedLabels);
customCruiseToggle->updateControl(1, 150, metricSpeedLabels);
@@ -957,6 +1002,8 @@ void StarPilotLongitudinalPanel::updateMetric(bool metric, bool bootRun) {
increasedStoppedDistanceRainStormToggle->updateControl(0, 10, imperialDistanceLabels);
increasedStoppedDistanceSnowToggle->updateControl(0, 10, imperialDistanceLabels);
ccmSpeedToggle->updateControl(0, 99, imperialSpeedLabels);
ccmSetSpeedMarginToggle->updateControl(0, 15, imperialSpeedLabels);
ceSignal->updateControl(0, 99, imperialSpeedLabels);
ceSpeedToggle->updateControl(0, 99, imperialSpeedLabels);
customCruiseToggle->updateControl(1, 99, imperialSpeedLabels);
@@ -1041,6 +1088,8 @@ void StarPilotLongitudinalPanel::updateToggles() {
toggles["AdvancedLongitudinalTune"]->setVisible(true);
} else if (aggressivePersonalityKeys.contains(key)) {
toggles["AggressivePersonalityProfile"]->setVisible(true);
} else if (conditionalChillKeys.contains(key)) {
toggles["ConditionalChill"]->setVisible(true);
} else if (conditionalExperimentalKeys.contains(key)) {
toggles["ConditionalExperimental"]->setVisible(true);
} else if (curveSpeedKeys.contains(key)) {
@@ -30,6 +30,7 @@ private:
QSet<QString> advancedLongitudinalTuneKeys = {"EVTuning", "TruckTuning", "LongitudinalActuatorDelay", "MaxDesiredAcceleration", "StartAccel", "StopAccel", "StoppingDecelRate", "VEgoStarting", "VEgoStopping"};
QSet<QString> aggressivePersonalityKeys = {"AggressiveFollow", "AggressiveFollowHigh", "AggressiveJerkAcceleration", "AggressiveJerkDeceleration", "AggressiveJerkDanger", "AggressiveJerkSpeed", "AggressiveJerkSpeedDecrease", "ResetAggressivePersonality"};
QSet<QString> conditionalChillKeys = {"PersistChillState", "CCMSpeed", "CCMSpeedLead", "CCMLead", "CCMSetSpeedMargin", "ShowCCMStatus"};
QSet<QString> conditionalExperimentalKeys = {"PersistExperimentalState", "CESpeed", "CESpeedLead", "CECurves", "CELead", "CEModelStopTime", "CESignalSpeed", "CEStopLights", "ShowCEMStatus"};
QSet<QString> curveSpeedKeys = {"CalibratedLateralAcceleration", "CalibrationProgress", "ResetCurveData", "ShowCSCStatus"};
QSet<QString> customDrivingPersonalityKeys = {"AggressivePersonalityProfile", "RelaxedPersonalityProfile", "StandardPersonalityProfile", "TrafficPersonalityProfile"};
@@ -468,9 +468,14 @@ void StarPilotAnnotatedCameraWidget::paintCEMStatus(QPainter &p) {
cemStatusPosition.setY(dmIconPosition.y() - widget_size / 2);
QRect cemWidget(cemStatusPosition, QSize(widget_size, widget_size));
const bool conditionalExperimentalMode = starpilot_toggles.value("conditional_experimental_mode").toBool();
const bool conditionalChillMode = starpilot_toggles.value("conditional_chill_mode").toBool();
const bool manualOverride =
(conditionalExperimentalMode && starpilot_scene.conditional_status == 1) ||
(conditionalChillMode && (starpilot_scene.conditional_status == 1 || starpilot_scene.conditional_status == 2));
p.setBrush(blackColor(166));
if (starpilot_scene.conditional_status == 1) {
if (manualOverride) {
p.setPen(QPen(QColor(bg_colors[STATUS_CEM_DISABLED]), 10));
} else if (experimentalMode) {
p.setPen(QPen(QColor(bg_colors[STATUS_EXPERIMENTAL_MODE_ENABLED]), 10));
@@ -480,7 +485,19 @@ void StarPilotAnnotatedCameraWidget::paintCEMStatus(QPainter &p) {
p.drawRoundedRect(cemWidget, 24, 24);
QSharedPointer<QMovie> icon = chillModeIcon;
if (experimentalMode) {
if (conditionalChillMode && !conditionalExperimentalMode) {
if (starpilot_scene.conditional_status == 1) {
icon = experimentalModeIcon;
} else if (starpilot_scene.conditional_status == 2) {
icon = chillModeIcon;
} else if (starpilot_scene.conditional_status == 4) {
icon = cemLeadIcon;
} else if (starpilot_scene.conditional_status == 6) {
icon = cemSpeedIcon;
} else {
icon = experimentalMode ? experimentalModeIcon : chillModeIcon;
}
} else if (experimentalMode) {
if (starpilot_scene.conditional_status == 1) {
icon = chillModeIcon;
} else if (starpilot_scene.conditional_status == 2) {
@@ -786,12 +803,17 @@ void StarPilotAnnotatedCameraWidget::paintPathEdges(QPainter &p, int height) {
gradient.setColorAt(0.5f, QColor(baseColor.red(), baseColor.green(), baseColor.blue(), 255.0f * 0.35f));
gradient.setColorAt(1.0f, QColor(baseColor.red(), baseColor.green(), baseColor.blue(), 255.0f * 0.0f));
};
const bool conditionalExperimentalMode = starpilot_toggles.value("conditional_experimental_mode").toBool();
const bool conditionalChillMode = starpilot_toggles.value("conditional_chill_mode").toBool();
const bool highlightOverride =
(conditionalExperimentalMode && starpilot_scene.conditional_status == 1) ||
(conditionalChillMode && (starpilot_scene.conditional_status == 1 || starpilot_scene.conditional_status == 2));
if (starpilot_scene.switchback_mode_enabled) {
setPathEdgeColors(bg_colors[STATUS_SWITCHBACK_MODE_ENABLED]);
} else if (starpilot_scene.always_on_lateral_active) {
setPathEdgeColors(bg_colors[STATUS_ALWAYS_ON_LATERAL_ACTIVE]);
} else if (starpilot_scene.conditional_status == 1) {
} else if (highlightOverride) {
setPathEdgeColors(bg_colors[STATUS_CEM_DISABLED]);
} else if (experimentalMode) {
setPathEdgeColors(bg_colors[STATUS_EXPERIMENTAL_MODE_ENABLED]);
@@ -128,7 +128,7 @@ void loadImage(const QString &basePath, QPixmap &pixmap, QSharedPointer<QMovie>
void openDescriptions(bool forceOpenDescriptions, std::map<QString, AbstractControl*> toggles) {
if (forceOpenDescriptions) {
for (auto &[key, toggle] : toggles) {
if (key != "CESpeed") {
if (key != "CESpeed" && key != "CCMSpeed") {
toggle->showDescription();
}
}
+6 -1
View File
@@ -114,6 +114,11 @@ StarPilotUIState *starpilotUIState() {
void StarPilotUIState::update() {
update_state(this);
starpilot_scene.conditional_status = starpilot_scene.enabled ? params_memory.getInt("CEStatus") : 0;
if (starpilot_scene.enabled && starpilot_scene.starpilot_toggles.value("conditional_chill_mode").toBool() &&
!starpilot_scene.starpilot_toggles.value("conditional_experimental_mode").toBool()) {
starpilot_scene.conditional_status = params_memory.getInt("CCStatus");
} else {
starpilot_scene.conditional_status = starpilot_scene.enabled ? params_memory.getInt("CEStatus") : 0;
}
starpilot_scene.driver_camera_timer = starpilot_scene.reverse && starpilot_scene.starpilot_toggles.value("driver_camera_in_reverse").toBool() ? starpilot_scene.driver_camera_timer + 1 : 0;
}