Increase max speed by 5 on short press

Added toggle to increase the value of the max speed by 5 instead of 1 and an additional function to enable/disable it by taping the "Max" speed icon in the onroad UI.
This commit is contained in:
FrogAi
2024-02-27 16:34:47 -07:00
parent 37fe001319
commit d78099c85b
9 changed files with 43 additions and 11 deletions

View File

@@ -297,6 +297,8 @@ std::unordered_map<std::string, uint32_t> keys = {
{"RefuseVolume", PERSISTENT},
{"RelaxedFollow", PERSISTENT},
{"RelaxedJerk", PERSISTENT},
{"ReverseCruise", PERSISTENT},
{"ReverseCruiseUI", PERSISTENT},
{"RoadEdgesWidth", PERSISTENT},
{"SilentMode", PERSISTENT},
{"ShowCPU", PERSISTENT},

View File

@@ -43,7 +43,7 @@ def create_accel_command(packer, accel, accel_raw, pcm_cancel, standstill_req, l
"PERMIT_BRAKING": 1,
"RELEASE_STANDSTILL": not standstill_req,
"CANCEL_REQ": pcm_cancel,
"ALLOW_LONG_PRESS": 1,
"ALLOW_LONG_PRESS": 2 if frogpilot_variables.reverse_cruise_increase else 1,
"ACC_CUT_IN": fcw_alert, # only shown when ACC enabled
"ACCEL_CMD_ALT": accel_raw, # raw accel command, pcm uses this to calculate a compensatory force
}

View File

@@ -606,7 +606,7 @@ class Controls:
def state_transition(self, CS):
"""Compute conditional state transitions and execute actions on state transitions"""
self.v_cruise_helper.update_v_cruise(CS, self.enabled, self.is_metric)
self.v_cruise_helper.update_v_cruise(CS, self.enabled, self.is_metric, self.frogpilot_variables)
# decrement the soft disable timer at every step, as it's reset on
# entrance in SOFT_DISABLING state
@@ -1062,6 +1062,7 @@ class Controls:
self.frogpilot_variables.sport_plus = longitudinal_tune and self.params.get_int("AccelerationProfile") == 3
quality_of_life = self.params.get_bool("QOLControls")
self.frogpilot_variables.reverse_cruise_increase = quality_of_life and self.params.get_bool("ReverseCruise")
def main():
controls = Controls()

View File

@@ -52,13 +52,13 @@ class VCruiseHelper:
def v_cruise_initialized(self):
return self.v_cruise_kph != V_CRUISE_UNSET
def update_v_cruise(self, CS, enabled, is_metric):
def update_v_cruise(self, CS, enabled, is_metric, frogpilot_variables):
self.v_cruise_kph_last = self.v_cruise_kph
if CS.cruiseState.available:
if 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)
self._update_v_cruise_non_pcm(CS, enabled, is_metric, frogpilot_variables)
self.v_cruise_cluster_kph = self.v_cruise_kph
self.update_button_timers(CS, enabled)
else:
@@ -68,7 +68,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):
def _update_v_cruise_non_pcm(self, CS, enabled, is_metric, frogpilot_variables):
# 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:
@@ -92,6 +92,10 @@ class VCruiseHelper:
long_press = True
break
# Reverse the long press value for reverse cruise increase
if frogpilot_variables.reverse_cruise_increase:
long_press = not long_press
if button_type is None:
return

View File

