Switch personalities via steering wheel / onroad UI

Added toggle to switch between the personalities via the steering wheel or an onroad UI button.

Co-Authored-By: henryccy <104284652+henryccy@users.noreply.github.com>
Co-Authored-By: Jason Jackrel <23621790+thinkpad4by3@users.noreply.github.com>
Co-Authored-By: Eric Brown <13560103+nworb-cire@users.noreply.github.com>
Co-Authored-By: Kevin Robert Keegan <3046315+krkeegan@users.noreply.github.com>
Co-Authored-By: Jacob Pfeifer <jacob@pfeifer.dev>
Co-Authored-By: mike8643 <98910897+mike8643@users.noreply.github.com>
This commit is contained in:
FrogAi
2024-02-27 16:34:47 -07:00
parent 71eecd224c
commit 437ecc73ca
38 changed files with 406 additions and 36 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 62 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 81 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

View File

@@ -5,8 +5,6 @@ from openpilot.common.params import Params
from openpilot.system.hardware import HARDWARE
params_memory = Params("/dev/shm/params")
DEFAULT_MODEL = "los-angeles"
CITY_SPEED_LIMIT = 25
@@ -51,6 +49,7 @@ class MovingAverageCalculator:
class FrogPilotFunctions:
def __init__(self) -> None:
self.params = Params()
self.params_memory = Params("/dev/shm/params")
@staticmethod
def get_min_accel_eco(v_ego):
@@ -82,19 +81,32 @@ class FrogPilotFunctions:
return min(distance_to_lane, distance_to_road_edge)
@staticmethod
@property
def current_personality(self):
return self.params.get_int("LongitudinalPersonality")
def distance_button_function(self, new_personality):
self.params.put_int("LongitudinalPersonality", new_personality)
self.params_memory.put_bool("PersonalityChangedViaWheel", True)
@property
def personality_changed_via_ui(self):
return self.params_memory.get_bool("PersonalityChangedViaUI")
def reset_personality_changed_param(self):
self.params_memory.put_bool("PersonalityChangedViaUI", False)
def update_cestatus_distance(self):
# Set "CEStatus" to work with "Conditional Experimental Mode"
conditional_status = params_memory.get_int("CEStatus")
conditional_status = self.params_memory.get_int("CEStatus")
override_value = 0 if conditional_status in (1, 2, 3, 4, 5, 6) else 3 if conditional_status >= 7 else 4
params_memory.put_int("CEStatus", override_value)
self.params_memory.put_int("CEStatus", override_value)
@staticmethod
def update_cestatus_lkas(self):
# Set "CEStatus" to work with "Conditional Experimental Mode"
conditional_status = params_memory.get_int("CEStatus")
conditional_status = self.params_memory.get_int("CEStatus")
override_value = 0 if conditional_status in (1, 2, 3, 4, 5, 6) else 5 if conditional_status >= 7 else 6
params_memory.put_int("CEStatus", override_value)
self.params_memory.put_int("CEStatus", override_value)
def update_experimental_mode(self):
experimental_mode = self.params.get_bool("ExperimentalMode")

View File

@@ -2,6 +2,8 @@
FrogPilotControlsPanel::FrogPilotControlsPanel(SettingsWindow *parent) : FrogPilotListWidget(parent) {
const std::vector<std::tuple<QString, QString, QString, QString>> controlToggles {
{"AdjustablePersonalities", "Adjustable Personalities", "Use the 'Distance' button on the steering wheel or the onroad UI to switch between openpilot's driving personalities.\n\n1 bar = Aggressive\n2 bars = Standard\n3 bars = Relaxed", "../frogpilot/assets/toggle_icons/icon_distance.png"},
{"AlwaysOnLateral", "Always on Lateral", "Maintain openpilot lateral control when the brake or gas pedals are used.\n\nDeactivation occurs only through the 'Cruise Control' button.", "../frogpilot/assets/toggle_icons/icon_always_on_lateral.png"},
{"AlwaysOnLateralMain", "Enable On Cruise Main", "Enable 'Always On Lateral' by simply turning on 'Cruise Control'.", ""},
{"HideAOLStatusBar", "Hide the Status Bar", "Don't use the status bar for 'Always On Lateral'.", ""},
@@ -82,7 +84,12 @@ FrogPilotControlsPanel::FrogPilotControlsPanel(SettingsWindow *parent) : FrogPil
for (const auto &[param, title, desc, icon] : controlToggles) {
ParamControl *toggle;
if (param == "AlwaysOnLateral") {
if (param == "AdjustablePersonalities") {
std::vector<QString> adjustablePersonalitiesToggles{"PersonalitiesViaWheel", "PersonalitiesViaScreen"};
std::vector<QString> adjustablePersonalitiesNames{tr("Distance Button"), tr("Screen")};
toggle = new FrogPilotParamToggleControl(param, title, desc, icon, adjustablePersonalitiesToggles, adjustablePersonalitiesNames);
} else if (param == "AlwaysOnLateral") {
FrogPilotParamManageControl *aolToggle = new FrogPilotParamManageControl(param, title, desc, icon, this);
QObject::connect(aolToggle, &FrogPilotParamManageControl::manageButtonClicked, this, [this]() {
parentToggleClicked();