Controls - Longitudinal Tuning - Traffic Mode

Enable the ability to activate 'Traffic Mode' by holding down the 'distance' button for 2.5 seconds. When 'Traffic Mode' is active the onroad UI will turn red and openpilot will drive catered towards stop and go traffic.
This commit is contained in:
FrogAi
2024-05-12 20:27:18 -07:00
parent b55b128677
commit dbe15596a1
11 changed files with 43 additions and 13 deletions
+7 -1
View File
@@ -402,7 +402,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 (trafficModeActive) {
p.setPen(QPen(redColor(), 10));
} else {
p.setPen(QPen(whiteColor(75), 6));
}
p.setBrush(blackColor(166));
drawRoundedRect(p, set_speed_rect, top_radius, top_radius, bottom_radius, bottom_radius);
@@ -794,6 +798,8 @@ void AnnotatedCameraWidget::updateFrogPilotWidgets() {
mapOpen = scene.map_open;
onroadDistanceButton = scene.onroad_distance_button;
trafficModeActive = scene.traffic_mode_active;
}
void AnnotatedCameraWidget::paintFrogPilotWidgets(QPainter &p) {
+1
View File
@@ -152,6 +152,7 @@ private:
bool onroadDistanceButton;
bool showAlwaysOnLateralStatusBar;
bool showConditionalExperimentalStatusBar;
bool trafficModeActive;
float accelerationConversion;
float distanceConversion;
+3
View File
@@ -224,6 +224,7 @@ static void update_state(UIState *s) {
if (sm.updated("frogpilotCarControl")) {
auto frogpilotCarControl = sm["frogpilotCarControl"].getFrogpilotCarControl();
scene.always_on_lateral_active = !scene.enabled && frogpilotCarControl.getAlwaysOnLateral();
scene.traffic_mode_active = frogpilotCarControl.getTrafficModeActive();
}
if (sm.updated("frogpilotCarState")) {
auto frogpilotCarState = sm["frogpilotCarState"].getFrogpilotCarState();
@@ -284,6 +285,8 @@ void UIState::updateStatus() {
status = STATUS_OVERRIDE;
} else if (scene.always_on_lateral_active) {
status = STATUS_ALWAYS_ON_LATERAL_ACTIVE;
} else if (scene.traffic_mode_active && scene.enabled) {
status = STATUS_TRAFFIC_MODE_ACTIVE;
} else {
status = controls_state.getEnabled() ? STATUS_ENGAGED : STATUS_DISENGAGED;
}
+4
View File
@@ -119,6 +119,7 @@ typedef enum UIStatus {
STATUS_CONDITIONAL_OVERRIDDEN,
STATUS_EXPERIMENTAL_MODE_ACTIVE,
STATUS_NAVIGATION_ACTIVE,
STATUS_TRAFFIC_MODE_ACTIVE,
} UIStatus;
enum PrimeType {
@@ -141,6 +142,7 @@ const QColor bg_colors [] = {
[STATUS_CONDITIONAL_OVERRIDDEN] = QColor(0xff, 0xff, 0x00, 0xf1),
[STATUS_EXPERIMENTAL_MODE_ACTIVE] = QColor(0xda, 0x6f, 0x25, 0xf1),
[STATUS_NAVIGATION_ACTIVE] = QColor(0x31, 0xa1, 0xee, 0xf1),
[STATUS_TRAFFIC_MODE_ACTIVE] = QColor(0xc9, 0x22, 0x31, 0xf1),
};
static std::map<cereal::ControlsState::AlertStatus, QColor> alert_colors = {
@@ -197,6 +199,8 @@ typedef struct UIScene {
bool show_aol_status_bar;
bool show_cem_status_bar;
bool tethering_enabled;
bool traffic_mode;
bool traffic_mode_active;
bool use_kaofui_icons;
int alert_size;