@@ -35,6 +35,7 @@ FrogPilotControlsPanel::FrogPilotControlsPanel(SettingsWindow *parent) : FrogPil
{"QOLControls", "Quality of Life", "Miscellaneous quality of life changes to improve your overall openpilot experience.", "../frogpilot/assets/toggle_icons/quality_of_life.png"},
{"DisableOnroadUploads", "Disable Onroad Uploads", "Prevent large data uploads when onroad.", ""},
{"HigherBitrate", "Higher Bitrate Recording", "Increases the quality of the footage uploaded to comma connect.", ""},
{"ReverseCruise", "Reverse Cruise Increase", "Reverses the 'long press' functionality when increasing the max set speed. Useful to increase the max speed quickly.", ""},
};
for (const auto &[param, title, desc, icon] : controlToggles) {
@@ -218,6 +219,10 @@ FrogPilotControlsPanel::FrogPilotControlsPanel(SettingsWindow *parent) : FrogPil
}
});
toggle = qolToggle;
} else if (param == "ReverseCruise") {
std::vector<QString> reverseCruiseToggles{"ReverseCruiseUI"};
std::vector<QString> reverseCruiseNames{tr("Control Via UI")};
toggle = new FrogPilotParamToggleControl(param, title, desc, icon, reverseCruiseToggles, reverseCruiseNames);
} else {
toggle = new ParamControl(param, title, desc, icon, this);

View File

@@ -42,7 +42,7 @@ private:
std::set<QString> lateralTuneKeys = {"ForceAutoTune"};
std::set<QString> longitudinalTuneKeys = {"AccelerationProfile", "DecelerationProfile", "AggressiveAcceleration"};
std::set<QString> mtscKeys = {};
std::set<QString> qolKeys = {"DisableOnroadUploads", "HigherBitrate"};
std::set<QString> qolKeys = {"DisableOnroadUploads", "HigherBitrate", "ReverseCruise"};
std::set<QString> speedLimitControllerKeys = {};
std::set<QString> speedLimitControllerControlsKeys = {};
std::set<QString> speedLimitControllerQOLKeys = {};

View File

@@ -105,15 +105,27 @@ void OnroadWindow::mousePressEvent(QMouseEvent* e) {
// FrogPilot clickable widgets
bool widgetClicked = false;
// Change cruise control increments button
QRect maxSpeedRect(7, 25, 225, 225);
bool isMaxSpeedClicked = maxSpeedRect.contains(e->pos());
// Hide speed button
QRect hideSpeedRect(rect().center().x() - 175, 50, 350, 350);
bool isSpeedClicked = hideSpeedRect.contains(e->pos());
if (isSpeedClicked && scene.hide_speed_ui) {
bool currentHideSpeed = scene.hide_speed;
if (isMaxSpeedClicked || isSpeedClicked) {
if (isMaxSpeedClicked && scene.reverse_cruise_ui) {
bool currentReverseCruise = scene.reverse_cruise;
uiState()->scene.hide_speed = !currentHideSpeed;
params.putBoolNonBlocking("HideSpeed", !currentHideSpeed);
uiState()->scene.reverse_cruise = !currentReverseCruise;
params.putBoolNonBlocking("ReverseCruise", !currentReverseCruise);
} else if (isSpeedClicked && scene.hide_speed_ui) {
bool currentHideSpeed = scene.hide_speed;
uiState()->scene.hide_speed = !currentHideSpeed;
params.putBoolNonBlocking("HideSpeed", !currentHideSpeed);
}
widgetClicked = true;
// If the click wasn't for anything specific, change the value of "ExperimentalMode"
@@ -483,7 +495,11 @@ void AnnotatedCameraWidget::drawHud(QPainter &p) {
int bottom_radius = has_eu_speed_limit ? 100 : 32;
QRect set_speed_rect(QPoint(60 + (default_size.width() - set_speed_size.width()) / 2, 45), set_speed_size);
p.setPen(QPen(whiteColor(75), 6));
if (scene.reverse_cruise) {
p.setPen(QPen(QColor(0, 150, 255), 6));
} else {
p.setPen(QPen(whiteColor(75), 6));
}
p.setBrush(blackColor(166));
drawRoundedRect(p, set_speed_rect, top_radius, top_radius, bottom_radius, bottom_radius);

View File

@@ -319,6 +319,8 @@ void ui_update_frogpilot_params(UIState *s) {
scene.unlimited_road_ui_length = scene.model_ui && params.getBool("UnlimitedLength");
bool quality_of_life_controls = params.getBool("QOLControls");
scene.reverse_cruise = quality_of_life_controls && params.getBool("ReverseCruise");
scene.reverse_cruise_ui = scene.reverse_cruise && params.getBool("ReverseCruiseUI");
bool quality_of_life_visuals = params.getBool("QOLVisuals");
scene.full_map = quality_of_life_visuals && params.getBool("FullMap");

View File

@@ -191,6 +191,8 @@ typedef struct UIScene {
bool lead_info;
bool map_open;
bool model_ui;
bool reverse_cruise;
bool reverse_cruise_ui;
bool show_driver_camera;
bool turn_signal_left;
bool turn_signal_right;