Compare commits

..

32 Commits

Author SHA1 Message Date
royjr 743aa8e736 Merge branch 'master' into hyundai-radar-toggle 2025-10-10 00:09:54 -04:00
royjr 5847256371 Update opendbc_repo 2025-10-10 00:09:37 -04:00
royjr c13f909390 Update opendbc_repo 2025-10-09 01:30:54 -04:00
royjr f1de835d17 Update opendbc_repo 2025-10-09 01:11:07 -04:00
royjr 76ddb20cd5 Merge branch 'master' into hyundai-radar-toggle 2025-10-09 01:10:40 -04:00
royjr ede7f70ddc Merge branch 'master' into hyundai-radar-toggle 2025-10-08 23:04:21 -04:00
royjr 46c3047fa7 Update opendbc_repo 2025-10-08 23:04:16 -04:00
royjr cf5b5c666d Merge branch 'master' into hyundai-radar-toggle 2025-09-30 13:57:57 -04:00
royjr 03b56d6f09 Update opendbc_repo 2025-09-30 13:57:52 -04:00
royjr ab180ce1e5 Update opendbc_repo 2025-09-22 23:13:42 -04:00
royjr e0d8bc88b2 Update opendbc_repo 2025-09-22 00:33:12 -04:00
royjr 1dc45adb1c Merge branch 'master' into hyundai-radar-toggle 2025-09-22 00:28:40 -04:00
royjr c3bd613885 Merge branch 'master' into hyundai-radar-toggle 2025-09-20 01:56:28 -04:00
royjr 55edb4efcb Update opendbc_repo 2025-09-20 01:56:23 -04:00
royjr 7ff9b28c94 Merge branch 'master' into hyundai-radar-toggle 2025-08-24 16:57:46 -04:00
royjr 5f9d340d7b Update opendbc_repo 2025-08-24 16:57:37 -04:00
royjr e82b47cb70 Update opendbc_repo 2025-08-22 12:03:48 -04:00
royjr 10b5e58558 Merge branch 'master' into hyundai-radar-toggle 2025-08-22 11:47:43 -04:00
royjr 116936341f Update opendbc_repo 2025-08-22 11:41:48 -04:00
royjr 8d5bd92d51 Update opendbc_repo 2025-08-14 22:13:26 -04:00
royjr 4453dba6ed Update opendbc_repo 2025-08-13 23:03:43 -04:00
royjr cc20313815 fix param 2025-08-13 20:38:33 -04:00
royjr 3b30b93bbb Merge branch 'master' into hyundai-radar-toggle 2025-08-13 18:34:52 -04:00
royjr 5d9de36d40 Update opendbc_repo 2025-08-13 18:31:10 -04:00
royjr a91b97b89a Set RADAR_OFF flag for Hyundai when radar is off
Adds logic to set the RADAR_OFF flag in CP_SP.flags when the Hyundai radar type is set to OFF. This ensures the correct flag is applied for vehicles with radar disabled.
2025-07-01 02:09:53 -04:00
royjr ec4e2ec3c1 Update opendbc_repo 2025-07-01 02:09:48 -04:00
royjr 1f49367380 Merge branch 'master-new' into hyundai-radar-toggle 2025-07-01 01:10:33 -04:00
royjr 040f81fc91 Update opendbc_repo 2025-07-01 01:10:02 -04:00
royjr 5253b33b7a buttonClicked 2025-06-03 01:34:18 -04:00
royjr fc46a0ed7f Update opendbc_repo 2025-06-03 01:18:21 -04:00
royjr 8056a797c7 Merge branch 'master-new' into hyundai-radar-toggle 2025-06-03 01:17:26 -04:00
royjr a492625927 init 2025-05-20 01:34:50 -04:00
44 changed files with 429 additions and 1059 deletions
+5 -11
View File
@@ -150,7 +150,6 @@ struct LongitudinalPlanSP @0xf35cc4560bbf6ec2 {
aTarget @5 :Float32;
events @6 :List(OnroadEventSP.Event);
e2eAlerts @7 :E2eAlerts;
accelPersonality @8 :AccelerationPersonality;
struct DynamicExperimentalControl {
state @0 :DynamicExperimentalControlState;
@@ -253,11 +252,6 @@ struct LongitudinalPlanSP @0xf35cc4560bbf6ec2 {
greenLightAlert @0 :Bool;
leadDepartAlert @1 :Bool;
}
enum AccelerationPersonality {
sport @0;
normal @1;
eco @2;
}
}
struct OnroadEventSP @0xda96579883444c35 {
@@ -412,11 +406,11 @@ struct ModelDataV2SP @0xa1680744031fdb2d {
laneTurnDirection @0 :TurnDirection;
}
enum TurnDirection {
none @0;
turnLeft @1;
turnRight @2;
}
enum TurnDirection {
none @0;
turnLeft @1;
turnRight @2;
}
struct CustomReserved10 @0xcb9fd56c7057593a {
}
+1 -4
View File
@@ -130,7 +130,6 @@ inline static std::unordered_map<std::string, ParamKeyAttributes> keys = {
{"Version", {PERSISTENT, STRING}},
// --- sunnypilot params --- //
{"AccelPersonality", {PERSISTENT | BACKUP, INT, std::to_string(static_cast<int>(cereal::LongitudinalPlanSP::AccelerationPersonality::NORMAL))}},
{"ApiCache_DriveStats", {PERSISTENT, JSON}},
{"AutoLaneChangeBsmDelay", {PERSISTENT | BACKUP, BOOL, "0"}},
{"AutoLaneChangeTimer", {PERSISTENT | BACKUP, INT, "0"}},
@@ -172,9 +171,6 @@ inline static std::unordered_map<std::string, ParamKeyAttributes> keys = {
{"ShowTurnSignals", {PERSISTENT | BACKUP, BOOL, "0"}},
{"StandstillTimer", {PERSISTENT | BACKUP, BOOL, "0"}},
{"TrueVEgoUI", {PERSISTENT | BACKUP, BOOL, "0"}},
{"VibePersonalityEnabled", {PERSISTENT | BACKUP, BOOL, "0"}},
{"VibeAccelPersonalityEnabled", {PERSISTENT | BACKUP, BOOL, "0"}},
{"VibeFollowPersonalityEnabled", {PERSISTENT | BACKUP, BOOL, "0"}},
// MADS params
{"Mads", {PERSISTENT | BACKUP, BOOL, "1"}},
@@ -209,6 +205,7 @@ inline static std::unordered_map<std::string, ParamKeyAttributes> keys = {
// sunnypilot car specific params
{"HyundaiLongitudinalTuning", {PERSISTENT | BACKUP, INT, "0"}},
{"HyundaiRadar", {PERSISTENT | BACKUP, INT, "0"}},
{"DynamicExperimentalControl", {PERSISTENT | BACKUP, BOOL, "0"}},
{"BlindSpot", {PERSISTENT | BACKUP, BOOL, "0"}},
@@ -10,8 +10,6 @@ from openpilot.common.swaglog import cloudlog
from openpilot.selfdrive.modeld.constants import index_function
from openpilot.selfdrive.controls.radard import _LEAD_ACCEL_TAU
from openpilot.sunnypilot.selfdrive.controls.lib.vibe_personality.vibe_personality import VibePersonalityController
if __name__ == '__main__': # generating code
from openpilot.third_party.acados.acados_template import AcadosModel, AcadosOcp, AcadosOcpSolver
else:
@@ -230,7 +228,6 @@ class LongitudinalMpc:
self.solver = AcadosOcpSolverCython(MODEL_NAME, ACADOS_SOLVER_TYPE, N)
self.reset()
self.source = SOURCES[2]
self.vibe_controller = VibePersonalityController()
def reset(self):
# self.solver = AcadosOcpSolverCython(MODEL_NAME, ACADOS_SOLVER_TYPE, N)
@@ -331,18 +328,10 @@ class LongitudinalMpc:
return lead_xv
def update(self, radarstate, v_cruise, x, v, a, j, personality=log.LongitudinalPersonality.standard):
t_follow = get_T_FOLLOW(personality)
v_ego = self.x0[1]
# Get following distance
t_follow_vibe = self.vibe_controller.get_follow_distance_multiplier(v_ego)
t_follow = t_follow_vibe if t_follow_vibe is not None else get_T_FOLLOW(personality)
self.status = radarstate.leadOne.status or radarstate.leadTwo.status
# Get acceleration limits
accel_limits = self.vibe_controller.get_accel_limits(v_ego)
a_cruise_min = accel_limits[0] if accel_limits is not None else CRUISE_MIN_ACCEL
lead_xv_0 = self.process_lead(radarstate.leadOne)
lead_xv_1 = self.process_lead(radarstate.leadTwo)
@@ -361,7 +350,7 @@ class LongitudinalMpc:
# Fake an obstacle for cruise, this ensures smooth acceleration to set speed
# when the leads are no factor.
v_lower = v_ego + (T_IDXS * a_cruise_min * 1.05)
v_lower = v_ego + (T_IDXS * CRUISE_MIN_ACCEL * 1.05)
# TODO does this make sense when max_a is negative?
v_upper = v_ego + (T_IDXS * CRUISE_MAX_ACCEL * 1.05)
v_cruise_clipped = np.clip(v_cruise * np.ones(N+1),
@@ -416,7 +405,7 @@ class LongitudinalMpc:
if any((lead_0_obstacle - get_safe_obstacle_distance(self.x_sol[:,1], t_follow))- self.x_sol[:,0] < 0.0):
self.source = 'lead0'
if any((lead_1_obstacle - get_safe_obstacle_distance(self.x_sol[:,1], t_follow))- self.x_sol[:,0] < 0.0) and \
(lead_1_obstacle[0] - lead_0_obstacle[0]):
(lead_1_obstacle[0] - lead_0_obstacle[0]):
self.source = 'lead1'
def run(self):
@@ -124,11 +124,7 @@ class LongitudinalPlanner(LongitudinalPlannerSP):
prev_accel_constraint = not (reset_state or sm['carState'].standstill)
if mode == 'acc':
accel_limits = self.vibe_controller.get_accel_limits(v_ego)
if accel_limits is not None:
accel_clip = [ACCEL_MIN, accel_limits[1]]
else:
accel_clip = [ACCEL_MIN, get_max_accel(v_ego)]
accel_clip = [ACCEL_MIN, get_max_accel(v_ego)]
steer_angle_without_offset = sm['carState'].steeringAngleDeg - sm['liveParameters'].angleOffsetDeg
accel_clip = limit_accel_in_turns(v_ego, steer_angle_without_offset, accel_clip, self.CP)
else:
+1 -19
View File
@@ -92,15 +92,7 @@ TogglesPanel::TogglesPanel(SettingsWindow *parent) : ListWidget(parent) {
"your steering wheel distance button."),
"../assets/icons/speed_limit.png",
longi_button_texts);
// accel controller
std::vector<QString> accel_personality_texts{tr("Sport"), tr("Normal"), tr("Eco")};
accel_personality_setting = new ButtonParamControlSP("AccelPersonality", tr("Acceleration Personality"),
tr("Normal is recommended. In sport mode, sunnypilot will provide aggressive acceleration for a dynamic driving experience. "
"In eco mode, sunnypilot will apply smoother and more relaxed acceleration. On supported cars, you can cycle through these "
"acceleration personality within Onroad Settings on the driving screen."),
"",
accel_personality_texts);
accel_personality_setting->showDescription();
// set up uiState update for personality setting
QObject::connect(uiState(), &UIState::uiUpdate, this, &TogglesPanel::updateState);
@@ -128,7 +120,6 @@ TogglesPanel::TogglesPanel(SettingsWindow *parent) : ListWidget(parent) {
// insert longitudinal personality after NDOG toggle
if (param == "DisengageOnAccelerator") {
addItem(long_personality_setting);
addItem(accel_personality_setting);
}
}
@@ -149,13 +140,6 @@ void TogglesPanel::updateState(const UIState &s) {
}
uiState()->scene.personality = personality;
}
if (sm.updated("longitudinalPlanSP")) {
auto accel_personality = sm["longitudinalPlanSP"].getLongitudinalPlanSP().getAccelPersonality();
if (accel_personality != s.scene.accel_personality && s.scene.started && isVisible()) {
accel_personality_setting->setCheckedButton(static_cast<int>(accel_personality));
}
uiState()->scene.accel_personality = accel_personality;
}
}
void TogglesPanel::expandToggleDescription(const QString &param) {
@@ -202,12 +186,10 @@ void TogglesPanel::updateToggles() {
experimental_mode_toggle->setEnabled(true);
experimental_mode_toggle->setDescription(e2e_description);
long_personality_setting->setEnabled(true);
accel_personality_setting->setEnabled(true);
} else {
// no long for now
experimental_mode_toggle->setEnabled(false);
long_personality_setting->setEnabled(false);
accel_personality_setting->setEnabled(true);
params.remove("ExperimentalMode");
const QString unavailable = tr("Experimental mode is currently unavailable on this car since the car's stock ACC is used for longitudinal control.");
-1
View File
@@ -88,7 +88,6 @@ protected:
Params params;
std::map<std::string, ParamControl*> toggles;
ButtonParamControl *long_personality_setting;
ButtonParamControl *accel_personality_setting;
virtual void updateToggles();
};
+167
View File
@@ -34,6 +34,7 @@ void ModelRenderer::draw(QPainter &painter, const QRect &surface_rect) {
drawLead(painter, lead_two, lead_vertices[1], surface_rect);
}
}
drawLeadStatus(painter, surface_rect.height(), surface_rect.width());
painter.restore();
}
@@ -174,6 +175,172 @@ QColor ModelRenderer::blendColors(const QColor &start, const QColor &end, float
}
void ModelRenderer::drawLeadStatus(QPainter &painter, int height, int width) {
auto *s = uiState();
auto &sm = *(s->sm);
if (!sm.alive("radarState")) return;
const auto &radar_state = sm["radarState"].getRadarState();
const auto &lead_one = radar_state.getLeadOne();
const auto &lead_two = radar_state.getLeadTwo();
// Check if we have any active leads
bool has_lead_one = lead_one.getStatus();
bool has_lead_two = lead_two.getStatus();
if (!has_lead_one && !has_lead_two) {
// Fade out status display
lead_status_alpha = std::max(0.0f, lead_status_alpha - 0.05f);
if (lead_status_alpha <= 0.0f) return;
} else {
// Fade in status display
lead_status_alpha = std::min(1.0f, lead_status_alpha + 0.1f);
}
// Draw status for each lead vehicle under its chevron
if (true) {
drawLeadStatusAtPosition(painter, lead_one, lead_vertices[0], height, width, "L1");
}
if (has_lead_two && std::abs(lead_one.getDRel() - lead_two.getDRel()) > 3.0) {
drawLeadStatusAtPosition(painter, lead_two, lead_vertices[1], height, width, "L2");
}
}
void ModelRenderer::drawLeadStatusAtPosition(QPainter &painter,
const cereal::RadarState::LeadData::Reader &lead_data,
const QPointF &chevron_pos,
int height, int width,
const QString &label) {
float d_rel = lead_data.getDRel();
float v_rel = lead_data.getVRel();
auto *s = uiState();
auto &sm = *(s->sm);
float v_ego = sm["carState"].getCarState().getVEgo();
int chevron_data = std::atoi(Params().get("ChevronInfo").c_str());
// Calculate chevron size (same logic as drawLead)
float sz = std::clamp((25 * 30) / (d_rel / 3 + 30), 15.0f, 30.0f) * 2.35;
QFont content_font = painter.font();
content_font.setPixelSize(35);
content_font.setBold(true);
painter.setFont(content_font);
QFontMetrics fm(content_font);
bool is_metric = s->scene.is_metric;
QStringList text_lines;
const int chevron_types = 3;
const int chevron_all = chevron_types + 1; // All metrics (value 4)
QStringList chevron_text[chevron_types];
int position;
float val;
// Distance display (chevron_data == 1 or all)
if (chevron_data == 1 || chevron_data == chevron_all) {
position = 0;
val = std::max(0.0f, d_rel);
QString distance_unit = is_metric ? "m" : "ft";
if (!is_metric) {
val *= 3.28084f; // Convert meters to feet
}
chevron_text[position].append(QString::number(val, 'f', 0) + " " + distance_unit);
}
// Absolute velocity display (chevron_data == 2 or all)
if (chevron_data == 2 || chevron_data == chevron_all) {
position = (chevron_data == 2) ? 0 : 1;
val = std::max(0.0f, (v_rel + v_ego) * (is_metric ? static_cast<float>(MS_TO_KPH) : static_cast<float>(MS_TO_MPH)));
chevron_text[position].append(QString::number(val, 'f', 0) + " " + (is_metric ? "km/h" : "mph"));
}
// Time-to-contact display (chevron_data == 3 or all)
if (chevron_data == 3 || chevron_data == chevron_all) {
position = (chevron_data == 3) ? 0 : 2;
val = (d_rel > 0 && v_ego > 0) ? std::max(0.0f, d_rel / v_ego) : 0.0f;
QString ttc_str = (val > 0 && val < 200) ? QString::number(val, 'f', 1) + "s" : "---";
chevron_text[position].append(ttc_str);
}
// Collect all non-empty text lines
for (int i = 0; i < chevron_types; ++i) {
if (!chevron_text[i].isEmpty()) {
text_lines.append(chevron_text[i]);
}
}
// If no text to display, return early
if (text_lines.isEmpty()) {
return;
}
// Text box dimensions
float str_w = 150; // Width of text area
float str_h = 45; // Height per line
// Position text below chevron, centered horizontally
float text_x = chevron_pos.x() - str_w / 2;
float text_y = chevron_pos.y() + sz + 15;
// Clamp to screen bounds
text_x = std::clamp(text_x, 10.0f, (float)width - str_w - 10);
// Shadow offset
QPoint shadow_offset(2, 2);
// Draw each line of text with shadow
for (int i = 0; i < text_lines.size(); ++i) {
if (!text_lines[i].isEmpty()) {
QRect textRect(text_x, text_y + (i * str_h), str_w, str_h);
// Draw shadow
painter.setPen(QColor(0x0, 0x0, 0x0, (int)(200 * lead_status_alpha)));
painter.drawText(textRect.translated(shadow_offset.x(), shadow_offset.y()),
Qt::AlignBottom | Qt::AlignHCenter, text_lines[i]);
// Determine text color based on content and danger level
QColor text_color;
// Check if this is a distance line (contains 'm' or 'ft')
if (text_lines[i].contains("m") || text_lines[i].contains("ft")) {
if (d_rel < 20.0f) {
text_color = QColor(255, 80, 80, (int)(255 * lead_status_alpha)); // Red - danger
} else if (d_rel < 40.0f) {
text_color = QColor(255, 200, 80, (int)(255 * lead_status_alpha)); // Yellow - caution
} else {
text_color = QColor(80, 255, 120, (int)(255 * lead_status_alpha)); // Green - safe
}
}
// Enhanced color coding for time-to-contact
else if (text_lines[i].contains("s") && !text_lines[i].contains("---")) {
float ttc_val = text_lines[i].left(text_lines[i].length() - 1).toFloat();
if (ttc_val < 3.0f) {
text_color = QColor(255, 80, 80, (int)(255 * lead_status_alpha)); // Red - urgent
} else if (ttc_val < 6.0f) {
text_color = QColor(255, 200, 80, (int)(255 * lead_status_alpha)); // Yellow - caution
} else {
text_color = QColor(0xff, 0xff, 0xff, (int)(255 * lead_status_alpha)); // White - safe
}
}
else {
text_color = QColor(0xff, 0xff, 0xff, (int)(255 * lead_status_alpha)); // White for other lines
}
// Draw main text
painter.setPen(text_color);
painter.drawText(textRect, Qt::AlignBottom | Qt::AlignHCenter, text_lines[i]);
}
}
// Reset pen
painter.setPen(Qt::NoPen);
}
void ModelRenderer::drawLead(QPainter &painter, const cereal::RadarState::LeadData::Reader &lead_data,
const QPointF &vd, const QRect &surface_rect) {
const float speedBuff = 10.;
+10
View File
@@ -34,6 +34,12 @@ protected:
bool mapToScreen(float in_x, float in_y, float in_z, QPointF *out);
void mapLineToPolygon(const cereal::XYZTData::Reader &line, float y_off, float z_off,
QPolygonF *pvd, int max_idx, bool allow_invert = true);
void drawLeadStatus(QPainter &painter, int height, int width);
void drawLeadStatusAtPosition(QPainter &painter,
const cereal::RadarState::LeadData::Reader &lead_data,
const QPointF &chevron_pos,
int height, int width,
const QString &label);
void drawLead(QPainter &painter, const cereal::RadarState::LeadData::Reader &lead_data, const QPointF &vd, const QRect &surface_rect);
void update_leads(const cereal::RadarState::Reader &radar_state, const cereal::XYZTData::Reader &line);
virtual void update_model(const cereal::ModelDataV2::Reader &model, const cereal::RadarState::LeadData::Reader &lead);
@@ -59,4 +65,8 @@ protected:
Eigen::Matrix3f car_space_transform = Eigen::Matrix3f::Zero();
QRectF clip_region;
float lead_status_alpha = 0.0f;
QPointF lead_status_pos;
QString lead_status_text;
QColor lead_status_color;
};
-10
View File
@@ -92,16 +92,6 @@ bool MainWindow::eventFilter(QObject *obj, QEvent *event) {
// ignore events when device is awakened by resetInteractiveTimeout
ignore = !device()->isAwake();
device()->resetInteractiveTimeout();
#ifdef SUNNYPILOT
auto *s_sp = uiStateSP();
bool onroadScreenControl = s_sp->scene.onroadScreenOffControl;
bool started = s_sp->scene.started;
bool timerExpired = (s_sp->scene.onroadScreenOffTimer == 0);
ignore |= (onroadScreenControl and started and timerExpired);
s_sp->reset_onroad_sleep_timer();
#endif
break;
}
default:
-4
View File
@@ -7,10 +7,6 @@
#include "selfdrive/ui/qt/offroad/onboarding.h"
#include "selfdrive/ui/qt/offroad/settings.h"
#ifdef SUNNYPILOT
#include "selfdrive/ui/sunnypilot/ui.h"
#endif
class MainWindow : public QWidget {
Q_OBJECT
@@ -56,13 +56,14 @@ DeveloperPanelSP::DeveloperPanelSP(SettingsWindow *parent) : DeveloperPanel(pare
addItem(errorLogBtn);
QObject::connect(uiState(), &UIState::offroadTransition, this, &DeveloperPanelSP::updateToggles);
is_release = params.getBool("IsReleaseBranch");
is_tested = params.getBool("IsTestedBranch");
is_development = params.getBool("IsDevelopmentBranch");
}
void DeveloperPanelSP::updateToggles(bool offroad) {
bool disable_updates = params.getBool("DisableUpdates");
bool is_release = params.getBool("IsReleaseBranch");
bool is_tested = params.getBool("IsTestedBranch");
bool is_development = params.getBool("IsDevelopmentBranch");
prebuiltToggle->setVisible(!is_release && !is_tested && !is_development);
prebuiltToggle->setEnabled(disable_updates);
@@ -22,6 +22,9 @@ private:
ParamControlSP *prebuiltToggle;
Params params;
ParamControlSP *showAdvancedControls;
bool is_development;
bool is_release;
bool is_tested;
private slots:
void updateToggles(bool offroad);
@@ -88,7 +88,7 @@ DevicePanelSP::DevicePanelSP(SettingsWindowSP *parent) : DevicePanel(parent) {
connect(toggleDeviceBootMode, &ButtonParamControlSP::buttonClicked, this, [=](int index) {
params.put("DeviceBootMode", QString::number(index).toStdString());
updateState(offroad);
updateState();
});
addItem(device_grid_layout);
@@ -122,7 +122,7 @@ DevicePanelSP::DevicePanelSP(SettingsWindowSP *parent) : DevicePanel(parent) {
addItem(power_group_layout);
always_enabled_btns = {
std::vector always_enabled_btns = {
rebootBtn,
poweroffBtn,
offroadBtn,
@@ -130,7 +130,17 @@ DevicePanelSP::DevicePanelSP(SettingsWindowSP *parent) : DevicePanel(parent) {
buttons["onroadUploadsBtn"],
};
QObject::connect(uiState(), &UIState::offroadTransition, this, &DevicePanelSP::updateState);
QObject::connect(uiState(), &UIState::offroadTransition, [=](bool _offroad) {
for (auto btn : findChildren<PushButtonSP*>()) {
bool always_enabled = std::find(always_enabled_btns.begin(), always_enabled_btns.end(), btn) != always_enabled_btns.end();
if (!always_enabled) {
btn->setEnabled(offroad);
}
}
offroad = _offroad;
updateState();
});
}
void DevicePanelSP::setOffroadMode() {
@@ -154,7 +164,7 @@ void DevicePanelSP::setOffroadMode() {
ConfirmationDialog::alert(tr("Disengage to Enter Always Offroad Mode"), this);
}
updateState(offroad);
updateState();
}
void DevicePanelSP::resetSettings() {
@@ -171,16 +181,12 @@ void DevicePanelSP::resetSettings() {
}
void DevicePanelSP::showEvent(QShowEvent *event) {
updateState(offroad);
updateState();
}
void DevicePanelSP::updateState(bool _offroad) {
for (auto btn : findChildren<PushButtonSP*>()) {
bool always_enabled = std::find(always_enabled_btns.begin(), always_enabled_btns.end(), btn) != always_enabled_btns.end();
if (!always_enabled) {
btn->setEnabled(_offroad);
}
void DevicePanelSP::updateState() {
if (!isVisible()) {
return;
}
bool offroad_mode_param = params.getBool("OffroadMode");
@@ -198,6 +204,4 @@ void DevicePanelSP::updateState(bool _offroad) {
} else {
AddWidgetAt(0, offroadBtn);
}
offroad = _offroad;
}
@@ -23,7 +23,7 @@ public:
explicit DevicePanelSP(SettingsWindowSP *parent = 0);
void showEvent(QShowEvent *event) override;
void setOffroadMode();
void updateState(bool _offroad);
void updateState();
void resetSettings();
private:
@@ -34,8 +34,6 @@ private:
QVBoxLayout *power_group_layout;
bool offroad;
std::vector<PushButtonSP*> always_enabled_btns = {};
const QString alwaysOffroadStyle = R"(
PushButtonSP {
border-radius: 20px;
@@ -158,7 +158,3 @@ void SpeedLimitSettings::refresh() {
void SpeedLimitSettings::showEvent(QShowEvent *event) {
refresh();
}
void SpeedLimitSettings::hideEvent(QHideEvent *event) {
setCurrentWidget(subPanelFrame);
}
@@ -21,7 +21,6 @@ public:
SpeedLimitSettings(QWidget *parent = nullptr);
void refresh();
void showEvent(QShowEvent *event) override;
void hideEvent(QHideEvent *event) override;
signals:
void backPress();
@@ -75,35 +75,6 @@ LongitudinalPanel::LongitudinalPanel(QWidget *parent) : QWidget(parent) {
main_layout->setCurrentWidget(cruisePanelScreen);
});
// Vibe Personality Controller
vibePersonalityControl = new ParamControlSP("VibePersonalityEnabled",
tr("Vibe Personality Controller"),
tr("Advanced driving personality system with separate controls for acceleration behavior (Eco/Normal/Sport) and following distance/braking (Relaxed/Standard/Aggressive). "
"Customize your driving experience with independent acceleration and distance personalities."),
"../assets/offroad/icon_shell.png");
list->addItem(vibePersonalityControl);
connect(vibePersonalityControl, &ParamControlSP::toggleFlipped, [=]() {
refresh(offroad);
});
// Vibe Acceleration Personality
vibeAccelPersonalityControl = new ParamControlSP("VibeAccelPersonalityEnabled",
tr("Acceleration Personality"),
tr("Controls acceleration behavior: Eco (efficient), Normal (balanced), Sport (responsive). "
"Adjust how aggressively the vehicle accelerates while maintaining smooth operation."),
"../assets/offroad/icon_shell.png");
list->addItem(vibeAccelPersonalityControl);
// Vibe Following Distance Personality
vibeFollowPersonalityControl = new ParamControlSP("VibeFollowPersonalityEnabled",
tr("Following Distance Personality"),
tr("Controls following distance and braking behavior: Relaxed (longer distance, gentler braking), Standard (balanced), Aggressive (shorter distance, firmer braking). "
"Fine-tune your comfort level in traffic situations."),
"../assets/offroad/icon_shell.png");
list->addItem(vibeFollowPersonalityControl);
main_layout->addWidget(cruisePanelScreen);
main_layout->addWidget(speedLimitScreen);
main_layout->setCurrentWidget(cruisePanelScreen);
@@ -115,10 +86,6 @@ void LongitudinalPanel::showEvent(QShowEvent *event) {
refresh(offroad);
}
void LongitudinalPanel::hideEvent(QHideEvent *event) {
main_layout->setCurrentWidget(cruisePanelScreen);
}
void LongitudinalPanel::refresh(bool _offroad) {
auto cp_bytes = params.get("CarParamsPersistent");
auto cp_sp_bytes = params.get("CarParamsSPPersistent");
@@ -164,14 +131,6 @@ void LongitudinalPanel::refresh(bool _offroad) {
intelligentCruiseButtonManagement->toggleFlipped(false);
}
}
bool vibePersonalityEnabled = params.getBool("VibePersonalityEnabled");
if (vibePersonalityEnabled) {
vibeAccelPersonalityControl->setVisible(true);
vibeFollowPersonalityControl->setVisible(true);
} else {
vibeAccelPersonalityControl->setVisible(false);
vibeFollowPersonalityControl->setVisible(false);
}
bool icbm_allowed = intelligent_cruise_button_management_available && !has_longitudinal_control;
intelligentCruiseButtonManagement->setEnabled(icbm_allowed && offroad);
@@ -183,13 +142,6 @@ void LongitudinalPanel::refresh(bool _offroad) {
SmartCruiseControlVision->setEnabled(has_longitudinal_control || icbm_allowed);
SmartCruiseControlMap->setEnabled(has_longitudinal_control || icbm_allowed);
// Vibe Personality controls - always enabled for toggling
vibePersonalityControl->setEnabled(true);
vibeAccelPersonalityControl->setEnabled(true);
vibeFollowPersonalityControl->setEnabled(true);
vibePersonalityControl->refresh();
vibeAccelPersonalityControl->refresh();
vibeFollowPersonalityControl->refresh();
offroad = _offroad;
}
@@ -18,7 +18,6 @@ class LongitudinalPanel : public QWidget {
public:
explicit LongitudinalPanel(QWidget *parent = nullptr);
void showEvent(QShowEvent *event) override;
void hideEvent(QHideEvent *event) override;
void refresh(bool _offroad);
private:
@@ -37,8 +36,4 @@ private:
ParamControl *intelligentCruiseButtonManagement = nullptr;
SpeedLimitSettings *speedLimitScreen;
PushButtonSP *speedLimitSettings;
ParamControlSP *vibePersonalityControl;
ParamControlSP *vibeAccelPersonalityControl;
ParamControlSP *vibeFollowPersonalityControl;
};
@@ -21,7 +21,7 @@ SunnylinkPanel::SunnylinkPanel(QWidget *parent) : QFrame(parent) {
paramsRefresh(param_name, param_value);
});
is_sunnylink_enabled = params.getBool("SunnylinkEnabled");
is_sunnylink_enabled = Params().getBool("SunnylinkEnabled");
connect(uiStateSP(), &UIStateSP::sunnylinkRolesChanged, this, &SunnylinkPanel::updatePanel);
connect(uiStateSP(), &UIStateSP::sunnylinkDeviceUsersChanged, this, &SunnylinkPanel::updatePanel);
connect(uiStateSP(), &UIStateSP::offroadTransition, [=](bool offroad) {
@@ -272,7 +272,7 @@ void SunnylinkPanel::updatePanel() {
const auto sunnylinkDongleId = getSunnylinkDongleId().value_or(tr("N/A"));
sunnylinkEnabledBtn->setEnabled(!is_onroad);
is_sunnylink_enabled = params.getBool("SunnylinkEnabled");
is_sunnylink_enabled = Params().getBool("SunnylinkEnabled");
bool is_sub = uiStateSP()->isSunnylinkSponsor() && is_sunnylink_enabled;
auto max_current_sponsor_rule = uiStateSP()->sunnylinkSponsorRole();
auto role_name = max_current_sponsor_rule.getSponsorTierString();
@@ -20,6 +20,19 @@ HyundaiSettings::HyundaiSettings(QWidget *parent) : BrandSettingsInterface(paren
QObject::connect(longitudinalTuningToggle, &ButtonParamControlSP::buttonClicked, this, &HyundaiSettings::updateSettings);
list->addItem(longitudinalTuningToggle);
longitudinalTuningToggle->showDescription();
std::vector<QString> radar_tuning_texts{ tr("Off"), tr("Lead Only"), tr("Full Radar") };
radarToggle = new ButtonParamControl(
"HyundaiRadar",
tr("Radar Tracks"),
"",
"",
radar_tuning_texts,
500
);
QObject::connect(radarToggle, &ButtonParamControlSP::buttonClicked, this, &HyundaiSettings::updateSettings);
list->addItem(radarToggle);
radarToggle->showDescription();
}
void HyundaiSettings::updateSettings() {
@@ -54,4 +67,25 @@ void HyundaiSettings::updateSettings() {
longitudinalTuningToggle->setEnabled(!longitudinal_tuning_disabled);
longitudinalTuningToggle->setDescription(longitudinal_tuning_description);
longitudinalTuningToggle->showDescription();
auto radar_param = std::atoi(params.get("HyundaiRadar").c_str());
RadarOption radar_option;
if (radar_param == int(RadarOption::LEAD_ONLY)) {
radar_option = RadarOption::LEAD_ONLY;
} else if (radar_param == int(RadarOption::FULL_RADAR)) {
radar_option = RadarOption::FULL_RADAR;
} else {
radar_option = RadarOption::OFF;
}
bool radar_disabled = !offroad || !has_longitudinal_control;
QString radar_description = radarDescription(radar_option);
if (radar_disabled) {
radar_description = toggleDisableMsg(offroad, has_longitudinal_control);
}
radarToggle->setEnabled(!radar_disabled);
radarToggle->setDescription(radar_description);
radarToggle->showDescription();
}
@@ -20,6 +20,12 @@ enum class LongitudinalTuningOption {
PREDICTIVE,
};
enum class RadarOption {
OFF,
LEAD_ONLY,
FULL_RADAR,
};
class HyundaiSettings : public BrandSettingsInterface {
Q_OBJECT
@@ -30,6 +36,7 @@ public:
private:
bool has_longitudinal_control = false;
ButtonParamControl *longitudinalTuningToggle = nullptr;
ButtonParamControl *radarToggle = nullptr;
static QString toggleDisableMsg(bool _offroad, bool _has_longitudinal_control) {
if (!_has_longitudinal_control) {
@@ -62,4 +69,24 @@ private:
.arg(dynamic_str)
.arg(predictive_str);
}
static QString radarDescription(RadarOption option = RadarOption::OFF) {
QString off_str = tr("Off: Disables radar tracking. Vision-only vehicle detection.");
QString lead_only_str = tr("Lead Only: Tracks only the closest vehicle ahead.");
QString full_radar_str = tr("Full Radar: Tracks all nearby vehicles using radar.");
if (option == RadarOption::LEAD_ONLY) {
lead_only_str = "<font color='white'><b>" + lead_only_str + "</b></font>";
} else if (option == RadarOption::FULL_RADAR) {
full_radar_str = "<font color='white'><b>" + full_radar_str + "</b></font>";
} else {
off_str = "<font color='white'><b>" + off_str + "</b></font>";
}
return QString("%1<br><br>%2<br>%3<br>%4<br>")
.arg(tr("Configure how radar tracks surrounding vehicles — turn it off, track only the lead, or track all."))
.arg(off_str)
.arg(lead_only_str)
.arg(full_radar_str);
}
};
@@ -140,40 +140,6 @@ VisualsPanel::VisualsPanel(QWidget *parent) : QWidget(parent) {
vlayout->addWidget(sunnypilotScroller);
main_layout->addWidget(sunnypilotScreen);
QObject::connect(uiState(), &UIState::offroadTransition, this, &VisualsPanel::refreshLongitudinalStatus);
refreshLongitudinalStatus();
}
void VisualsPanel::refreshLongitudinalStatus() {
auto cp_bytes = params.get("CarParamsPersistent");
if (!cp_bytes.empty()) {
AlignedBuffer aligned_buf;
capnp::FlatArrayMessageReader cmsg(aligned_buf.align(cp_bytes.data(), cp_bytes.size()));
cereal::CarParams::Reader CP = cmsg.getRoot<cereal::CarParams>();
has_longitudinal_control = hasLongitudinalControl(CP);
} else {
has_longitudinal_control = false;
}
if (chevron_info_settings) {
QString chevronEnabledDescription = tr("Display useful metrics below the chevron that tracks the lead car (only applicable to cars with openpilot longitudinal control).");
QString chevronNoLongDescription = tr("This feature requires openpilot longitudinal control to be available.");
if (has_longitudinal_control) {
chevron_info_settings->setDescription(chevronEnabledDescription);
} else {
// Reset to "Off" when longitudinal not available
params.put("ChevronInfo", "0");
chevron_info_settings->setDescription(chevronNoLongDescription);
}
// Enable only when longitudinal is available
chevron_info_settings->setEnabled(has_longitudinal_control);
chevron_info_settings->refresh();
}
}
void VisualsPanel::paramsRefresh() {
@@ -19,7 +19,6 @@ public:
explicit VisualsPanel(QWidget *parent = nullptr);
void paramsRefresh();
void refreshLongitudinalStatus();
protected:
QStackedLayout* main_layout = nullptr;
@@ -30,6 +29,4 @@ protected:
ParamWatcher * param_watcher;
ButtonParamControlSP *chevron_info_settings;
ButtonParamControlSP *dev_ui_settings;
bool has_longitudinal_control = false;
};
@@ -18,10 +18,4 @@ void AnnotatedCameraWidgetSP::updateState(const UIState &s) {
void AnnotatedCameraWidgetSP::showEvent(QShowEvent *event) {
AnnotatedCameraWidget::showEvent(event);
ui_update_params_sp(uiState());
uiStateSP()->reset_onroad_sleep_timer(OnroadTimerStatusToggle::RESUME);
}
void AnnotatedCameraWidgetSP::hideEvent(QHideEvent *event) {
AnnotatedCameraWidget::hideEvent(event);
uiStateSP()->reset_onroad_sleep_timer(OnroadTimerStatusToggle::PAUSE);
}
@@ -18,5 +18,4 @@ public:
protected:
void showEvent(QShowEvent *event) override;
void hideEvent(QHideEvent* event) override;
};
+9 -38
View File
@@ -127,9 +127,6 @@ void HudRendererSP::updateState(const UIState &s) {
leftBlindspot = car_state.getLeftBlindspot();
rightBlindspot = car_state.getRightBlindspot();
showTurnSignals = s.scene.turn_signals;
carControlEnabled = car_control.getEnabled();
speedCluster = car_state.getCruiseState().getSpeedCluster() * speedConv;
}
void HudRendererSP::draw(QPainter &p, const QRect &surface_rect) {
@@ -688,23 +685,10 @@ void HudRendererSP::drawSetSpeedSP(QPainter &p, const QRect &surface_rect) {
}
}
// Draw "MAX" or carState.cruiseState.speedCluster (when ICBM is active) text
if (carControlEnabled) {
if (std::nearbyint(set_speed) != std::nearbyint(speedCluster)) {
icbm_active_counter = 3 * UI_FREQ;
} else if (icbm_active_counter > 0) {
icbm_active_counter--;
}
} else {
icbm_active_counter = 0;
}
int max_str_size = (icbm_active_counter != 0) ? 60 : 40;
int max_str_y = (icbm_active_counter != 0) ? 15 : 27;
QString max_str = (icbm_active_counter != 0) ? QString::number(std::nearbyint(speedCluster)) : tr("MAX");
p.setFont(InterFont(max_str_size, QFont::DemiBold));
// Draw "MAX" text
p.setFont(InterFont(40, QFont::DemiBold));
p.setPen(max_color);
p.drawText(set_speed_rect.adjusted(0, max_str_y, 0, 0), Qt::AlignTop | Qt::AlignHCenter, max_str);
p.drawText(set_speed_rect.adjusted(0, 27, 0, 0), Qt::AlignTop | Qt::AlignHCenter, tr("MAX"));
// Draw set speed
QString setSpeedStr = is_cruise_set ? QString::number(std::nearbyint(set_speed)) : "";
@@ -716,8 +700,9 @@ void HudRendererSP::drawSetSpeedSP(QPainter &p, const QRect &surface_rect) {
void HudRendererSP::drawE2eAlert(QPainter &p, const QRect &surface_rect, const QString &alert_alt_text) {
int size = devUiInfo > 0 ? e2e_alert_small : e2e_alert_large;
int x = surface_rect.center().x() + surface_rect.width() / 4;
int y = surface_rect.center().y() + 20;
int y = surface_rect.center().y() + 40;
x += devUiInfo > 0 ? 0 : 50;
y += devUiInfo > 0 ? 0 : 80;
QRect alertRect(x - size, y - size, size * 2, size * 2);
// Alert Circle
@@ -778,33 +763,19 @@ void HudRendererSP::drawCurrentSpeedSP(QPainter &p, const QRect &surface_rect) {
}
void HudRendererSP::drawBlinker(QPainter &p, const QRect &surface_rect) {
const bool hazard = leftBlinkerOn && rightBlinkerOn;
int blinkerStatus = hazard ? 2 : (leftBlinkerOn or rightBlinkerOn) ? 1 : 0;
if (!leftBlinkerOn && !rightBlinkerOn) {
blinkerFrameCounter = 0;
lastBlinkerStatus = 0;
return;
}
if (blinkerStatus != lastBlinkerStatus) {
blinkerFrameCounter = 0;
lastBlinkerStatus = blinkerStatus;
}
++blinkerFrameCounter;
const int BLINKER_COOLDOWN_FRAMES = UI_FREQ / 10;
if (blinkerFrameCounter < BLINKER_COOLDOWN_FRAMES) {
return;
}
const int circleRadius = 60;
const int arrowLength = 60;
const int x_gap = 160;
const int circleRadius = 44;
const int arrowLength = 44;
const int x_gap = 180;
const int y_offset = 272;
const int centerX = surface_rect.center().x();
const bool hazard = leftBlinkerOn && rightBlinkerOn;
const QPen bgBorder(Qt::white, 5);
const QPen arrowPen(Qt::NoPen);
-5
View File
@@ -114,10 +114,5 @@ private:
bool leftBlindspot;
bool rightBlindspot;
int blinkerFrameCounter;
int lastBlinkerStatus;
bool showTurnSignals;
bool carControlEnabled;
float speedCluster = 0;
int icbm_active_counter = 0;
};
+2 -137
View File
@@ -24,7 +24,7 @@ void ModelRendererSP::update_model(const cereal::ModelDataV2::Reader &model, con
void ModelRendererSP::drawPath(QPainter &painter, const cereal::ModelDataV2::Reader &model, const QRect &surface_rect) {
auto *s = uiState();
auto &sm = *(s->sm);
bool blindspot = s->scene.blindspot_ui;
bool blindspot = Params().getBool("BlindSpot");
if (blindspot) {
bool left_blindspot = sm["carState"].getCarState().getLeftBlindspot();
@@ -49,7 +49,7 @@ void ModelRendererSP::drawPath(QPainter &painter, const cereal::ModelDataV2::Rea
}
}
bool rainbow = s->scene.rainbow_mode;
bool rainbow = Params().getBool("RainbowMode");
//float v_ego = sm["carState"].getCarState().getVEgo();
if (rainbow) {
@@ -87,139 +87,4 @@ void ModelRendererSP::drawPath(QPainter &painter, const cereal::ModelDataV2::Rea
// Normal path rendering
ModelRenderer::drawPath(painter, model, surface_rect.height());
}
drawLeadStatus(painter, surface_rect.height(), surface_rect.width());
}
void ModelRendererSP::drawLeadStatus(QPainter &painter, int height, int width) {
auto *s = uiState();
auto &sm = *(s->sm);
bool longitudinal_control = sm["carParams"].getCarParams().getOpenpilotLongitudinalControl();
if (!longitudinal_control) {
lead_status_alpha = std::max(0.0f, lead_status_alpha - 0.05f);
return;
}
if (!sm.alive("radarState")) {
lead_status_alpha = std::max(0.0f, lead_status_alpha - 0.05f);
return;
}
const auto &radar_state = sm["radarState"].getRadarState();
const auto &lead_one = radar_state.getLeadOne();
const auto &lead_two = radar_state.getLeadTwo();
bool has_lead_one = lead_one.getStatus();
bool has_lead_two = lead_two.getStatus();
if (!has_lead_one && !has_lead_two) {
lead_status_alpha = std::max(0.0f, lead_status_alpha - 0.05f);
if (lead_status_alpha <= 0.0f) return;
} else {
lead_status_alpha = std::min(1.0f, lead_status_alpha + 0.1f);
}
if (has_lead_one) {
drawLeadStatusAtPosition(painter, lead_one, lead_vertices[0], height, width, "L1");
}
if (has_lead_two && std::abs(lead_one.getDRel() - lead_two.getDRel()) > 3.0) {
drawLeadStatusAtPosition(painter, lead_two, lead_vertices[1], height, width, "L2");
}
}
void ModelRendererSP::drawLeadStatusAtPosition(QPainter &painter,
const cereal::RadarState::LeadData::Reader &lead_data,
const QPointF &chevron_pos,
int height, int width,
const QString &label) {
float d_rel = lead_data.getDRel();
float v_rel = lead_data.getVRel();
auto *s = uiState();
auto &sm = *(s->sm);
float v_ego = sm["carState"].getCarState().getVEgo();
int chevron_data = s->scene.chevron_info;
float sz = std::clamp((25 * 30) / (d_rel / 3 + 30), 15.0f, 30.0f) * 2.35;
QFont content_font = painter.font();
content_font.setPixelSize(50);
content_font.setBold(true);
painter.setFont(content_font);
bool is_metric = s->scene.is_metric;
QStringList text_lines;
const int chevron_all = 4;
QStringList chevron_text[3];
// Distance display
if (chevron_data == 1 || chevron_data == chevron_all) {
int pos = 0;
float val = std::max(0.0f, d_rel);
QString unit = is_metric ? "m" : "ft";
if (!is_metric) val *= 3.28084f;
chevron_text[pos].append(QString::number(val, 'f', 0) + " " + unit);
}
// Speed display
if (chevron_data == 2 || chevron_data == chevron_all) {
int pos = (chevron_data == 2) ? 0 : 1;
float multiplier = is_metric ? static_cast<float>(MS_TO_KPH) : static_cast<float>(MS_TO_MPH);
float val = std::max(0.0f, (v_rel + v_ego) * multiplier);
QString unit = is_metric ? "km/h" : "mph";
chevron_text[pos].append(QString::number(val, 'f', 0) + " " + unit);
}
// Time to contact
if (chevron_data == 3 || chevron_data == chevron_all) {
int pos = (chevron_data == 3) ? 0 : 2;
float val = (d_rel > 0 && v_ego > 0) ? std::max(0.0f, d_rel / v_ego) : 0.0f;
QString ttc = (val > 0 && val < 200) ? QString::number(val, 'f', 1) + "s" : "---";
chevron_text[pos].append(ttc);
}
for (int i = 0; i < 3; ++i) {
if (!chevron_text[i].isEmpty()) text_lines.append(chevron_text[i]);
}
if (text_lines.isEmpty()) return;
QFontMetrics fm(content_font);
float text_width = 120.0f;
for (const QString &line : text_lines) {
text_width = std::max(text_width, fm.horizontalAdvance(line) + 20.0f);
}
text_width = std::min(text_width, 250.0f);
float line_height = 50.0f;
float total_height = text_lines.size() * line_height;
float margin = 20.0f;
float text_y = chevron_pos.y() + sz + 15;
if (text_y + total_height > height - margin) {
float y_max = chevron_pos.y() > (height - margin) ? (height - margin) : chevron_pos.y();
text_y = y_max - 15 - total_height;
text_y = std::max(margin, text_y);
}
float text_x = chevron_pos.x() - text_width / 2;
text_x = std::clamp(text_x, margin, (float)width - text_width - margin);
QPoint shadow_offset(2, 2);
QColor text_color = QColor(255, 255, 255, (int)(255 * lead_status_alpha));
for (int i = 0; i < text_lines.size(); ++i) {
float y = text_y + (i * line_height);
if (y + line_height > height - margin) break;
QRect rect(text_x, y, text_width, line_height);
// Draw shadow
painter.setPen(QColor(0, 0, 0, (int)(200 * lead_status_alpha)));
painter.drawText(rect.translated(shadow_offset), Qt::AlignCenter, text_lines[i]);
painter.setPen(text_color);
painter.drawText(rect, Qt::AlignCenter, text_lines[i]);
}
painter.setPen(Qt::NoPen);
}
-11
View File
@@ -17,17 +17,6 @@ private:
void update_model(const cereal::ModelDataV2::Reader &model, const cereal::RadarState::LeadData::Reader &lead) override;
void drawPath(QPainter &painter, const cereal::ModelDataV2::Reader &model, const QRect &rect) override;
// Lead status display methods
void drawLeadStatus(QPainter &painter, int height, int width);
void drawLeadStatusAtPosition(QPainter &painter,
const cereal::RadarState::LeadData::Reader &lead_data,
const QPointF &chevron_pos,
int height, int width,
const QString &label);
QPolygonF left_blindspot_vertices;
QPolygonF right_blindspot_vertices;
// Lead status animation
float lead_status_alpha = 0.0f;
};
@@ -25,8 +25,10 @@ void OnroadWindowSP::updateState(const UIStateSP &s) {
void OnroadWindowSP::mousePressEvent(QMouseEvent *e) {
OnroadWindow::mousePressEvent(e);
uiStateSP()->reset_onroad_sleep_timer();
}
void OnroadWindowSP::offroadTransition(bool offroad) {
OnroadWindow::offroadTransition(offroad);
uiStateSP()->reset_onroad_sleep_timer();
}
+5 -10
View File
@@ -71,21 +71,16 @@ void ui_update_params_sp(UIStateSP *s) {
s->scene.onroadScreenOffBrightness = std::atoi(params.get("OnroadScreenOffBrightness").c_str());
s->scene.onroadScreenOffControl = params.getBool("OnroadScreenOffControl");
s->scene.onroadScreenOffTimerParam = std::atoi(params.get("OnroadScreenOffTimer").c_str());
s->reset_onroad_sleep_timer();
s->scene.turn_signals = params.getBool("ShowTurnSignals");
s->scene.chevron_info = std::atoi(params.get("ChevronInfo").c_str());
s->scene.blindspot_ui = params.getBool("BlindSpot");
s->scene.rainbow_mode = params.getBool("RainbowMode");
}
void UIStateSP::reset_onroad_sleep_timer(OnroadTimerStatusToggle toggleTimerStatus) {
// Toggling from active state to inactive
if (toggleTimerStatus == OnroadTimerStatusToggle::PAUSE and scene.onroadScreenOffTimer != -1) {
scene.onroadScreenOffTimer = -1;
}
// Toggling from a previously inactive state or resetting an active timer
else if ((scene.onroadScreenOffTimerParam >= 0 and scene.onroadScreenOffControl and scene.onroadScreenOffTimer != -1) or toggleTimerStatus == OnroadTimerStatusToggle::RESUME) {
void UIStateSP::reset_onroad_sleep_timer() {
if (scene.onroadScreenOffTimerParam >= 0 and scene.onroadScreenOffControl) {
scene.onroadScreenOffTimer = scene.onroadScreenOffTimerParam * UI_FREQ;
} else {
scene.onroadScreenOffTimer = -1;
}
}
+1 -7
View File
@@ -15,12 +15,6 @@
#include "selfdrive/ui/ui.h"
#include "selfdrive/ui/qt/util.h"
enum OnroadTimerStatusToggle {
NONE,
PAUSE,
RESUME
};
class UIStateSP : public UIState {
Q_OBJECT
@@ -67,7 +61,7 @@ public:
return user.user_id.toLower() != "unregisteredsponsor" && user.user_id.toLower() != "temporarysponsor";
});
}
void reset_onroad_sleep_timer(OnroadTimerStatusToggle toggleTimerStatus = OnroadTimerStatusToggle::NONE);
void reset_onroad_sleep_timer();
signals:
void sunnylinkRoleChanged(bool subscriber);
-3
View File
@@ -18,7 +18,4 @@ typedef struct UISceneSP : UIScene {
bool trueVEgoUI;
bool hideVEgoUI;
bool turn_signals = false;
int chevron_info;
bool blindspot_ui;
bool rainbow_mode;
} UISceneSP;
+130 -135
View File
@@ -144,11 +144,11 @@ Please use caution when using this feature. Only use the blinker when traffic an
</message>
<message>
<source>Global Brightness</source>
<translation> </translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Overrides the brightness of the device. This applies to both onroad and offroad screens. </source>
<translation> . ( ) . </translation>
<translation type="unfinished"></translation>
</message>
</context>
<context>
@@ -256,11 +256,11 @@ This only toggles the visibility of the controls; it does not toggle the actual
</message>
<message>
<source>Enable Copyparty service</source>
<translation>Copyparty </translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copyparty is a very capable file server, you can use it to download your routes, view your logs and even make some edits on some files from your browser. Requires you to connect to your comma locally via it&apos;s IP.</source>
<translation>Copyparty는 , , , . comma IP를 .</translation>
<translation type="unfinished"></translation>
</message>
</context>
<context>
@@ -538,32 +538,32 @@ Steering lag calibration is complete.</source>
</message>
<message>
<source>Onroad Uploads</source>
<translation> </translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enable Always Offroad</source>
<translation> </translation>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>DisplayPanel</name>
<message>
<source>Onroad Screen: Reduced Brightness</source>
<translation> 화면: 밝기 </translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Turn off device screen or reduce brightness after driving starts. It automatically brightens again when screen is touched or a visible alert is displayed.</source>
<translation> . .</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Interactivity Timeout</source>
<translation> </translation>
<translation type="unfinished"> </translation>
</message>
<message>
<source>Apply a custom timeout for settings UI.
This is the time after which settings UI closes automatically if user is not interacting with the screen.</source>
<translation> UI에 .
UI가 .</translation>
<translation type="unfinished"> .
.</translation>
</message>
</context>
<context>
@@ -630,55 +630,55 @@ This is the time after which settings UI closes automatically if user is not int
<name>ExternalStorageControl</name>
<message>
<source>External Storage</source>
<translation> </translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Extend your comma device&apos;s storage by inserting a USB drive into the aux port.</source>
<translation>USB AUX comma .</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>CHECK</source>
<translation></translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>MOUNT</source>
<translation></translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>UNMOUNT</source>
<translation> </translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>FORMAT</source>
<translation></translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Are you sure you want to format this drive? This will erase all data.</source>
<translation> ? .</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Format</source>
<translation></translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>formatting</source>
<translation> </translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>insert drive</source>
<translation> </translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>needs format</source>
<translation> </translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>mounting</source>
<translation> </translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>unmounting</source>
<translation> </translation>
<translation type="unfinished"></translation>
</message>
</context>
<context>
@@ -737,58 +737,57 @@ Firehose 모드를 사용하면 훈련 데이터 업로드를 극대화하여 op
<name>HudRendererSP</name>
<message>
<source>km/h</source>
<translation>km/h</translation>
<translation type="unfinished">km/h</translation>
</message>
<message>
<source>mph</source>
<translation>mph</translation>
<translation type="unfinished">mph</translation>
</message>
<message>
<source>GREEN
LIGHT</source>
<translation> </translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>LEAD VEHICLE
DEPARTING</source>
<translation>
</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>SPEED</source>
<translation>SPEED</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>LIMIT</source>
<translation>LIMIT</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Near</source>
<translation></translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>km</source>
<translation>km</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>m</source>
<translation>m</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>mi</source>
<translation>mi</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>ft</source>
<translation>ft</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>AHEAD</source>
<translation></translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>MAX</source>
<translation></translation>
<translation type="unfinished"></translation>
</message>
</context>
<context>
@@ -906,15 +905,15 @@ DEPARTING</source>
</message>
<message>
<source>Enforce Torque Lateral Control</source>
<translation> </translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enable this to enforce sunnypilot to steer with Torque lateral control.</source>
<translation>sunnypilot이 .</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Customize Params</source>
<translation> </translation>
<translation type="unfinished"></translation>
</message>
</context>
<context>
@@ -941,31 +940,31 @@ DEPARTING</source>
</message>
<message>
<source>Intelligent Cruise Button Management (ICBM) (Alpha)</source>
<translation> (ICBM) ()</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>When enabled, sunnypilot will attempt to manage the built-in cruise control buttons by emulating button presses for limited longitudinal control.</source>
<translation>, sunnypilot은 .</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Smart Cruise Control - Vision</source>
<translation> - </translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Use vision path predictions to estimate the appropriate speed to drive through turns ahead.</source>
<translation> .</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Smart Cruise Control - Map</source>
<translation> - </translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Use map data to estimate the appropriate speed to drive through turns ahead.</source>
<translation> .</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Speed Limit</source>
<translation> </translation>
<translation type="unfinished"></translation>
</message>
</context>
<context>
@@ -1196,47 +1195,47 @@ The default software delay value is 0.2</source>
</message>
<message>
<source>Refresh Model List</source>
<translation> </translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>REFRESH</source>
<translation></translation>
<translation type="unfinished"> </translation>
</message>
<message>
<source>Fetching Latest Models</source>
<translation> </translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enable this for the car to learn and adapt its steering response time. Disable to use a fixed steering response time. Keeping this on provides the stock openpilot experience.</source>
<translation> . . openpilot .</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Live Steer Delay:</source>
<translation> :</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Actuator Delay:</source>
<translation> :</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Software Delay:</source>
<translation> :</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Total Delay:</source>
<translation> :</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Use Lane Turn Desires</source>
<translation> </translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Adjust Lane Turn Speed</source>
<translation> </translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Set the maximum speed for lane turn desires. Default is 19 %1.</source>
<translation> . 19 %1 .</translation>
<translation type="unfinished"></translation>
</message>
</context>
<context>
@@ -1401,7 +1400,7 @@ The default software delay value is 0.2</source>
</message>
<message>
<source>&lt;b&gt;Unsupported branch detected&lt;/b&gt; - The current version of &lt;b&gt;&lt;u&gt;%1&lt;/u&gt;&lt;/b&gt; branch is no longer supported on the comma three. Please go to &lt;b&gt;[Device &gt; Software]&lt;/b&gt; and install a supported branch with &lt;b&gt;&lt;u&gt;-tici&lt;/u&gt;&lt;/b&gt; in the branch name for the comma three.</source>
<translation>&lt;b&gt; &lt;/b&gt; - &lt;b&gt;&lt;u&gt;%1&lt;/u&gt;&lt;/b&gt; comma three . &lt;b&gt;[ &gt; ]&lt;/b&gt; &lt;b&gt;&lt;u&gt;-tici&lt;/u&gt;&lt;/b&gt; comma three .</translation>
<translation type="unfinished"></translation>
</message>
</context>
<context>
@@ -1780,59 +1779,56 @@ Warning: You are on a metered connection!</source>
</message>
<message>
<source>None</source>
<translation></translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Fixed</source>
<translation></translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Percent</source>
<translation></translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Car
Only</source>
<translation></translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Map
Only</source>
<translation></translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Car
First</source>
<translation>
</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Map
First</source>
<translation>
</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Combined
Data</source>
<translation>
</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Off</source>
<translation></translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Information</source>
<translation></translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Warning</source>
<translation></translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Assist</source>
<translation></translation>
<translation type="unfinished"></translation>
</message>
</context>
<context>
@@ -1930,7 +1926,7 @@ Data</source>
</message>
<message>
<source>Display</source>
<translation></translation>
<translation type="unfinished"></translation>
</message>
</context>
<context>
@@ -2172,78 +2168,78 @@ Data</source>
<name>SpeedLimitPolicy</name>
<message>
<source>Back</source>
<translation></translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Speed Limit Source</source>
<translation> </translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>⦿ Car Only: Use Speed Limit data only from Car</source>
<translation>⦿ 차량만: 차량에서 </translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>⦿ Map Only: Use Speed Limit data only from OpenStreetMaps</source>
<translation>⦿ 지도만: OpenStreetMaps에서 </translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>⦿ Car First: Use Speed Limit data from Car if available, else use from OpenStreetMaps</source>
<translation>⦿ 우선: 사용 , OpenStreetMaps의 </translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>⦿ Map First: Use Speed Limit data from OpenStreetMaps if available, else use from Car</source>
<translation>⦿ 우선: 사용 OpenStreetMaps의 , </translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>⦿ Combined: Use combined Speed Limit data from Car &amp; OpenStreetMaps</source>
<translation>⦿ 결합: 차량 OpenStreetMaps의 </translation>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SpeedLimitSettings</name>
<message>
<source>Back</source>
<translation></translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Speed Limit</source>
<translation> </translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Customize Source</source>
<translation> </translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Speed Limit Offset</source>
<translation> </translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>⦿ None: No Offset</source>
<translation>⦿ 없음: 오프셋 </translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>⦿ Fixed: Adds a fixed offset [Speed Limit + Offset]</source>
<translation>⦿ 고정: 고정 . [ + ]</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>⦿ Percent: Adds a percent offset [Speed Limit + (Offset % Speed Limit)]</source>
<translation>⦿ 비율: 백분율 . [ + ( % )]</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>⦿ Off: Disables the Speed Limit functions.</source>
<translation>⦿ 끄기: 속도 .</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>⦿ Information: Displays the current road&apos;s speed limit.</source>
<translation>⦿ 정보: 현재 .</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>⦿ Warning: Provides a warning when exceeding the current road&apos;s speed limit.</source>
<translation>⦿ 경고: 현재 .</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>⦿ Assist: Adjusts the vehicle&apos;s cruise speed based on the current road&apos;s speed limit when operating the +/- buttons.</source>
<translation>⦿ : +/- .</translation>
<translation type="unfinished"></translation>
</message>
</context>
<context>
@@ -2416,27 +2412,27 @@ Data</source>
</message>
<message>
<source>Enable sunnylink uploader to allow sunnypilot to upload your driving data to sunnypilot servers. (only for highest tiers, and does NOT bring ANY benefit to you. We are just testing data volume.)</source>
<translation>sunnylink sunnypilot이 sunnypilot . ( , . .)</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>[Don&apos;t use] Enable sunnylink uploader</source>
<translation>[ ] sunnylink </translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>🚀 sunnylink 🚀</source>
<translation>🚀 sunnylink 🚀</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>For secure backup, restore, and remote configuration</source>
<translation> , </translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Sponsorship isn&apos;t required for basic backup/restore</source>
<translation> / </translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Click the sponsor button for more details</source>
<translation> </translation>
<translation type="unfinished"></translation>
</message>
</context>
<context>
@@ -2632,54 +2628,54 @@ Data</source>
<name>TorqueLateralControlCustomParams</name>
<message>
<source>Manual Real-Time Tuning</source>
<translation> </translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enforces the torque lateral controller to use the fixed values instead of the learned values from Self-Tune. Enabling this toggle overrides Self-Tune values.</source>
<translation> . .</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Lateral Acceleration Factor</source>
<translation> </translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Friction</source>
<translation></translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Real-time and Offline</source>
<translation> </translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Offline Only</source>
<translation></translation>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>TorqueLateralControlSettings</name>
<message>
<source>Self-Tune</source>
<translation> </translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enables self-tune for Torque lateral control for platforms that do not use Torque lateral control by default.</source>
<translation> .</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Less Restrict Settings for Self-Tune (Beta)</source>
<translation> ()</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Less strict settings when using Self-Tune. This allows torqued to be more forgiving when learning values.</source>
<translation> . torqued가 .</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enable Custom Tuning</source>
<translation> </translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enables custom tuning for Torque lateral control. Modifying Lateral Acceleration Factor and Friction below will override the offline values indicated in the YAML files within &quot;opendbc/car/torque_data&quot;. The values will also be used live when &quot;Manual Real-Time Tuning&quot; toggle is enabled.</source>
<translation> . &quot;opendbc/car/torque_data&quot; YAML . &quot; &quot; .</translation>
<translation type="unfinished"></translation>
</message>
</context>
<context>
@@ -2694,7 +2690,7 @@ Data</source>
</message>
<message>
<source>Favorites</source>
<translation></translation>
<translation type="unfinished"></translation>
</message>
</context>
<context>
@@ -2741,89 +2737,88 @@ Data</source>
</message>
<message>
<source>Enable Tesla Rainbow Mode</source>
<translation> </translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>A beautiful rainbow effect on the path the model wants to take.</source>
<translation> .</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>It</source>
<translation> </translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>does not</source>
<translation></translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>affect driving in any way.</source>
<translation> .</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enable Standstill Timer</source>
<translation> </translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show a timer on the HUD when the car is at a standstill.</source>
<translation> HUD에 .</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Display Road Name</source>
<translation> </translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Displays the name of the road the car is traveling on. The OpenStreetMap database of the location must be downloaded from the OSM panel to fetch the road name.</source>
<translation> . OSM OpenStreetMap .</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Green Traffic Light Alert (Beta)</source>
<translation> ()</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>A chime and on-screen alert will play when the traffic light you are waiting for turns green and you have no vehicle in front of you.</source>
<translation> , .</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Note: This chime is only designed as a notification. It is the driver&apos;s responsibility to observe their environment and make decisions accordingly.</source>
<translation>참고: . .</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Lead Departure Alert (Beta)</source>
<translation> ()</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>A chime and on-screen alert will play when you are stopped, and the vehicle in front of you start moving.</source>
<translation> , .</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Speedometer: Always Display True Speed</source>
<translation>속도계: 항상 </translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Always display the true vehicle current speed from wheel speed sensors.</source>
<translation> .</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Speedometer: Hide from Onroad Screen</source>
<translation>속도계: 주행 </translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Right</source>
<translation></translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Right &amp;&amp;
Bottom</source>
<translation> &amp;&amp;
</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Developer UI</source>
<translation> UI</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Display real-time parameters and metrics from various sources.</source>
<translation> .</translation>
<translation type="unfinished"></translation>
</message>
</context>
<context>
-1
View File
@@ -60,7 +60,6 @@ typedef struct UIScene {
cereal::PandaState::PandaType pandaType;
cereal::LongitudinalPersonality personality;
cereal::LongitudinalPlanSP::AccelerationPersonality accel_personality;
float light_sensor = -1;
bool started, ignition, is_metric, recording_audio;
+2 -1
View File
@@ -81,7 +81,8 @@ def initialize_params(params) -> list[dict[str, Any]]:
# hyundai
keys.extend([
"HyundaiLongitudinalTuning"
"HyundaiLongitudinalTuning",
"HyundaiRadar"
])
return [{k: params.get(k, return_default=True)} for k in keys]
@@ -17,7 +17,6 @@ from openpilot.sunnypilot.selfdrive.controls.lib.speed_limit.speed_limit_resolve
from openpilot.sunnypilot.selfdrive.selfdrived.events import EventsSP
from openpilot.sunnypilot.models.helpers import get_active_bundle
from openpilot.sunnypilot.selfdrive.controls.lib.vibe_personality.vibe_personality import VibePersonalityController
DecState = custom.LongitudinalPlanSP.DynamicExperimentalControl.DynamicExperimentalControlState
LongitudinalPlanSource = custom.LongitudinalPlanSP.LongitudinalPlanSource
@@ -30,7 +29,6 @@ class LongitudinalPlannerSP:
self.scc = SmartCruiseControl()
self.resolver = SpeedLimitResolver()
self.sla = SpeedLimitAssist(CP)
self.vibe_controller = VibePersonalityController()
self.generation = int(model_bundle.generation) if (model_bundle := get_active_bundle()) else None
self.source = LongitudinalPlanSource.cruise
self.e2e_alerts_helper = E2EAlertsHelper()
@@ -83,7 +81,6 @@ class LongitudinalPlannerSP:
self.events_sp.clear()
self.dec.update(sm)
self.e2e_alerts_helper.update(sm, self.events_sp)
self.vibe_controller.update()
def publish_longitudinal_plan_sp(self, sm: messaging.SubMaster, pm: messaging.PubMaster) -> None:
plan_sp_send = messaging.new_message('longitudinalPlanSP')
@@ -1,74 +0,0 @@
"""
Copyright (c) 2021-, rav4kumar, Haibin Wen, sunnypilot, and a number of other contributors.
This file is part of sunnypilot and is licensed under the MIT License.
See the LICENSE.md file in the root directory for more details.
"""
from cereal import log, custom
import numpy as np
from openpilot.common.realtime import DT_MDL
from openpilot.common.params import Params
LongPersonality = log.LongitudinalPersonality
AccelPersonality = custom.LongitudinalPlanSP.AccelerationPersonality
MAX_ACCEL_PROFILES = {
AccelPersonality.eco: [2.0, 1.99, 1.88, 1.10, .500, .292, .15, .10],
AccelPersonality.normal: [2.0, 2.00, 1.94, 1.22, .635, .33, .20, .16],
AccelPersonality.sport: [2.0, 2.00, 2.00, 1.85, .800, .54, .32, .22],
}
MAX_ACCEL_BREAKPOINTS = [0., 4., 6., 9., 16., 25., 30., 55.]
MIN_ACCEL_PROFILES = {
LongPersonality.relaxed: [-.0007, -.0007, -.07, -1.00, -1.00],
LongPersonality.standard: [-.0007, -.0007, -.08, -1.10, -1.10],
LongPersonality.aggressive: [-.0006, -.0007, -.09, -1.20, -1.20],
}
MIN_ACCEL_BREAKPOINTS = [0., 3.0, 11., 22., 50.]
class AccelPersonalityController:
def __init__(self):
self.params = Params()
self.frame = 0
self.accel_personality = AccelPersonality.normal
self.long_personality = LongPersonality.standard
def _update_from_params(self):
if self.frame % int(1. / DT_MDL) != 0:
return
accel_bytes = self.params.get('AccelPersonality')
if accel_bytes:
self.accel_personality = int(accel_bytes)
long_bytes = self.params.get('LongitudinalPersonality')
if long_bytes:
self.long_personality = int(long_bytes)
def is_enabled(self) -> bool:
return self.params.get_bool('VibeAccelPersonalityEnabled') or False
def set_accel_personality(self, personality: int) -> bool:
if personality not in [AccelPersonality.eco, AccelPersonality.normal, AccelPersonality.sport]:
return False
self.accel_personality = personality
self.params.put('AccelPersonality', str(personality))
return True
def cycle_accel_personality(self) -> int:
personalities = [AccelPersonality.eco, AccelPersonality.normal, AccelPersonality.sport]
idx = personalities.index(self.accel_personality)
next_p = personalities[(idx + 1) % len(personalities)]
self.set_accel_personality(next_p)
return int(next_p)
def get_accel_limits(self, v_ego: float) -> tuple[float, float] | None:
if not self.is_enabled():
return None
self._update_from_params()
max_a = np.interp(v_ego, MAX_ACCEL_BREAKPOINTS, MAX_ACCEL_PROFILES[self.accel_personality])
min_a = np.interp(v_ego, MIN_ACCEL_BREAKPOINTS, MIN_ACCEL_PROFILES[self.long_personality])
return float(min_a), float(max_a)
def update(self):
self.frame += 1
@@ -1,46 +0,0 @@
"""
Copyright (c) 2021-, rav4kumar, Haibin Wen, sunnypilot, and a number of other contributors.
This file is part of sunnypilot and is licensed under the MIT License.
See the LICENSE.md file in the root directory for more details.
"""
from cereal import log
import numpy as np
from openpilot.common.realtime import DT_MDL
from openpilot.common.params import Params
LongPersonality = log.LongitudinalPersonality
FOLLOW_PROFILES = {
LongPersonality.relaxed: [1.55, 1.65, 1.65, 1.80, 1.80],
LongPersonality.standard: [1.35, 1.45, 1.45, 1.55, 1.55],
LongPersonality.aggressive: [1.05, 1.10, 1.10, 1.25, 1.35],
}
FOLLOW_BREAKPOINTS = [0., 6., 18., 20., 36.]
class FollowPersonalityController:
def __init__(self):
self.params = Params()
self.frame = 0
self.long_personality = LongPersonality.standard
def _update_from_params(self):
if self.frame % int(1. / DT_MDL) != 0:
return
long_bytes = self.params.get('LongitudinalPersonality')
if long_bytes:
self.long_personality = int(long_bytes)
def is_enabled(self) -> bool:
return self.params.get_bool('VibeFollowPersonalityEnabled') or False
def get_follow_distance_multiplier(self, v_ego: float) -> float | None:
if not self.is_enabled():
return None
self._update_from_params()
return float(np.interp(v_ego, FOLLOW_BREAKPOINTS, FOLLOW_PROFILES[self.long_personality]))
def update(self):
self.frame += 1
@@ -1,314 +0,0 @@
import pytest
# Import the actual modules
from cereal import log, custom
from openpilot.common.realtime import DT_MDL
# Import the enums we need for testing
LongPersonality = log.LongitudinalPersonality
AccelPersonality = custom.LongitudinalPlanSP.AccelerationPersonality
class MockParams:
"""Simple mock for Params class"""
def __init__(self):
self.data = {}
self.bool_data = {
'VibePersonalityEnabled': True,
'VibeAccelPersonalityEnabled': True,
'VibeFollowPersonalityEnabled': True
}
def get(self, key, encoding=None):
return self.data.get(key)
def get_bool(self, key):
return self.bool_data.get(key, True)
def put(self, key, value):
self.data[key] = value
def put_bool(self, key, value):
self.bool_data[key] = value
def reset_mock(self):
self.call_count = 0
@property
def call_count(self):
return getattr(self, '_call_count', 0)
@call_count.setter
def call_count(self, value):
self._call_count = value
@pytest.fixture
def mock_params():
"""Create mock params instance"""
return MockParams()
@pytest.fixture
def controller(mock_params, monkeypatch):
"""Create controller instance with mocked Params"""
# Patch the Params import in the controller module
monkeypatch.setattr('openpilot.sunnypilot.selfdrive.controls.lib.vibe_personality.vibe_personality.Params',
lambda: mock_params)
from openpilot.sunnypilot.selfdrive.controls.lib.vibe_personality.vibe_personality import VibePersonalityController
return VibePersonalityController()
class TestVibePersonalityController:
def test_initialization(self, controller):
"""Test controller initializes with correct defaults"""
assert controller.frame == 0
assert controller.accel_personality == AccelPersonality.normal
assert controller.long_personality == LongPersonality.standard
assert 'accel_personality' in controller.param_keys
assert 'long_personality' in controller.param_keys
def test_frame_increment(self, controller):
"""Test frame counter increments correctly"""
initial_frame = controller.frame
controller.update()
assert controller.frame == initial_frame + 1
controller.update()
assert controller.frame == initial_frame + 2
def test_parameter_reading_throttled(self, controller, mock_params):
"""Test parameters are only read every DT_MDL frames"""
# Track calls manually
original_get = mock_params.get
call_count = 0
def counting_get(*args, **kwargs):
nonlocal call_count
call_count += 1
return original_get(*args, **kwargs)
mock_params.get = counting_get
# First call should read params (frame 0)
controller._update_from_params()
# Reset counter
call_count = 0
# Advance frame but not to threshold
controller.frame = 5 # Less than int(1/DT_MDL)
controller._update_from_params()
assert call_count == 0 # Should not read params
# Advance to threshold
controller.frame = int(1. / DT_MDL) # Equal to threshold
controller._update_from_params()
assert call_count >= 2 # Should read both personality params
def test_accel_personality_management(self, controller, mock_params):
"""Test acceleration personality setting and cycling"""
# Test setting valid personality
assert controller.set_accel_personality(AccelPersonality.eco)
assert controller.accel_personality == AccelPersonality.eco
assert controller.set_accel_personality(AccelPersonality.sport)
assert controller.accel_personality == AccelPersonality.sport
# Test setting invalid personality
assert not controller.set_accel_personality(999)
assert controller.accel_personality == AccelPersonality.sport # Should remain unchanged
# Test cycling
controller.accel_personality = AccelPersonality.eco
next_personality = controller.cycle_accel_personality()
assert next_personality == AccelPersonality.normal # should cycle to normal
assert controller.accel_personality == AccelPersonality.normal
next_personality = controller.cycle_accel_personality()
assert next_personality == AccelPersonality.sport # should cycle to sport
next_personality = controller.cycle_accel_personality()
assert next_personality == AccelPersonality.eco # should cycle back to eco
def test_long_personality_management(self, controller, mock_params):
"""Test longitudinal personality setting and cycling"""
# Test setting valid personality
assert controller.set_long_personality(LongPersonality.relaxed)
assert controller.long_personality == LongPersonality.relaxed
assert controller.set_long_personality(LongPersonality.aggressive)
assert controller.long_personality == LongPersonality.aggressive
# Test setting invalid personality
assert not controller.set_long_personality(999)
assert controller.long_personality == LongPersonality.aggressive # Should remain unchanged
# Test cycling
controller.long_personality = LongPersonality.standard
next_personality = controller.cycle_long_personality()
assert next_personality == LongPersonality.aggressive # should cycle to aggressive
assert controller.long_personality == LongPersonality.aggressive
next_personality = controller.cycle_long_personality()
assert next_personality == LongPersonality.relaxed # should cycle to relaxed
next_personality = controller.cycle_long_personality()
assert next_personality == LongPersonality.standard # should cycle back to standard
def test_toggle_functions(self, controller, mock_params):
"""Test toggle functionality"""
# Set initial state to False
mock_params.bool_data['VibePersonalityEnabled'] = False
result = controller.toggle_personality()
assert result # Should toggle to True
assert mock_params.bool_data['VibePersonalityEnabled']
# Set initial state to True
mock_params.bool_data['VibeAccelPersonalityEnabled'] = True
result = controller.toggle_accel_personality()
assert not result # Should toggle to False
assert not mock_params.bool_data['VibeAccelPersonalityEnabled']
def test_enable_checks(self, controller, mock_params):
"""Test various enable state checks"""
# All enabled
mock_params.bool_data = {
'VibePersonalityEnabled': True,
'VibeAccelPersonalityEnabled': True,
'VibeFollowPersonalityEnabled': True
}
assert controller.is_enabled()
assert controller.is_accel_enabled()
assert controller.is_follow_enabled()
# Main toggle disabled
mock_params.bool_data['VibePersonalityEnabled'] = False
assert not controller.is_enabled()
assert not controller.is_accel_enabled()
assert not controller.is_follow_enabled()
def test_accel_limits_calculation(self, controller, mock_params):
"""Test acceleration limits calculation"""
# Enable all features through mock_params bool_data
mock_params.bool_data = {
'VibePersonalityEnabled': True,
'VibeAccelPersonalityEnabled': True,
'VibeFollowPersonalityEnabled': True
}
# Test with different speeds and personalities
controller.accel_personality = 1 # normal
controller.long_personality = 1 # standard
limits = controller.get_accel_limits(10.0) # 10 m/s
assert limits is not None
min_a, max_a = limits
assert isinstance(min_a, float)
assert isinstance(max_a, float)
assert min_a < 0 # Should be negative (braking)
assert max_a > 0 # Should be positive (acceleration)
# Test with disabled controller
mock_params.bool_data['VibePersonalityEnabled'] = False
limits = controller.get_accel_limits(10.0)
assert limits is None
def test_follow_distance_multiplier(self, controller, mock_params):
"""Test following distance multiplier calculation"""
# Enable controller
mock_params.bool_data['VibePersonalityEnabled'] = True
mock_params.bool_data['VibeFollowPersonalityEnabled'] = True
# Test with different speeds and personalities
controller.long_personality = LongPersonality.relaxed
multiplier = controller.get_follow_distance_multiplier(15.0) # 15 m/s
assert multiplier is not None
assert isinstance(multiplier, float)
assert multiplier > 0
# Test with different personality - aggressive should have shorter distance
controller.long_personality = LongPersonality.aggressive
aggressive_multiplier = controller.get_follow_distance_multiplier(15.0)
assert aggressive_multiplier is not None
assert aggressive_multiplier < multiplier # Aggressive should have shorter distance
# Test with disabled controller
mock_params.bool_data['VibeFollowPersonalityEnabled'] = False
multiplier = controller.get_follow_distance_multiplier(15.0)
assert multiplier is None
def test_personality_differences(self, controller, mock_params):
"""Test that different personalities actually produce different values"""
# Enable controller
mock_params.bool_data['VibePersonalityEnabled'] = True
mock_params.bool_data['VibeAccelPersonalityEnabled'] = True
mock_params.bool_data['VibeFollowPersonalityEnabled'] = True
# Test acceleration differences - sport should have higher max acceleration than eco
controller.accel_personality = AccelPersonality.eco
eco_limits = controller.get_accel_limits(20.0)
controller.accel_personality = AccelPersonality.sport
sport_limits = controller.get_accel_limits(20.0)
assert sport_limits[1] > eco_limits[1] # Sport should have higher max acceleration
# Test following distance differences - relaxed should have longer distance than aggressive
controller.long_personality = LongPersonality.relaxed
relaxed_dist = controller.get_follow_distance_multiplier(20.0)
controller.long_personality = LongPersonality.aggressive
aggressive_dist = controller.get_follow_distance_multiplier(20.0)
assert relaxed_dist > aggressive_dist # Relaxed should have longer following distance
def test_reset(self, controller):
"""Test reset functionality"""
# Change some values
controller.accel_personality = AccelPersonality.sport
controller.long_personality = LongPersonality.relaxed
controller.frame = 100
# Reset
controller.reset()
# Check defaults are restored
assert controller.accel_personality == AccelPersonality.normal
assert controller.long_personality == LongPersonality.standard
assert controller.frame == 0
def test_edge_cases(self, controller, mock_params):
"""Test edge cases and error handling"""
# Enable all features
mock_params.bool_data = {
'VibePersonalityEnabled': True,
'VibeAccelPersonalityEnabled': True,
'VibeFollowPersonalityEnabled': True
}
# Test with zero speed
limits = controller.get_accel_limits(0.0)
assert limits is not None
multiplier = controller.get_follow_distance_multiplier(0.0)
assert multiplier is not None
# Test with very high speed
limits = controller.get_accel_limits(100.0)
assert limits is not None
multiplier = controller.get_follow_distance_multiplier(100.0)
assert multiplier is not None
# Test interpolation works correctly
low_speed_limits = controller.get_accel_limits(5.0)
high_speed_limits = controller.get_accel_limits(50.0)
assert low_speed_limits[1] > high_speed_limits[1] # Max accel should decrease with speed
@@ -1,81 +0,0 @@
"""
Copyright (c) 2021-, rav4kumar, Haibin Wen, sunnypilot, and a number of other contributors.
This file is part of sunnypilot and is licensed under the MIT License.
See the LICENSE.md file in the root directory for more details.
"""
from cereal import log, custom
from openpilot.common.params import Params
from openpilot.sunnypilot.selfdrive.controls.lib.vibe_personality.accel_personality import AccelPersonalityController
from openpilot.sunnypilot.selfdrive.controls.lib.vibe_personality.follow_personality import FollowPersonalityController
LongPersonality = log.LongitudinalPersonality
AccelPersonality = custom.LongitudinalPlanSP.AccelerationPersonality
class VibePersonalityController:
def __init__(self):
self.accel = AccelPersonalityController()
self.follow = FollowPersonalityController()
self.params = Params()
@property
def frame(self):
return self.accel.frame
@frame.setter
def frame(self, value):
self.accel.frame = self.follow.frame = value
@property
def accel_personality(self):
return self.accel.accel_personality
@property
def long_personality(self):
return self.accel.long_personality
@long_personality.setter
def long_personality(self, value):
self.accel.long_personality = self.follow.long_personality = value
def set_accel_personality(self, personality: int) -> bool:
return self.accel.set_accel_personality(personality)
def cycle_accel_personality(self) -> int:
return self.accel.cycle_accel_personality()
def set_long_personality(self, personality: int) -> bool:
if personality not in [LongPersonality.relaxed, LongPersonality.standard, LongPersonality.aggressive]:
return False
self.long_personality = personality
self.params.put('LongitudinalPersonality', str(personality))
return True
def cycle_long_personality(self) -> int:
personalities = [LongPersonality.relaxed, LongPersonality.standard, LongPersonality.aggressive]
idx = personalities.index(self.long_personality)
next_p = personalities[(idx + 1) % len(personalities)]
self.set_long_personality(next_p)
return int(next_p)
def is_enabled(self) -> bool:
main_enabled = self.params.get_bool('VibePersonalityEnabled') or False
return main_enabled and (self.accel.is_enabled() or self.follow.is_enabled())
def get_accel_limits(self, v_ego: float) -> tuple[float, float] | None:
main_enabled = self.params.get_bool('VibePersonalityEnabled') or False
if not (main_enabled and self.accel.is_enabled()):
return None
return self.accel.get_accel_limits(v_ego)
def get_follow_distance_multiplier(self, v_ego: float) -> float | None:
main_enabled = self.params.get_bool('VibePersonalityEnabled') or False
if not (main_enabled and self.follow.is_enabled()):
return None
return self.follow.get_follow_distance_multiplier(v_ego)
def update(self):
self.accel.update()
self.follow.update()