Always On Lateral
Added toggle for Always On Lateral / No disengage lateral on gas and brake. Lots of credit goes to "pfeiferj"! Couldn't of done it without him! https: //github.com/pfeiferj/openpilot Co-Authored-By: Jacob Pfeifer <jacob@pfeifer.dev>
This commit is contained in:
@@ -121,7 +121,7 @@ void MapWindow::updateState(const UIState &s) {
|
||||
if (sm.updated("modelV2")) {
|
||||
// set path color on change, and show map on rising edge of navigate on openpilot
|
||||
bool nav_enabled = sm["modelV2"].getModelV2().getNavEnabled() &&
|
||||
sm["controlsState"].getControlsState().getEnabled();
|
||||
(sm["controlsState"].getControlsState().getEnabled() || sm["frogpilotCarControl"].getFrogpilotCarControl().getAlwaysOnLateral());
|
||||
if (nav_enabled != uiState()->scene.navigate_on_openpilot) {
|
||||
if (loaded_once) {
|
||||
m_map->setPaintProperty("navLayer", "line-color", getNavPathColor(nav_enabled));
|
||||
|
||||
@@ -175,7 +175,7 @@ void OnroadAlerts::paintEvent(QPaintEvent *event) {
|
||||
|
||||
int margin = 40;
|
||||
int radius = 30;
|
||||
int offset = true ? 25 : 0;
|
||||
int offset = scene.always_on_lateral ? 25 : 0;
|
||||
if (alert.size == cereal::ControlsState::AlertSize::FULL) {
|
||||
margin = 0;
|
||||
radius = 0;
|
||||
@@ -242,7 +242,7 @@ void ExperimentalButton::changeMode() {
|
||||
|
||||
void ExperimentalButton::updateState(const UIState &s) {
|
||||
const auto cs = (*s.sm)["controlsState"].getControlsState();
|
||||
bool eng = cs.getEngageable() || cs.getEnabled();
|
||||
bool eng = cs.getEngageable() || cs.getEnabled() || scene.always_on_lateral_active;
|
||||
if ((cs.getExperimentalMode() != experimental_mode) || (eng != engageable)) {
|
||||
engageable = eng;
|
||||
experimental_mode = cs.getExperimentalMode();
|
||||
@@ -255,7 +255,7 @@ void ExperimentalButton::updateState(const UIState &s) {
|
||||
void ExperimentalButton::paintEvent(QPaintEvent *event) {
|
||||
QPainter p(this);
|
||||
QPixmap img = experimental_mode ? experimental_img : engage_img;
|
||||
drawIcon(p, QPoint(btn_size / 2, btn_size / 2), img, QColor(0, 0, 0, 166), (isDown() || !engageable) ? 0.6 : 1.0);
|
||||
drawIcon(p, QPoint(btn_size / 2, btn_size / 2), img, QColor(0, 0, 0, 166), (isDown() || !(engageable || scene.always_on_lateral_active)) ? 0.6 : 1.0);
|
||||
}
|
||||
|
||||
|
||||
@@ -545,7 +545,7 @@ void AnnotatedCameraWidget::drawDriverState(QPainter &painter, const UIState *s)
|
||||
|
||||
// base icon
|
||||
int offset = UI_BORDER_SIZE + btn_size / 2;
|
||||
offset += true ? 25 : 0;
|
||||
offset += alwaysOnLateral ? 25 : 0;
|
||||
int x = rightHandDM ? width() - offset : offset;
|
||||
int y = height() - offset;
|
||||
float opacity = dmActive ? 0.65 : 0.2;
|
||||
@@ -734,9 +734,12 @@ void AnnotatedCameraWidget::initializeFrogPilotWidgets() {
|
||||
}
|
||||
|
||||
void AnnotatedCameraWidget::updateFrogPilotWidgets(QPainter &p) {
|
||||
alwaysOnLateral = scene.always_on_lateral;
|
||||
alwaysOnLateralActive = scene.always_on_lateral_active;
|
||||
|
||||
experimentalMode = scene.experimental_mode;
|
||||
|
||||
if (true) {
|
||||
if (alwaysOnLateral) {
|
||||
drawStatusBar(p);
|
||||
}
|
||||
|
||||
@@ -768,6 +771,11 @@ void AnnotatedCameraWidget::drawStatusBar(QPainter &p) {
|
||||
p.setOpacity(1.0);
|
||||
p.drawRoundedRect(statusBarRect, 30, 30);
|
||||
|
||||
// Update status text
|
||||
if (alwaysOnLateralActive) {
|
||||
newStatus = QString("Always On Lateral active. Press the \"Cruise Control\" button to disable");
|
||||
}
|
||||
|
||||
// Check if status has changed
|
||||
if (newStatus != lastShownStatus) {
|
||||
displayStatusText = true;
|
||||
|
||||
@@ -118,6 +118,8 @@ private:
|
||||
|
||||
QHBoxLayout *bottom_layout;
|
||||
|
||||
bool alwaysOnLateral;
|
||||
bool alwaysOnLateralActive;
|
||||
bool experimentalMode;
|
||||
|
||||
protected:
|
||||
|
||||
@@ -210,6 +210,9 @@ static void update_state(UIState *s) {
|
||||
}
|
||||
if (sm.updated("frogpilotCarControl")) {
|
||||
auto frogpilotCarControl = sm["frogpilotCarControl"].getFrogpilotCarControl();
|
||||
if (scene.always_on_lateral) {
|
||||
scene.always_on_lateral_active = !scene.enabled && frogpilotCarControl.getAlwaysOnLateral();
|
||||
}
|
||||
}
|
||||
if (sm.updated("frogpilotPlan")) {
|
||||
auto frogpilotPlan = sm["frogpilotPlan"].getFrogpilotPlan();
|
||||
@@ -243,6 +246,8 @@ void ui_update_frogpilot_params(UIState *s) {
|
||||
Params params = Params();
|
||||
UIScene &scene = s->scene;
|
||||
|
||||
scene.always_on_lateral = params.getBool("AlwaysOnLateral");
|
||||
|
||||
bool custom_onroad_ui = params.getBool("CustomUI");
|
||||
scene.acceleration_path = custom_onroad_ui && params.getBool("AccelerationPath");
|
||||
|
||||
@@ -257,6 +262,8 @@ void UIState::updateStatus() {
|
||||
auto state = controls_state.getState();
|
||||
if (state == cereal::ControlsState::OpenpilotState::PRE_ENABLED || state == cereal::ControlsState::OpenpilotState::OVERRIDING) {
|
||||
status = STATUS_OVERRIDE;
|
||||
} else if (scene.always_on_lateral_active) {
|
||||
status = STATUS_LATERAL_ACTIVE;
|
||||
} else {
|
||||
status = controls_state.getEnabled() ? STATUS_ENGAGED : STATUS_DISENGAGED;
|
||||
}
|
||||
|
||||
@@ -107,6 +107,7 @@ typedef enum UIStatus {
|
||||
STATUS_ENGAGED,
|
||||
|
||||
// FrogPilot statuses
|
||||
STATUS_LATERAL_ACTIVE,
|
||||
} UIStatus;
|
||||
|
||||
enum PrimeType {
|
||||
@@ -125,6 +126,7 @@ const QColor bg_colors [] = {
|
||||
[STATUS_ENGAGED] = QColor(0x17, 0x86, 0x44, 0xf1),
|
||||
|
||||
// FrogPilot colors
|
||||
[STATUS_LATERAL_ACTIVE] = QColor(0x0a, 0xba, 0xb5, 0xf1),
|
||||
};
|
||||
|
||||
static std::map<cereal::ControlsState::AlertStatus, QColor> alert_colors = {
|
||||
@@ -168,6 +170,8 @@ typedef struct UIScene {
|
||||
|
||||
// FrogPilot variables
|
||||
bool acceleration_path;
|
||||
bool always_on_lateral;
|
||||
bool always_on_lateral_active;
|
||||
bool enabled;
|
||||
bool experimental_mode;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user