This commit is contained in:
firestar5683
2026-03-29 18:29:17 -05:00
parent a6721ca3af
commit e8cce63b7f
36 changed files with 164 additions and 53 deletions
+26 -21
View File
@@ -7,6 +7,7 @@ from opendbc.car.gm import gmcan
from opendbc.car.common.conversions import Conversions as CV
from opendbc.car.gm.values import ASCM_INT, CAR, CC_ONLY_CAR, CC_REGEN_PADDLE_CAR, DBC, EV_CAR, SDGM_CAR, AccState, CanBus, CarControllerParams, CruiseButtons, GMFlags
from opendbc.car.interfaces import CarControllerBase
from opendbc.car.gm.cancel_logic import get_stock_cc_active_for_cancel
from openpilot.common.params import Params, UnknownKeyName
from openpilot.starpilot.common.testing_grounds import testing_ground
@@ -534,7 +535,12 @@ class CarController(CarControllerBase):
cc_long_cancel = ((self.CP.flags & GMFlags.CC_LONG.value) and
self.prev_op_enabled and not CC.enabled and CS.out.cruiseState.enabled)
if pedal_cancel or cc_long_cancel:
if self.CP.carFingerprint == CAR.CHEVROLET_MALIBU_HYBRID_CC:
stock_cc_active = get_stock_cc_active_for_cancel(self.CP, CS)
pedal_cancel = bool(self.CP.flags & GMFlags.PEDAL_LONG.value) and CC.longActive
cc_long_cancel = bool(self.CP.flags & GMFlags.CC_LONG.value) and not CC.enabled
if (pedal_cancel or cc_long_cancel) and (stock_cc_active if self.CP.carFingerprint == CAR.CHEVROLET_MALIBU_HYBRID_CC else True):
if self.CP.carFingerprint == CAR.CHEVROLET_MALIBU_HYBRID_CC:
malibu_cancel_requested = True
elif (self.frame - self.last_button_frame) * DT_CTRL > 0.04:
@@ -548,27 +554,26 @@ class CarController(CarControllerBase):
self.cancel_counter = self.cancel_counter + 1 if CC.cruiseControl.cancel else 0
# Stock longitudinal, integrated at camera
if (self.frame - self.last_button_frame) * DT_CTRL > 0.04:
if self.CP.carFingerprint == CAR.CHEVROLET_MALIBU_HYBRID_CC and self.cancel_counter > CAMERA_CANCEL_DELAY_FRAMES:
malibu_cancel_requested = True
elif (self.frame - self.last_button_frame) * DT_CTRL > 0.04:
if self.cancel_counter > CAMERA_CANCEL_DELAY_FRAMES:
if self.CP.carFingerprint == CAR.CHEVROLET_MALIBU_HYBRID_CC:
malibu_cancel_requested = True
else:
self.last_button_frame = self.frame
sdgm_stock_cancel_pt = (
self.CP.carFingerprint in SDGM_CAR and
self.CP.carFingerprint not in {
CAR.CHEVROLET_VOLT,
CAR.CHEVROLET_VOLT_2019,
CAR.CHEVROLET_VOLT_ASCM,
CAR.CHEVROLET_VOLT_CAMERA,
CAR.CHEVROLET_VOLT_CC,
CAR.CHEVROLET_BLAZER,
CAR.CHEVROLET_MALIBU_SDGM,
CAR.CHEVROLET_TRAVERSE,
}
)
cancel_bus = CanBus.POWERTRAIN if sdgm_stock_cancel_pt else CanBus.CAMERA
can_sends.append(gmcan.create_buttons(self.packer_pt, cancel_bus, CS.buttons_counter, CruiseButtons.CANCEL))
self.last_button_frame = self.frame
sdgm_stock_cancel_pt = (
self.CP.carFingerprint in SDGM_CAR and
self.CP.carFingerprint not in {
CAR.CHEVROLET_VOLT,
CAR.CHEVROLET_VOLT_2019,
CAR.CHEVROLET_VOLT_ASCM,
CAR.CHEVROLET_VOLT_CAMERA,
CAR.CHEVROLET_VOLT_CC,
CAR.CHEVROLET_BLAZER,
CAR.CHEVROLET_MALIBU_SDGM,
CAR.CHEVROLET_TRAVERSE,
}
)
cancel_bus = CanBus.POWERTRAIN if sdgm_stock_cancel_pt else CanBus.CAMERA
can_sends.append(gmcan.create_buttons(self.packer_pt, cancel_bus, CS.buttons_counter, CruiseButtons.CANCEL))
if self.CP.carFingerprint == CAR.CHEVROLET_MALIBU_HYBRID_CC:
if malibu_cancel_requested and malibu_oem_button_slot:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+1 -1
View File
@@ -1,2 +1,2 @@
extern const uint8_t gitversion[19];
const uint8_t gitversion[19] = "DEV-3af9b873-DEBUG";
const uint8_t gitversion[19] = "DEV-523a26be-DEBUG";
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+1 -1
View File
@@ -1 +1 @@
DEV-3af9b873-DEBUG
DEV-523a26be-DEBUG
+19 -2
View File
@@ -118,9 +118,26 @@ assert_image_arch() {
}
expected_capnp_version() {
if [[ -n "${COMMA_EXPECTED_CAPNP_VERSION:-}" ]]; then
echo "${COMMA_EXPECTED_CAPNP_VERSION}"
return
fi
local dockerfile_version=""
dockerfile_version="$(sed -n 's/^ARG CAPNP_VERSION=\(.*\)$/\1/p' "${ROOT_DIR}/tools/laptop_device_build/Dockerfile" | head -n 1)"
if [[ -n "${dockerfile_version}" ]]; then
echo "${dockerfile_version}"
return
fi
local header_path="${ROOT_DIR}/cereal/gen/cpp/custom.capnp.h"
if [[ ! -f "${header_path}" ]]; then
err "Unable to determine expected Cap'n Proto version. Set COMMA_EXPECTED_CAPNP_VERSION or restore tools/laptop_device_build/Dockerfile ARG CAPNP_VERSION."
fi
local raw_version=""
raw_version="$(sed -n 's/^#elif CAPNP_VERSION != \([0-9][0-9]*\)$/\1/p' "${ROOT_DIR}/cereal/gen/cpp/custom.capnp.h" | head -n 1)"
[[ -n "${raw_version}" ]] || err "Unable to determine expected Cap'n Proto version from cereal/gen/cpp/custom.capnp.h."
raw_version="$(sed -n 's/^#elif CAPNP_VERSION != \([0-9][0-9]*\)$/\1/p' "${header_path}" | head -n 1)"
[[ -n "${raw_version}" ]] || err "Unable to determine expected Cap'n Proto version from ${header_path}."
local major=$(( raw_version / 1000000 ))
local minor=$(( (raw_version / 1000) % 1000 ))
BIN
View File
Binary file not shown.
+117 -28
View File
@@ -11,6 +11,98 @@
#include "system/hardware/hw.h"
namespace {
QString paramDefaultValue(const Params &params, const char *key) {
return QString::fromStdString(const_cast<Params &>(params).getKeyDefaultValue(key).value_or("")).trimmed();
}
QString builtinDefaultModelKey(const Params &params) {
QString key = paramDefaultValue(params, "Model");
if (key.isEmpty()) {
key = paramDefaultValue(params, "DrivingModel");
}
return key.isEmpty() ? QStringLiteral("sc2") : key;
}
QString builtinDefaultModelName(const Params &params) {
QString name = paramDefaultValue(params, "DrivingModelName");
return name.isEmpty() ? QStringLiteral("South Carolina") : name;
}
QStringList builtinDefaultModelAliases(const QString &defaultKey) {
QString canonical = defaultKey.trimmed();
if (canonical.isEmpty()) {
canonical = QStringLiteral("sc2");
}
QStringList aliases{canonical};
if (canonical.endsWith("2")) {
aliases.append(canonical.left(canonical.size() - 1));
} else {
aliases.append(canonical + "2");
}
if (canonical.endsWith("_default")) {
aliases.append(canonical.left(canonical.size() - QStringLiteral("_default").size()));
}
aliases.removeAll("");
aliases.removeDuplicates();
return aliases;
}
bool isBuiltinDefaultModel(const Params &params, const QString &key) {
return builtinDefaultModelAliases(builtinDefaultModelKey(params)).contains(key.trimmed());
}
QString canonicalModelKey(const Params &params, const QString &key) {
const QString trimmedKey = key.trimmed();
return isBuiltinDefaultModel(params, trimmedKey) ? builtinDefaultModelKey(params) : trimmedKey;
}
void ensureDefaultModelVisible(const Params &params, const QString &fallbackSeries,
QMap<QString, QString> &modelFileToNameMap,
QMap<QString, QString> &modelFileToNameMapProcessed,
QMap<QString, QString> &modelSeriesMap,
QMap<QString, QString> &modelReleasedDates) {
const QString defaultKey = builtinDefaultModelKey(params);
QString displayName = builtinDefaultModelName(params);
QString series = fallbackSeries;
QString releasedDate;
for (const QString &alias : builtinDefaultModelAliases(defaultKey)) {
if (!modelFileToNameMap.contains(alias)) {
continue;
}
displayName = modelFileToNameMap.value(alias, displayName);
if (series == fallbackSeries && modelSeriesMap.contains(alias)) {
series = modelSeriesMap.value(alias);
}
if (releasedDate.isEmpty() && modelReleasedDates.contains(alias)) {
releasedDate = modelReleasedDates.value(alias);
}
if (alias != defaultKey) {
modelFileToNameMap.remove(alias);
modelFileToNameMapProcessed.remove(alias);
modelSeriesMap.remove(alias);
modelReleasedDates.remove(alias);
}
}
modelFileToNameMap.insert(defaultKey, displayName);
modelFileToNameMapProcessed.insert(defaultKey, cleanModelName(displayName));
modelSeriesMap.insert(defaultKey, series);
if (!releasedDate.isEmpty()) {
modelReleasedDates.insert(defaultKey, releasedDate);
}
}
} // namespace
StarPilotModelPanel::StarPilotModelPanel(StarPilotSettingsWindow *parent) : StarPilotListWidget(parent),
allModelsDownloaded(false),
allModelsDownloading(false),
@@ -366,10 +458,6 @@ StarPilotModelPanel::StarPilotModelPanel(StarPilotSettingsWindow *parent) : Star
}
QString modelName = modelFileToNameMap.value(modelKey);
if (modelName.contains("(Default)")) {
continue;
}
installedModelFileToNameMap.insert(modelKey, modelName);
if (modelReleasedDates.contains(modelKey)) {
installedReleasedDates.insert(modelKey, modelReleasedDates.value(modelKey));
@@ -385,15 +473,12 @@ StarPilotModelPanel::StarPilotModelPanel(StarPilotSettingsWindow *parent) : Star
}
// Add default model to the beginning of its series
QString defaultModelKey = QString::fromStdString(params.getKeyDefaultValue("Model").value());
if (defaultModelKey.isEmpty()) {
defaultModelKey = QString::fromStdString(params.getKeyDefaultValue("DrivingModel").value());
}
QString defaultModelName = modelFileToNameMap.value(defaultModelKey);
QString defaultSeries = modelSeriesMap.value(defaultModelKey, "Custom Series");
if (seriesToModels.contains(defaultSeries) && seriesToModels[defaultSeries].contains(defaultModelName)) {
seriesToModels[defaultSeries].removeAll(defaultModelName);
seriesToModels[defaultSeries].prepend(defaultModelName);
const QString defaultKey = builtinDefaultModelKey(params);
const QString defaultName = modelFileToNameMap.value(defaultKey, builtinDefaultModelName(params));
const QString defaultSeries = modelSeriesMap.value(defaultKey, tr("Custom Series"));
if (seriesToModels.contains(defaultSeries) && seriesToModels[defaultSeries].contains(defaultName)) {
seriesToModels[defaultSeries].removeAll(defaultName);
seriesToModels[defaultSeries].prepend(defaultName);
}
// Prepare favorites and dates for the enhanced dialog
@@ -525,6 +610,10 @@ bool StarPilotModelPanel::isModelInstalled(const QString &key) const {
return false;
}
if (isBuiltinDefaultModel(params, key)) {
return true;
}
bool has_thneed = false;
bool has_policy_meta = false;
bool has_policy_tg = false;
@@ -579,12 +668,9 @@ bool StarPilotModelPanel::isModelInstalled(const QString &key) const {
QMap<QString, QString> StarPilotModelPanel::getDeletableModelDisplayNames() {
QMap<QString, QString> deletable;
QString defaultModelKey = QString::fromStdString(params.getKeyDefaultValue("Model").value());
if (defaultModelKey.isEmpty()) {
defaultModelKey = QString::fromStdString(params.getKeyDefaultValue("DrivingModel").value());
}
QString defaultModelName = modelFileToNameMap.value(defaultModelKey);
QString processedDefault = cleanModelName(defaultModelName);
const QString defaultKey = builtinDefaultModelKey(params);
const QString defaultName = modelFileToNameMap.value(defaultKey, builtinDefaultModelName(params));
const QString processedDefault = cleanModelName(defaultName);
QString processedCurrent = cleanModelName(currentModel);
for (auto it = modelFileToNameMap.constBegin(); it != modelFileToNameMap.constEnd(); ++it) {
@@ -636,7 +722,10 @@ void StarPilotModelPanel::showEvent(QShowEvent *event) {
QJsonObject versionObj;
int verCount = qMin(availableModels.size(), versionList.size());
for (int i = 0; i < verCount; ++i) {
versionObj.insert(availableModels[i], versionList[i]);
const QString modelKey = canonicalModelKey(params, availableModels[i]);
if (!modelKey.isEmpty()) {
versionObj.insert(modelKey, versionList[i]);
}
}
QFile out(modelDir.filePath(".model_versions.json"));
if (out.open(QIODevice::WriteOnly)) {
@@ -651,7 +740,7 @@ void StarPilotModelPanel::showEvent(QShowEvent *event) {
modelReleasedDates.clear();
int size = qMin(availableModels.size(), availableModelNames.size());
for (int i = 0; i < size; ++i) {
const QString modelKey = availableModels[i].trimmed();
const QString modelKey = canonicalModelKey(params, availableModels[i]);
const QString modelName = availableModelNames[i].trimmed();
if (modelKey.isEmpty() || modelName.isEmpty()) {
continue;
@@ -676,6 +765,9 @@ void StarPilotModelPanel::showEvent(QShowEvent *event) {
}
}
}
ensureDefaultModelVisible(params, tr("Custom Series"), modelFileToNameMap, modelFileToNameMapProcessed, modelSeriesMap, modelReleasedDates);
allModelsDownloaded = true;
for (auto it = modelFileToNameMap.constBegin(); it != modelFileToNameMap.constEnd(); ++it) {
if (it.value().isEmpty()) {
@@ -687,17 +779,14 @@ void StarPilotModelPanel::showEvent(QShowEvent *event) {
}
}
QString modelKey = QString::fromStdString(params.get("Model"));
QString modelKey = canonicalModelKey(params, QString::fromStdString(params.get("Model")));
if (modelKey.isEmpty()) {
modelKey = QString::fromStdString(params.get("DrivingModel"));
modelKey = canonicalModelKey(params, QString::fromStdString(params.get("DrivingModel")));
}
if (!isModelInstalled(modelKey)) {
modelKey = QString::fromStdString(params.getKeyDefaultValue("Model").value());
if (modelKey.isEmpty()) {
modelKey = QString::fromStdString(params.getKeyDefaultValue("DrivingModel").value());
}
modelKey = builtinDefaultModelKey(params);
}
currentModel = modelFileToNameMap.value(modelKey);
currentModel = modelFileToNameMap.value(modelKey, builtinDefaultModelName(params));
selectModelButton->setValue(currentModel);
noModelsDownloaded = getDeletableModelDisplayNames().isEmpty();